4

I have two equations in the \gathered environment.

\documentclass{book} 
  \usepackage{amsmath}
 
 \begin{document}  
 

\begin{equation} 
 \begin{gathered}
     \Delta U_{ab}+\Delta U_{ba}=0\\
    \int_{\vec r_a}^{\vec r_b}\vec F\cdot d\vec r +\int_{\vec r_b}^{\vec r_a}\vec F\cdot d\vec r=0
     \label{ce23}  

  \end{gathered} 
 \end{equation}
 
 \end{document}

Producing the output:

enter image description here

But instead, I want the following output using \gathered itself, instead of \align which I used for this MWE

enter image description here

Code for which is

   \documentclass{book} 
      \usepackage{amsmath}
     
     \begin{document}  
     

   
     \begin{align}
         \Delta U_{ab}&+\Delta U_{ba}=0 \nonumber\\
        \int_{\vec r_a}^{\vec r_b}\vec F\cdot d\vec r &+\int_{\vec r_b}^{\vec r_a}\vec F\cdot d\vec r=0
         \label{ce23}  
      \end{align} 
     
     
     \end{document}
1
  • There are no \gather, \gathered, or \align environments. There are environments called gather, gathered, and align. Using backslashes in front of environments will only lead to confusion and bad syntax (such as \align...\endalign, which technically works, but is bad practice).
    – Gaussler
    Dec 23, 2022 at 17:32

2 Answers 2

5

Just use gather instead of gathered.

\documentclass{book} 
\usepackage{amsmath}

\begin{document}  

\begin{gather}
    \Delta U_{ab}+\Delta U_{ba}=0 \nonumber\\
    \int_{\vec r_a}^{\vec r_b}\vec F\cdot d\vec r +\int_{\vec r_b}^{\vec r_a}\vec F\cdot d\vec r=0
    \label{ce23}
\end{gather}
 
\end{document}
1
  • Thanks for the answer, ironically I did write the correct environment in the title Dec 23, 2022 at 16:22
4

It's better to use gathered, if possible, so TeX is able to use short vertical skips in case the line preceding the display is short. Compare the two otherwise identical displays: the space surrounding the second one is too wide.

The key is \begin{gathered}[b].

\documentclass{book}
\usepackage{amsmath}

\usepackage{lipsum}

\begin{document}
 
\lipsum[1][1-3]
\begin{equation}\label{ce23}
\begin{gathered}[b]
  \Delta U_{ab}+\Delta U_{ba}=0 \\
  \int_{\vec{r}_a}^{\vec{r}_b}\vec{F}\cdot d\vec{r}
  +\int_{\vec{r}_b}^{\vec{r}_a}\vec{F}\cdot d\vec{r}=0
\end{gathered}
\end{equation}
\lipsum[2][1-3]

\lipsum[1][1-3]
\begin{gather}
  \Delta U_{ab}+\Delta U_{ba}=0 \notag \\
  \int_{\vec{r}_a}^{\vec{r}_b}\vec{F}\cdot d\vec{r} 
  +\int_{\vec{r}_b}^{\vec{r}_a}\vec{F}\cdot d\vec{r}=0
  \label{ce23bad}
\end{gather}
\lipsum[2][1-3]

\end{document}

enter image description here

I changed all \vec r and similar into the better \vec{r}, not more difficult to type and definitely clearer.

1
  • +1 for "I changed all \vec r and similar into the better \vec{r}".
    – Mico
    Dec 23, 2022 at 18:59

You must log in to answer this question.

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