Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've got a section in my document in which every \subsection{} is about some paper and should be headed by a (textual) reference to that paper in the bibliography.

However, with hyperref included, \subsection{\citeauthor{some-bib-ref}} leads

  1. to a "Token not allowed" warning. This is because the output of \citeauthor{} is not just textual, but a PDF link.
  2. to a toc entry named some-bib-ref; I would much prefer the author's name.

If I had just \subsection{\cite{some-bib-ref}}, I gather, I could just use the starred-version of \cite{}. However, for \citeauthor, the starred version just produces different (linked) output.

Does anyone know how to get the author's name as plain text?

share|improve this question
4  
Welcome to TeX.sx! This can be fixed using the answers to the similar question Equations in section heading/title. Use either the optional argument of the sectioning macro or the \texorpdfstring{<..>}{<..>} macro to use a different version for the PDF bookmark entry. –  Martin Scharrer Jul 21 '11 at 14:21
    
@Martin: Please turn your comment into an answer. –  lockstep Jul 22 '11 at 20:54
    
@lockstep: It's just a partial answer (and that is a duplicate). The main issue here is how to get the author's name as plain text, isn't it? –  Martin Scharrer Jul 22 '11 at 21:03
    
@MartinScharrer @Johannes, what package provides \citeauthor? A minimal example would be welcome. –  Bruno Le Floch Jul 28 '11 at 9:10
    
@Bruno: I don't know myself. –  Martin Scharrer Jul 28 '11 at 9:12
add comment

1 Answer

If \citeauthor (or any other command) is defined with \newcommand or \DeclareRobustCommand and has an optional argument it can't be expanded when PDF strings (PDF bookmarks etc.) are generated. The same is true if \citeauthor is defined as a \protected command (e.g. via \newrobustcmd of the etoolbox package). In all these cases, the hyperref package outputs a warning message similar to:

Token not allowed in a PDF string (Unicode):
removing `\citeauthor' on input line 378.

You can add an expandable substitution for \citeauthor to the hook \pdfstringdefDisableCommands which is only evaluated in the context of PDF-string generation, e.g.:

\pdfstringdefDisableCommands{\def\citeauthor#1{#1}}

\begin{document}
...

As a result, the warning message disappears and you get the bare citation key in PDF bookmarks. Obviously, this is not an optimal solution, but better than nothing.

Whether it is possible to really get the author name in PDF bookmarks depends on the implementation of \citeauthor. Clearly, if \citeauthor is a complex command it is difficult or even infeasible to add a usable substitution to \pdfstringdefDisableCommands that is simple enough for PDF-string generation. In particular, the latter might be the case for \citeauthor as defined by the biblatex package.

Finally note that the xparse package (part of the l3packages collection) provides the command \DeclareExpandableDocumentCommand which can be very useful for adding command substitutions to \pdfstringdefDisableCommands.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.