7

I am writing a sequence of inequalities in math mode, where the first line defines the first object. To be clear, I have something like

\documentclass[12pt]{amsart} 
\usepackage{amsfonts,graphics,amsmath,amsthm}
\usepackage{amsfonts,amscd, amssymb,amsmath,latexsym}
\usepackage{mathtools}

\begin{document}
\begin{equation}
\begin{split}
A &:= B - C \\
&= U + V \\
&\geq Z.
\end{split}
\end{equation}
\end{document}

I would like the = from the := in the first line to be aligned with the = in the second line. If I use the code above, it does not happen. Similarly, if I use \coloneqq in place of :=, the same misplacement happen. On the other hand, if I write :&=, I get the alignment I want; yet, in this way the column gets too far from the equal sign and it renders in an unpleasant way.

How can I get the alignment I want without having : too far from =?

Stefano
  • 377

4 Answers4

10

enter image description here

\documentclass[12pt]{amsart} 
\usepackage{amsfonts,graphics,amsmath,amsthm}
\usepackage{amsfonts,amscd, amssymb,amsmath,latexsym}
\usepackage{mathtools}

\begin{document}
\begin{equation}
\begin{split}
A :={}& B - C \\
={}& U + V \\
\geq{}& Z.
\end{split}
\end{equation}
\end{document}
David Carlisle
  • 757,742
5

With a TABstack, one does not need to add the blank groups that the split version needs, because TABstacks automatically, by default, add a group to the right end of each cell. The blank group can be defaulted to the left of each cell with the declaration \TABbinaryLeft (also \TABunaryRight), or blank groups can be added to both ends of each cell with \TABbinary. The original default condition can be restored with \TABbinaryRight (also \TABunaryLeft).

\documentclass[12pt]{amsart} 
\usepackage{amsfonts,graphics,amsmath,amsthm}
\usepackage{amsfonts,amscd, amssymb,amsmath,latexsym}
\usepackage{mathtools}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\begin{equation}
\tabbedCenterstack[r]{
A \coloneqq& B - C \\
=& U + V \\
\geq& Z.
}
\end{equation}
\end{document}

enter image description here

Note that I preferably use \coloneqq instead of :=, since \coloneqq comes ready made with vertical symmetry, whereas := does not.

enter image description here

3

This produces perfect alignment, and only affects the first line.

as shown by replacing the first \\ by \\[-.9\baselineskip].

However, it might be a bit silly...

The output

with \\[-.9\baselineskip]

enter image description here

without

enter image description here

The code

\documentclass[12pt]{standalone} 
\usepackage{mathtools}
\newlength\myUselessLength
\begin{document}
\settowidth{\myUselessLength}{${}={}$}
$
\begin{aligned}
  A\coloneqq{}\hspace{-\myUselessLength} & \phantom{{}={}} B - C \\
                                         & = U + V               \\
                                         & \geq Z.               \\
\end{aligned}
$
\end{document}
marsupilam
  • 6,383
2

Another way, same output.

\documentclass[12pt]{article} 
\usepackage{mathtools}
\begin{document}
\begin{equation}
  \begin{split}
    & \phantom{{}={}} \mathllap{A\coloneqq{}} B - C \\
    & = U + V                                       \\
    & \geq Z.                                       \\
  \end{split}
\end{equation}
\end{document}
marsupilam
  • 6,383