Cadabra
Computer algebra system for field theory problems
DisplayTeX.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Props.hh"
5 #include "Storage.hh"
6 #include "DisplayBase.hh"
7 #include <ostream>
8 
9 typedef uint32_t kunichar;
10 
11 namespace cadabra {
12 
20 
21  class DisplayTeX : public DisplayBase {
22  public:
23  DisplayTeX(const Kernel&, const Ex&);
24 
25  protected:
26  virtual bool needs_brackets(Ex::iterator it) override;
27 
28  private:
29  // FIXME: just make this take the multiplier, instead of the node. Then mult can go away.
30  void print_multiplier(std::ostream&, Ex::iterator, int mult=1);
33  void print_parent_rel(std::ostream&, str_node::parent_rel_t, bool first);
34  void print_children(std::ostream&, Ex::iterator, int skip=0);
35 
36  std::string texify(std::string) const;
37 
38  bool print_star=false;
39  bool tight_star=false;
40  // bool tight_plus=false;
41  // bool utf8_output=false;
42  bool latex_spacing=true;
43  // bool latex_linefeeds=true; // to prevent buffer overflows in TeX
44  bool extra_brackets_for_symbols=false; // wrap extra {} around symbols to ensure typesetting safety
45 
47 
54 
55  virtual void dispatch(std::ostream&, Ex::iterator) override;
56 
62 
63  void print_productlike(std::ostream&, Ex::iterator, const std::string& inbetween);
64  void print_sumlike(std::ostream&, Ex::iterator);
65  void print_fraclike(std::ostream&, Ex::iterator);
66  void print_commalike(std::ostream&, Ex::iterator);
67  void print_arrowlike(std::ostream&, Ex::iterator);
68  void print_powlike(std::ostream&, Ex::iterator);
69  void print_intlike(std::ostream&, Ex::iterator);
70  void print_equalitylike(std::ostream&, Ex::iterator);
71  void print_commutator(std::ostream& str, Ex::iterator it, bool comm);
72  void print_components(std::ostream&, Ex::iterator);
73  void print_conditional(std::ostream&, Ex::iterator);
74  void print_relation(std::ostream&, Ex::iterator);
75  void print_indexbracket(std::ostream&, Ex::iterator);
76  void print_wedgeproduct(std::ostream&, Ex::iterator);
77  void print_tableau(std::ostream&, Ex::iterator);
78  void print_ftableau(std::ostream&, Ex::iterator);
79  void print_dot(std::ostream& str, Ex::iterator it);
80  void print_dots(std::ostream& str, Ex::iterator it);
81  void print_other(std::ostream& str, Ex::iterator it);
82 
83  bool children_have_brackets(Ex::iterator ch) const;
84 
90 
91  bool reads_as_operator(Ex::iterator obj, Ex::iterator arg) const;
92 
94  std::map<std::string, std::string> symmap;
95 
98  std::set<std::string> curly_bracket_operators;
99 
100  };
101 
102  const char *unichar(kunichar c);
103 
104  }
cadabra::DisplayTeX::curly_bracket_operators
std::set< std::string > curly_bracket_operators
List of operators which need all arguments fed with curly brackets, not round ones (e....
Definition: DisplayTeX.hh:98
cadabra::DisplayTeX::children_have_brackets
bool children_have_brackets(Ex::iterator ch) const
Definition: DisplayTeX.cc:969
cadabra::DisplayTeX::print_relation
void print_relation(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:947
cadabra::DisplayTeX::dispatch
virtual void dispatch(std::ostream &, Ex::iterator) override
For every object encountered, dispatch will figure out the most appropriate way to convert it into a ...
Definition: DisplayTeX.cc:462
cadabra::DisplayTeX::print_sumlike
void print_sumlike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:690
cadabra::DisplayTeX::print_star
bool print_star
Definition: DisplayTeX.hh:38
cadabra::Kernel
Definition: Kernel.hh:15
cadabra::DisplayTeX::print_fraclike
void print_fraclike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:542
cadabra::DisplayTeX::print_powlike
void print_powlike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:741
cadabra::DisplayTeX::print_dots
void print_dots(std::ostream &str, Ex::iterator it)
Definition: DisplayTeX.cc:884
cadabra::DisplayTeX::print_components
void print_components(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:896
cadabra::DisplayTeX::symmap
std::map< std::string, std::string > symmap
Map from Cadabra symbols to LaTeX symbols (for some typographic cleanup).
Definition: DisplayTeX.hh:94
cadabra::DisplayTeX::print_wedgeproduct
void print_wedgeproduct(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:502
cadabra::DisplayTeX::print_commutator
void print_commutator(std::ostream &str, Ex::iterator it, bool comm)
Definition: DisplayTeX.cc:865
cadabra::DisplayTeX::print_tableau
void print_tableau(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:197
cadabra::DisplayTeX::latex_spacing
bool latex_spacing
Definition: DisplayTeX.hh:42
cadabra::DisplayTeX::print_ftableau
void print_ftableau(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:222
cadabra::DisplayTeX::print_intlike
void print_intlike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:801
cadabra::DisplayTeX::print_closing_bracket
void print_closing_bracket(std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
Definition: DisplayTeX.cc:409
cadabra::unichar
const char * unichar(kunichar c)
Definition: DisplayTeX.cc:1018
cadabra::DisplayTeX::print_arrowlike
void print_arrowlike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:524
cadabra::DisplayTeX::extra_brackets_for_symbols
bool extra_brackets_for_symbols
Definition: DisplayTeX.hh:44
cadabra::DisplayTeX::print_multiplier
void print_multiplier(std::ostream &, Ex::iterator, int mult=1)
Definition: DisplayTeX.cc:365
cadabra::DisplayTeX::print_indexbracket
void print_indexbracket(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:957
Storage.hh
cadabra::DisplayTeX::bracket_level
int bracket_level
Definition: DisplayTeX.hh:46
cadabra::DisplayTeX::reads_as_operator
bool reads_as_operator(Ex::iterator obj, Ex::iterator arg) const
Determine whether the indicated object 'obj', when acting on the single argument 'arg',...
Definition: DisplayTeX.cc:96
kunichar
uint32_t kunichar
Definition: DisplayMMA.hh:9
Props.hh
cadabra::DisplayTeX::tight_star
bool tight_star
Definition: DisplayTeX.hh:39
cadabra::DisplayTeX::print_conditional
void print_conditional(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:938
kunichar
uint32_t kunichar
Definition: DisplayTeX.hh:9
cadabra::DisplayTeX
Definition: DisplayTeX.hh:21
DisplayBase.hh
cadabra
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
cadabra::Ex
Definition: Storage.hh:140
cadabra::str_node::bracket_t
bracket_t
Definition: Storage.hh:57
cadabra::DisplayTeX::print_opening_bracket
void print_opening_bracket(std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
Definition: DisplayTeX.cc:384
cadabra::DisplayTeX::needs_brackets
virtual bool needs_brackets(Ex::iterator it) override
Determine if a node needs extra brackets around it.
Definition: DisplayTeX.cc:41
cadabra::DisplayTeX::print_other
void print_other(std::ostream &str, Ex::iterator it)
Definition: DisplayTeX.cc:119
cadabra::DisplayTeX::texify
std::string texify(std::string) const
Definition: DisplayTeX.cc:260
cadabra::DisplayTeX::print_parent_rel
void print_parent_rel(std::ostream &, str_node::parent_rel_t, bool first)
Definition: DisplayTeX.cc:434
cadabra::DisplayTeX::print_children
void print_children(std::ostream &, Ex::iterator, int skip=0)
Definition: DisplayTeX.cc:301
cadabra::DisplayBase
Definition: DisplayBase.hh:19
cadabra::DisplayTeX::print_dot
void print_dot(std::ostream &str, Ex::iterator it)
Definition: DisplayTeX.cc:533
cadabra::DisplayTeX::print_commalike
void print_commalike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:486
cadabra::str_node::parent_rel_t
parent_rel_t
Child nodes are related to their parent node by a so-called parent relation, which can be one of thes...
Definition: Storage.hh:61
cadabra::DisplayTeX::print_productlike
void print_productlike(std::ostream &, Ex::iterator, const std::string &inbetween)
Printing members for various standard constructions, e.g.
Definition: DisplayTeX.cc:563
cadabra::DisplayTeX::print_equalitylike
void print_equalitylike(std::ostream &, Ex::iterator)
Definition: DisplayTeX.cc:852
cadabra::DisplayTeX::DisplayTeX
DisplayTeX(const Kernel &, const Ex &)
Definition: DisplayTeX.cc:27