3

Although I searched the Web and indeed found an answer here, I still seem unable to address my issue of aligning two rows in my step-by-step process for solving a very basic equation. Just in case it matters, I am using MathJax, which is a JavaScript library that renders LaTeX in various forms of output (in my case, as MathML and HTML/CSS).

My code:

\begin{eqnarray}
    \hphantom{-} 9 + x &=& 12   \\
    -9 \hphantom{+ x} &=& -9    \\
    \hline                      \\
    \implies x &=& 3
\end{eqnarray}

My goal is to get the "9" to align in the first two rows, however, the \hphantom macro in the first row isn't adjusting the 9 + x = 12 at all. I came up with the code using the help of people who answered a similar alignment question elsewhere here.

I noted that when I reversed the first two rows in my code, \hphantom did indeed align the 9 correctly.

I would appreciate anyone helping me determine if there is an issue with my LaTeX. If not, I can investigate the HTML/CSS layout issues.

Moriambar
  • 11,466
Curtis
  • 51
  • 6
  • 4
    Yes, it matters because MathJaX is not really TeX, it only uses TeX for markup. Though, you can try \hphantom{{} + x}. And do not use eqnarray: eqnarray vs align – Qrrbrbirlbel Mar 03 '13 at 06:29
  • Thank you, @Qrrbrbirlbel, your suggestion addressed the problem perfectly. I'll better keep in mind that MathJax may have discrepancies down the line, as well. EDIT: also, I wasn't aware of the issues of eqnarray, thank you for the reference! – Curtis Mar 03 '13 at 07:25
  • 1
    Summarize your findings (and the comments) into an answer, and later accept it to close the issue. – vonbrand Mar 03 '13 at 17:46

1 Answers1

2

Thanks to @Qrrbrbirlbel, I was able to address the problem by using: \hphantom{{} + x}. So, if you're a MathJax user, this does address the issue.

Although I have yet to turn up on the Web further information as to why this alteration fixes things, it's nevertheless useful to keep in mind.

Curtis
  • 51
  • 6
  • 1
    The spacing rules are in the TeXbook. + is class \mathbin when between to ordinary (\mathord) symbols such as x, 9 or {}, otherwise it is an ordinary symbol. No spacing is placed between mathord's, whereas Ord-Bin-Ord gets extra spacing around the binary operator. The reason that a unitary + should be placed right up by the symbol it affects, whereas a binary one should be spaced off from its symbols. – Andrew Swann Mar 11 '13 at 08:04