11

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?

  • 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 '14 at 21:17
14

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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