Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following problem with \underbrace: underbrace

As you can see, the third underbrace and its comment are not in the line with the first two. Here is my code:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}

$\underbrace{\text{A long word}}_{=a}$,
$\underbrace{\text{Another long word}}_{=b}$,
$\underbrace{\text{Word}}_{=c}$

\end{document}

Update: It looks like it's because of the g's and not the length. But still: is there a way to make them in the line?

share|improve this question
2  
That's because you have no letter with positive depth (e.g., g, y, p, q,… have depth). You can just add in the last Word\vphantom{g}. –  Manuel Jul 25 at 21:17

1 Answer 1

up vote 14 down vote accepted

This is because Word has no descenders, while A long word and Another long word both have a descender (g). Here are some options:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\underbrace{\text{A long word}}_{=a}$,
$\underbrace{\text{Another long word}}_{=b}$,
$\underbrace{\text{Word}}_{=c}$

$\underbrace{\text{A long word}}_{=a}$,
$\underbrace{\text{Another long word}}_{=b}$,
$\underbrace{\text{\vphantom{g}Word}}_{=c}$

$\underbrace{\text{\strut A long word}}_{=a}$,
$\underbrace{\text{\strut Another long word}}_{=b}$,
$\underbrace{\text{\strut Word}}_{=c}$

\end{document}

I've overlaid the bounding boxes associated with each \text string to highlight its vertical/horizontal scope.

The first option is to provide a vertical strut equivalent to the other descenders (using \vphantom{<chars>}), while the second uses a uniform \strut across the entire usage.

The same holds for an \overbrace:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\overbrace{\text{A long word}}^{=a}$,
$\overbrace{\text{Another long word}}^{=b}$,
$\overbrace{\text{pop rows}}^{=c}$

$\overbrace{\text{A long word}}^{=a}$,
$\overbrace{\text{Another long word}}^{=b}$,
$\overbrace{\text{\vphantom{A}pop rows}}^{=c}$

$\overbrace{\text{\strut A long word}}^{=a}$,
$\overbrace{\text{\strut Another long word}}^{=b}$,
$\overbrace{\text{\strut pop rows}}^{=c}$

\end{document}

This time pop rows have no ascenders in them, while the letters A, t, h, l and d all have ascenders. Choose a representative ascender in \vphantom, or use a \strut.

In both all instances above it should be clear how the bounding box is adjusted with the struts to properly align the \underbrace/overbrace.

share|improve this answer
    
\strut is indeed the solution! –  Juan A. Navarro Jul 30 at 9:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.