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}
3

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? – Sr. Schneider Apr 11 '16 at 11:00
  • @Sr.Schneider: I've edited some seconds ago ;-) – user31729 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 – user31729 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

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.