7
$\begingroup$

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:

enter image description here

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

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

1 Answer 1

12
$\begingroup$

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)

Mathematica graphics

And this is inside Mathematica:

Mathematica graphics

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}]

Mathematica graphics

Graphics[{m1,m2}]

Mathematica graphics

$\endgroup$
6
  • $\begingroup$ 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.) $\endgroup$
    – Michael E2
    Dec 4, 2017 at 0:00
  • $\begingroup$ @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. $\endgroup$
    – Nasser
    Dec 4, 2017 at 0:04
  • $\begingroup$ 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.... $\endgroup$
    – Michael E2
    Dec 4, 2017 at 0:07
  • $\begingroup$ @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. $\endgroup$
    – Nasser
    Dec 4, 2017 at 0:14
  • $\begingroup$ 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. $\endgroup$
    – Michael E2
    Dec 4, 2017 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.