When I try to mark-up text that contains a citation, I have trouble. Here's an attempt at a minimal working example called mwe-pdfcomment.tex
\documentclass[11pt]{article}
\usepackage[square,sort,comma,numbers]{natbib}
%pdfcomment stuff below:
\usepackage[opacity=1.0,version=1]{pdfcomment}
\usepackage{tikz}
\usetikzlibrary{calc}
\pdfcommentsetup{color=yellow,opacity=1.0}
%pdfcomment stuff above
\author{John Doe} \title{Sample Document}
\begin{document}
\maketitle
\section{Introduction}
According to a handbook \pdfmarkupcomment[color=yellow,opacity=1.0,markup=Highlight]{
{\citep{texbook}} %commenting this line out works
Blah
}{Why do you think this citation is important?},
this paragraph---and certainly this
section---should be longer than one sentence.
\bibliographystyle{plain} % (uses file "plain.bst")
\bibliography{mwe} % expects file "mwe.bib"
\end{document}
and the corresponding mwe.bib
@BOOK{texbook,
author = "Donald E. Knuth",
title= "The {{\TeX}book}",
publisher = "Addison-Wesley",
year = 1984
}
Initially, I got the error
! Argument of \@citex has an extra }.
which is why I put an extra set of {}
around the \citep
stuff. However, that leads to the following error:
! Package soul Error: Reconstruction failed.
Does \pdfcomment allow for citations inside the markup? If so, how?
There are related questions Problem when using pdfcomment in figure captions and then referencing and possibly Conflict between amsmath and pdfcomment
Best Answer
The error here is coming from the
soul
package, which is being used bypdfcomment
to do the highlighting. If you read thesoul
docs, you'll find that there are cases where it can't operate successfully. I suspect what you are seeing here is the case of a hyphenation point inside a group. What you do find is that if you keep going past the error, run BibTeX then run LaTeX again twice, on the final run everything is OK. That's presumably because the\citep
now produces text thatsoul
can handle.I'm not sure there is much you can do about this: it's a known limitation of
soul
and you'll just have to put up with it.