2

The ulem package provides several commands for underlining text. I tried all of these commands to style the label in my enumerate environment. Some of the commands work, some of them do not. I'm afraid these ones I want to use for my document doesn't work.

  • what works: \uline{}, \uuline{}, \uwave{}, \sout{}, \xout{}
  • what doesn't work: \dashuline{}, \dotuline{}

The following code works

\documentclass[12pt, a4paper]{article}
\usepackage{enumitem}
\usepackage{ulem} 

\begin{document}

\begin{enumerate}[label = \uline{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}

\end{document}

The following code doesn't work

\documentclass[12pt, a4paper]{article}
\usepackage{enumitem}
\usepackage{ulem} 

\begin{document}

\begin{enumerate}[label = \dashuline{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}

\end{document}

Additional information
Thanks to Christan's answer even underlining with TikZ is no problem anymore. In my case I'll use TikZ (instead of the ulem package) which allows to easily modify the style of underlining (like mentioned in this post: https://tex.stackexchange.com/a/27260/101831).

\documentclass[12pt, a4paper]{article}
\usepackage{enumitem}
\usepackage{ulem}

\usepackage{tikz}

\newcommand{\udot}[1]{
    \tikz[baseline=(todotted.base)]{
        \node[inner sep=1pt,outer sep=0pt] (todotted) {#1};
        \draw[dotted] (todotted.south west) -- (todotted.south east);
    }
}

\begin{document}

\begin{enumerate}[label =\protect\udot{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}

\end{document}
  • Please have a look at http://tex.stackexchange.com/questions/4736/what-is-the-difference-between-fragile-and-robust-commands – percusse Apr 11 '16 at 13:26

1 Answers1

4

You need to to \protect \dashuline,that's all. However, I doubt this style of typography ;-) (The some is true for \dotuline).

Contrary to \uline etc. \dashuline is no robust command, i.e. it's fragile.

Other way: Use \robustify{\dashuline} (needs etoolbox package), \protect is not needed then.

\documentclass[12pt, a4paper]{article}

\usepackage{enumitem}
\usepackage{ulem} 

\begin{document}

\begin{enumerate}[label = \uline{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}

\begin{enumerate}[label = \protect\dashuline{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}
\begin{enumerate}[label=\protect\dotuline{\textit{Step \arabic*:}}]
\item First item.
\item Second item
\item A third item
\end{enumerate}


\end{document}

enter image description here

  • Is there a reason why \dashuline needs \protect and \uline{} not? – Andreas Schneider Apr 11 '16 at 11:00
  • @Sr.Schneider: I've edited some seconds ago ;-) –  Apr 11 '16 at 11:00
  • You could clarify (or even add an small example) that \robustify is intended to the preamble, so you don't have to alter the code of the document. – Manuel Apr 11 '16 at 11:10
  • 1
    @Manuel: I could, but if compare some other solutions here on this platforms I have the impression that I provide sometimes too much and one-line-solutions by others gets the tick/upvotes ;-) and a lot of complains about do this or do that with mine –  Apr 11 '16 at 11:13
  • Mmm... I don't follow. I'm just suggesting that you add a little bit of explanation, i.e., to expand one of your lines. – Manuel Apr 11 '16 at 11:20
  • @Manuel: I hinted that I a provide a lot of explanations, detailed examples in my answers and others provide a single line of code (to the same question), get a bunch of votes and my answer is basically disregarded) –  Apr 11 '16 at 11:22
  • Mmm... still don't see the relation. In fact I do agree with what you are saying, yes, it's true that single lines get a bunch of votes and long detailed answers are basically disregarded. You can add a few explanation or don't add it, but I don't see what are you trying to say – Manuel Apr 11 '16 at 11:26
  • @Manuel: It's about the effort and the resulting appreciation –  Apr 11 '16 at 11:38