Solving the LaTeX hyperref error: "\pdfendlink ended up in different nesting level than \pdfstartlink"

The following error message is due to a hyperlink breaking across two pages[1].

pdfTeX error (ext4): \pdfendlink ended up in different nesting level than \pdfstartlink.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 

Since pdflatex cannot deal with it, a suggested method is to identify the breaking hyperlink and edit the document to avoid it. In the meantime, to continue working on your document without error messages, you can configure hyperref in the preamble:

\hypersetup{draft}

However this will also disable hyperlinks. The best solution I found[2][3][4] is to add this code in your preamble:

\usepackage{etoolbox}

\makeatletter
\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{%
    \errmessage{\noexpand\@combinedblfloats could not be patched}%
}%
\makeatother

If this still didn’t solve the problem, you can have a look at the references at the bottom of this page.

References


  1. Overleaf: What does “\pdfendlink ended up in different nesting level than \pdfstartlink” mean? ↩︎

  2. Github: top float in two column mode leads to nesting error for links ↩︎

  3. StackExchange: \pdfendlink ended up in different nesting level than \pdfstartlink ↩︎

  4. StackExchange: ‘\pdfendlink ended up in different nesting level than \pdfstartlink’ error with current version of hyperref ↩︎