How to combine \overbrace and \overline the way I want?

Typeset the whole thing three times. The first one as a horizontal phantom to set the width, the second time as the real thing, the third time as a vertical phantom.

The first two times the two objects are superimposed with \ooalign.

In order to save typing, the object is saved in a temporary command, which takes as argument an invisible rule stating its height.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{lipsum} % for giving context

\newcommand{\func}[1]{\operatorname{#1}}
\newcommand{\var}[1]{\mathit{#1}}

\begin{document}

\lipsum*[2]
\[
\newcommand{\contents}[1]{%
  \exists\, \var{degree} \: 
  \overbrace{
    #1
    \bigl(\,
      \underbrace{\func{degrees}(\var{course},\var{degree})}_{u_1}
      \wedge
      \underbrace{\var{degree}\neq 1}_{u_2}
    \,\bigr)
  }^{u_3}
}
u={\ooalign{%
    $\displaystyle\overline{\rule{0pt}{2ex}\hphantom{\contents{}}}$\cr
    $\displaystyle\contents{\rule{0pt}{2.75ex}}$\cr
}}
\vphantom{\contents{\rule{0pt}{2.75ex}}}
\]
\lipsum[2]

\end{document}

enter image description here


Another solution prints the formula only once (no three times):

$$
  u =
  \vbox{\def\shiftA{3.3ex}\def\shiftB{\vrule height2.7ex width0pt} %spec. numbers for this formula
    \kern\shiftA\hrule\kern-\shiftA
    \hbox{$\displaystyle
       \exists\, {\it degree} 
           \overbrace{\big(
               \underbrace{\shiftB{\rm degrees}({\it course},{\it degree})}_{u_1}
               \wedge
               \underbrace{{\it degree}\neq 1}_{u_2}
           \big)}^{u_3}
    $}}
$$

Tags:

Math Mode