# align in array causes right shift

Compile the code:

\documentclass{article}

\usepackage{enumitem,amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{hyperref}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{array}
\usepackage{makecell}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{L}{>{\displaystyle}l}

\begin{document}

\everymath{\displaystyle}

\setlength\arraycolsep{15pt} % default is '5pt' \begin{array}{@{} *{3}{L} @{}} \toprule \sin (x + 2k\pi) = \sin x & \cos (x + 2k\pi) = \cos x & \tan (x + 2k\pi) = \tan x \\ \midrule % \sin (x + \pi) = -\sin x & % \sin (x + \pi) = -\sin x & % \tan (x + \pi) = \tan x \\ \addlinespace % \sin (\pi - x) = \sin x & % \cos (\pi - x) = -\cos x & % \tan (\pi - x) = -\tan x \\ \midrule % \sin (x + \frac{\pi}{2}) = \cos x & % \cos (x + \frac{\pi}{2}) = -\sin x & % \tan (x + \frac{\pi}{2}) = -\cot x \\ \addlinespace % \sin (\frac{\pi}{2} - x) = \cos x & % \cos (\frac{\pi}{2} - x) = \sin x & % \tan (\frac{\pi}{2} - x) = \cot x \\ \midrule \begin{aligned}[t] & \sin (\alpha+\beta) \\ & = \sin\alpha\cos\beta + \cos\alpha\sin\beta \end{aligned} & \begin{aligned}[t] & \cos (\alpha+\beta) \\ & = \sin\alpha\cos\beta + \cos\alpha\sin\beta \end{aligned} & \begin{aligned}[t] & \tan (\alpha+\beta)\\ & = \frac{\tan\alpha + \tan\beta} {1 - \tan\alpha\tan\beta} \end{aligned} \\ \addlinespace[2ex] \sin 2x = 2 \cos x \sin x & \begin{aligned}[t] \cos 2x & = \cos^2 x - \sin^2 x \\ & = 2\cos^2 x - 1 \\ & = 1 - 2\sin^2 x \end{aligned} & \tan 2x = \frac{2\tan x}{1 - \tan^2 x} \\ \addlinespace[2ex] \sin \frac{x}{2} = \sqrt{\frac{1 - \cos x}{2}} & \cos \frac{x}{2} = \sqrt{\frac{1 + \cos x}{2}} & \tan \frac{x}{2} = \sqrt{\frac{1 - \cos x}{1 + \cos x}} \\ \bottomrule \end{array}


Pay attention to the second row regarding sin(α+β). There's some weird right shift of the whole row. I notice that this happens when I use aligned in all three cells, but not happening when I only use aligned in one of the three cells (just like the next row). How to solve this?

There are two different spacing issues.

For technical reasons, after & the environments align, aligned and similar insert {} which has the effect of triggering \mathop or \mathrel spacing if the following item is an operator or a relation.

You need to kill these spacings.

\documentclass{article}

\usepackage{enumitem,amssymb}
\usepackage{amsmath}
\usepackage{booktabs,array}
\newcolumntype{L}{>{\displaystyle}l}

\begin{document}

\setlength\arraycolsep{15pt} % default is '5pt' \begin{array}{@{} *{3}{L} @{}} \toprule \sin (x + 2k\pi) = \sin x & \cos (x + 2k\pi) = \cos x & \tan (x + k\pi) = \tan x \\ \midrule % \sin (x + \pi) = -\sin x & % \sin (x + \pi) = -\sin x & % \tan (x + \pi) = \tan x \\ \addlinespace % \sin (\pi - x) = \sin x & % \cos (\pi - x) = -\cos x & % \tan (\pi - x) = -\tan x \\ \midrule % \sin (x + \frac{\pi}{2}) = \cos x & % \cos (x + \frac{\pi}{2}) = -\sin x & % \tan (x + \frac{\pi}{2}) = -\cot x \\ \addlinespace % \sin (\frac{\pi}{2} - x) = \cos x & % \cos (\frac{\pi}{2} - x) = \sin x & % \tan (\frac{\pi}{2} - x) = \cot x \\ \midrule \begin{aligned}[t] & \negthinspace \sin (\alpha+\beta) \\ & \negthickspace = \sin\alpha\cos\beta + \cos\alpha\sin\beta \end{aligned} & \begin{aligned}[t] & \negthinspace \cos (\alpha+\beta) \\ & \negthickspace = \sin\alpha\cos\beta + \cos\alpha\sin\beta \end{aligned} & \begin{aligned}[t] & \negthinspace \tan (\alpha+\beta)\\ & \negthickspace = \frac{\tan\alpha + \tan\beta}{1 - \tan\alpha\tan\beta} \end{aligned} \\ \addlinespace[2ex] \sin 2x = 2 \cos x \sin x & \begin{aligned}[t] \!\cos 2x & = \cos^2 x - \sin^2 x \\ & = 2\cos^2 x - 1 \\ & = 1 - 2\sin^2 x \end{aligned} & \tan 2x = \frac{2\tan x}{1 - \tan^2 x} \\ \addlinespace[2ex] \left\lvert\sin \frac{x}{2}\right\rvert = \sqrt{\frac{1 - \cos x}{2}} & \left\lvert\cos \frac{x}{2}\right\rvert = \sqrt{\frac{1 + \cos x}{2}} & \left\lvert\tan \frac{x}{2}\right\rvert = \sqrt{\frac{1 - \cos x}{1 + \cos x}} \\ \bottomrule \end{array}

\end{document}


I also fixed the formulas in the last line: please, don't teach that the square root can take two values. The (least) period of the tangent is pi.

Also, don't do \everymath{\displaystyle}. It's wrong.

• Thank you for your patience and warmth. Those were actually typos for I haven't checked this document, no worries. – Neo Aug 27 '20 at 11:16

So that &= gives infix spacing the left aligned columns of ams alignments have {} inserted, this means that you get {}\sin which causes the \mathop thin space to be added. If you just use \sin at the top level then TeX automatically drops the extra space.

So you can either use {}\sin in the top level cases to force the space, or use &\!\sin in the aligned cases to remove the space, so things are consistent.