I have a generic equation, into which I want to "insert" something so that the reader can see what I inserted into the equation and at which point.



\[ f = < x | R y > \]

Insert $\int d^3 p |p> <p|$ = 1 before y.

What I imagine is a horizontal curly brace, which extends underneath the equation, and which has its tip touching a spot just slightly to the left of the $y$, while in the brace there is written $\int d^3 p |p> <p|$. It would look something like an inverted \underbrace{foo}_{bar}, but I have no idea how to achieve something like that.

In ASCII art this would maybe look like this:

f = <x | R y >            (1)
   ____|     |____
  | Insert here! | 

3 Answers 3


Here's a variant of Gonzalo's code that uses \mathop{}\limits instead of \raisebox. The output is almost the same.

  f = \langle x | R\mathclap{\mathop{}\limits_{\overbrace{
                   \textstyle\int d^3 p |p\rangle \langle p|}}}y

If you want something more flexible, use the \braceinsert macro from the code below. It takes one optional argument (the amount by which the brace should be lowered, with default 0ex) and one mandatory argument (the stuff you want under the brace). Moreover, it takes care of the case that the \braceinsert is surrounded by \left...\right delimiters, like this:

example for \braceinsert

To be precise, you'll have to use \bileft...\biright instead of \left...\right (like braceinsert left and right). After the outermost \biright, only explicit superscripts will work, so instead of ' you'd have to use ^\prime. (Subscripts won't work properly, but I don't know when one would want one.)

In the formula
  f = 5 \bileft( b^2 + \langle x | R
      \braceinsert[0.2ex]{\textstyle\int d^3 p |p\rangle \langle p|}
      y \rangle \biright)^2,
the depth of the stuff under the brace is added only \emph{after}

(Maybe this is wayyy too complicated?)

  • Thanks for the addition. However, with \mathop{}\limits you run into the problem that you cannot change the vertical placement of the overbrace. That makes it protrude into the actual equation (that, of course, depends on the equation; in the example though it happens). Do you maybe know how to adjust the placement?
    – mSSM
    Commented Jun 16, 2012 at 17:31
  • @mSSM: See my edit. Commented Jun 20, 2012 at 8:11
  • Ha, fun. Thanks for that solution. Just curious - why did you come up with it? Were you not satisfied with the raisebox solution given above? Btw, one minor downside of both solutions is that it "blows up" the vertical size of the content inside the braces. E.g., if I wanted to do \left\langle ... \right\rangle, LaTeX would make those huuuuuge. The obvious work-around would be to use manual sizes from the \big{l,r} family.
    – mSSM
    Commented Jun 20, 2012 at 11:15
  • @mSSM: The reason why I was not quite satisfied with Gonzalo's nice answer was that the 4ex in \raisebox{-4ex} has to be guessed. In my solution, the vertical placement is almost OK, which makes the guessing at least simpler. You're right with the \left...\right downside; it was not so easy to come up with a solution. See my edit! (Maybe it's way too complicated, I don't know.) Commented Jun 20, 2012 at 14:55
  • 1
    @mSSM: OK, now it works with amsmath, but you'll have to use \bileft...\biright around \braceinserts (brace insert left and right). Commented Jun 20, 2012 at 18:09

Ok, before people wonder what happened to the tikz solution, here is an alternate method, using, well... tikz. \tikzmark is used to name the location in the equation that you want to refer to. This name is then given to \Insert along with various options to control the behavior of the brace and the line connecting them.

enter image description here

The parameters passed to \Insert are:

#1. Vertical shift to be applied to the brace

#2. Options to control the behavior of the connecting line.

#3. Name of the marker in the equation.

#4. Text to be braced, which is to be inserted.


  • This does require two runs. First one to determine the locations, and the second to do the drawing.
  • Probably will have issues if the text begin inserted is not on the first line as the arrow will probably overlap other text.




\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

    \begin{tikzpicture}[overlay,remember picture]
\draw [decoration={brace,amplitude=\BraceAmplitude},decorate,ultra thick,blue,#2]
        ($(a.north)+(0,#1)$) -- ($(b.north)+(0,#1)$);
\draw [thick, blue, #3] ($(a.north)!0.5!(b.north)+(0,#1)+(0,\BraceAmplitude+2pt)$) to (#4);

\[ f = < x | R \tikzmark{MyMarker} y > \]

In the above equation, we need to insert \Insert[1.5ex]{orange}{out=90, in=-90,->,shorten >=-1pt}{MyMarker}{$\int d^3 p |p> <p| = 1$} before $y$.

\[ f = < x | R \tikzmark{MyMarkerA} y \tikzmark{MyMarkerB}> \]

Insert \Insert[1.5ex]{blue}{out=90, in=-90,->,shorten >=-1pt,red}{MyMarkerA}{$\int d^3 p |p> <p| = 1$} before $y$, and some more
\Insert[1.0ex]{brown}{out=135, in=-70,->,shorten >=-2pt}{MyMarkerB}{\textbf{stuff}} after $y$.
  • How do those \tikz commands work with the externalize library?
    – mSSM
    Commented Jun 16, 2012 at 17:34
  • @mSSM: Hmmm... Had not considered that. If you can compose a MWE that shows the problem that would be an excellent question to post considering how widely \tikzmark is used. If it is a problem you'd probably have to disable externalization for the pictures that use \tikzmark, unless some came up with a better solution. Commented Jun 16, 2012 at 17:59

Here's one possible solution (in LaTeX2e) using an \overbrace and \mathclap (from the mathtools package); the vertical position was adjusted using \raisebox:



  f = < x | R\mathclap{\raisebox{-4ex}{$\overbrace{\textstyle\int d^3 p |p> <p|}$}} y > 


enter image description here

I also would suggest you to use \langle, \rangle instead of the relational symbols <, >a:



  f = \langle x | R\mathclap{\raisebox{-4ex}{$\overbrace{\textstyle\int d^3 p |p\rangle \langle p|}$}} y \rangle 


enter image description here

  • You were too fast. Commented Mar 6, 2012 at 18:08
  • That \raisebox trick is pretty cool. Thanks alot! And yeah - I am of course using \langle and \rangle, and all that other stuff that is out there (like \lvert). I just did not want to clutter the example. :-)
    – mSSM
    Commented Mar 6, 2012 at 18:16
  • I have changed my accepted answer to the one given by Hendrik Vogt. The code is a tad more elegant as it removes a lot of logic from the document itself, and also has a better default placement (as compared to the raisebox method). See the comments below the answer.
    – mSSM
    Commented Jun 21, 2012 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .