4

How can I reduce the vertical spacing between the equations or at least keep it "normal"? I am using 2 align environments and 1 multiline environment and the amount of space between each equation is more than "normal". How can I instead put them all into one environment?

\documentclass[lettersize,journal]{IEEEtran}
\usepackage{amsmath}
\usepackage{mathtools}

\NewDocumentCommand{\ubracetext}{smm}{%
  {% avoid bad spacing
   \underbrace{#2}_{%
     \IfBooleanTF{#1}{\mathclap{\text{#3}}}{\text{#3}}%
   }%
  }
}


\begin{document}
\begin{align}
    L_1 &= \sum_\tau \underbrace{\lVert \hat{x}_h^{\tau} - x_h^{\tau} \rVert_2^2}_{\text{Keypose}} + \underbrace{\lVert \hat{\Delta t^\tau} - \Delta t^\tau \rVert_2^2}_{\text{Time to keypose}}
\end{align}
\begin{align}
    L_2 &= \sum_{t,j} \underbrace{\lVert \hat{x}_j^t - x_j^t \rVert_2^2}_{\text{Spacetimeformer}} + \underbrace{\hat{\gamma}_a \log \gamma_a}_{\text{Memory bank cluster}}
\end{align}
\begin{multline}
L_3 = 
  \sum_{s,i,j,t}
  \ubracetext{\mathllap{\lambda_2}\hat{\alpha}^t_i \log \alpha^t_i}{object motion probability} \\
+ \lambda_1 \ubracetext{\delta_s^t\lVert(\hat{y}^t_{\Phi,s} - y^t)\circ (1-m_s)\rVert_2^2}{refined arms}
+ \lambda_2 \ubracetext*{\hat{\beta}^t_{s,j} \log \beta^t_{s,j}}{hand-object contact probability}
\end{multline}
\end{document}

enter image description here

1
  • never use single row align (there can be no alignment and the vertical spacing is poorer) and (almost) never have consecutive display math. Commented Jun 23 at 23:05

1 Answer 1

7

Use a single align environment:

\documentclass[lettersize,journal]{IEEEtran}
\usepackage{amsmath}
\usepackage{mathtools}

\NewDocumentCommand{\ubracetext}{smm}{%
  {% avoid bad spacing
   \underbrace{#2}_{%
     \IfBooleanTF{#1}{\mathclap{\text{#3}}}{\text{#3}}%
   }%
  }
}


\begin{document}

\begin{align}
    L_1 &= \sum_\tau \ubracetext{\lVert \hat{x}_h^{\tau} - x_h^{\tau} \rVert_2^2}{Keypose}
         + \ubracetext{\lVert \hat{\Delta t^\tau} - \Delta t^\tau \rVert_2^2}{Time to keypose}
\\
    L_2 &= \sum_{t,j} \ubracetext{\lVert \hat{x}_j^t - x_j^t \rVert_2^2}{Spacetimeformer}
         + \ubracetext{\hat{\gamma}_a \log \gamma_a\vphantom{x^i_j}}{Memory bank cluster}
\\
L_3 &= 
  \sum_{s,i,j,t} 
  \ubracetext{\mathllap{\Bigl(\lambda_2}\hat{\alpha}^t_i \log \alpha^t_i}
             {object motion probability} 
\notag \\
&\qquad\qquad+ \lambda_1
   \ubracetext{\delta_s^t\lVert(\hat{y}^t_{\Phi,s} - y^t)\circ (1-m_s)\rVert_2^2}
              {refined arms}
\notag \\
&\qquad\qquad+ \lambda_2
   \ubracetext*{\hat{\beta}^t_{s,j} \log \beta^t_{s,j}}
               {hand-object contact probability}\,\Bigr)
\end{align}

\end{document}

I changed \underbrace into \ubracetext and also added parentheses for the last (split) summation for better clarity. Also a phantom for aligning the two texts in the second formula.

enter image description here

If you want to save space at the expense of readability:

\documentclass[lettersize,journal]{IEEEtran}
\usepackage{amsmath}
\usepackage{mathtools}

\NewDocumentCommand{\ubracetext}{smm}{%
  {% avoid bad spacing
   \underbrace{#2}_{%
     \IfBooleanTF{#1}{\mathclap{\text{#3}}}{\text{#3}}%
   }%
  }
}


\begin{document}

\begin{gather}
    L_1 = \sum_\tau \ubracetext{\lVert \hat{x}_h^{\tau} - x_h^{\tau} \rVert_2^2}{Keypose}
         + \ubracetext{\lVert \hat{\Delta t^\tau} - \Delta t^\tau \rVert_2^2}{Time to keypose}
\\
    L_2 = \sum_{t,j} \ubracetext{\lVert \hat{x}_j^t - x_j^t \rVert_2^2}{Spacetimeformer}
         + \ubracetext{\hat{\gamma}_a \log \gamma_a\vphantom{x^i_j}}{Memory bank cluster}
\\
\begin{multlined} L_3 = 
  \sum_{s,i,j,t} 
  \ubracetext{\mathllap{\Bigl(\lambda_2}\hat{\alpha}^t_i \log \alpha^t_i}
             {object motion probability} 
\\
+ \lambda_1
   \ubracetext{\delta_s^t\lVert(\hat{y}^t_{\Phi,s} - y^t)\circ (1-m_s)\rVert_2^2}
              {refined arms}
+ \lambda_2
   \ubracetext*{\hat{\beta}^t_{s,j} \log \beta^t_{s,j}}
               {hand-object contact probability}\,\Bigr)
\end{multlined}
\end{gather}

\end{document}

enter image description here

3
  • You should explain that there is always extra space added before and after a display environment, which is why separate environments shouldn't be used for adjacent displayed equations. Commented Jun 24 at 0:38
  • 1
    @egreg How can I reduce L_3 to only use 2 lines? I do not need them aligned. I really do not have enough space for an extra newline for equation L_3 ! I cannot remove a single reference, cannot paraphrase my text, and cannot resize the figures. I just need L3 to only occupy two lines.
    – Kong
    Commented Jun 24 at 1:22
  • @Kong Use gather as shown in the edited answer
    – egreg
    Commented Jun 24 at 8:06

You must log in to answer this question.

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