I want the text under an underbrace in mathmode to 1. Have linebreaks. 2. Be raggedright 3. Remain centered with respect to the midpoint of the underbrace.
I have tried with the two methods in the following code, but without success:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\sometext}{Given the conditions we impose}
\begin{document}
With \textbackslash mbox:
\begin{equation}\nonumber
x
\underbrace{=}_{%
\mbox{%
\parbox[c]{2cm}{%
\raggedright
\scriptsize
\sometext
}
}
}
y
\end{equation}
With amsmath \textbackslash text:
\begin{equation}\nonumber
x
\underbrace{=}_{%
\text{%
\parbox[c]{2cm}{%
\raggedright
\sometext
}
}
}
y
\end{equation}
\end{document}
\parbox
to know how to break lines, a width is necessary. Therefore, the moment you set it to 2cm, the boxes' width becomes that and the whole box (white space included) is centered with respect to the underbrace (change\mbox
for\fbox
to see the idea). You can avoid this in two ways. 1. Avoid the\parbox
and break lines on your own, like suggested below. 2. Choose and appropiate size for each case. 1.28cm or 1.66cm seem to give a nicer picture.\makebox[0pt]{<center aligned parbox>}