3

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? enter image description here

6

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}%
    \addtolength{\ULdepth}{.4pt}% line width
    \uuline{#1}%
  \endgroup
}
\newcommand*{\testB}[1]{%
  \begingroup
    \settodepth{\ULdepth}{#1}%
    \addtolength{\ULdepth}{.4pt}% line width
    \uuline{#1}%
  \endgroup
}

\testA{0pt} \testA{1.5pt} \testA{1pt} \testA{2pt} \testA{4pt}

\testB{j} \testB{()} \testB{x} \testB{$\int_0^\infty$}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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