Math & ScienceVertical Alignment of Text When Using Multiple Underbraces

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
cbkschroeder
Posts: 55
Joined: Sun Nov 09, 2008 7:48 pm

Vertical Alignment of Text When Using Multiple Underbraces

Post by cbkschroeder »

Hi!

Thanks for taking the time to read my posting.

I have the following equation:

Code: Select all

\frac{1}{T_{2}^\ast}=\underbrace{\frac{1}{T_2}}_\text{Irreversible}+\underbrace{\frac{\gamma}{2\pi}\Delta B}_\text{Reversible}
The two terms on the right of the equal sign are both "underbraced". When one compiles this document, however, the result is that there is no vertical alignment of the text which accompanies the underbraces. In other words, the final product has "Irreversible" sit slightly (but very noticeably) lower on the page than "Reversible". Is there any way to ensure consistent vertical alignment of text in multiple-underbrace scenarios? Perhaps an even better solution would be to have text sit at a constant distance below each underbrace but instead have the underbraces vertically aligned...

Your (always helpful) thoughts would be much appreciated; thanks for your time!

Christian

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Vertical Alignment of Text When Using Multiple Underbraces

Post by Stefan Kottwitz »

Hi Christian,

a quick workaround would be to use \vphantom to ensure the vertical alignment:

Code: Select all

\frac{1}{T_{2}^\ast}=\underbrace{\frac{1}{T_2}}_\text{Irreversible}
+\underbrace{\frac{\gamma}{2\pi\vphantom{T_2}}\Delta B}_\text{Reversible}
Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical Alignment of Text When Using Multiple Underbraces

Post by localghost »

Another approach could be to make the compiler neglect the vertical size of the denominator in the first fraction on the right side of the equation.

Code: Select all

\begin{equation}
  \frac{1}{T_{2}^\ast}=\underbrace{\frac{1}{\smash{T_2}}}_\text{Irreversible}+\underbrace{\frac{\gamma}{2\pi}\,\Delta B}_\text{Reversible}
\end{equation}

Best regards
Thorsten¹
cbkschroeder
Posts: 55
Joined: Sun Nov 09, 2008 7:48 pm

Re: Vertical Alignment of Text When Using Multiple Underbraces

Post by cbkschroeder »

Thank you both for your quick replies. Of the two contrasting solutions, using the \vphantom creates a subtly more pretty equation. Using \smash seems to crowd things a bit.

Thorsten, thanks for your subtle insertion of a "\,"; it does make things prettier!

Again, thank you both!

Christian
adnaniut
Posts: 11
Joined: Tue Aug 10, 2010 1:23 am

Vertical Alignment of Text When Using Multiple Underbraces

Post by adnaniut »

Hi guys,

I have a similar problem of vertical alignment in array. Could you please suggest me how can I align n and m in same level.

Thanks
Adnan

Code: Select all

$$ =\left[
 \underbrace{
\begin{array}{ccccc}
 \displaystyle\frac{\displaystyle \sum_{i=0}^{n-1} q_2^i + q_2^n}{q_2^n} &
 \displaystyle \frac{\displaystyle \sum_{i=0}^{n-2} q_2^i + q_2^n}{q_2^n} &
  \cdots &
  \displaystyle \frac{\displaystyle \sum_{i=0}^{n-(n+1)} q_2^i + q_2^n}{q_2^n} &
   \displaystyle \frac{1 + q_2^n}{q_2^n} 
    \end{array}
  }_n
\underbrace{%
    \begin{array}{ccc}
   1 &
    \cdots &
    1 
        \end{array}
    }_m
    \right]^T$$
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Vertical Alignment of Text When Using Multiple Underbraces

Post by gmedina »

Hi,

you could use a "vertical phantom":

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
  =\left[
  \underbrace{
  \begin{array}{ccccc}
    \dfrac{\sum\displaystyle_{i=0}^{n-1} q_2^i + q_2^n}{q_2^n} &
    \dfrac{\displaystyle \sum_{i=0}^{n-2} q_2^i + q_2^n}{q_2^n} &
    \cdots &
    \dfrac{\displaystyle \sum_{i=0}^{n-(n+1)} q_2^i + q_2^n}{q_2^n} &
    \dfrac{1 + q_2^n}{q_2^n} 
  \end{array}
  }_n
  \underbrace{%
  \begin{array}{ccc} &\\[-10pt]
    1 & \cdots & 
    1\vphantom{\dfrac{\displaystyle\sum_{i=0}^{n-1} q_2^i + q_2^n}{q_2^n}}
  \end{array}
  }_m
  \right]^T
\]

\end{document}
Note that I used \[...\] instead of the obsolete $$...$$ construct.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply