# Adjust the position of overbrace-text relative to a formula

I have the following design-problem (there's probably a solution, unfortunately I just can't remember anymore):

$a^2 b^2 + c \overbrace{r \cdot \Underbrace{\eta}_{\equiv 1} \cdot x}^{\shortstack{ \text{variable costs} \rightarrow K = \eta} } a^2 + b^2 + c$


It should do the following:

• make the brace-text ignore the size of the brace and the underlying formula
• if possible, don't center the brace-text, but left-align it right above the first element of the brace-formula (here r)

Thanks for any suggestions :)

Do I have to use tables or tikzpictures?

The solution (by paint) is very easy to achieve. And there has to be a way within latex. But of course in case there's no easy way to modifty the braces, I rather will rewrite my entire text and formulas.

• The \shortstack instruction doesn't seem to be doing anything. Can it be omitted?
– Mico
Feb 28, 2016 at 8:29
• Oh yes, I think it can. It's a a relict of another code.
– Mac
Feb 28, 2016 at 8:53

Here is a solution aligned on one line as you want. It relies on the eqparbox package. I define an \eqmathbox command, which stores the width of the ‘over/underbraced’ formula with a system of tags, and I use it for another \eqmakebox which contains the text, combined with \rlap and \mathclap at appropriate places. Note the spacing aroud the \cdots is now correct.

For small formulae to be overbracketed, I suggest to use the \over/underbracket commands from mathtools, as they look nicer, in my opinion.

\documentclass{article}
\usepackage{mathtools} % for \mathclap macro; calls 'amsmath' automatically
\usepackage{eqparbox}
\newcommand\eqmathbox[1]{\eqmakebox[M]{$\displaystyle #1$}}
\begin{document}

$a^2 b^2 + c \overbracket[0.5pt]{\eqmathbox{\mathstrut r \cdot\! {\underbracket[0.5pt]{\,\eta\,}_{\mathclap{\equiv 1}}}\! \cdot x}}^{ \eqmakebox[M][l]{\rlap{variable costs  \rightarrow K = \eta }}} a^2 + b^2 + c$

\end{document}


Rather than let the material above the overbrace dangle out to the right, I'd introduce a line break in the overbrace material, and I'd enclose the two-line material in a \mathclap wrapper so that it's allowed to stick out to both the left and the right, if necessary.

\documentclass{article}
\usepackage{mathtools} % for \mathclap macro; calls 'amsmath' automatically
\begin{document}

$a^2 b^2 + c \overbrace{r \cdot {\underbrace{\eta}_{\equiv 1}} \cdot x}^{ \mathclap{\substack{\text{variable costs }\\[0.75ex] \rightarrow K = \eta}}} a^2 + b^2 + c$
\end{document}

• For my special purpose, a two-line solution isn't that suitable. I often need to deal with even longer issues.
– Mac
Feb 28, 2016 at 8:54