[Tex/LaTex] Decrease spacing between double bars

accentsbarmath-modetext-decorationstypography

I'd like double bars over my X, that I can get using these overline symbols

\[\overline{\overline{X}}\]

I also tried the bar symbols, but they're misaligned over the X.

\[\bar{\bar{X}}\]

What I end up with is two bars, but the spacing seems too large between the bars. How do I decrease the spacing with double bars?

enter image description here

Best Answer

A general version that works across math styles.

\documentclass{article}
\usepackage{amsmath,scalerel}
\newcommand\doverline[1]{\ThisStyle{%
  \setbox0=\hbox{$\SavedStyle\overline{#1}$}%
  \ht0=\dimexpr\ht0-.15ex\relax% CHANGE .15 TO AFFECT SPACING
  \overline{\copy0}%
}}

\begin{document}
$\overline{X} + \doverline{X}$

$\scriptstyle\overline{X} + \doverline{X}$

$\scriptscriptstyle\overline{X} + \doverline{X}$
\end{document}

enter image description here

If you only require it in \displaystyle,

\documentclass{article}
\usepackage{amsmath}
\newcommand\doverline[1]{%
  \setbox0=\hbox{$\overline{#1}$}%
  \ht0=\dimexpr\ht0-.15ex\relax% CHANGE .15 TO AFFECT SPACING
  \overline{\copy0}%
}

\begin{document}
$\overline{X} + \doverline{X}$
\end{document}