3
\begin{alignat}{3}
\cos \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&& \sum_{|A|=2k} & \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j \\
\sin \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&& \sum_{|A|=2k+1} & \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j
\end{alignat}

It seems that "alignat" aligns everything either on the right or on the left. However, in the interest of a sort of poetic rhythm that I think may actually aid understanding and reduce distractions, it seems like a good idea for the two giant Sigmas with subscripts |A|=2k and |A|=2k+1 should be aligned with each other, and they're not because of the difference in the subscripts.

So how should that be done?

Also, the subscript 2k+1 is uncomfortably close to the subscript j\in A that follows it. How should that be dealt with?

Postscript in response to the answer and comments below: I've just run TeXworks on the document that I quote in its entirety below. I still get this: "Sorry, but "C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\texify.exe" did not succeed."

\documentclass{article}

\usepackage{mathtools}
\usepackage{eqparbox}
\newcommand\eqmathbox[2][M]{\eqmakebox[M#1 {$\scriptstyle#2$}}

\begin{document}

trigonometric identities

\end{document}
  • 1
    I tried adding '\phantom{{}+1}' to the subscript '|A|=2k', and the Sigmas did get aligned, but then the subscript '|A|=2k' in the first one ends up looking stupidly badly positioned. – Michael Hardy May 29 '16 at 01:01

3 Answers3

6

Two alignments will do.You can use the eqparbox package, and the \smashoperator command from mathtools. Two compilations are necessary.

\documentclass{article}
\usepackage{mathtools}
\usepackage{eqparbox}
 \newcommand\eqmathbox[2][M]{\eqmakebox[M#1]{$\scriptstyle#2$}}

\begin{document}

\begin{alignat}{2}
\cos \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&& \smashoperator[l]{\sum_{\eqmathbox[i]{|A|=2k}}} \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j \\
\sin \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&&\smashoperator[l]{ \sum_{\eqmathbox[i]{|A|=2k+1}}} \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j
\end{alignat}

\end{document} 

enter image description here

Bernard
  • 271,350
  • I ran into an error message with this. I'm wondering if that's because of another package I'm using. To be continued.... – Michael Hardy May 29 '16 at 17:27
  • Did you load mathtools, not merely amsmath? – Bernard May 29 '16 at 17:48
  • I've got exactly the three lines that you wrote under '\documentclass{article}'. They're the last three lines before my '\begin{document}'. (But I haven't yet tried it without any other packages.) – Michael Hardy May 30 '16 at 13:51
  • Console output: Sorry, but "C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\texify.exe" did not succeed.

    The log file hopefully contains the information to get MiKTeX going again:

    C:/Users/Mike/AppData/Local/MiKTeX/2.9/miktex/log/texify.log

    You may want to visit the MiKTeX project page, if you need help.

    – Michael Hardy May 30 '16 at 13:57
  • The quoted console output appeared when I ran a version that had no other instances of \usepackage{}. However, I have another suspicion about where the problem may be: I used some macros. To be continued..... – Michael Hardy May 30 '16 at 14:01
  • . . . and now I've tried it when my entire LaTeX document is what you see below, and the problem is still there:
    \documentclass{article}
    
    \usepackage{mathtools}
    \usepackage{eqparbox}
    \newcommand\eqmathbox[2][M]{\eqmakebox[M#1 {$\scriptstyle#2$}}
    
    \begin{document}
    
    trigonometric identities
    
    \end{document}
    
    – Michael Hardy May 30 '16 at 14:06
  • 1
    @Michael Hardy: I'm back again. Could you post somewhere the exact code you compile and the .log file? – Bernard May 30 '16 at 19:06
  • . . . and now I find the code in your answer works. (I haven't yet tried it in the original document in which I was using some other packages --- just the file in your answer. To be continued.... – Michael Hardy May 30 '16 at 19:47
1

One needs to fine-tune both the horizontal alignment of the sum and product symbols and the vertical placement of the symbols in the limits of summation/multiplication. For the latter, I suggest you insert \mathstrut instructions in all subscript positions. For the former, I suggest a combination of \mathclap (on all subscript terms) and a selected \mkern("math kern") statement.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for \mathclap and \DeclarePairedDelimiter macros
\DeclarePairedDelimiter\abs\lvert\rvert
\begin{document}

\begin{align}
\cos\sum_{\mathstrut j}\alpha_j
&= \sum_{\mathstrut\mathclap{k=0}}^\infty (-1)^k
   \sum_{\mathstrut\mathclap{\smash{\abs{A}=2k}}} \mkern21mu
   \prod_{\mathstrut\mathclap{j\in A}} \sin\alpha_j
   \prod_{\mathstrut\mathclap{j\notin A}} \cos\alpha_j \\
\sin\sum_{\mathstrut j}\alpha_j
&= \sum_{\mathstrut\mathclap{k=0}}^\infty (-1)^k
   \sum_{\mathstrut\mathclap{\abs{A}=2k+1}} \mkern21mu
   \prod_{\mathstrut\mathclap{j\in A}} \sin\alpha_j
   \prod_{\mathstrut\mathclap{j\notin A}} \cos\alpha_j
\end{align}
\end{document} 
Mico
  • 506,678
1

This is in the interest of providing a simple answer for those who don't have the patience for the extra work required for more sophisticated solutions. The OP didn't like the result of \phantom{+1}, but it is possible to simply distribute it either side of the subscript to get a nicer result. Note the use of the \enspace, taking advantage of the \alignat spacing feature (hence why it is only needed on the first line), to put a little space between |A| = 2k + 1 and j \in A.

\documentclass{article}
\usepackage[a6paper,landscape]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{3}
\cos \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&& \sum_{\phantom{+}|A|=2k\phantom{1}} &\enspace \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j \\
\sin \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&& \sum_{|A|=2k+1} &\  \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j
\end{alignat}
\end{document}

enter image description here

If you don't like the space between the second two sums, that's a question of taste, then there are two simple solutions for that. The first is to rearrange the use of & in the original code, so the problem sum is before the alignment & instead of after. This tightens things a little bit.

\cos \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
& \sum_{\phantom{+}|A|=2k\phantom{1}} & &\enspace \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j \\
\sin \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
& \sum_{|A|=2k+1} & & \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j

enter image description here

If that's not enough, the second solution is to use a negative \hskip in front of the last sum in both rows. But this only works in the original arrangement, that is, after the alignment & not the spacing &.

\cos \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&&\hskip-0.5em \sum_{\phantom{+}|A|=2k\phantom{1}} &\enspace \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j \\
\sin \sum_j \alpha_j
& = \sum_{k=0}^\infty (-1)^k
&&\hskip-0.5em \sum_{|A|=2k+1} & \prod_{j\in A} \sin\alpha_j \prod_{j\notin A} \cos\alpha_j

enter image description here