2

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}
6
  • 1
    Off-topic: It is prtetty strange to cite something in a structural title.
    – Johannes_B
    Aug 4, 2017 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, 2017 at 9:07
  • Yes, I think so. But this is a style question not a TeX question. Aug 4, 2017 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, 2017 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, 2017 at 9:29

1 Answer 1

5

\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}}
4
  • 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, 2017 at 9:06
  • @purpleTentacle Use the optional argument of \subsection and don't use \cite in that optional argument. Aug 4, 2017 at 9:10
  • Is there any way of getting the equivalent information automatically e.g. from the .bbl Biber generates? I mostly need author and title, possibly year occasionally, but right now I just let the ill-named links go because any manual solution is not really practical. The toc entries are mostly being generated automatically from bibkeys and I can't realistically manage them manually so the bookmarks are a bit of a mess.
    – cfr
    Mar 20, 2022 at 1:53
  • @cfr Ask a separate question and it will get more views and a better chance of getting a useful answer. Mar 20, 2022 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .