I would like to underline a math object with an arrowhead (from tikz) without adding extra space to the line skip, like so

The object C has an underline with an arrowhead
from tikz. The only problem  is the extra space
between the lines.

At the moment, I'm using the following code (MWE)

  {\tikz[baseline=-2ex] \draw[-stealth,line width=.4pt] (.3ex,0ex) -- (1.7ex,0ex);}

The object $\mathop{C}\limits_{\subtodisplay}$ has an underline with an 
arrowhead from tikz. The only problem is the extra space between the lines,
which becomes apparent when adding extra text to get at least three lines.

Extra space from subscripts/superscripts is often a problem for me. Is there a way to force the line spacing? Clearly in this case the extra space is not needed:

underline with arrowhead

(I usually just need it to underline a single letter, so the size could be fixed, although I welcome an answer that would work with variable width.)


Why don't you use the \underrightarrow command instead? For example like this:



underlinearrow mho

You can underline multiple letters/expressions too:


underline expression

But you won't use this with multiple letters very often

  • Knowing about \underrightarrow now, maybe I want to rephrase my question as "How can I redefine \underrightarrow with tikz (i.e., to use a tikz arrowhead)?". – Earthliŋ Dec 14 '14 at 12:53
  • Well I thought you only wanted to place the arrow. If you absolutely want to use the tikz arrowhead, so you can surely redefine the question. But why do you want the tikz arrowhead? From a style point of view, the tikz arrows must remain in tikz pictures, the "text/math" arrow must remain in text/math. If you want to change this arrowhead you also have to change all the other arrowheads (30 or more). Moreover the tikz arrowhead in text and expressions looks awful. – Davide Dec 14 '14 at 13:06
  • I'm using tikz arrowheads throughout my document (redefining \to \mapsto etc.). So, I'd like to be consistent with my use of arrowheads. I chose tikz, because I can't really typeset commutative diagrams beautifully with other packages I've tried. "Awful" is, I guess, a matter of taste. At the very least, though, different arrowheads look better/worse depending on the choice of font, and I'm not using Computer Modern... – Earthliŋ Dec 14 '14 at 13:13
  • 1
    Ok, "awful" can become "good looking" with other fonts and of course is only a matter of taste. I'm just trying to help you finding better solutions. Why don't redefine the tikz arrowheads (1 redefining) instead of the different "text" arrows? This would maintain the consistent use of them. Unless you don't like the "text" arrowhead... – Davide Dec 14 '14 at 13:19
  • @Earthliŋ It really is better to use amsmath arrows because they are designed for math expressions, they have the proper left and right spacing, they have proper positions for subscripts and superscripts, and they are extensible. TikZ arrows are designed for pictures. – user10274 Dec 14 '14 at 14:11

Here is one possible solution :


  \node[inner sep=0, outer sep=0](N) {#2};
  \draw[overlay, -latex, line width=.04em, #1]
    ([yshift=-.14em]N.south west) -- ([yshift=-.14em]N.south east);}}

  A test sentence : \tikzunderarrow{ypqj to ckeck if it is ok ;)}.

  And we check with math formula \tikzunderarrow{$\left[ \sqrt{x^2+y^2} \right]$},
  and a {\Large \tikzunderarrow[purple,|-stealth]{Large}} underarrow.

enter image description here

EDIT: Following the suggestion of Peter Grill, I added overlay to keep the vertical size equal to the text in the node.

EDIT 2: I added some blind text to show that the vertical distance is ok.

EDIT 3: As suggested by Paul Gaborit and Earthliŋ I replaced inner xsep=0 by inner sep=0. And now this answer is a community wiki.

EDIT 4: And now we can change the arrow style as optional argument.

  • I would suggest adding the overlay option to the \draw so that the arrow has no impact on the spacing. – Peter Grill Dec 14 '14 at 19:15
  • @PeterGrill My first version used \useasboundingbox for the same reason, but I decided to simplify it. But you are right overlay is simpler. I was not aware that we can use overlay on a path. Thanks for the suggestion. – Kpym Dec 14 '14 at 19:24
  • This works very well. I found overlay very useful for solving many of my other line skip issues. I'm using inner sep=0 (instead of inner xsep=0), though, because inner ysep does seem to add space to the line skip. – Earthliŋ Dec 14 '14 at 21:06
  • @Earthliŋ I keep inner ysep because I use it to draw the arrow at some distance from the text. That is why overlay is not so important in my case (only the part of the arrow's head that is under the bottom of the node is ignored by overlay). But If somebody wants a 0 ysep it has to yshift the arrow down. – Kpym Dec 14 '14 at 22:19
  • 1
    Did you try with gest instead of test? You must use inner sep=0. – Paul Gaborit Dec 14 '14 at 22:45

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.