MathGroup Archive 2009

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

Search the Archive

Re: TeX output via TeXForm: variable name translation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101031] Re: TeX output via TeXForm: variable name translation
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 21 Jun 2009 07:07:08 -0400 (EDT)
  • References: <h1hbfh$mq$1@smc.vnet.net>

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 first
> 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 using
> my translation table after I had converted to TeXForm or (3) is there
> a better solution altogether?
> 
> Thanks!
> 


  • Prev by Date: Re: BarChart and Ticks
  • Next by Date: Re: Integrate[], Sort[] and Hold[]
  • Previous by thread: Re: TeX output via TeXForm: variable name translation
  • Next by thread: Re: TeX output via TeXForm: variable name translation