2

I have the following questionwith \[ of amsmath package, and I would like to split it into multiple lines.

\[
TP_{apt} = \beta_0 +  \underbrace{\boldsymbol{D_{ap(t-1)} \cdot \beta}}_{\text{Dyad variables}} +
\underbrace{\delta MM_{apt}  }_{\text{Mismatch}}  + \underbrace{\eta Gap_{apt} }_{\text{Mismatch}}  +  \underbrace{\boldsymbol{A_{a(t-1)}\cdot \alpha}  + \boldsymbol{P_{p(t-1)}\cdot \gamma}  + \boldsymbol{N_{t}\cdot \theta}}_{\text{Controls}} + \underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} +  \mu_{t}}_{\text{Fixed effects}} + \epsilon_{apt}
\] 
2
  • 3
    Welcome to TeX.SE! Can you please make your code snippet be compilable, then we do not have to guess what you are doing ...
    – Mensch
    Oct 7, 2021 at 15:50
  • 2
    \[ ... \] is meant for single-line equations. Other environments are provided for multi-line displays. Oct 7, 2021 at 16:16

4 Answers 4

5

I would use an align* environment and introduce a single line break.

I think you should also avoid making some subscripts bold while others remain non-bold. Hence, I'd limit the scope of the \boldsymbol directives to exclude subscript terms. To simplify inputs, you could load the bm package and use its \bm macro instead of \boldsymbol.

Also, in case your notational setup allows it, I'd replace (t-1) in the subscript terms with ,t-1, of a less-busy "look". And, do make it clearer to readers that TP, MM, and Gap are variable names by, say, encasing them in \mathit wrappers.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'align*' env.
\usepackage{bm}      % for '\bm' macro
\newcommand\vn[1]{\mathit{#1}{}} % macro for displaying variable names

\begin{document} 

\begin{align*}
\vn{TP}_{\!apt} 
&= \beta_0 
   + {\underbrace{\bm{D}_{ap,t-1} \cdot \bm{\beta}}_{\textnormal{Dyad variables}}}
   + {\underbrace{\delta \vn{MM}_{apt}  }_{\textnormal{Mismatch}}}  
   + {\underbrace{\eta \vn{Gap}_{apt} }_{\textnormal{Mismatch}}}   \\
&\quad
   + {\underbrace{\bm{A}_{a,t-1} \cdot \bm{\alpha}  
                + \bm{P}_{p,t-1} \cdot \bm{\gamma}  
                + \bm{N}_{t} \cdot \bm{\theta}}_{\textnormal{Controls}}}
   + {\underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} +  \mu_{t}}_{\textnormal{Fixed effects}}}
   + \epsilon_{apt}
\end{align*}

\end{document}
1
  • Thank you so much for your help! Amazing solution. I used yours in my paper.
    – J.K.
    Oct 17, 2021 at 15:26
5

With aligned math environment (defined in amsmath package) and bm package:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}
\[
    \begin{aligned}
TP_{apt} = \beta_0 
    +{} &   \underbrace{\bm{D}_{ap(t-1)} \cdot \beta}_{\text{Dyad variables}} 
          + \underbrace{\delta MM_{apt}}_{\text{Mismatch}}  
          + \underbrace{\eta Gap_{apt}}_{\text{Mismatch}}  +   \\
        &   \underbrace{\bm{A}_{a(t-1)}\cdot\alpha 
                         + \bm{P}_{p(t-1)}\cdot\gamma
                         + \bm{N}_{t}\cdot \theta}_{\text{Controls}}
          + \underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} + \mu_{t}}_{\text{Fixed effects}}
          + \epsilon_{apt}
    \end{aligned}
\]
    \end{document}

enter image description here

2
  • 3
    @Mico, you are right. I forgot on curly braces after + sign. Corrected now. Thank you very much for all :-)
    – Zarko
    Oct 7, 2021 at 17:57
  • Thank you so much for your help! Amazing solution.
    – J.K.
    Oct 17, 2021 at 15:23
5

The environment of choice for this kind of situation is split.

I'd use three lines for getting a better balance (but I wouldn't use \boldsymbol for emphasis).

Some notes before showing the code.

  1. \underbrace{...}_{...} should be braced in order to get the correct spacing around + signs.
  2. Gap should probably be upright, as it doesn't seem the product of three quantities, but a variable by itself. The same for TP and MM.
  3. I added \, between \eta and `\mathrm{Gap} to make the formula clearer.
  4. Since the first row has three underbraces, they should be at the same height, which is achieved by adding a phantom bar that artificially makes the formulas to have the same depth.
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

\[
\newcommand{\bs}{\smash[t]{\vphantom{\big|}}}% local command for this alignment
\begin{split}
\mathrm{TP}_{apt} = \beta_0
  &+ {\underbrace{\boldsymbol{D_{ap(t-1)} \cdot \beta}\bs}_{\text{Dyad variables}}}
   + {\underbrace{\delta \mathrm{MM}_{apt}\bs}_{\text{Mismatch}}}
   + {\underbrace{\eta\, \mathrm{Gap}_{apt}\bs}_{\text{Mismatch}}}
\\
  &+ {\underbrace{
       \boldsymbol{A_{a(t-1)}\cdot \alpha} +
       \boldsymbol{P_{p(t-1)}\cdot \gamma} +
       \boldsymbol{N_{t}\cdot \theta}
     }_{\text{Controls}}}
\\
  &+ {\underbrace{
       \varphi_{a} + \omega_{p} + \tau_{ap} + \mu_{t}
     }_{\text{Fixed effects}}}
   + \epsilon_{apt}
\end{split}
\]

\end{document}

enter image description here

5
  • I'm curious why you didn't give "TP" and "MM" the same treatment as "Gap".
    – Mico
    Oct 8, 2021 at 5:40
  • 2
    @Mico I don't really know whether they are individual variables or products.
    – egreg
    Oct 8, 2021 at 7:01
  • @egreg Thank you for your solution. they are individual variables (TP, MM, Gap). :)
    – J.K.
    Oct 17, 2021 at 15:25
  • 1
    @J.K. I fixed the code in view of your comment.
    – egreg
    Oct 17, 2021 at 15:47
  • @egreg Thank you so much for the follow-up!
    – J.K.
    Oct 18, 2021 at 19:39
3
    \documentclass[a4paper,12pt]{article}
    \usepackage{amsmath}

    \begin{document}

enter image description here

    \begin{multline*}
    TP_{apt} = \beta_0 +  \underbrace{\boldsymbol{D_{ap(t-1)} \cdot \beta}}_{\text{Dyad variables}} +
    \underbrace{\delta MM_{apt}  }_{\text{Mismatch}}  + \underbrace{\eta Gap_{apt} }_{\text{Mismatch}}  +\\
    \underbrace{\boldsymbol{A_{a(t-1)}\cdot \alpha}  + \boldsymbol{P_{p(t-1)}\cdot \gamma}  +
    \boldsymbol{N_{t}\cdot \theta}}_{\text{Controls}} + \underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} +  \mu_{t}}_{\text{Fixed effects}} + \epsilon_{apt}
    \end{multline*}

enter image description here

    \begin{align*}
    TP_{apt} = \beta_0 +  \underbrace{\boldsymbol{D_{ap(t-1)} \cdot \beta}}_{\text{Dyad variables}} +
    \underbrace{\delta MM_{apt}  }_{\text{Mismatch}}  + \underbrace{\eta Gap_{apt} }_{\text{Mismatch}}  &+\\
    \underbrace{\boldsymbol{A_{a(t-1)}\cdot \alpha}  + \boldsymbol{P_{p(t-1)}\cdot \gamma}  +
    \boldsymbol{N_{t}\cdot \theta}}_{\text{Controls}} + \underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} +  \mu_{t}}_{\text{Fixed effects}} + \epsilon_{apt}
    \end{align*}

enter image description here

    \begin{gather*} 
    TP_{apt} = \beta_0 +  \underbrace{\boldsymbol{D_{ap(t-1)} \cdot \beta}}_{\text{Dyad variables}} +
    \underbrace{\delta MM_{apt}  }_{\text{Mismatch}}  + \underbrace{\eta Gap_{apt} }_{\text{Mismatch}}  +\\
    \underbrace{\boldsymbol{A_{a(t-1)}\cdot \alpha}  + \boldsymbol{P_{p(t-1)}\cdot \gamma}  +
    \boldsymbol{N_{t}\cdot \theta}}_{\text{Controls}} + \underbrace{\varphi_{a} +\omega_{p} + \tau_{ap} +  \mu_{t}}_{\text{Fixed effects}} + \epsilon_{apt}
    \end{gather*}

    \end{document}
2
  • Suggestion: put the \underbrace constructs in an additional set of braces, especially when they occur between binary operators. Spacing is quite messed up right now.
    – campa
    Oct 7, 2021 at 16:26
  • In your second solution, where you employ an align* environment, the spacing around the final + symbol in row 1 looks off.
    – Mico
    Oct 7, 2021 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.