Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to overline a piece of text, but the line is too close to the number, which is not nice, so I want to add some kind of padding between the overline and the text. This is what I've made up so far:


where XXX is the text I want to overline.

This looks very ugly for me, so I was wondering whether there is any better way to do it.

share|improve this question
probably \overline{\strut XXX} (or make a similar different strut if that isn't the correct spacing, but strut is used in other places to get even vertical spaces) –  David Carlisle Dec 19 '12 at 11:12

2 Answers 2

up vote 5 down vote accepted

The following example shows some alternatives.

  • \raisebox can also be used to specify the final height (and depth). The height is known as \height that can be used for calculations (\dimexpr or package calc).

  • \vphantom: placeholder for height and depth of the argument. The argument is not set and the width is zero.

  • \rule with zero width can be used to insert an invisible vertical rule.

  • \strut adds a invisible vertical box with height .7\baselineskip and depth .3\baselineskip.

Example file:


  % Package `calc' can be used as alternative for `\dimexpr'.



\ov{XXX} \ov{xxx} \ov{\"A}

\ovA{XXX} \ovA{xxx} \ov{\"A} \qquad\verb|\raisebox{3mm}{}|

\ovB{XXX} \ovB{xxx} \ov{\"A} \qquad\verb|\rule{0pt}{3mm}{}|

\ovC{XXX} \ovC{xxx} \ov{\"A} \qquad\verb|\strut|

\ovD{XXX} \ovD{xxx} \ov{\"A} \qquad\verb|\vphantom{\"A}|

\ovE{XXX} \ovE{xxx} \ov{\"A} \qquad\verb|\raisebox{0pt}{1.2\height}|

\ovF{XXX} \ovF{xxx} \ov{\"A} \qquad\verb|\raisebox{0pt}{\height+1mm}|

\ovG{XXX} \ovG{xxx} \ov{\"A} \qquad\verb|\raisebox{0pt}{\height+1mm} + \vphantom{A}|



share|improve this answer
Very nice list, for all kind of different needs. I actually went the \strut way, but the \vphantom method looks very nice for longer texts –  SztupY Dec 19 '12 at 18:07

The separation is controlled by a font parameter, so it's a bit difficult to change it. You can add a predetermined height to the text:


  \vrule height\dimexpr\fontcharht\font`\A+.1ex\relax width 0pt\relax


\textoverline{no} \textoverline{with}

Play with the 0.1ex dimension, trying various values until you're satisfied.

enter image description here

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.