# Control ulines for cloze text

@Martin Scharrer suggested me the following amazing solution to make cloze texts: http://tex.stackexchange.com/a/16004/4011

\documentclass{article}
\usepackage[normalem]{ulem}

\makeatletter
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner
\vrule\@width\z@ \LA@penalty\@M
\phantom{\box\UL@box}%
\fi}
\makeatother

\begin{document}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some    text
to complete some  text to complete} some more text.

\end{document}


1. How can I adjust this such that I can choose all the "underline styles" offered by the ulem package \dotuline, \dashuline, \uwave and\uuline?
2. How can I adjust the vertical space between the phantom text and the underline?
3. Is it possible to get a normal working version of \uline at the same time? (Call it for example \Uline, \Uuline etc.).
-

1. Just use them.

2. \setlength{\ULdepth}{...}

3. The following example adds the switch \ifulphantom that can be set to enable or disable the phantom version for the macros of package ulem.

Full example:

\documentclass{article}
\usepackage[normalem]{ulem}

\makeatletter
\@ifdefinable\UL@putbox@original{%
\let\UL@putbox@original\UL@putbox
\def\UL@putbox@phantom{%
\ifx\UL@start\@empty
\else % not inner
\vrule\@width\z@
\LA@penalty\@M
\phantom{\box\UL@box}%
\fi
}%
\newif\ifulphantom
\renewcommand*{\UL@putbox}{%
\ifulphantom
\expandafter\UL@putbox@phantom
\else
\expandafter\UL@putbox@original
\fi
}%
}
\makeatother

\usepackage{parskip}

\begin{document}

\ulphantomtrue

\begingroup
\setlength{\ULdepth}{0pt}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\setlength{\ULdepth}{1ex}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.
\endgroup

Some text \uuline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

Some text \uwave{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\ulphantomfalse

\begingroup
\setlength{\ULdepth}{0pt}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\setlength{\ULdepth}{1ex}

Some text \uline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.
\endgroup

Some text \uuline{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

Some text \uwave{some text to complete some  text to complete
some  text to complete some  text to complete some  text to complete some
text to complete some  text to complete} some more text.

\end{document}


-
@student Switch \ifulphantom added that enables/disables the phantom versions of the macros from package ulem. –  Heiko Oberdiek Oct 30 '12 at 15:27
Thanks, works great! –  student Oct 30 '12 at 16:06