2

I'm learning LaTeX and writing code on overleaf.

I am particular about the alignment of equal (=) signs and after banging my head for a few hours, it seems best to keep all equations in a single align environment and then repeatedly use \intertext{} for discussions.

However, I came across a segment in my practice reference that has a number of equations in a row unnumbered. My solution was to write \nonumberat the end of each equation.

#1. Building a new \begin{align*} inside of \begin{align} gives me errors.

#2. Adding a \begin{split} works until the last line which can be corrected with a single \nonumber, but all equations are now left justified.

#3. If I enclose everything with a \begin{center} the \intertext{} are also centered. This is with a \setlength\parindent{0pt} preamble. \begin{centered} does no visual change to #2

Is there a better way? I would prefer to keep only the equations centered.

x Here is the compiled output for #1: enter image description here

x Here's the compiled output for #2: enter image description here

x Here's the compiled output for #3: enter image description here

x Here's my code for #1, the \nonumber statements are in the last 5 lines: (I'm sorry it's a complicated mess)

\begin{align} 
    \psi_\mathbf{k}(r) & = \sum_{IJ} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r} - \mathbf{R}_{IJ}})
    \\
    \intertext{We add a translation of an arbitrary vector \(\mathbf{R'}\) and obtain}
    \psi_\mathbf{k}(r) & = \sum_{IJ} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r + R' - R}_{IJ}}) \\
                       & = \sum_{IJ} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r - (R_\mathit{IJ} - R')}})
    \\
    \intertext{Now let us define:}
    \Tilde{\mathbf{R}}_{IJ} & = \mathbf{R_\mathit{IJ}-R'}
%\end{align}
%%
%\begin{align}
    \intertext{Then, since the summation in (2) is over an infinite number of pairs \((I, J)\), we can rewrite it as}
    \psi_\mathbf{k}\mathbf{(r+R')} & = \sum_{IJ}\mathrm{e}^{i\mathbf{k} \cdot (\mathbf{\Tilde{R}}_{IJ}+R')} \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ} \nonumber\\
                                   & = \sum_{IJ}\mathrm{e}^{i\mathbf{k \cdot R'}} \cdot \mathrm{e}^{i\mathbf{k}\mathbf{\Tilde{R}}_{IJ}}  \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ} \nonumber\\
                                   & = \mathrm{e}^{i\mathbf{k \cdot R'}} \sum_{IJ} \mathrm{e}^{i\mathbf{k}\mathbf{\Tilde{R}}_{IJ}}  \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ} \nonumber\\
                                   & = \mathrm{e}^{i\mathbf{k \cdot R'}} \psi_\mathbf{k}\mathbf{(r)} \nonumber
\end{align}

Here is the code for #2:

\begin{align} 
    \psi_\mathbf{k}(r) & = \sum_{IJ} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r} - \mathbf{R}_{IJ}})
    \\
    \intertext{We add a translation of an arbitrary vector \(\mathbf{R'}\) and obtain}
    \psi_\mathbf{k}(r) & = \sum_{IJ} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r + R' - R}_{IJ}}) \\
                       & = \sum_{I J} \ \mathrm{e}^{i\mathbf{k}\cdot \mathbf{R}_{IJ}} \ \phi_o{(\mathbf{r - (R_\mathit{IJ} - R')}})
    \\
    \intertext{Now let us define:}
    \Tilde{\mathbf{R}}_{IJ} & = \mathbf{R_\mathit{IJ}-R'} \\
%\end{align}
%%
    \begin{split}
        \intertext{Then, since the summation in (2) is over an infinite number of pairs \((I, J)\), we can rewrite it as}
        \psi_\mathbf{k}\mathbf{(r+R')} & = \sum_{IJ}\mathrm{e}^{i\mathbf{k} \cdot (\mathbf{\Tilde{R}}_{IJ}+R')} \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ} \\
                                       & =\sum_{IJ}\mathrm{e}^{i\mathbf{k \cdot R'}} \cdot \mathrm{e}^{i\mathbf{k}\mathbf{\Tilde{R}}_{IJ}}  \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ} \\
                                       & = \mathrm{e}^{i\mathbf{k \cdot R'}} \sum_{IJ} \mathrm{e}^{i\mathbf{k}\mathbf{\Tilde{R}}_{IJ}}  \ \phi_o(\mathbf{r - \Tilde{R})}_{IJ}\\
                                       & = \mathrm{e}^{i\mathbf{k \cdot R'}} \psi_\mathbf{k}\mathbf{(r)}
    \end{split}
\end{align}

Code for #3 is just code for #2 with \begin{center} and \end{center} at both ends

6
  • Welcome to the community of the TeX users.
    – Sebastiano
    Jul 22, 2020 at 15:24
  • Personal opinion: there is absolutely no reason as why all the equations should be aligned with each other. Personal suggestion: lose the \intertext and be happy. Apart from this: your second solution would in principle work but you must write the \intertext outside of split.
    – campa
    Jul 22, 2020 at 15:27
  • @campa. RE personal suggestion, thanks! I commented out \intertext inside split and all equations are centered again. Would you happen to know why that worked? | RE personal opinion, for my case, the logic is easier to follow if all equations are aligned. Maybe related to micro-decisions and decision fatigue - don't really know but it's just easier. Jul 22, 2020 at 16:17
  • @Sebastiano thanks for the greeting. Learning LaTeX is an uphill battle for now huhu. It takes so much effort compared to microsoft word just to to write and format everything. Jul 22, 2020 at 16:20
  • @PestoPotato that seems to be more because you make it a lot harder for your self than needed. As egreg shows in his answer it is not that hard.
    – daleif
    Jul 22, 2020 at 18:03

1 Answer 1

2

I see no reason to align all those equals sign. Maybe the first two blocks can use \intertext, but I'm not really sure. Personally, I'd not align them.

Some advice. Define a command for the Euler constant to avoid explicit \mathrm{e} all along your document. Also avoid \mathbf and use a semantic command, here \vec, but you can decide for a different name. Also it should be

\tilde{\mathbf{R}}

and never \mathbf{r-R} or similar shortcuts. Your document loses in semantics this way and becomes confused: why \mathbf{(r)} somewhere, for instance?

The last display is too distant from the first two to benefit from an alignment of the equals signs. Readers will see them as separate entities anyway. For sure, the middle display should not align with the others and this separates the blocks, so no alignment is necessary or good.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\eul}{\mathrm{e}}
\renewcommand{\vec}[1]{\mathbf{#1}}

\begin{document}

\begin{align} 
\psi_{\vec{k}}(\vec{r})
  & = \sum_{IJ} \eul^{i\vec{k}\cdot \vec{R}_{IJ}} 
                \phi_o(\vec{r} - \vec{R}_{IJ})
\\
\intertext{We add a translation of an arbitrary vector \(\vec{R}'\) and obtain}
\begin{split}
\psi_{\vec{k}}(\vec{r})
  & = \sum_{IJ} \eul^{i\vec{k}\cdot \vec{R}_{IJ}}
                \phi_o(\vec{r} + \vec{R}' - \vec{R}_{IJ})
\\
  & = \sum_{IJ} \eul^{i\vec{k}\cdot \vec{R}_{IJ}}
                \phi_o(\vec{r} - (\vec{R}_{IJ} - \vec{R}'))
\end{split}
\end{align}
Now let us define
\begin{equation}
\Tilde{\vec{R}}_{IJ} = \vec{R}_{IJ}-\vec{R}'
\end{equation}
Then, since the summation in (2) is over an infinite number of pairs \((I, J)\), 
we can rewrite it as
\begin{equation}
\begin{split}
\psi_{\vec{k}}(\vec{r}+\vec{R}')
  & = \sum_{IJ} \eul^{i\vec{k} \cdot (\tilde{\vec{R}}_{IJ}+\vec{R}')}
                \phi_o(\vec{r} - \tilde{\vec{R}})_{IJ} \\
  & = \sum_{IJ} \eul^{i\vec{k} \cdot \vec{R}'} \cdot 
                \eul^{i\vec{k}\cdot\tilde{\vec{R}}_{IJ}}
                \phi_o(\vec{r} - \tilde{\vec{R}})_{IJ} \\
  & = \eul^{i\vec{k} \cdot \vec{R}'}
      \sum_{IJ} \eul^{i\vec{k}\cdot\tilde{\vec{R}}_{IJ}}
                \phi_o(\vec{r} - \tilde{\vec{R}})_{IJ} \\
  & = \eul^{i\vec{k} \cdot \vec{R}'} \psi_{\vec{k}}(\vec{r})
\end{split}
\end{equation}

\end{document}

enter image description here

If you want the number aligned to the bottom line of split load amsmath with the tbtags option.

1
  • hi @egreg, apologies for the very late response. Thanks for the tips on new commands, vectors, tbtags, code semantics/readability, and the sample code you provided! I appreciate it!! Aug 1, 2020 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .