2

Sometimes I want to use align in this fashion:

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

But latex flushes A, B, C against the equals sign, and I end up having to type something like this instead:

\begin{align}
 &\,\, A\\
=&\,\, B\\
=&\,\, C
\end{align}

Is there a "best practice" solution to avoid the use of \,, while visually achieving the same result as the second piece of code?

(Nb: I have checked that this is not a duplicate of: Spacing after equals sign in align)

Labrador
  • 245

3 Answers3

6
\begin{align}
 & A\\
={}& B\\
={}& C
\end{align}

placing the = to the left of the & and space to the right does not work as you would still have incorrect space to the left of the =, adding the empty {} math atom allows the = to have \mathrel spacing.

David Carlisle
  • 757,742
3

Hum... in the meanwhile of writing up my question, I found that

\begin{align}
&\phantom{{}={}} A\\
&= B\\
&= C
\end{align}

work as desired. (I guess this is best practice?)

Labrador
  • 245
  • It's certainly what I do:) –  Mar 27 '18 at 03:14
  • With the original setup, it is faster to just type {} &, the = sees the empty token ({}) and inserts the proper spacing – daleif Mar 27 '18 at 06:47
  • @daleif: Didn't quite understand what you were saying, maybe because of typos in your comment... did you mean the same as David Carlisle's comment below? – Labrador Mar 28 '18 at 00:49
  • It was, not sure was went wrong in the comment. Nevermind – daleif Mar 28 '18 at 05:36
1

If A, B or C is an expression beginning with a binary or prefix operator like - or \sum, then the previous answers give incorrect spacings. But the following solution will work.

The \phantom command downgrades a relation to an ordinary symbol. We therefore also define a relational phantom command \rphantom that preserves the class of a relation.

\documentclass{article}

\usepackage{amsmath}

\newcommand{\rphantom}[1]{\mathrel{\phantom{#1}}}

\begin{document}

\begin{align} &\rphantom{=} -A\ &= B\ &= -C-D\ &\phantom{=}\ -E \end{align}

\end{document}

A binary operator like - following a relation like = or \rphantom{=} is interpreted by LaTeX as an ordinary symbol. That's what we want in the first and the third line of our example.

LaTeX encloses relation symbols in thick spaces \; and binary operator symbols in medium spaces \:. In the fourth line of our example, the \phantom command strips = of its relation status, leaving it short of two thick spaces. On the other hand, LaTeX interprets - as a binary operator, creating a spurious medium space. So we need an extra normal space: \ = \; + \; - \:.

image