# Using the align environment?

I was trying to use the align environment on the main site. Here were the things I tried without success:

\begin{align*} A &= B \ &= C \ &= D \end{align*}

\begin{align*} A &= B \ &= C \ &= D \end{align*}

\begin{align*} A &= B \ &= C \ &= D \end{align*}

\begin{align*} A &= B \ &= C \ &= D \end{align*}

(incidentally, I'm also not sure how to display some code on this site, so if someone could go in an edit it so everyone else can see the code used for each of these attempts, that would be awesome)

\begin{align*} A &= B \\ &= C \\ &= D \end{align*}

• Looks fine to me. – Rasmus Jan 22 '12 at 15:18
• That's because I failed to communicate properly that the C and D were supposed to be on separate lines. I figured it out already, though. – Dustan Levenstein Jan 22 '12 at 15:23
• Using \\\ or \newline instead of \\ should work (see my edit). – Rasmus Jan 22 '12 at 16:19

The particular implementation/configuration of MathJax on this site allows for the use of \begin{align} and \end{align} environments to indicate the start and end of displayed material with syntax using the environments introduced in AMSTeX of the same name. That is, you can use \begin{align} and \end{align} in place of the  signs to trigger the activation of the Math environment. That is how things work on the MathJax side. However, for rendering the user content, in the text boxes we use the MarkDown (or an extension thereof) syntax, where underscores _ translates to italics and double asterisks ** gives bold. As part of the MarkDown syntax, the backslash character \ is co-opted as an escape character, so you can type \* when you actually want to display the asterisk * without having it interpreted as part of the "mark up". It is now necessary then to also escape backslash itself, since it has acquired a functional meaning. That is, to display the backslash, you need to type \\ to get \. Now you begin to see a little bit of conflict brewing on the horizon. MarkDown wants to change \\s to \s. In the context of an align environment, when you use \\ for line breaks, MarkDown substitutes in \ and when MathJax processes, it sees just \ followed by a blank-space character, so it interprets it just as a space, not as a line break. The reason that enclosing things in dollar signs can fix this is that SE has modified their MarkDown engine to explicitly ignore things inside special environments. For example, if you enclose things in back-ticks , you enter the "code" environment and things will be displayed verbatim, without MarkDown mucking about and interpreting stuff. One of the special environments is the math environments when delimited by dollar signs. To illustrate: \begin{align} A & = B \\ & = C \end{align}  gives \begin{align} A & = B \ & = C \end{align} while \begin{align} A & = B \\\\ & = C \end{align}  gives \begin{align} A & = B \\ & = C \end{align} and  \begin{align} A & = B \\ & = C \end{align} $$ gives$$ \begin{align} A & = B \\ & = C \end{align} $$In the middle case MarkDown changes the four consecutive backslashes \\\\` to \\, which when parsed by MathJax gives the intended output. One last remark: while the middle syntax works, it is exploiting the fact that the current implementation of MarkDown processes content before MathJax, and that it does not ignore non-dollar-sign-enclosed math environments. It can easily break if any of the conditions are changed. So I suggest taking the final syntax, that is, enclose everything in dollar signs, to make what you type more "future-proof". I figured it out; unlike in regular TeX, it seems that the \$$ is necessary to render the align environment on this website.
\begin{align*}A &= B \\ &= C \\ &=D\end{align*}