[Tex/LaTex] Citations and Hyperref

citinghyperref

If I introduce a citation in a subsection title I get the following warning:

Package hyperref Warning: Token not allowed in a PDF string
(PDFDocEncoding): (hyperref) removing `\@ifnextchar' on
input line 18.

This is my minimal example:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\begin{filecontents}{jobname.bib}
    @article{myref,
        author = {author},
        title = {Title},
        journal = {Journal},
        year = {9999},
        volume = {1},
        number = {1},
        pages = {10--20}
    }
\end{filecontents}

\begin{document}
    \subsection{Subsection Title \cite{myref} }

  \bibliographystyle{apalike}
  \bibliography{jobname}

\end{document}

Best Answer

\cite is not expandable and will therefore not work, when the subsection title is expanded to a bookmark string. \texorpdfstring can be used to provide an alternative or omit it:

\subsection{Subsection Title\texorpdfstring{ \cite{myref}}{}}

Or use the optional argument to remove the citation in the table of contents, too.

\subsection[Subsection Title]{Subsection Title \cite{myref}}
Related Question