\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?

up vote 4 down vote accepted

You can easily vary the command \doverline 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}

enter image description here


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?.

  • 1
    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 at 15:35
  • 1
    @CampanIgnis The answer of mine you linked to does not address this. You may have been thinking of this answer? – Circumscribe Sep 23 at 22:41
  • @Circumscribe Yep, many thanks. – CampanIgnis Sep 23 at 22:48
  • @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 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 at 23:04

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}$}%
  \ht\z@=\dimexpr\ht\z@-2\dbl@adjust{#1}\relax
  \box\z@
  \ifx#1\scriptstyle\kern-\scriptspace\else
  \ifx#1\scriptscriptstyle\kern-\scriptspace\fi\fi
  \endgroup
}
\newcommand{\dbl@adjust}[1]{%
  \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.

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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