# Aligning \overline to “italics” font

In math mode, the slanted characters look somewhat disconnected from an \overline: $\overline{P}$ looks odd; of course I would like the bar to be aligned more on the right, at least as much slanted as the top of the letter. How can this be achieved?

-
–  Claudio Fiandrino Jan 23 '13 at 14:50
Some related problems : tex.stackexchange.com/questions/27142/… and tex.stackexchange.com/questions/4192/… for beamer but can give you an insight why this is not so trivial if you don't want to adjust manually. –  percusse Jan 23 '13 at 15:13
@percusse: thanks, manual adjustment shall be enough for now, skew works fine! However I'm working with standard fonts and no beamer, so from my understanding the problem should not arise and accents be skewed automatically, how comes it is not so? I only have amsmath, amssymb and other non-interfering packages... Feel free to make this an answer, btw. –  Quartz Jan 23 '13 at 16:13
add comment

## 2 Answers

The following is taken from a recent discussion in chat.

For most cases, the following definition of a modified \overline, called \myol, works:

\newcommand{\myol}[2][3]{{}\mkern#1mu\overline{\mkern-#1mu#2}}


where the default adjustment to the \overline is 3mu (click the image to enlarge for higher detail):

\documentclass{article}
\newcommand{\myol}[2][3]{{}\mkern#1mu\overline{\mkern-#1mu#2}}
\begin{document}
$\begin{array}{c} \overline{A}\ \overline{B}\ \overline{C}\ \overline{D}\ \overline{E}\ \overline{F}\ \overline{G}\ \overline{H}\ \overline{I}\ \overline{J}\ \overline{K}\ \overline{L}\ \overline{M}\ \overline{N}\ \overline{O}\ \overline{P}\ \overline{Q}\ \overline{R}\ \overline{S}\ \overline{T}\ \overline{U}\ \overline{V}\ \overline{W}\ \overline{X}\ \overline{Y}\ \overline{Z}\\[\jot] \myol{A}\ \myol{B}\ \myol{C}\ \myol{D}\ \myol{E}\ \myol{F}\ \myol{G}\ \myol{H}\ \myol{I}\ \myol{J}\ \myol{K}\ \myol{L}\ \myol{M}\ \myol{N}\ \myol{O}\ \myol{P}\ \myol{Q}\ \myol{R}\ \myol{S}\ \myol[1]{T}\ \myol{U}\ \myol[1]{V}\ \myol[1]{W}\ \myol{X}\ \myol[1]{Y}\ \myol{Z} \end{array}$
\end{document}


Note that \myol requires some adjustment for letters that are top-heavy and bottom-narrow (T, V, W and Y in my example above).

-
add comment

Here is an automated macro. It is inspired from the TeXBook, page 375, and from the \skew defined by the LaTeX2e kernel. I was annoyed at going in and out of math mode, but this way, the macro \skoverline allows some more general material to be intermixed with the letters in its argument.

\documentclass{article}

\newbox\usefulbox

\makeatletter
\def\getslant #1{\strip@pt\fontdimen1 #1}

\def\skoverline #1{\mathchoice
{{\setbox\usefulbox=\hbox{$\m@th\displaystyle #1$}%
\dimen@ \getslant\the\textfont\symletters \ht\usefulbox
\divide\dimen@ \tw@
\kern\dimen@
\overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
{{\setbox\usefulbox=\hbox{$\m@th\textstyle #1$}%
\dimen@ \getslant\the\textfont\symletters \ht\usefulbox
\divide\dimen@ \tw@
\kern\dimen@
\overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
{{\setbox\usefulbox=\hbox{$\m@th\scriptstyle #1$}%
\dimen@ \getslant\the\scriptfont\symletters \ht\usefulbox
\divide\dimen@ \tw@
\kern\dimen@
\overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}
{{\setbox\usefulbox=\hbox{$\m@th\scriptscriptstyle #1$}%
\dimen@ \getslant\the\scriptscriptfont\symletters \ht\usefulbox
\divide\dimen@ \tw@
\kern\dimen@
\overline{\kern-\dimen@ \box\usefulbox\kern\dimen@ }\kern-\dimen@ }}%
{}}
\makeatother

\begin{document}\thispagestyle{empty}

$\overline{P}$

$\skoverline{P}$

$x^{\overline{M}}$

$x^{\skoverline{M}}$

$\overline{SPQR}$

$\skoverline{SPQR}$

\end{document}


Code stolen from Werner's answer:

$\begin{array}{c} \overline{A}\ \overline{B}\ \overline{C}\ \overline{D}\ \overline{E}\ \overline{F}\ \overline{G}\ \overline{H}\ \overline{I}\ \overline{J}\ \overline{K}\ \overline{L}\ \overline{M}\ \overline{N}\ \overline{O}\ \overline{P}\ \overline{Q}\ \overline{R}\ \overline{S}\ \overline{T}\ \overline{U}\ \overline{V}\ \overline{W}\ \overline{X}\ \overline{Y}\ \overline{Z}\\[\jot] \skoverline{A}\ \skoverline{B}\ \skoverline{C}\ \skoverline{D}\ \skoverline{E}\ \skoverline{F}\ \skoverline{G}\ \skoverline{H}\ \skoverline{I}\ \skoverline{J}\ \skoverline{K}\ \skoverline{L}\ \skoverline{M}\ \skoverline{N}\ \skoverline{O}\ \skoverline{P}\ \skoverline{Q}\ \skoverline{R}\ \skoverline{S}\ \skoverline{T}\ \skoverline{U}\ \skoverline{V}\ \skoverline{W}\ \skoverline{X}\ \skoverline{Y}\ \skoverline{Z} \end{array}$


-
add comment