6

Consider the following:

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath}

\begin{document}

$u=\overline{\exists degree\hspace{3pt} \overbrace{\big(\underbrace{degrees(course, degree)}_{u_1}\wedge\underbrace{degree\neq 1}_{u_2}\big)}^{u_3}}$

\end{document}

Which produces this:

enter image description here

I want that the \overbrace with the u_3 label will appear above the \overline, but still encompass only the parentheses. I can't find a way to do it.

Can it be done somehow?

4 Answers 4

7

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

2
  • 2
    Why did you define the command inside document body? Is there some reason? Nice solution, by the way.
    – Sigur
    Dec 13, 2014 at 14:18
  • 2
    @Sigur It's probably something that won't be used anywhere else, so defining it in the math display is just like typing it “there”. If it was in the preamble it would be more difficult to access in case some correction has to be made.
    – egreg
    Dec 13, 2014 at 14:20
3

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}
    $}}
$$
1
\documentclass[12pt]{article}
\usepackage{mathtools}

\begin{document}
\def\contento{\exists\,\mathit{degree}}
\def\contenti{\big(
    \underbrace{{\rm degrees}({\it course},{\it degree})}_{u_1}
    \wedge
    \underbrace{{\it degree}\neq 1}_{u_2}
    \big)}
\[
u=\overline{\contento\phantom{\contenti}}
  \llap{$\displaystyle
        \overbrace{\vphantom{\overline{\contento\contenti}}\contenti}^{u_3}
    $}
\]

\[
u=\overline{\contento\vphantom{\contenti}}\!
\overbrace{
    \overline{\vphantom{\contento}\contenti}
}^{u_3}
\]
\end{document}

enter image description here

1

I want that the \overbrace with the u_3 label will appear above the \overline, but still encompass only the parentheses. I can't find a way to do it.

So. Forget \overline. Simply use \hspace and draw a \rule at the desired position, height, length, (and width.)

$$
u=\exists degree\hspace{3pt}
\overbrace{\big(\underbrace{degrees(course, degree)}_{u_1}
\wedge\underbrace{degree\neq 1}_{u_2}\big)
   \hspace{-21em}\rule[2.25ex]{21em}{}
}^{u_3}
$$

enter image description here

4
  • 1
    It is better IMHO to write all the text in textmode. You can give a little space between \exist and degree. +1
    – Sebastiano
    Mar 8, 2020 at 22:09
  • @Sebastiano Sure, I agree in principle with writing text in textmode \textrm etc., but that wasn't the question. That's a different issue entirely. Mar 8, 2020 at 22:15
  • Yes, my it was only a suggestion like never to use double $$. See tex.stackexchange.com/questions/503/why-is-preferable-to
    – Sebastiano
    Mar 8, 2020 at 22:23
  • I was using KaTex in wiki.js. Mar 10, 2020 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.