3

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}

Seemingly misaligned 2nd component on right-hand side of 1st equation

murray
  • 7,944
  • 1
    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 09 '20 at 21:04
  • 1
    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 09 '20 at 21:06
  • @Bernard: Where do I put a 3rd & to avoid the misalignment? – murray Apr 09 '20 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 09 '20 at 21:21

4 Answers4

4

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} 

Result of above code

F. Pantigny
  • 40,250
4

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.

enter image description here

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}

enter image description here

egreg
  • 1,121,712
  • 1
    multline looks a bit stretched. I'd be inclined to add \qquad at the two ends to narrow it. – barbara beeton Apr 09 '20 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 '20 at 00:15
3

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} 

enter image description here

Bernard
  • 271,350
  • Since alignat adds no "padding", I'd add \, after \varphi,; the following parenthsis looks a bit too close, – barbara beeton Apr 09 '20 at 21:41
  • 1
    =& is wrong; there's no need for multiple alignment points. – egreg Apr 09 '20 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 09 '20 at 21:53
2

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.

enter image description here

\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}
Mico
  • 506,678