4

I want to write equation which is too long for one line. So I use the \alignat environment to break this equation down into 2 lines. But in the case of multi-column alignment, it shows a lot of white space.

Here is my MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{physics}
\newcommand{\p}{\partial}
\newcommand{\dthree}[1]{\dd[3]{#1}}
\begin{document}
    
\begin{alignat*}{2}
    H& = \int \dthree{x} \psi^\dagger(x) i \p_0 \psi(x)\\
    &= \int \dthree{x} \int \frac{\dthree{p}\dthree{q}}{(2\pi)^6}\frac{1}{\sqrt{2E_{\vb{p}}2E_{\vb{q}}}} \sum_{s,r} \qty[a_{\vb{p}}^\dagger u^{s\dagger}(p)e^{ipx} + b_{\vb{p}}^{s} v^{s\dagger}(p)e^{ipx}] i\p_0 \qty[a_{\vb{q}}^r u^r(q) e^{-iqx} + b_{\vb{q}}^{r\dagger} v^r(q) e^{iqx}]\\
    &= \int \dthree{x} \int\frac{\dthree{p}\dthree{q}}{(2\pi)^6}\sqrt{\frac{E_{\vb{q}}}{4E_{\vb{p}}}} \sum_{s,r}\qty[a_{\vb{p}}^{s\dagger} u^{s\dagger}(p)e^{ipx} + b_{\vb{p}}^{s}v^{s\dagger}(p)e^{-ipx}]\qty[a_{\vb{q}}^{r} u^r(q)e^{-iqx} - b_{\vb{q}}^{r\dagger}v^{r}(q)e^{iqx}]\\
    &=\int \dthree{x} \int\frac{\dthree{p}\dthree{q}}{(2\pi)^6}\sqrt{\frac{E_{\vb{q}}}{4E_{\vb{p}}}} \sum_{s,r} 
    \Big[& a_{\vb{p}}^{s\dagger} a_{q}^r u^{s\dagger}(p)u^{r}(q) e^{i(p-q)x} - a_{\vb{p}}^{s\dagger}b_{q}^{r\dagger} u^{s\dagger}(p)v^{r}(q)e^{i(p+q)x}\\
        &&a_{\vb{p}}^{s\dagger} a_{q}^r u^{s\dagger}(p)u^{r}(q) e^{i(p-q)x} - a_{\vb{p}}^{s\dagger}b_{q}^{r\dagger} u^{s\dagger}(p)v^{r}(q)e^{i(p+q)x} \Big]
\end{alignat*}

\end{document}

which gives the result enter image description here

My attempt:

Probably because the formulas on the second and third lines are too long, the alignment worked fine when I tried to remove them enter image description here My question:

I wonder if there is another solution that would reduce the whitespace without removing these two lines of formula. I'd be grateful if you could help me.

4
  • 3
    I would simply typeset the [...] as a \begin{aligned}[t] [...] \end{aligned} construction and not attempt to have alignat cover it
    – daleif
    Commented Apr 30, 2022 at 16:58
  • @daleif Do you mean I aligned the formulas myself by setting the spacing instead of using the aligned environment?
    – Huanyu Shi
    Commented Apr 30, 2022 at 17:11
  • Basically what Mico just did
    – daleif
    Commented Apr 30, 2022 at 17:12
  • @daleif Thank you for your help. I think I know what to do.
    – Huanyu Shi
    Commented Apr 30, 2022 at 17:17

1 Answer 1

5

You could nest an aligned environment inside the align environment.

enter image description here

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}  % set page parameters appropriately
\usepackage{mathtools} % for \mathllap macro
\usepackage{physics}
\newcommand{\p}{\partial}
\newcommand{\dthree}[1]{\dd[3]{#1}}

\begin{document}
    
\begin{align}
  H &= \int \dthree{x} \psi^\dagger(x) i \p_0 \psi(x)\\
    &= \int \dthree{x} \int \frac{\dthree{p}\dthree{q}}{(2\pi)^6}\frac{1}{\sqrt{2E_{\vb{p}}2E_{\vb{q}}}} \sum_{s,r} \qty[a_{\vb{p}}^\dagger u^{s\dagger}(p)e^{ipx} + b_{\vb{p}}^{s} v^{s\dagger}(p)e^{ipx}] i\p_0 \qty[a_{\vb{q}}^r u^r(q) e^{-iqx} + b_{\vb{q}}^{r\dagger} v^r(q) e^{iqx}]\\
    &= \int \dthree{x} \int\frac{\dthree{p}\dthree{q}}{(2\pi)^6}\sqrt{\frac{E_{\vb{q}}}{4E_{\vb{p}}}} \sum_{s,r}\qty[a_{\vb{p}}^{s\dagger} u^{s\dagger}(p)e^{ipx} + b_{\vb{p}}^{s}v^{s\dagger}(p)e^{-ipx}]\qty[a_{\vb{q}}^{r} u^r(q)e^{-iqx} - b_{\vb{q}}^{r\dagger}v^{r}(q)e^{iqx}]\\
    &=\int \dthree{x} \int\frac{\dthree{p}\dthree{q}}{(2\pi)^6}\sqrt{\frac{E_{\vb{q}}}{4E_{\vb{p}}}} \sum_{s,r} 
    \Bigl[
\begin{aligned}[t]
    &a_{\vb{p}}^{s\dagger} a_{q}^r u^{s\dagger}(p)u^{r}(q) e^{i(p-q)x} - a_{\vb{p}}^{s\dagger}b_{q}^{r\dagger} u^{s\dagger}(p)v^{r}(q)e^{i(p+q)x}\\
    \mathllap{{}+{}}
    &a_{\vb{p}}^{s\dagger} a_{q}^r u^{s\dagger}(p)u^{r}(q) e^{i(p-q)x} - a_{\vb{p}}^{s\dagger}b_{q}^{r\dagger} u^{s\dagger}(p)v^{r}(q)e^{i(p+q)x} \Bigr]
\end{aligned}
\end{align}

\end{document}
5
  • There are some issues with (lack of) boldfacing of some subscripts, which I will leave to the OP to fix.
    – Mico
    Commented Apr 30, 2022 at 17:02
  • Thanks for you help. That did solve my problem. But the aligned environment doesn't seem to be able to do automatic page crossing.
    – Huanyu Shi
    Commented Apr 30, 2022 at 17:06
  • 1
    It's a good idea anyway, unless I have a really long formula that NEEDS to be split into many rows, which is very rare, at least I don't need it right now. Thank you again for your answer.
    – Huanyu Shi
    Commented Apr 30, 2022 at 17:08
  • 1
    @HuanyuShi in those cases it is often better to rewrite. People tend to get list in these multipage formulas
    – daleif
    Commented Apr 30, 2022 at 17:14
  • @HuanyuShi - You're correct in observing that no page breaks are allowed inside an aligned environment. I would argue that that's probably a good thing; for sure, in the equations shown above, it's almost certainly utterly inappropriate to allow a page break between the two rows of the aligned environment.
    – Mico
    Commented May 1, 2022 at 16:38

You must log in to answer this question.

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