GeneralNew line in \text command in math mode

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
James
Posts: 7
Joined: Tue Jan 13, 2009 12:23 am

New line in \text command in math mode

Post by James »

Hi, I'm trying to format the following equation nicely and need to be able to force a newline in the \text{interval of integration} command so that it doesn't merge into the other text. It's hard to describe without seeing it rendered, but the problem is obvious when it is.

Code: Select all

\documentclass{minimal}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\left| \int_{-\pi}^\pi f(x) (p(x))^k\, dx \right| \le \underbrace{2\pi}_{\mathclap{\text{interval of integration}}}
   \overbrace{B}^{\mathclap{|f(x)| \le B}} 
   \underbrace{\left(1 - \frac{\epsilon}{2}\right)^{k}}_{\mathclap{p(x) \le 1 - \frac{\epsilon}{2}}}
\end{equation}
\end{document}
I've rendered it here: http://www.scribtex.com/pages/newline-in-text

Is it possible to force a newline in the \text command? Or is there a better way to format something like this?

Thanks,
James

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

New line in \text command in math mode

Post by localghost »

I rendered the equation environment on my machine and it looks a little bit better, but not good. Put the text into a parbox of a certain width.

Code: Select all

\text{\parbox{2cm}{interval of integration}}
Perhaps the "Math mode" document has further suggestions to solve this in a more elegant way.


Best regards
Thorsten¹
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

New line in \text command in math mode

Post by phi »

One possibility is the \substack command:

Code: Select all

X_{\substack{\text{aaa} \\ \text{bbb}}}
Those over- and underbraces are widespread in handwritten notes, but uncommon in typeset documents. It might be better to replace them with real text; like "Because |f(x)| ≤ B and p(x) ≤ 1 - ε/2, the inequality … holds". In most cases, this is appreciated by the reader.
James
Posts: 7
Joined: Tue Jan 13, 2009 12:23 am

Re: New line in \text command in math mode

Post by James »

Thanks for the responses, both solutions achieve the desired effect. You're right phi, I'm transcribing some handwritten notes and I think it's best if I write them out more fully. Either way, that's another two LaTeX commands under my belt!

Thanks again,
James
Post Reply