# How to remove an unwanted white space at the last end of a horizontal curly brace?

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

\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?

-
Does tex.stackexchange.com/q/24912/21591 help? – mafp Feb 1 '13 at 9:02

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:

\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?

-

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$


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.)

-
Have you registered this to "Problems lead to package creations"? – kiss my armpit Mar 30 '13 at 23:16