# MaTeX and \phantom

My understanding of the \phantom directive is that it should preserve the sizes of all elements in the expression. But when I try this:

m1 = Inset[MaTeX["\\sqrt{\\phantom{a^2}b}", Magnification -> 5], {0, 0}];

m2 = Inset[MaTeX["\\sqrt{a^2b}", Magnification -> 5], {0, 0}];

Graphics[{m1, m2}]


I get this:

I would have expected the two square roots to be right on top of each other.

• Please use code blocks for code, not quote blocks, otherwise some of the code might be destroyed (as it was here). – Szabolcs Dec 3 '17 at 9:24
• That's a very strange position for one of the b's! – Michael E2 Dec 4 '17 at 0:27

## 1 Answer

The same sizes show up using pure Latex.

\documentclass[11pt]{article}
\begin{document}

\Huge
$\sqrt{\phantom{a^2}b}$

$\sqrt{a^2b}$

\end{document}


Gives (compiled with pdflatex)

And this is inside Mathematica:

I do not see any difference. But I think your question is really about Latex itself and not Matex, which just compiles using Latex.

You could see this how-do-i-create-an-invisible-character on Tex Exchange where it says

\phantom inserts an empty box with the same dimensions (horizontal as well as vertical) as the argument

But if you think it is not doing what it should, I would suggest asking at https://tex.stackexchange.com

Update

What you want is \hphantom and not \phantom

m1=Inset[MaTeX["\\sqrt{\\hphantom{a^2}b}",Magnification->5],{0,0}]
m2=Inset[MaTeX["\\sqrt{a^2b}",Magnification->5],{0,0}]


Graphics[{m1,m2}]


• In plain TeX, $\sqrt{\phantom{a^2}b}$ and $\sqrt{{a^2}b}$ seem to coincide. (It could be that LaTeX messes things up. I'm not sure how to use it.) – Michael E2 Dec 4 '17 at 0:00
• @MichaelE2 that is interesting,. But no one uses Plain TeX anymore, well may be except for Donald Knuth himself :) This could be a good question for tex exchange to explain this difference between TeX and Latex. – Nasser Dec 4 '17 at 0:04
• And me. :-) Too many packages written in years gone by....When LaTeX came out, it seemed like the kid's version. ;-P -- Wait, do they not coincide in LaTeX? I didn't think LaTeX did anything drastic to TeX, unlike ConTeXt.... – Michael E2 Dec 4 '17 at 0:07
• @MichaelE2 I just compiled using plain TeX using \phantom and the output is the same as with Latex as shown in the post. i.e. Same spacing difference. They do not coincide. I am using texlive 2017 on Linux. ps. I tried to learn Context, but it is really a completely different system from Latex, so I decided not worth the time. – Nasser Dec 4 '17 at 0:14
• Isn't that interesting. I'm using pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015), MacOS. I wouldn't think plain TeX would have changed, and from what I know about plain TeX, they should coincide. Ah, well. However, I get the OP's output using MaTeX. – Michael E2 Dec 4 '17 at 0:19