# Setting the vertical distance in \overline

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:

$\overline{\mbox{XXX\raisebox{0.8cm}{}}}$


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.

-
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

The following example shows some alternatives.
Remarks:

• \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:

\documentclass{article}

\makeatletter
\newcommand*{\ov}[1]{%
$\m@th\overline{\mbox{#1}}$%
}
\newcommand*{\ovA}[1]{%
$\m@th\overline{\mbox{#1}\raisebox{3mm}{}}$%
}
\newcommand*{\ovB}[1]{%
$\m@th\overline{\mbox{#1\rule{0pt}{3mm}}}$%
}
\newcommand*{\ovC}[1]{%
$\m@th\overline{\mbox{#1\strut}}$%
}
\newcommand*{\ovD}[1]{%
$\m@th\overline{\mbox{#1\vphantom{\"A}}}$%
}
\newcommand*{\ovE}[1]{%
$\m@th\overline{\raisebox{0pt}[1.2\height]{#1}}$%
}
\newcommand*{\ovF}[1]{%
$\m@th\overline{\raisebox{0pt}[\dimexpr\height+1mm\relax]{#1}}$%
% Package calc' can be used as alternative for \dimexpr'.
}
\newcommand*{\ovG}[1]{%
$\m@th\overline{\raisebox{0pt}[\dimexpr\height+1mm\relax]{#1\vphantom{A}}}$%
}
\makeatother

\begin{document}

\setlength{\parskip}{5mm}

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

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

\end{document}


-
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:

\documentclass{article}

\newcommand{\tolstrut}{%
\vrule height\dimexpr\fontcharht\font\A+.1ex\relax width 0pt\relax
}

\DeclareRobustCommand{\textoverline}[1]{%
\ensuremath{\overline{\mbox{\tolstrut#1}}}%
}

\begin{document}
\textoverline{no} \textoverline{with}
\end{document}


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

-