[Tex/LaTex] cross out the text in the section title

soulstrikeout

It seems that \st{} for crossing out a text (strike through) doesn't work on the section title. For example, this

\documentclass{article}
\usepackage{soul,color}
\begin{document}
\section{\st{Motivation}}\label{sec:theproblem}
In this section, we are going to explain the detail and you will see...
\end{document}

fails while it works fine with the body text

\documentclass{article}
\usepackage{soul,color}
\begin{document}
\section{Motivation}\label{sec:theproblem}
In this section, we are going to \st{explain the detail} and you will see...
\end{document}

BTW, yes the soul package is included 🙂

UPDATE

UPDATE

Using \protect\st works fine but the bug is, if you add \usepackage{hyperref}, you will get this error

! Argument of \let has an extra }.
<inserted text>
                \par
l.5 \section{\protect\st{Motivation}}
                                     \label{sec:theproblem}
?

The problem has been addressed by Christian Hupfer in his answer.

Best Answer

Early version of this solution

The specific behaviour of the sectioning commands require special treatment for the content to be designed as title of chapters etc, in this case for the \st command from the soul package. It must be protected, i.e. preceeded by a \protect.

Edit

I just tested: The \st macro is already robust. \protect is not really needed.

\documentclass{book}
\usepackage{soul}
\begin{document}
\tableofcontents
\chapter{\protect\st{This is crossed-out}}
\end{document}

enter image description here

Edit Number Two

If hyperref is used, this runs into the typical problem with the bookmarks and hyperlinks. Use \texorpdfstring to get around for such a woe ;-)

\documentclass{book}
\usepackage{soul}
\usepackage[bookmarksopen=true]{hyperref}
\begin{document}
\tableofcontents
\chapter{\texorpdfstring{\st{This is crossed-out}}{This is not crossed out}}
\end{document}