I have several Mathematica expressions in which subscripts are expressed with square brackets. E.g. x[12]
is meant to represent x12, etc. If I evaluate TeXForm
on such an expression, x[12]
, e.g., gets converted to x(12)
. Is there a way to get it to produce the x_{12}
form instead?
Answer
Probably the easiest solution here is to use
Format[x[arg_],TraditionalForm]:=Subscript[x, arg]
This makes sure that the subscript form is used when the display is in TraditionalForm
, which is also an intermediate step in creating TeXForm
. Then you get for example
1+x[13]//TeXForm
$x_{13}+1$
The Format
can't be specified directly for TeXForm
because then expressions where your x[12]
is surrounded by other things as in 1 + x[12]
won't get translated correctly.
Comments
Post a Comment