1

I have 2 equations with two equality signs each. The equality signs should be vertically aligned. I can produce the expected output like this:1
Please read the footnote if you think this is just the wrong approach. You're right.

% Full MWE at the bottom of the question
\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz
\end{align*}

Output 1

But if I just at a (seemingly) innocent \\ to the end of the second equation, the \hspace apparently has no effect anymore:

\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz \\
\end{align*}
%
\begin{align*}
foooo &= bar &&= baz \\
abc &= defgh  &&= xyz \\
\end{align*}

Output 2

I used to think that \\ has no effect in the last line of an equation. Now, this example proves me wrong.

Question: I would like to understand why the trailing \\ changes the alignment in my equation / why it defeats the effect of \hspace{-3.6cm}.

I added an scrartcl tag because I realized that the behavior is different in article. My question is based on scrartcl.


MWE:

\documentclass{scrartcl}
\usepackage{amsmath}
\begin{document}
\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz 
\end{align*}

\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz \\
\end{align*}
\end{document}

1 I know that I shouldn't be using negative whitespace as shown in my example but rather alignat:

\begin{alignat*}{2}
foooo &= bar &&= baz \\
abc &= defgh  &&= xyz
\end{alignat*}

However, the point of this question is not how to produce a certain alignment but to understand why the trailing \\ matters.

  • 1
    The `\\` adds another empty equation, and in this equation the second alignment is wider than in the first two lines: indeed, in these the width of the left hand side of the equation is negative, while in the last line it is zero. – GuM Jul 20 '18 at 12:52
6

The reason for the observed behaviour is not really the trailing \\, but rather the fact that there is a third line without \hspace{-3.6cm}. In the code below I have added such a line inbetween, so there is no trailing \\.

\documentclass{scrartcl}
\usepackage{amsmath}
\begin{document}
\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz 
\end{align*}

\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
abc &= defgh  &\hspace{-3.6cm}&= xyz\\
\end{align*}
\begin{align*}
foooo &= bar &\hspace{-3.6cm}&= baz \\
      &      &               &      \\
abc &= defgh  &\hspace{-3.6cm}&= xyz 
\end{align*}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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