MathGroup Archive 2009

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

Search the Archive

Re: ToExpression[..,TexForm] does not seem to work on


Put a space after sum in the TeX

s = TeXForm[Sum[f[n], {n, 1, m}]]

\sum _{n=1}^m f(n)

Note the space after sum in the above output

ToExpression["\\sum _{n=1}^m f(n)", TeXForm]

Sum[f[n], {n, 1, m}]

ToExpression["\\sum _ {n=1}^m f(n)", TeXForm]

Sum[f[n], {n, 1, m}]


Bob Hanlon

---- "Nasser M. Abbasi" <nma at 12000.org> wrote: 

=============
 Version 7.

Some Latex commands are converted ok to Mathematica expressions, such as:

ToExpression["\\sqrt{3}", TeXForm]
ToExpression["\\frac{a}{b}", TeXForm]

But the next Latex "sum" command does not seem to work. Is this a known 
"issue" or is there a trick for one command?

I take the output of the TexForm command, and then try to convert it back to 
Mathematica expression, but the conversion back fails:

s = TeXForm[Sum[f[n], {n, 1, m}]]
ToExpression[ToString[s], TeXForm]

Even when I type the Latex output by hand, it does not work:

ToExpression["\\sum_{n=1}^m f(n)", TeXForm]

the error is :

Syntax::sntxi:Incomplete expression; more input is needed.
ToExpression::esntx:Could not parse \sum_{n=1}^m f(n) as Mathematica input.

--Nasser 



  • Prev by Date: Re: ToExpression[..,TexForm] does not seem to work on some Latex commands?
  • Next by Date: Re: Distribution of state occupancies in a multistate Markov model
  • Previous by thread: Re: Re: Opportunities and Player Pro
  • Next by thread: Re: ToExpression[..,TexForm] does not seem to work on