Cadabra
Computer algebra system for field theory problems
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
cadabra::DisplayTeX Class Reference

Description

Class to handle display of expressions using LaTeX notation.

This is a very non-local bit of logic, in the sense that it will try to look around the property assignments in order to figure out the best way to print any given object. See the DisplayTeX::dispatch method to see how this works in more detail.

#include <DisplayTeX.hh>

Inheritance diagram for cadabra::DisplayTeX:
cadabra::DisplayBase

Public Member Functions

 DisplayTeX (const Kernel &, const Ex &)
 
- Public Member Functions inherited from cadabra::DisplayBase
 DisplayBase (const Kernel &, const Ex &)
 
void output (std::ostream &)
 
void output (std::ostream &, Ex::iterator)
 

Protected Member Functions

virtual bool needs_brackets (Ex::iterator it) override
 Determine if a node needs extra brackets around it. More...
 

Private Member Functions

void print_multiplier (std::ostream &, Ex::iterator, int mult=1)
 
void print_opening_bracket (std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
 
void print_closing_bracket (std::ostream &, str_node::bracket_t, str_node::parent_rel_t)
 
void print_parent_rel (std::ostream &, str_node::parent_rel_t, bool first)
 
void print_children (std::ostream &, Ex::iterator, int skip=0)
 
std::string texify (std::string) const
 
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 LaTeX expression. More...
 
void print_productlike (std::ostream &, Ex::iterator, const std::string &inbetween)
 Printing members for various standard constructions, e.g. More...
 
void print_sumlike (std::ostream &, Ex::iterator)
 
void print_fraclike (std::ostream &, Ex::iterator)
 
void print_commalike (std::ostream &, Ex::iterator)
 
void print_arrowlike (std::ostream &, Ex::iterator)
 
void print_powlike (std::ostream &, Ex::iterator)
 
void print_intlike (std::ostream &, Ex::iterator)
 
void print_equalitylike (std::ostream &, Ex::iterator)
 
void print_commutator (std::ostream &str, Ex::iterator it, bool comm)
 
void print_components (std::ostream &, Ex::iterator)
 
void print_conditional (std::ostream &, Ex::iterator)
 
void print_relation (std::ostream &, Ex::iterator)
 
void print_indexbracket (std::ostream &, Ex::iterator)
 
void print_wedgeproduct (std::ostream &, Ex::iterator)
 
void print_tableau (std::ostream &, Ex::iterator)
 
void print_ftableau (std::ostream &, Ex::iterator)
 
void print_dot (std::ostream &str, Ex::iterator it)
 
void print_dots (std::ostream &str, Ex::iterator it)
 
void print_other (std::ostream &str, Ex::iterator it)
 
bool children_have_brackets (Ex::iterator ch) const
 
bool reads_as_operator (Ex::iterator obj, Ex::iterator arg) const
 Determine whether the indicated object 'obj', when acting on the single argument 'arg', reads as an operator, and therefore 'arg' does not need to be wrapped in brackets. More...
 

Private Attributes

bool print_star =false
 
bool tight_star =false
 
bool latex_spacing =true
 
bool extra_brackets_for_symbols =false
 
int bracket_level =0
 
std::map< std::string, std::string > symmap
 Map from Cadabra symbols to LaTeX symbols (for some typographic cleanup). More...
 
std::set< std::string > curly_bracket_operators
 List of operators which need all arguments fed with curly brackets, not round ones (e.g. More...
 

Additional Inherited Members

- Protected Attributes inherited from cadabra::DisplayBase
const Extree
 
const Kernelkernel
 

Constructor & Destructor Documentation

◆ DisplayTeX()

DisplayTeX::DisplayTeX ( const Kernel k,
const Ex e 
)

Member Function Documentation

◆ children_have_brackets()

bool DisplayTeX::children_have_brackets ( Ex::iterator  ch) const
private

◆ dispatch()

void DisplayTeX::dispatch ( std::ostream &  str,
Ex::iterator  it 
)
overrideprivatevirtual

For every object encountered, dispatch will figure out the most appropriate way to convert it into a LaTeX expression.

This may be done by simply looking at the object's name (e.g. \prod will print as a product) but may also involve looking up properties and deciding on the best course of action based on the attached properties.

Implements cadabra::DisplayBase.

◆ needs_brackets()

bool DisplayTeX::needs_brackets ( Ex::iterator  it)
overrideprotectedvirtual

Determine if a node needs extra brackets around it.

Uses context from the parent node if necessary. Has to be implemented in a derived class, because the answer depends on the printing method (e.g. (a+b)/c needs brackets when printed like this, but does not need brackets when printed as \frac{a+b}{c}).

Implements cadabra::DisplayBase.

◆ print_arrowlike()

void DisplayTeX::print_arrowlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_children()

void DisplayTeX::print_children ( std::ostream &  str,
Ex::iterator  it,
int  skip = 0 
)
private

◆ print_closing_bracket()

void DisplayTeX::print_closing_bracket ( std::ostream &  str,
str_node::bracket_t  br,
str_node::parent_rel_t  pr 
)
private

◆ print_commalike()

void DisplayTeX::print_commalike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_commutator()

void DisplayTeX::print_commutator ( std::ostream &  str,
Ex::iterator  it,
bool  comm 
)
private

◆ print_components()

void DisplayTeX::print_components ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_conditional()

void DisplayTeX::print_conditional ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_dot()

void DisplayTeX::print_dot ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_dots()

void DisplayTeX::print_dots ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_equalitylike()

void DisplayTeX::print_equalitylike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_fraclike()

void DisplayTeX::print_fraclike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_ftableau()

void DisplayTeX::print_ftableau ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_indexbracket()

void DisplayTeX::print_indexbracket ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_intlike()

void DisplayTeX::print_intlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_multiplier()

void DisplayTeX::print_multiplier ( std::ostream &  str,
Ex::iterator  it,
int  mult = 1 
)
private

◆ print_opening_bracket()

void DisplayTeX::print_opening_bracket ( std::ostream &  str,
str_node::bracket_t  br,
str_node::parent_rel_t  pr 
)
private

◆ print_other()

void DisplayTeX::print_other ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_parent_rel()

void DisplayTeX::print_parent_rel ( std::ostream &  str,
str_node::parent_rel_t  pr,
bool  first 
)
private

◆ print_powlike()

void DisplayTeX::print_powlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_productlike()

void DisplayTeX::print_productlike ( std::ostream &  str,
Ex::iterator  it,
const std::string &  inbetween 
)
private

Printing members for various standard constructions, e.g.

print as a list, or as a decorated symbol with super/subscripts etc. The names reflect the structure of the output, not necessarily the meaning or name of the object that is being printed.

◆ print_relation()

void DisplayTeX::print_relation ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_sumlike()

void DisplayTeX::print_sumlike ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_tableau()

void DisplayTeX::print_tableau ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ print_wedgeproduct()

void DisplayTeX::print_wedgeproduct ( std::ostream &  str,
Ex::iterator  it 
)
private

◆ reads_as_operator()

bool DisplayTeX::reads_as_operator ( Ex::iterator  obj,
Ex::iterator  arg 
) const
private

Determine whether the indicated object 'obj', when acting on the single argument 'arg', reads as an operator, and therefore 'arg' does not need to be wrapped in brackets.

Example: the tree \partial{A} can be displayed as \partial A (or rather, \partial{A}, instead of \partial(A).

◆ texify()

std::string DisplayTeX::texify ( std::string  str) const
private

Member Data Documentation

◆ bracket_level

int cadabra::DisplayTeX::bracket_level =0
private

◆ curly_bracket_operators

std::set<std::string> cadabra::DisplayTeX::curly_bracket_operators
private

List of operators which need all arguments fed with curly brackets, not round ones (e.g.

\sqrt).

◆ extra_brackets_for_symbols

bool cadabra::DisplayTeX::extra_brackets_for_symbols =false
private

◆ latex_spacing

bool cadabra::DisplayTeX::latex_spacing =true
private

◆ print_star

bool cadabra::DisplayTeX::print_star =false
private

◆ symmap

std::map<std::string, std::string> cadabra::DisplayTeX::symmap
private

Map from Cadabra symbols to LaTeX symbols (for some typographic cleanup).

◆ tight_star

bool cadabra::DisplayTeX::tight_star =false
private

The documentation for this class was generated from the following files: