MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

TeX output via TeXForm: variable name translation

I am trying to find a good way to interoperate between Mathematica and
LaTeX (or LyX).
Typically, I am workign with multi-character variable names, which
TeXForm interprets as text:

In[65]:= TeXForm[e1]

To get around this, I am trying to create a translation table of
sorts: e.g.

TranslationTable1 = {{e1, "\\epsilon_1"}, {e0, "\\epsilon_0"}, {kz0t,
"\\tilde{k^{(0)}_z}"}, {kz1t, "\\tilde{k^{(1)}_z}"}};

I would like, if possible, to perform those replacements in
Mathematica, without writing and invoking external scripts.  The first
thing I tried was this:

TeXReplacements := (Rule[#[[1]], ToExpression[#[[2]], TeXForm,
HoldForm]] & /@ TranslationTable1)

In[67]:= (e1*kz0t) /. TeXReplacements // TeXForm

\epsilon _1 \tilde{k_z^0}

(This simply does the following:
In[69]:= (e1*kz0t) /. {e1 -> ToExpression["\\epsilon_1", TeXForm,
   kz0t -> ToExpression["\\tilde{k^{(0)}_z}", TeXForm, HoldForm]} //

\epsilon _1 \tilde{k_z^0}

Notice how this doesn't work: Take a look at the translation table
above and notice parentheses around in k_z^{(0)}.  Mathematica
discards these parentheses.

So the question to the group is: (1) is it possible to preserve the
formatting exactly how I specified it in the translation table before
converting to TeXForm  or (2) is it possible to do a replacement using
my translation table after I had converted to TeXForm or (3) is there
a better solution altogether?


  • Prev by Date: Re: Strange Behaviour: CellAutoOverwrite
  • Next by Date: Re: Text and multiple calculations in an IF condition
  • Previous by thread: My first calculator =)
  • Next by thread: Re: TeX output via TeXForm: variable name translation