I'm referring to chapters and sections in a description list. I want the link to include the chapter or section part as well.
I found two options to achieve this: use \protect
or use \texorpdfstring
. Both appear to work and do the same thing.
Are there differences between these two, and should I prefer one over the other?
MWE:
\documentclass{report}
\usepackage{hyperref}
\begin{document}
Both options work:
\begin{description}
\item [Section~\ref{sec:label}] foo 1
% This fails, need braces for protected contents:
%\item [\protect\hyperref[sec:label]{Section~\ref*{sec:label}}{}] foo 2
\item [\protect{\hyperref[sec:label]{Section~\ref*{sec:label}}{}}] foo 2
\item [\texorpdfstring{\hyperref[sec:label]{Section~\ref*{sec:label}}{}}{}] foo 3
\end{description}
\section{First Section is Here}
\label{sec:label}
\end{document}