[Tex/LaTex] Text inside equation with \\

equationssubstacktext;underbrace

Sometimes I want to plug in text using overbrace/stackrel inside an equation, and have it in more than one line. what is the most straightforward way to do it?

What I wish to have is in the picture below. My (somewhat dumb) workaround is:

\documentclass[a4paper]{article}
\usepackage{amsmath,times}
\begin{document}
$$e = \underbrace{m}_{\substack{\text{I wish this text}\\ \text{ to be in two lines}} }\cdot \underbrace{c^2}_{\text{and the same here} }$$
\end{document}

enter image description here

Any (better) solutions?

Thanks!

Best Answer

You could use \parbox instructions. In the following example, I use \Centering (from the raggede package) rather than the basic \centering instruction, as \Centering provides automatic line length balancing.

enter image description here

\documentclass[a4paper]{article}
\usepackage{amsmath,newtxtext,ragged2e} % 'times' package is deprecated
\begin{document}
\[
E = \underbrace{m}_{\parbox{1.75cm}{\Centering\scriptsize I wish this text to be in two lines}}    
\cdot \underbrace{c^2}_{\parbox{1.25cm}{\Centering\scriptsize and the same here}}
\]
\end{document}
Related Question