Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

A recent question has gotten me to look more into the tex conversion rules. Consider the following latex string:

\int_{a \hphantom{b} c}^{\hphantom{a} b \hphantom{c} d}

In latex it generates:

$$ \int_{a \hphantom{b} c}^{\hphantom{a} b \hphantom{c} d} $$

Mathematica has an undocumented function that it uses when it imports latex files. This is the function Convert`TeX`TeXToBoxes. Let us see what Mathematica does when it encounters that $\TeX$ string string.

RawBoxes@Convert`TeX`TeXToBoxes["\\int_{a\\hphantom{b} c}^{\\hphantom{a} b\\hphantom{c} d}"]

The output is:

enter image description here

So it seems that Mathematica has no boxes to put the \hphantom latex command. There are others such as the aligned environment in latex that doesn't know how to import.

RawBoxes@Convert`TeX`TeXToBoxes["\\begin{aligned}
  a+b+c&=d \\\\
  c&=d-a-b
\\end{aligned}"]

enter image description here

When it should have been displayed as:

\begin{aligned} a+b+c&=d \\ c&=d-a-b \end{aligned}

Mathematica is capable of displaying correctly by using the \[AlignmentMarker], see this answer to see how it is done. In this question I'm curious to see how a perfectly aligned equation can be exported to LaTeX, I already provided one solution which Mr.Wizard helped me complete. But I have a feeling that using "BoxRules" options might be a better way of doing things. So the question here is:

Can you come up with the right set of rules to transform from Mathematica Boxes to Tex and from Tex To Mathematica Boxes? This should be done at least in these two examples.

Edit:

It seems that this question is only valid for exporting mathematica boxes to latex. I tried to look for the options allowed in in the two functions and this is what I got:

enter image description here

This means that it is only fair to make this question about changing the mathematica boxes to latex using the "BoxRules" option. A simple example can be found here

Convert`TeX`BoxesToTeX[SqrtBox["3"], "BoxRules" -> {SqrtBox[x_] :> x <> "^(1/2)"}]

which returns:

"3^(1/2)"
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.