# Why is column pushed right in alignat?

I thought that alignat inserted no extra spaces between columns. Then why in the following is the part \left.(r \cos \theta + R) \sin \varphi,\right. of the first row pushed toward the right?

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{3}
F(\theta, \varphi)= & \left((r \cos \theta + R) \cos \varphi, \right. & \left.(r \cos \theta + R) \sin \varphi,\right.
\\
& & \left. r \sin \theta \cos (\varphi/2),\, r \sin (\theta ) \sin (\varphi/2)\,\right)
\end{alignat*}

\end{document}


• It's because the columns are alternatively flushed right, left, right and so on, hence the third column is flushed right. The "extra space" that appears here is only due to the second row, on which the content of the third column is larger. – Vincent Apr 9 at 21:04
• Thatis because, as you used only 2 & instead of 3, the alignment point of the second column is not specified, and by default, it is set at the end of the column, i.e. the latter is right-aligned. – Bernard Apr 9 at 21:06
• @Bernard: Where do I put a 3rd & to avoid the misalignment? – murray Apr 9 at 21:08
• I've updated my code – didn't notice you had alignat{3} for two columns! Also, I removed the pairs of \left ... \right which did nothing to replace all of them by a single pair \bigl( ... \bigr) ((which can have ampersands or line breaks in between). – Bernard Apr 9 at 21:21

I would use a simple split environment with a single alignment point per line. I'd also get rid of the distracting \left and \right sizing directives (in particular, because they don't accomplish anything meaningful) and use \bigl[ and \bigr], respectively.

\documentclass{article}
\usepackage{amsmath} % for 'split' environment
\begin{document}
$\begin{split} F(\theta, \varphi) &= \bigl[( r \cos\theta + R) \cos\varphi,\, (r \cos\theta + R) \sin\varphi, \\ &\qquad r \sin\theta \cos(\varphi/2),\, r \sin\theta \sin(\varphi/2) \bigr] \end{split}$
\end{document}

• Perhaps this way is the simplest and gives the most attractive result – murray Apr 11 at 0:43

If you want, you can also use witharrows. Maybe the syntax may seem more natural (of course, the main usage of witharrows is to add arrows in such alignments).

\documentclass{article}
\usepackage{witharrows}
\begin{document}
\begin{DispWithArrows*}[format = rll]
F(\theta, \varphi)= & \bigl((r \cos \theta + R) \cos \varphi, &  (r \cos \theta + R) \sin \varphi,
\\
& &  r \sin \theta \cos (\varphi/2),\, r \sin (\theta ) \sin (\varphi/2)\,\bigr)
\end{DispWithArrows*}
\end{document}


• Oooh...that's a trick I never encountered before; useful! – murray Apr 10 at 0:18

You're using the wrong tool: this wants multline:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{multline*}
F(\theta, \varphi)= \bigl((r \cos \theta + R) \cos \varphi, (r \cos \theta + R) \sin \varphi,
\\
r \sin \theta \cos (\varphi/2), r \sin \theta \sin (\varphi/2)\bigr)
\end{multline*}

\end{document}


No \left and \right.

Alternatively, align:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
F(\theta, \varphi)= \bigl((r \cos \theta + R) \cos \varphi&, (r \cos \theta + R) \sin \varphi,
\\
&\quad r \sin \theta \cos (\varphi/2), r \sin \theta \sin (\varphi/2)\bigr)
\end{align*}

\end{document}


• multline looks a bit stretched. I'd be inclined to add \qquad at the two ends to narrow it. – barbara beeton Apr 9 at 21:54
• Indeed, multline requires some fiddling to compress the dislay and, in particular, to align the 3rd entry in the list on the right-hand side of the equation with the 2nd one – murray Apr 10 at 0:15

Use this (and remember that n alignment columns require 2 n – 1 &). Using \bigl( and bigr), which accept ampersands or line breaks in between, will save you the plethora of \left ... \right:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
F(\theta, \varphi)= & \bigl((r \cos \theta + R) \cos \varphi, & & (r \cos \theta + R) \sin \varphi,
\\
& & & r \sin \theta \cos (\varphi/2),\, r \sin (\theta ) \sin (\varphi/2)\,\bigr)
\end{alignat*}

\end{document}


• Since alignat adds no "padding", I'd add \, after \varphi,; the following parenthsis looks a bit too close, – barbara beeton Apr 9 at 21:41
• =& is wrong; there's no need for multiple alignment points. – egreg Apr 9 at 21:44
• @egreg: I agree, but I supposed that in the real equations, there are other lines with an alignment on the = sign. Maybe this hypothesis was erroneous… – Bernard Apr 9 at 21:53