# Dashed underline in caption using ulem

I'm trying to dashed underline a word in a caption using the ulem package. While the \dashuline{} command works fine everywhere else, I get "Undefined control sequence" as error message in caption.

\begin{figure}
While it does work \dashuline{here}
\caption{It does not work \dashuline{here}}
\end{figure}


Has anyone an idea why it doesn't work and how to get it working?

• This does work correctly with ulem (and it should have been the case already back then given the last update of the package), ie \dashuline is already robust! – Frank Mittelbach Jun 20 '18 at 20:42

Protecting the command should solve the problem:

\documentclass{article}

\usepackage{ulem}

\begin{document}

\begin{figure}
While it does work \dashuline{here}
\caption{It does not work \protect\dashuline{here}}
\end{figure}

\end{document}