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.

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.

share|improve this question
    
I've never had a problem using showkeys with hyperref, although the hyperref documentation claims that they aren't completely compatible, and the hyperref author is not willing to fix that. I load showkeys before hyperref, which may be relevant. I think you need to give us a minimal test case. –  Lev Bishop Aug 11 '10 at 14:22
    
The thing about the minimal example is that it is not easy to construct but I will see if I can come up with something. –  Leo Liu Aug 11 '10 at 15:59
    
you can use the lipsum package to get some dummy text to construct your minimal example. (Or simply accept Charles' answer below.) –  Bruno Le Floch Feb 25 '11 at 19:35
    
@LevBishop This is strange; from the way showkeys works I'd have guessed the other way round (modifications to \label by showkeys must come after hyperref). –  Stephan Lehmke Nov 20 '12 at 5:12
    
For reference, the correct solution is given by tex.stackexchange.com/a/65224/3406 (I think). The problem disappeared for me once I updated hyperref as described in that answer. The corresponding question also has a MWE. –  Faheem Mitha Jan 4 at 19:07

3 Answers 3

Without an MWE, it's hard to say something that we can be sure will fix the problem. I haven't, for the obvious reason, tested any of what follows.

If the problem arises when:

  1. showkeys is used near the end of the document, then you can force a page eject if the command is used near the end of the document. E.g.: \let\urshowkeys=\showkeys \def\showkeys{\needspace{5ex}\urshowkeys} (requires needspace package).
  2. Likewise if it occurs when a hyperref is used near the end of the document.
  3. If it occurs because the link is split between the main body and the margin text, then the best thing might be to write your own wrappers that puts the label in the body text, so that the problem doesn't arise. This should be easy, and I'm guessing this is an acceptable workaround given that the text is a draft.
share|improve this answer
3  
This entry was very helpful but failed to let me know how to find the problematic citation when using multiple files (pdflatex wouldn't point to the right line). Although trivial, this might save some time to some users out there. Use the general option [debug] in the hyperref package and go through the pdflatex log to find the exact citation that is causing the problem. Cheers! –  user22326 Nov 20 '12 at 3:36
1  
For this wondering about it, MWE = minimal working example. –  Rabarberski Nov 29 '13 at 9:20
    
@user2236: the [debug] approach seemed promising, but I couldn't find any clues in the log. I've inserted an answer using the [draft] option instead. –  Rabarberski Jan 15 at 10:16

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.)

share|improve this answer
    
This definitely worked for me, and seems to be the best way to proceed with this issue that I encountered many times. –  jibe Aug 12 at 7:55

I have just resolved a similar error by putting the offending citation inside an \mbox. You just have to figure out where is the offending citation, for example, by successively commenting and uncommenting your LaTeX file. It worked for me, so I hope this works for anyone else, as unfortunately, the error message is not helpful (as usual in LaTeX).

share|improve this answer

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.