# Converting Tex fragment to its corresponding expression?

Posted 5 months ago
1179 Views
|
4 Replies
|
2 Total Likes
|
 I would think, by now, the LaTex parser can translate $\\ log _{c} c=p$ Tex fragment correctly instead of making me rewrite it?? Is this a bug or a limitation of the Tex parser? Am I misunderstanding something; sorry for being dense? Thanks
4 Replies
Sort By:
Posted 5 months ago
 Playing Devil's Advocate: you might think it should format as you desire but because Log[c,c] evaluates to 1, should you not end up in Mathematica with 1 == p if it evaluated as desired?
Posted 5 months ago
 Correct, a typo on my part, but my point was the parsing of the Tex into Mathematica. There is no log, only Log in Mathematica. It does not make sense to me why the Tex parser would not give me Log.
Posted 5 months ago
 By reading the documentation about TeXForm and ToExpression, I found a solution: t = TeXForm[HoldForm[Log[c, c] == p]] (*\log _c(c)=p*) ToExpression[ToString[t], TeXForm, HoldForm] (*Log[c, c] == p*) 
Posted 5 months ago
 Interesting....learned more. Currently am using a helper function to convert Tex to Mathematica: getTex[eq_String] := NotebookWrite[SelectedNotebook[], ImportString[eq, "LaTeX"]]; using it like this: getTex@"- Set of natural numbers: $\\quad N =\\{0,1,2,3, \\ldots\\}$, - Set of integers: $\\quad Z =\\{\\ldots,-2,-1,0,1,2, \\ldots\\}$, - Set of rational numbers: $\\quad Q =\\left\\{x \\mid x=\\frac{p}{q}\ \\right.$ with $p \\in Z , \\quad q \\in Z$ and $\\left.q \\neq \ 0\\right\\}$." This code has given the most stable direct easy way to convert TeX via copy and paste. The kernel asks to escape things when needed. Am open to suggestions to improve the code. And I wonder if there are other Tex stuff it fails to convert correctly like log. Is there a test bed to discover other exceptions? Thanks.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments