# How to control space length between lines of double-underline?

I use \uuline command from ulem package to make double-underlined text. I would like to know if it is possible to control space length between lines? I drew below what I mean. If not, how to make custom double-underline with space length controlled?

The space between the double lines is hard-coded: 1.2pt, see the definition of \uuline in package ulem.

The following example changes the definition in two ways:

• The hard-coded space is replaced by dimen register \uulinesep.

• Also the top line is aligned, not the bottom line. This avoids that the top line overprints the descenders or even moves above the base line, when \uulinesep is increased too much.

The depth of the whole double line can be changed by setting \ULdepth as shown in the second and third line of the example. The default is \maxdimen. Then package ulem uses the depth of j().

Full example:

\documentclass{article}

\usepackage{ulem}

\newdimen\uulinesep
\setlength{\uulinesep}{1.2pt}

\makeatletter
\renewcommand*{\uuline}{%
\bgroup
\UL@setULdepth
\markoverwith{%
\lower\ULdepth\hbox{%
\kern-.03em%
\vtop{%
\hrule width.2em%
\kern\uulinesep
\hrule
}%
\kern-.03em%
}%
}%
\ULon
}
\makeatother

\begin{document}
\newcommand*{\test}[1]{%
\begingroup
\renewcommand*{\uulinesep}{#1}%
\uuline{#1}%
\endgroup
}
\test{0pt} \test{0.6pt} \uuline{1.2pt}\,\uline{(default)}
\test{2pt} \test{1ex}

\newcommand*{\testA}[1]{%
\begingroup
\setlength{\ULdepth}{#1}%
\uuline{#1}%
\endgroup
}
\newcommand*{\testB}[1]{%
\begingroup
\settodepth{\ULdepth}{#1}%
\testB{j} \testB{()} \testB{x} \testB{$\int_0^\infty$}