I have stumbled over a rare case of the notorious \pdfendlink ended up in different nesting level than \pdfstartlink error on an up to date system (Ubuntu 14.10, hyperref 6.83m). It occurs if all of the conditions below are met:
- double column mode
- when a link spans two pages
- when there is a figure that spans over two columns on the same page as the start of the link.
Note that, for links that don't span a page but two lines, natbib and hyperref for (Author, Year) style produces two links (correctly). The issue occurs only at page boundary. Also, the issue doesn't occur in single column mode (see modified example). The figure also seems to be necessary (see yet another modified example).
What is a good workaround for this issue during development of a document? (I find it useful to have clickable links, and I also prefer sticking to twocolumn mode for now.) Is a fix for hyperref technically possible?
This can be seen as one of those Questions which are bug reports. While I'm aware of this, a workaround still might be of use for the limited time it takes for a fix to propagate to, say, Ubuntu LTS (which might be up to four years, an eternity to some). Thus, it might be useful for documentation purposes; please feel free to close if it's not appropriate.
MWE (also on GitHub)
...minimal to me but unfortunately not small, and uses the btxdoc.bib from natbib.
\documentclass[a5paper,twocolumn]{scrartcl}
\pagestyle{empty}
% Fatal combination
\usepackage{natbib,hyperref}
% For constructing the MWE
\usepackage{mwe,lipsum}
\bibliographystyle{chicago}
\begin{document}
\begin{figure*}[t]
\includegraphics[width=\textwidth]{example-image-golden}
\end{figure*}
\lipsum[1]
\lipsum[1]
\lipsum[2]
Test line break:
\citep{strunk-and-white}
Works for first word.
\citep{strunk-and-white}
And for second.
Conclusion: Line breaks work well.
Now what happens if we force the break at the page boundary?
Let's take a look
We make this just long enough to break the link at page boundary
\citep{strunk-and-white}
\bibliography{btxdoc}
\end{document}
Error message
! pdfTeX error (ext4): \pdfendlink ended up in different nesting level than \pd
fstartlink.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox
\fi \fi
l.33 \end{document}
Output
(page 2) of a slightly modified non-breaking example:
