[Tex/LaTex] \pdfendlink ended up in different nesting level than \pdfstartlink

cross-referencingdrafterrorshyperref

I started using showkeys in one of my documents and see this error

\pdfendlink ended up in different nesting level than \pdfstartlink

A bit of google suggests that this "happens when hyperref is used under pdftex and a citation splits across a page boundary". (See: http://tug.org/errors.html).

But this package is only useful at drafting stage where the text is changing frequently i.e. the chance of the error is high. Is there a general way to smoothly use showkeys with hyperref? Thanks.

Best Answer

I figured out the location of the link causing the error using the [draft] option in the hyperref package definition, as explained in this 2002 mailing list post by James A. Bednar:

... when this error occurs, write down the page number where pdflatex aborted, then add the "draft" option to hyperref:

\usepackage[draft]{hyperref}

and recompile the document. PDF output will now be generated, the problematic link should be the citation whose latter half begins the page where pdflatex aborted. After slightly rearranging the text to avoid the linebreak, the [draft] option can be removed.

(I tried user22326's useful suggestion to use the [debug] option in the hyperref package definition, however, this didn't help me in finding the location (in the log, or in the latex file) of the link causing the error. Not even after I figured it out using the draft option solution.)

Related Question