1

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}
  • 1
    Off-topic: It is prtetty strange to cite something in a structural title. – Johannes_B Aug 4 '17 at 9:05
  • That was in fact my second question. If I add introduce method name in a title. Should I only add a reference in the content? – Juan Leni Aug 4 '17 at 9:07
  • Yes, I think so. But this is a style question not a TeX question. – Schweinebacke Aug 4 '17 at 9:09
  • I agree. Sorry and thank you for the feedback. By the way, I sometimes have some "style" questions. What would be an appropriate stackexchange group for that? – Juan Leni Aug 4 '17 at 9:10
  • Off-topic: Since you're using the apalike bibliography style, you should use the field name journal, not journaltitle. – Mico Aug 4 '17 at 9:29
3

\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}}
  • Thanks! Is there any way to keep the citation in the title but that it does not appear anywhere else? If I write cite outside the subsection brackets it appears in another line – Juan Leni Aug 4 '17 at 9:06
  • @purpleTentacle Use the optional argument of \subsection and don't use \cite in that optional argument. – Schweinebacke Aug 4 '17 at 9:10

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.