From: snowrain on
Hi all
Does anyone know how to convert LaTex file to Mathematica ?
For example, the formula that I typed in LaTex is:
ln{H}^{*} &= {X}_{1} {\beta}_{1} + {\alpha}_{1}lnE+ {\varepsilon}_{1}\\
If I copy the above LaTex command to Mathematica, it only shows the
original LaTex command. I'd like to have symbols for beta, alpha, and also
for subscript and superscript. That is, I hope it looks like the pdf file
that LaTex produces instead of showing "\beta", "\alpha", etc.
Please advise.
thanks a lot !



--
Message posted using http://www.talkaboutcomputing.com/group/comp.soft-sys.math.mathematica/
More information at http://www.talkaboutcomputing.com/faq.html


From: Jens-Peer Kuska on
Hi,

ImportString[
"$ln{H}^{*}&={X}_{1} \
{\\beta}_{1}+{\\alpha}_{1}lnE+{\\varepsilon}_{1}$",
"TeX"] // NotebookPut

??

Regards
Jens

snowrain wrote:
> Hi all
> Does anyone know how to convert LaTex file to Mathematica ?
> For example, the formula that I typed in LaTex is:
> ln{H}^{*} &= {X}_{1} {\beta}_{1} + {\alpha}_{1}lnE+ {\varepsilon}_{1}\\
> If I copy the above LaTex command to Mathematica, it only shows the
> original LaTex command. I'd like to have symbols for beta, alpha, and also
> for subscript and superscript. That is, I hope it looks like the pdf file
> that LaTex produces instead of showing "\beta", "\alpha", etc.
> Please advise.
> thanks a lot !
>
>
>
> --
> Message posted using http://www.talkaboutcomputing.com/group/comp.soft-sys.math.mathematica/
> More information at http://www.talkaboutcomputing.com/faq.html
>
>

From: Jean-Marc Gulliet on
snowrain wrote:

> Does anyone know how to convert LaTex file to Mathematica ?
> For example, the formula that I typed in LaTex is:
> ln{H}^{*} &= {X}_{1} {\beta}_{1} + {\alpha}_{1}lnE+ {\varepsilon}_{1}\\
> If I copy the above LaTex command to Mathematica, it only shows the
> original LaTex command. I'd like to have symbols for beta, alpha, and also
> for subscript and superscript. That is, I hope it looks like the pdf file
> that LaTex produces instead of showing "\beta", "\alpha", etc.

First, note that Mathematica handles AMS-LaTeX. Depending on how the
code you have adheres to this standard, you will get varying results
with the automatic conversion process.

Converting a LaTeX file can be done via the command *Import* [1], e.g.

Import["filename.tex"]

If you want to convert just one expression in TeX/LaTeX, you can use use
ToExpression with the option TeXForm [2, 3].

Note that the expression must be enclosed within double quotes, must
start and end with a dollar sign, and backlashes must be repeated.

In[12]:= ToExpression["$ln{H}^{*}&={X}_{1}
{\\beta}_{1}+{\\alpha}_{1}lnE+{\\varepsilon}_{1}\\\\$", TeXForm]

Out[12]= l n
\!\(\*SuperscriptBox["H", "*"]\) ==
E l n Subscript[\[Alpha], 1] +
Subscript[X, 1] Subscript[\[Beta], 1] + Subscript[\[Epsilon], 1]

Regards,
- Jean-Marc

[1] http://reference.wolfram.com/mathematica/ref/format/LaTeX.html

[2] http://reference.wolfram.com/mathematica/ref/TeXForm.html

[3] http://reference.wolfram.com/mathematica/ref/ToExpression.html

From: snowrain on
Thanks for your reply !
I tried "Import" to import the Latex file but it shows error info as below:
Import::texerr: Error: Math character '\alpha ' in non-math mode.

Can you please let me know what is the problem?
thanks a lot !

From: Murray Eisenberg on
I tried something similar, but using ToExpression[...,"TeXForm"],
likewise removing the trailing "\\" from the original.

(I was surprised that Mathematica just ignored the "&", which is
evidently in the original expression because that expression is part of
a larger LaTeX construct such as a \begin{align}...\end{align).

However, I was unable to see how to let Mathematica itself convert the
single backslashes, which of course are interpreted as escape symbols,
to the needed double-backslashes. The obvious thing,

expr = "\ln{H}^{*} &= {X}_{1} {\beta}_{1} + {\alpha}_{1}lnE+ \
{\varepsilon}_{1}";

expr/. "\"->"\\"

does not work, of course.

Jens-Peer Kuska wrote:
> Hi,
>
> ImportString[
> "$ln{H}^{*}&={X}_{1} \
> {\\beta}_{1}+{\\alpha}_{1}lnE+{\\varepsilon}_{1}$",
> "TeX"] // NotebookPut
>
> ??
>
> Regards
> Jens
>
> snowrain wrote:
>> Hi all
>> Does anyone know how to convert LaTex file to Mathematica ?
>> For example, the formula that I typed in LaTex is:
>> ln{H}^{*} &= {X}_{1} {\beta}_{1} + {\alpha}_{1}lnE+ {\varepsilon}_{1}\\
>> If I copy the above LaTex command to Mathematica, it only shows the
>> original LaTex command. I'd like to have symbols for beta, alpha, and also
>> for subscript and superscript. That is, I hope it looks like the pdf file
>> that LaTex produces instead of showing "\beta", "\alpha", etc.
>> Please advise.
>> thanks a lot !
>>
>>
>>
>> --
>> Message posted using http://www.talkaboutcomputing.com/group/comp.soft-sys.math.mathematica/
>> More information at http://www.talkaboutcomputing.com/faq.html
>>
>>
>

--
Murray Eisenberg murray(a)math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305