# Align $:=$ with $=$ in align/split mode

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{split} A &:= B - C \\ &= U + V \\ &\geq Z. \end{split}$$
\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 =?

• &\mathrel{\phantom{:}}= U + V – Manuel May 30 '17 at 17:43
• Do you mean that you want to have the = in := aligned with the = below ? – marsupilam May 30 '17 at 17:43
• @Manuel But then you have to add the \phantom to all subsequent lines, don't you ? Maybe it is more simple to have : A:&= B-C and then leave all further lines unchanged ? An even better solution probably involves the mathtools command \coloneqq – marsupilam May 30 '17 at 17:47
• @marsupilam Or define \colonalign and use that every instance you need. Or may be :\joinrel\joinrel&= works if you put it just in the first line? (Can't test right now.) – Manuel May 30 '17 at 17:53
• @marsupilam Yes, I mean that – Stefano May 30 '17 at 18:09

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

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


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}
$$\tabbedCenterstack[r]{ A \coloneqq& B - C \\ =& U + V \\ \geq& Z. }$$
\end{document}


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

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 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}

• If someone knows how not to have to use a useless length for doing such a thing, I'm all ears ! – marsupilam May 30 '17 at 18:46

Another way, same output.

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