TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want to draw an overline over some text, not an equation, how can I do it? \overline seems to only work in math mode, and when used outside of math mode, it automatically says "Missing $ inserted".

share|improve this question
up vote 15 down vote accepted

Easy answer:


Not so easy, but neater:


We use the normal \overline of math mode, exploiting the fact that a \hbox in math mode typesets its argument in the font which was current at the time the math formula starts (also keeping spaces).

The strange \m@th is a precaution against possible setting of the parameter \mathsurround, a space added before and after in-line math formulas; it's usually zero, but a class might change it. When math mode is used for things like this, it's best to be on the safe side: \m@th sets the parameter to zero, but since a math formula forms a group, the setting is local and won't change the global one.

share|improve this answer
IMHO it should be called \textoverline, just to be consistent with all the other \text... macros. – Martin Scharrer Jul 26 '11 at 14:01
@Martin Done. The definition is just copied from the kernel (re)definition of \underline. – egreg Jul 26 '11 at 14:04
I don't know if more recent packages define it, but just to note: if \textoverline definition fails, using \renewcommand will do the trick. Really good answer! – logo_writer May 28 at 3:11

If you want to have line breaks in the text you can use the soul package:



\ol{This is under a line.}

\Huge\ol{This is under a line.}

The disadvantage of this approach is that the line height does not depend on the height of the content (so capital letters with accents will be problematic). It does scale with font size though.

share|improve this answer


share|improve this answer

The basic answer to your question is that you can use the \overline{} command from math mode for text, too, if you combine it with \mbox{} command. The \mbox{} command lets you shift out of math mode while being in math mode. So try this:

$\overline{\mbox{This is under a line}}$ but this isn't.

Your question was essentially answered by egreg but there wasn't much explanation and this is a little too long to put as a comment.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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