# How to make double overline with less vertical displacement

\overline{\overline{ABC}} produces a double bar over ABC, but it takes up too much vertical space.

How can I make the top bar closer to the bar below it?

You can easily vary the command \doverline defined below by changing the vertical offset (e.g. 0.5ex).

\documentclass{memoir}

\usepackage{amsmath,tikz}
\usetikzlibrary{calc}

\newcommand\doverline[1]{%
\tikz[baseline=(nodeAnchor.base)]{
\node[inner sep=0] (nodeAnchor) {$#1$};
\draw[line width=0.1ex,line cap=round]
($(nodeAnchor.north west)+(0.0em,0.2ex)$)
--
($(nodeAnchor.north east)+(0.0em,0.2ex)$)
($(nodeAnchor.north west)+(0.0em,0.5ex)$)
--
($(nodeAnchor.north east)+(0.0em,0.5ex)$)
;
}}

\begin{document}
\noindent{}Officia quidem est accusamus labore architecto. Ullam hic corporis quod consectetur sequi quod eaque.
Ducimus iste excepturi et cumque ut. Earum animi autem eum tempora.
.$\overline{\overline{1234567890}}$.
Officia quidem est accusamus labore architecto. Ullam hic corporis quod consectetur sequi quod eaque.
Ducimus iste excepturi et cumque ut.
.$\doverline{1234567890}$.
Earum animi autem eum tempora. Officia quidem est accusamus labore architecto. Ullam hic.
\begin{align*}
Z&=1234567890\\
Z&=\overline{\overline{1234567890}}\\
Z&=\doverline{1234567890}\\
Z&={1234567890}
\end{align*}
\end{document}


Ti*k*Z is a mighty tool which allows those quick definitions without digging in to the core of TeX.

EDIT: egreg's solution is more concise when dealing with subscripts and superscripts. My solution could be adopted to this by using LuaTeX's access to \mathstyle but as his solutions already deals with this issue there is not really a need for it.

There is another solution on How to reduce the vertical space between two overlines?.

• I am accepting this solution because it does not affect the document spacing (between lines of text). When I tried @egreg's solution, there were still gaps between lines of text created by the dbloverline. – D.S. Lipham Sep 23 '18 at 15:35
• @CampanIgnis The answer of mine you linked to does not address this. You may have been thinking of this answer? – Circumscribe Sep 23 '18 at 22:41
• @David The issue with document spacing cannot be avoided if you have too high objects in a line; a single overline is already near the limit. I don't think this solution avoids the issue. – egreg Sep 23 '18 at 22:52
• @David Actually, in my test neither solution changes the spacing, at least with CampanIgnis example text. You can try by setting \lineskip=10pt in the preamble. – egreg Sep 23 '18 at 23:04
• @egreg yes, it appears now you are correct that both change the vertical spacing. But in my document this solution causes less vertical skip (I'm not sure what the explanation could be). – D.S. Lipham Sep 23 '18 at 23:35

The \overline operation inserts a kern three times \fontdimen8 of the math extension font (which is also used as the rule thickness).

We can so reduce this kerning by artificially making the inner overlined box less tall by twice the applied kerning.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\dbloverline}[1]{\overline{\dbl@overline{#1}}}
\newcommand{\dbl@overline}[1]{\mathpalette\dbl@@overline{#1}}
\newcommand{\dbl@@overline}[2]{%
\begingroup
\sbox\z@{$\m@th#1\overline{#2}$}%
\box\z@
\ifx#1\scriptstyle\kern-\scriptspace\else
\ifx#1\scriptscriptstyle\kern-\scriptspace\fi\fi
\endgroup
}
\fontdimen8
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 3
}
\makeatother

\begin{document}

$\overline{\overline{ABC}}$
$\dbloverline{ABC}$

$X_{\overline{\overline{ABC}\kern-\scriptspace}}$
$X_{\dbloverline{ABC}}$

\end{document}


I took the occasion for removing the \scriptspace which is added in subscripts/superscripts for the inner overline atom.

Two other solutions: one with the \widebar command, borrowed from mathabx, another based on \overbracket, from mathtools:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\newcommand{\wideBar}[1]{\overbracket[0.3pt][0pt]{\overbracket[0.3pt][0pt]{\mkern-2.8mu #1}}}

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<-6> mathx5 <6-7> mathx6 <7-8> mathx7
<8-9> mathx8 <9-10> mathx9
<10-12> mathx10 <12-> mathx12
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}

\begin{document}

$\widebar{\widebar{X}}\quad\widebar{\widebar{XYZ}}$%

$\wideBar{X}\quad\wideBar{XYZ}$%

\end{document}