Goal
I am trying to export a very long expression like
expr = c1*bracket1[a+b+c2*bracket2[d+e+f...]]+...
to LaTeX using TeXForm
.
bracket1[arg_]
should end up as \Biggl\{<arg>\Biggr\}
, bracket2[arg_]
as \biggl<arg>\biggr]
and so on.
What I have
What I have managed so far is defining a format for bracket1
and bracket2
that adds text before and after the argument:
Format[bracket1[arg_]] := Row[{"beginbracket1",arg,"endbracket1"}]
Format[bracket2[arg_]] := Row[{"beginbracket2",arg,"endbracket2"}]
This renders expr
(without the ellipsis) as
In[1] := expr//TeXForm
Out[1] := \text{c1} \text{beginbracket1}a+b+\text{c2} \text{beginbracket2}d+e+f\text{endbracket2}\text{endbracket1}
What I have not / Questions
The above does not work if I include
TeXForm
in theFormat
definition. I think I read somewhere that theTeXForm
is not distributed to the recursive calls ofFormat
during formatting. The implementation above leads toStandardForm
being cluttered by the strings as well. Is there a way to restrict this formatting to TeXForm?What I could not achieve as well was outputting raw LaTeX commands:
Format[foo,TeXForm] := "\\foo"
produces
In[1] := foo//TeXForm Out[1] := "\text{$\backslash \backslash $foo}"
and using
[\Backslash]
instead of\\
only reduces the number of$\backslash$
to one. Is there a way to define raw TeX commands?
Remarks
- I would like to avoid using
\left
and\right
because of the line breaks which are necessary due to the length of the expressions. - I would be content with a solution which allows me use the different sizes of LaTeX brackets (and braces and parentheses) without the raw TeX commands. It would be nice to know whether raw TeX is possible at all though.