Re: TeX output via TeXForm: variable name translation

*To*: mathgroup at smc.vnet.net*Subject*: [mg101200] Re: TeX output via TeXForm: variable name translation*From*: dnquark <dnquark at gmail.com>*Date*: Fri, 26 Jun 2009 06:53:17 -0400 (EDT)*References*: <h1hbfh$mq$1@smc.vnet.net> <h1l43o$2e4$1@smc.vnet.net>

Thanks -- this is insightful, but doesn't address the main problem I had: eo /: MakeBoxes[eo, fmt_: StandardForm] := SuperscriptBox["\ [Epsilon]", "(o)"] In[438]:= eo // TeXForm Out[438]//TeXForm= \epsilon ^{\text{(o)}} How do I get rid of the "text" tag?.. On Jun 21, 7:04 am, Jens-Peer Kuska <ku... at informatik.uni-leipzig.de> wrote: > Hi, > > set up the boxes for you symbol in a proper way and Mathematica > does the rest, i.e. > > e1 /:MakeBoxes[e1, fmt_: StandardForm] := > SubscriptBox["\[Epsilon]", "1"] > > and > > TeXForm[e1] > > gives > > \epsilon _1 > > Regards > Jens > > > > dnquark wrote: > > 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] > > Out[65]//TeXForm= > > \text{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 firs= t > > thing I tried was this: > > > TeXReplacements := (Rule[#[[1]], ToExpression[#[[2]], TeXForm, > > HoldForm]] & /@ TranslationTable1) > > > In[67]:= (e1*kz0t) /. TeXReplacements // TeXForm > > > Out[67]//TeXForm= > > \epsilon _1 \tilde{k_z^0} > > > (This simply does the following: > > In[69]:= (e1*kz0t) /. {e1 -> ToExpression["\\epsilon_1", TeXForm, > > HoldForm], > > kz0t -> ToExpression["\\tilde{k^{(0)}_z}", TeXForm, HoldForm]} /= / > > TeXForm > > > Out[69]//TeXForm= > > \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 usin= g > > my translation table after I had converted to TeXForm or (3) is there > > a better solution altogether? > > > Thanks!- Hide quoted text - > > - Show quoted text -