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.

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 }.
share|improve this question
    
No problem here (under TeX Live 2011 on ShareLaTeX). Perhaps related to packages versions? –  Werner Apr 29 '13 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 '13 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). –  Kurt Apr 29 '13 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 '13 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 '13 at 21:44
show 1 more comment

1 Answer

up vote 2 down vote accepted

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}.
    
share|improve this answer
    
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 '13 at 17:20
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.