Make several underbrace more compact (to look nice)
Building on other answers, I've imported the stuff from MnSymbol
to define both \underbrace
and \overbrace
.
Then I've used them together with \mathclap
.
Code:
\documentclass{scrartcl}
\usepackage{mathtools}
%------------------ MnSymbol stuff ------------------%
\DeclareFontFamily{OMX}{MnSymbolE}{}
\DeclareSymbolFont{largesymbolsX}{OMX}{MnSymbolE}{m}{n}
\DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
<-6> MnSymbolE5
<6-7> MnSymbolE6
<7-8> MnSymbolE7
<8-9> MnSymbolE8
<9-10> MnSymbolE9
<10-12> MnSymbolE10
<12-> MnSymbolE12}{}
\DeclareMathSymbol{\downbrace} {\mathord}{largesymbolsX}{'251}
\DeclareMathSymbol{\downbraceg} {\mathord}{largesymbolsX}{'252}
\DeclareMathSymbol{\downbracegg} {\mathord}{largesymbolsX}{'253}
\DeclareMathSymbol{\downbraceggg} {\mathord}{largesymbolsX}{'254}
\DeclareMathSymbol{\downbracegggg}{\mathord}{largesymbolsX}{'255}
\DeclareMathSymbol{\upbrace} {\mathord}{largesymbolsX}{'256}
\DeclareMathSymbol{\upbraceg} {\mathord}{largesymbolsX}{'257}
\DeclareMathSymbol{\upbracegg} {\mathord}{largesymbolsX}{'260}
\DeclareMathSymbol{\upbraceggg} {\mathord}{largesymbolsX}{'261}
\DeclareMathSymbol{\upbracegggg} {\mathord}{largesymbolsX}{'262}
\DeclareMathSymbol{\braceld} {\mathord}{largesymbolsX}{'263}
\DeclareMathSymbol{\bracelu} {\mathord}{largesymbolsX}{'264}
\DeclareMathSymbol{\bracerd} {\mathord}{largesymbolsX}{'265}
\DeclareMathSymbol{\braceru} {\mathord}{largesymbolsX}{'266}
\DeclareMathSymbol{\bracemd} {\mathord}{largesymbolsX}{'267}
\DeclareMathSymbol{\bracemu} {\mathord}{largesymbolsX}{'270}
\DeclareMathSymbol{\bracemid} {\mathord}{largesymbolsX}{'271}
\makeatletter
\def\horiz@expandable#1#2#3#4#5#6#7#8{%
\@mathmeasure\z@#7{#8}%
\@tempdima=\wd\z@
\@mathmeasure\z@#7{#1}%
\ifdim\noexpand\wd\z@>\@tempdima
$\m@th#7#1$%
\else
\@mathmeasure\z@#7{#2}%
\ifdim\noexpand\wd\z@>\@tempdima
$\m@th#7#2$%
\else
\@mathmeasure\z@#7{#3}%
\ifdim\noexpand\wd\z@>\@tempdima
$\m@th#7#3$%
\else
\@mathmeasure\z@#7{#4}%
\ifdim\noexpand\wd\z@>\@tempdima
$\m@th#7#4$%
\else
\@mathmeasure\z@#7{#5}%
\ifdim\noexpand\wd\z@>\@tempdima
$\m@th#7#5$%
\else
#6#7%
\fi
\fi
\fi
\fi
\fi}
\def\overbrace@expandable#1#2#3{\vbox{\m@th\ialign{##\crcr
#1#2{#3}\crcr\noalign{\kern2\p@\nointerlineskip}%
$\m@th\hfil#2#3\hfil$\crcr}}}
\def\underbrace@expandable#1#2#3{\vtop{\m@th\ialign{##\crcr
$\m@th\hfil#2#3\hfil$\crcr
\noalign{\kern2\p@\nointerlineskip}%
#1#2{#3}\crcr}}}
\def\overbrace@#1#2#3{\vbox{\m@th\ialign{##\crcr
#1#2\crcr\noalign{\kern2\p@\nointerlineskip}%
$\m@th\hfil#2#3\hfil$\crcr}}}
\def\underbrace@#1#2#3{\vtop{\m@th\ialign{##\crcr
$\m@th\hfil#2#3\hfil$\crcr
\noalign{\kern2\p@\nointerlineskip}%
#1#2\crcr}}}
\def\bracefill@#1#2#3#4#5{$\m@th#5#1\leaders\hbox{$#4$}\hfill#2\leaders\hbox{$#4$}\hfill#3$}
\def\downbracefill@{\bracefill@\braceld\bracemd\bracerd\bracemid}
\def\upbracefill@{\bracefill@\bracelu\bracemu\braceru\bracemid}
\def\upbrace@expandable{%
\horiz@expandable
\upbrace
\upbraceg
\upbracegg
\upbraceggg
\upbracegggg
\upbracefill@}
\def\downbrace@expandable{%
\horiz@expandable
\downbrace
\downbraceg
\downbracegg
\downbraceggg
\downbracegggg
\downbracefill@}
\DeclareRobustCommand{\overbrace}[1]{\mathop{\mathpalette{\overbrace@expandable\downbrace@expandable}{#1}}\limits}
\DeclareRobustCommand{\underbrace}[1]{\mathop{\mathpalette{\underbrace@expandable\upbrace@expandable}{#1}}\limits}
\makeatother
%------------------ MnSymbol stuff ------------------%
\begin{document}
\[ p(x) \cdot x - \overbrace{r \cdot \underbrace{\smash{\eta}}_{\equiv 1} \cdot x}^{\mathclap{\text{\tiny variable costs}}} \]
\end{document}