2

Is there a good-looking way to produce an overbrace for a single letter? The overbrace produced by

\[
\overbrace{P}^{some annotation}
\]

is too wide for the single letter P. Note that the focus really lies upon the annotation, the reader has already seen the unannotated term and now gets to see an example which formal annotations are inserted where in the term.

Here is a simplified example from my sources. The overbraced P does not look good.

\documentclass{minimal}

\usepackage{proof}
\usepackage{mathtools}

\newcommand{\hoare}[3]{\{#1\}\;#2\;\{#3\}}
\newcommand{\ctxt}[3]{C:\langle#1,#2,#3\rangle}

\begin{document}

\begin{equation*}
\infer[Rule]
    {\underbrace{\hoare P c Q}_{\ctxt{i}{x \cdot \mathrm{xs}}{o_2}}}
    { \overbrace{\hoare{P'}{c'}{Q'}}^{\ctxt{i+1}{\mathrm{xs}}{o_1}}
    & R \implies \overbrace{P}^{\mathclap{\ctxt{o_1}{\text{a bit longer}}{o_2}}}
    }
\end{equation*}

\end{document}
8
  • 2
    If you make it shorter, it will not stand out enough. If you really need to annotate a single letter, do it after the equation: \[ P = U I , \] where $P$ denoted the effective power.
    – yo'
    Sep 21 '15 at 7:10
  • (sorry for a typo, it should of course be denotes)
    – yo'
    Sep 21 '15 at 7:37
  • 2
    For very short items, \overbracket from mathtools generally looks better. It has two optional arguments; linewidth and bracket height.
    – Bernard
    Sep 21 '15 at 7:43
  • Putting the annotation after the equation won't work here, as the position is relevant. The annotations really are part of the term (a logical formula).
    – cebewee
    Sep 21 '15 at 10:04
  • overbracket looks strange if the annotation is much longer then the bracket. I think it is missing a tip, like the middle element of an overbrace.
    – cebewee
    Sep 21 '15 at 10:07
0

In the end, I used the abraces package. This package provides commands to construct your own variants of overbrace/underbrace. I ended up using just the "middle" part of the overbrace, without the small arcs at the left and right end. This can be obtained by:

\aoverbrace[U]{formula}^{brace-formula}

Where necessary, I also used \mathclap from mathtools so that the annotation does not introduce to much whitespace into the rest of the formula.

\newcommand{\shortoverbrace}[2]{\aoverbrace[U]{#1}^{\mathclap{#2}}}%

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.