Cadabra
a field-theory motivated approach to computer algebra

LaTeXForm

Changes the way in which expressions are displayed.
The LaTeXForm property changes the way in which expressions are displayed in the graphical interface. In its simplest form, it acts just like a node rename operation,
\del{#}::LaTeXForm("\partial"). ex:=\del_{m}(A);
\(\displaystyle{}\partial_{m}\left(A\right)\)
\del_{m}(A)
This prints $\partial_{m}(A);$ in the notebook, despite the fact that \del is not a LaTeX{} command. If you use this property to make a symbol printable, make sure to declare it before any other properties are declared, otherwise the notebook will not know how to display the symbol and produce an error message. Note that the property is attached to a pattern (\del{#} in this case) which matches the expression in which the replacement has to be made. If the pattern matches, the replacement will be done on the head symbol (\del in this case). A pattern \del without the argument wildcard # would only replace when \del occurs without any arguments (as in e.g. \del + A).
If you want more control over the way in which elements of your original expression are printed, you can use patterns like in the example below:
\ket{A??}{q??}::LaTeXForm("|", A??, "\rangle_{", q??, "}").
ex:=\ket{n+1}{a};
\(\displaystyle{}|n+1\rangle_{a}\)
\ket(n + 1 , a)
The comma-separated list of arguments to LaTeXForm will be concatenated into a single LaTeX output string, with patterns replaced by their normal output form.
Note that in all of the strings used inside the LaTeXForm property, you do not need to do any escaping of special characters: these strings are always interpreted as raw strings. Also note that you need to use double quotes, not single quotes.
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science