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.

You can see there is an unwanted white space at the last term below.

enter image description here

\documentclass[border=12pt]{standalone}
\usepackage{amsmath}
\begin{document}
$
\lefteqn{\textstyle\overbrace{\phantom{1+2+3+4}}^{\alpha}}1+2+
    \underbrace{3+4+
        \lefteqn{\textstyle\overbrace{\phantom{5+6+7}}^{\beta}}5+6}_{\gamma}+7
$
\end{document}

What causes the white space? And how to remove it?

share|improve this question
    
Does tex.stackexchange.com/q/24912/21591 help? –  mafp Feb 1 '13 at 9:02
add comment

2 Answers

up vote 18 down vote accepted

The boxing interferes with the math spacing, if you make the phantoms visible you see what is being braced:

If you correct for the mathop spacing you can make them align exactly:

enter image description here

\documentclass[border=12pt]{article}
\usepackage{amsmath,color}
\begin{document}
$
\lefteqn{\textstyle\overbrace{\phantom{1+2+3+4}}^{\alpha}}1+2+
    \underbrace{3+4+
        \lefteqn{\textstyle\overbrace{\phantom{5+6+7}}^{\beta}}5+6}_{\gamma}+7
$


\def\xphantom#1{\hbox{{\color{red}$#1$}}}
$
\lefteqn{\textstyle\overbrace{\xphantom{1+2+3+4}}^{\alpha}}1+2+
    \underbrace{3+4+
        \lefteqn{\textstyle\overbrace{\xphantom{5+6+7}}^{\beta}}5+6}_{\gamma}+7
$

$\setbox0\hbox{$3+4$}
\overbrace{1+2+3+4}^{\alpha}
\kern-\wd0\!
\underbrace{3+4+5+6}_{\gamma}
\kern-\wd0\!
\overbrace{5+6+7}^{\beta}
$
\end{document}

See the discussion in

How to fix the math-spacing when a lot of \phantom, \mathrlap, etc. are used?

share|improve this answer
add comment

I've just released a new package designed to solve just this problem! It is called underoverlap.

Here's how I would then set your example:

$
    \UOLoverbrace{1+2+}[3+4]^\alpha \UOLunderbrace{+}[5+6]_\gamma \UOLoverbrace{+7}^\beta
$

enter image description here

It needs no duplication in your source code and spacing is automatically correct in most cases (mostly thanks to David's help in the question he links to in his answer.)

share|improve this answer
    
Have you registered this to "Problems lead to package creations"? –  Please don't touch Mar 30 '13 at 23:16
add comment

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.