2

I have never used this before, so please bear with me. I am trying to label parts of the flow conservation equation for momentum with braces, which I have done before. However, I can't figure out how to add appropriate line breaks in the label. Here's an example:

\begin{equation*}
    \underbrace{\oiiint\limits_V \rho\vec{F}_b\:\mathrm{d}V}_{\text{Body forces (acceleration, emf, etc.)}}
\end{equation*}

Ideally, I would like for there to be a line break between "Body Forces" and "(acceleration, emf, etc.)". These equations get long for those familiar, and having huge labels just distorts the equation by adding extraneous space (and making it go off of the page in some cases). Does anyone know how to do this? I have tried adding all of the following where I would like the line break, to no avail:

\linebreak
\newline
\\

When I add the first two, it appears to just remove the space after compilation. When I try the last one, it won't compile at all. The \text command is from AMSMath, though I can't find any documentation on how to add in line breaks. Any thoughts?

Edit: Below is the entire equation that I am trying to label.

\begin{equation*}
    \overbrace{\underbrace{\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol}_{\text{Body forces (acceleration, emf, gravity, etc.)}}-\underbrace{\oiint\limits_SP\diff S}_{\text{Pressure forces}}+\underbrace{\phantom{\intup\limits_l}\vec{F}_\mu\phantom{\intup\limits_l}}_{\text{Viscous forces}}}^{\vec{F}}=\overbrace{\underbrace{\oiint\limits_S\left(\rho\vec{v}\cdot\mathrm{d}S\right)\vec{v}}_{m\frac{\dd v}{\dd t}}+\underbrace{\frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol}_{\vec{v}\frac{\dd m}{\dd t}}}^{\frac{\dd}{\dd t}\left(m\vec{v}\right)}
\end{equation*}

It will print this result: Conservation of Momentum Equation printout

As you can see, the underbraces and subsequently the terms of the equation are spread out quite a bit. The idea is to condense those into a multi-line solution when they exceed the width of the term (the width of the underbrace itself). The Body Forces, Viscous forces, and probably the Pressure forces labels are the ones that would be affected by the solution for which I am looking. The right side of the equation would be unaffected due to the labels being smaller than the underbraces itself.

Here is the relevant information that needs to be in the preamble in order to print properly (I have more packages in my document, but I think these are the only ones necessary to print that line):

\usepackage{stix2}
\usepackage{amsmath}

\newcommand{\vol}{\makebox[0pt][l]{\ooalign{\hfil$V$\hfil\cr\kern0.09em--\hfil\cr}}}

The \vol is a command that I found on this site and modified to my liking. It would be nice to have a solution that includes both an overbrace and underbrace option, but I am not sure something like this exists. Thank you all for the help so far!

Another edit: I guess I don't understand what MWE means, so maybe below is what you're looking for? With the \begin{document} and such?

\documentclass[10pt,twoside,letterpaper,titlepage]{article}

\usepackage{amsmath}
\usepackage{stix2}

\newcommand{\vol}{\makebox[0pt][l]{\ooalign{\hfil$V$\hfil\cr\kern0.09em-- 
\hfil\cr}}}
\newcommand{\diff}{\,\mathrm{d}}
\newcommand{\dd}{\mathrm{d}}

\begin{document}

\begin{equation*}
\overbrace{\underbrace{\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol}_{\text{Body forces (acceleration, emf, gravity, etc.)}}-\underbrace{\oiint\limits_SP\diff S}_{\text{Pressure forces}}+\underbrace{\phantom{\intup\limits_l}\vec{F}_\mu\phantom{\int\limits_S}}_{\text{Viscous forces}}}^{\vec{F}}=\overbrace{\underbrace{\oiint\limits_S\left(\rho\vec{v}\cdot\mathrm{d}S\right)\vec{v}}_{m\frac{\dd v}{\dd t}}+\underbrace{\frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol}_{\vec{v}\frac{\dd m}{\dd t}}}^{\frac{\dd}{\dd t}\left(m\vec{v}\right)}
\end{equation*}

\end{document}
4
  • 1
    Welcome to TeX SX! Could you post a complete code, not just a fragment? In particular, where is \oiiint defined?
    – Bernard
    Oct 15, 2019 at 20:35
  • Hi, yes I’d be happy to. I am on my phone now, but I will once I get back to my computer. /oiiint is defined in the stix2 package I believe, it also could be in amsmath (if I remember correctly, it’s defined in both and the way I have it typesetting is the stix2 version). How much of the code do you want? The document is quite long.
    – Publius
    Oct 16, 2019 at 0:21
  • We need only MWE (Minimal Working Example, something similar as you can see in my answer), which reproduce your problem .
    – Zarko
    Oct 16, 2019 at 1:06
  • But we ask you for an MWE, not for a bunch codes' fragments.
    – Zarko
    Oct 16, 2019 at 3:08

2 Answers 2

2

There are a couple of errors in your code; the definition of \vol should not have \makebox[0pt], because this makes the symbol having zero width.

Also \phantom should be \vphantom, so to just use the vertical size. No need for \left and \right here.

I made \vol good for the STIX Two fonts, with a smaller kern, and resizable in subscripts and superscripts. The modified definition of \diff allows you to use it also for the derivatives.

\documentclass[10pt,twoside,letterpaper,titlepage]{article}

\usepackage{amsmath}
\usepackage{stix2}
\usepackage{varwidth}

\newcommand{\vol}{%
  \mathord{\text{%
    \ooalign{\hfil$V$\hfil\cr\kern0.03em--\hfil\cr}%
  }}%
}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
%\newcommand{\dd}{\mathrm{d}} % not needed, just use \diff
\newcommand{\btext}[1]{\text{\begin{varwidth}[t]{\textwidth}\centering#1\end{varwidth}}}

\begin{document}

\begin{equation*}
\overbrace{
  \underbrace{\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol}
    _{\btext{Body forces  \\ (acceleration, emf, \\ gravity, etc.)}}
 -\underbrace{\oiint\limits_SP\diff S}_{\btext{Pressure \\ forces}}
 +\underbrace{\vphantom{\intup\limits_S}\vec{F}_\mu\vphantom{\int\limits_S}}
    _{\btext{Viscous \\ forces}}}^{\vec{F}}
 =\overbrace{\underbrace{\oiint\limits_S (\rho\vec{v}\cdot\diff S)\vec{v}}
    _{m\frac{\diff v}{\diff t}}
 +\underbrace{\frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol}
    _{\vec{v}\frac{\diff m}{\diff t}}}^{\frac{\diff}{\diff t}(m\vec{v})}
\end{equation*}

\end{document}

For the long subscripts, I exploited varwidth that makes a box as wide as necessary. The name \btext stands for “broken (across lines) text”.

enter image description here

A refined version, that corrects some bad spacing:

\documentclass[10pt,twoside,letterpaper,titlepage]{article}

\usepackage{amsmath}
\usepackage{stix2}
\usepackage{varwidth}

\newcommand{\vol}{%
  \mathord{\text{%
    \ooalign{\hfil$V$\hfil\cr\kern0.03em--\hfil\cr}%
  }}%
}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
%\newcommand{\dd}{\mathrm{d}} % not needed, just use \diff
\newcommand{\btext}[1]{\text{\begin{varwidth}[t]{\textwidth}\centering#1\end{varwidth}}}

\newcommand{\ob}[2]{{\overbrace{#1}^{#2}}}
\newcommand{\ub}[2]{{\underbrace{#1}_{#2}}}


\begin{document}

\begin{equation*}
\ob{
  \ub{\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol}
     {\btext{Body forces  \\ (acceleration, \\ emf, gravity, etc.)}}
 -\ub{\oiint\limits_SP\diff S}{\btext{Pressure \\ forces}}
 +\ub{\vphantom{\intup\limits_S}\vec{F}_\mu\vphantom{\int\limits_S}}
     {\hspace{-2em}\btext{Viscous \\ forces}\hspace{-2em}}
   }{\vec{F}}
=
\ob{
   \ub{\oiint\limits_S (\rho\vec{v}\cdot\diff S)\vec{v}}{m\frac{\diff v}{\diff t}}
  +\ub{\frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol}
       {\vec{v}\frac{\diff m}{\diff t}}
   }{\frac{\diff}{\diff t}(m\vec{v})}
\end{equation*}

\end{document}

It's better to use the defined macros \ob and \ub so to hide the nature of \mathop attributed to \overbrace and \underbrace by its standard definition.

enter image description here

I'd consider avoiding too many under- and overbraces. Here I added also a few \, bits that are missing from the above codes, but should indeed be applied.

\documentclass[10pt,twoside,letterpaper,titlepage]{article}

\usepackage{amsmath}
\usepackage{stix2}
\usepackage{varwidth}

\newcommand{\vol}{%
  \mathord{\text{%
    \ooalign{\hfil$V$\hfil\cr\kern0.03em--\hfil\cr}%
  }}%
}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
%\newcommand{\dd}{\mathrm{d}} % not needed, just use \diff
\newcommand{\btext}[1]{\text{\begin{varwidth}[t]{\textwidth}\centering#1\end{varwidth}}}

\newcommand{\ob}[2]{{\overbrace{#1}^{#2}}}
\newcommand{\ub}[2]{{\underbrace{#1}_{#2}}}


\begin{document}

The force $\vec{F}$ can be split as the sum of
\begin{align*}
&\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol && \text{Body forces (acceleration, emf, gravity, etc.)} \\
&\oiint\limits_SP\diff S && \text{Pressure forces} \\
&\vec{F}_\mu && \text{Viscous forces}
\end{align*}
and $\frac{\diff}{\diff t}(m\vec{v})=m\frac{\diff\vec{v}}{\diff t}+\vec{v}\,\frac{\diff m}{\diff t}$, where
\begin{align*}
m\frac{\diff\vec{v}}{\diff t}  &= \oiint\limits_S (\rho\vec{v}\cdot\diff S)\vec{v} \\
\vec{v}\,\frac{\diff m}{\diff t} &= \frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol
\end{align*}
so we arrive at the main formula
\begin{equation*}
\oiiint\limits_{\vol} \rho \vec{f}_b\diff \vol +
\oiint\limits_SP\diff S +
\vec{F}_\mu
=
\oiint\limits_S (\rho\vec{v}\cdot\diff S)\vec{v} +
\frac{\partial}{\partial t}\oiiint\limits_{\vol}\rho \vec{v}\diff \vol
\end{equation*}

\end{document}

enter image description here

1
  • This works great! Thank you. To answer your question, this is a reference sheet for me and for some reason I understand these long equations so much better with braces. As a quick side question, is there an easy way to control line spacing in the brace text?
    – Publius
    Oct 17, 2019 at 3:55
3

Try:

\documentclass{article}
\usepackage{stix}
\usepackage{mathtools}
\newlength\ubwidth
\newcommand\parunderbrace[2]{\settowidth\ubwidth{$#1$}% founded somewhere on this site
                             \underbrace{#1}_{\parbox{\ubwidth}{%
                                \scriptsize\centering#2}}
                             }

\begin{document}
    \[
\parunderbrace{\oiiint\limits_V\rho\vec{F}_b\,\mathrm{d}V}{Body forces (acceleration, emf, etc.)}
    \]
\end{document}

enter image description here

Addendum: your complete equation you can simply obtain with use of above solution. For example as:

\documentclass{article}
\usepackage{stix2}
\usepackage{mathtools}
\usepackage{esdiff}
\newcommand{\dd}{\,\mathrm{d}}
\newlength\ubwidth
\newcommand\parunderbrace[2]{\settowidth\ubwidth{$#1$}% found somewhere on this site
                             \underbrace{#1}_{\parbox{\ubwidth}{%
                                \scriptsize\centering#2}}
                             }

\begin{document}
    \[
\overbrace{
\parunderbrace{\oiiint\limits_V\rho\vec{F}_b \dd V}{Body forces (acceleration, emf, etc.)}
+ 
\parunderbrace{\oiiint\limits_S\rho P \dd S}{Pressure forces}
+ 
\parunderbrace{\ \vphantom{\int\limits_S}\vec{F}_\mu\ }{Viscous forces}
           }^{\vec{F}}
= \overbrace{
\parunderbrace{\oiint\limits_S\left(\rho\vec{v}\cdot\dd S\right)\vec{v}}{$m\diff{d}{v}$}
+ \parunderbrace{\diffp{}{t}\oiiint\limits_{V}\rho \vec{v}\dd V}{$\vec{v}\diff{m}{t}$}
            }^{\diff{}{t} (m\vec{v})}
    \]
\end{document}

enter image description here

1
  • As I mentioned above, I’m not on my computer right now but I will try as soon as I can. Thank you!
    – Publius
    Oct 16, 2019 at 0:24

You must log in to answer this question.

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