# TeXToBoxes and BoxesToTeX BoxRules options

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 ConvertTeXTeXToBoxes. Let us see what Mathematica does when it encounters that $\TeX$ string string.

RawBoxes@ConvertTeXTeXToBoxes["\\int_{a\\hphantom{b} c}^{\\hphantom{a} b\\hphantom{c} d}"]


The output is:

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@ConvertTeXTeXToBoxes["\\begin{aligned}
a+b+c&=d \\\\
c&=d-a-b
\\end{aligned}"]


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:

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

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


which returns:

"3^(1/2)"

-