In math I often find that single underlined letters have too long of a line. Here is an example: $\beta\in[\underline{\beta},\bar{\beta}]$

enter image description here

Or perhaps worse:

enter image description here

I can solve the too narrow bar loading some accents from the mathxm font of package mathabx, but I have not found a good way to decrease the width of e.g. \underline{U}.

I would appreciate a hint.

Here is a summary of different functions. I have added the nunder-function, which is kind of fun. However, it desperately needs an additional optional argument to set the division factor \mkern\the\numexpr#1/2mu\relax (hard-coded to two).

Two see why compare the following examples of KP-fonts (left) and CM|nunder div by 2 (middle) and CM|nunder div. by 10 (right). On the right image nunder is perhaps as nice as bunderline.

Kp-font CM1 CM2

nunder works very well KP-fonts, but performs poorly with CM with the hard-coded value of 2. I will have two look further into two optional arguments, but my first attempt was not a success (using the blah example of TeX Faq).




  • a remark possibly a bit off-topic: your comparison of \underline with \bar is a bit misguided; replace \bar with \overline and you get something visually compatible with \underline. \bar is supposed to denote some other variable, like a statistical mean, and this is not what \underline is supposed to be used for. So your quite legitimate question could have been formulated rather as "is there an \underbar?".
    – user4686
    Oct 24, 2013 at 13:58

3 Answers 3


You can set the object to underline making TeX into believing it's shorter:

\newcommand{\bunderline}[1]{\underline{#1\mkern-4mu}\mkern4mu }

$\beta\in[\bunderline{\beta},\bar{\beta}]\qquad \bunderline{U}$

enter image description here

As remarked by Rasmus, one might also introduce an optional argument for deciding, in particular cases, the amount of shortening:

\newcommand{\bunderline}[2][4]{\underline{#2\mkern-#1mu}\mkern#1mu }

With \bunderline[6]{U} one would get more shortening.


Every font family seems to need a particular default for the shortening and, maybe also a "front shortening". For example, this seems to work well with KPfonts:

\newcommand{\bunderline}[1]{\mkern2mu\underline{\mkern-2mu#1\mkern-4mu}\mkern4mu }

enter image description here

A package to consider is accents that provides \underaccent:


Here's the result (with KPfonts) of


enter image description here

  • 2
    A potentially nice addition is \newcommand{\bunderline}[2][4]{\underline{#2\mkern-#1mu}\mkern#1mu }
    – Rasmus
    Mar 24, 2012 at 23:26
  • @Rasmus I agree.
    – egreg
    Mar 24, 2012 at 23:31
  • Do you think it would be re-center the underline ex post shortening? The appropriate length for U might be something like \bunderline[6]{U}, but then, at least with KP-fonts, the line is sort of dragged to the left.
    – Rasmus
    Mar 24, 2012 at 23:57

Based upon the first solution of egreg, one could also center the underline:

\newcommand{\ubar}[1]{\mkern3mu\underline{\mkern-3mu #1\mkern-3mu}\mkern3mu}

Well, the reason is clear: the letters are italic, and "stick out" to the right. This is a quick hack, working only (or mainly) for letters (and not very robust: it assumes that the same font (or font with same widths, to be precise) is used for text and math):





As you can see, it's neither elegant, nor gives beautiful results - but it's better than the default.

  • I did not even think about the reason, but yeah, you are right on the italic thing.
    – Rasmus
    Mar 24, 2012 at 23:28
  • 1
    More robustness and adjustment: \newcommand{\narrowunderline}[2][1]{\mathrlap{underline{\phantom{\ensuremath{\mathrm{#2}\mkern-#1mu}}}}#2\mkern#1mu} (I hoped I managed to copy it correctly from my internet-less work machine)
    – Rasmus
    Mar 25, 2012 at 0:09
  • @Rasmus, make this into an answer! (After adding the missing backslash;).)
    – mbork
    Mar 25, 2012 at 0:22
  • I tried to edit it, but the 5 min rule caught me :) I am reluctant as it seems to change the "kerneling" of letters (as it used that mathrm{.} version). Thus, it might be better to use the vphantom(.)/hphantom(.) functions. I'd have to check more...
    – Rasmus
    Mar 25, 2012 at 0:42

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.