2

Is there a simple workaround for using citations inside a pdfcomment? Here it is a MWE:

\documentclass{article}
\usepackage{pdfcomment}

\begin{document}

Works \cite{Smith1959}.

Works \pdfmarkupcomment{here}{comment1}

Doesn't work \pdfmarkupcomment{here \cite{Smith1959}}{comment2}.

\begin{thebibliography}{100}
\bibitem{Smith1959}J. Smith, J. Chem. Phys. {\bf 3}, 764 (1935).
\end{thebibliography}
\end{document}

The error message is:

! Argument of \@citex has an extra }.
6
  • No problem here (under TeX Live 2011 on ShareLaTeX). Perhaps related to packages versions?
    – Werner
    Apr 29, 2013 at 19:59
  • @Werner, my versions are: This is pdfTeX, Version 3.1415926-2.5-1.40.13 (TeX Live 2013/dev) and \ProvidesPackage{pdfcomment}[2012/09/28 pdfcomment.sty v2.3a - Josef Kleber (C) 2008-2012]
    – alfC
    Apr 29, 2013 at 20:09
  • 1
    Same error (and 19 more) with MiKTeX 2.9 and unchanged given MWE (exact: This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9) (preloaded format=pdflatex 2013.4.5, pdfcomment 2012/09/28 pdfcomment.sty v2.3a).
    – Mensch
    Apr 29, 2013 at 20:12
  • For reference, ShareLaTeX reports This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011) (format=pdflatex 2012.2.4) and pdfcomment.sty 2012/01/25 pdfcomment.sty v2.2a - Josef Kleber (C) 2008-2012 and compiles without problem.
    – Werner
    Apr 29, 2013 at 20:15
  • @Werner, yes, it is a big mistery. ShareLaTeX works but not my versions, and they are not that different.
    – alfC
    Apr 30, 2013 at 21:44

1 Answer 1

7

It seems that cite is fragile. However you can do two things:

  1. Put \protect before \cite

    \pdfmarkupcomment{here \protect\cite{Smith1959}}{comment2}.
    
  2. Put extra curly braces around cite

    \pdfmarkupcomment{here {\cite{Smith1959}}}{comment2}.
    
1
  • thanks, both worked and give the expected output. It is still a mystery that ShareLaTeX (or some version of TeXLive accepts the original code). Perhaps ShareTeX does some modification of the code behind scenes.
    – alfC
    Jun 3, 2013 at 17:20

You must log in to answer this question.

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