> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/questions-and-answers/83-what-does-pdfendlink-ended-up-in-different-nesting-level-than-pdfstartlink-mean.md).

# What does "\pdfendlink ended up in different nesting level than \pdfstartlink" mean?

## Some background to this error (warning)

As their names suggest, the `\pdfstartlink` and `\pdfendlink` commands are used to create hyperlinks within TeX/LaTeX-generated PDF files—for example, links to different pages within the PDF file or links to websites. These commands are so-called *primitives*: low-level commands built into TeX engines—they are not macros. As a consequence, most users do not encounter them directly but use them indirectly via macros (commands) provided by packages such as `hyperref`.

At the time of writing (December 2022) `\pdfstartlink` and `\pdfendlink` are supported by just two TeX engines: pdfTeX and LuaTeX (and LuaHBTeX). Historically, both pdfTeX and LuaTeX generated an *error* message of the form

```latex
\pdfendlink ended up in different nesting level than \pdfstartlink
```

in response to low-level problems related to the depth of box-nesting. Note that the text of this message originates deep within TeX engine software, it is not produced by any LaTeX package nor, of course, by Overleaf.

Starting with TeX Live 2021, pdfTeX and LuaTeX diverged in their handling of the underlying (box nesting) issue and now exhibit different behaviour:

* pdfTeX now issues that message as a **warning**, it no longer triggers an error and compilation *does not* terminate;
* LuaTeX (LuaHBTeX) continues to treat this issue as a **fatal error**, causing compilation to terminate—the wording of that error message differs slightly from the one given above.

Readers wishing to further explore the underlying cause of this error can:

* open this Overleaf project

  which compiles successfully with pdfLaTeX but triggers the error with LuaLaTeX;
* browse an [in-depth technical discussion on GitHub](https://github.com/latex3/latex2e/issues/94), conducted between leading TeX and LaTeX experts.

## At a practical level, what causes it?

At the user level, this warning (or error) can be triggered when using the `hyperref` package and a hyperlink—such as a citation, URL or cross-reference—breaks across two pages or two columns in a multi-column document; i.e., the link starts near the end of one page (or column) and ends on the next page (or column).

As discussed, pdfTeX (pdfLaTeX) with TeX Live 2021 or later no longer generates an error but, at the time of writing (December 2022), LuaLaTeX continues to do so. If you are using LuaLaTeX, a temporary workaround whilst working on your document is to disable hyperlinks by writing

```latex
\hypersetup{draft}
```

just before your

```latex
\begin{document}
```

Although this prevents hyperlinks from appearing in your document, it avoids the error whilst writing and, when you're ready to compile the final document, you can comment out or delete `\hypersetup{draft}`. If you are unlucky enough to still encounter this problem at the final-compilation stage, re-enable the `draft` and then go through your PDF to find the possible offender (citations, cross-references, floats at top of pages...), so that you can, *hopefully*..., find a way to edit/reword your text to avoid the problem.

## Further information

If you encounter this issue as a fatal error it can require some detective work to track the precise cause. tex.stackexchange has several discussions but note that some of these pages pre-date pdfTeX's downgrading of the error to a warning:

* <https://tex.stackexchange.com/questions/1522/pdfendlink-ended-up-in-different-nesting-level-than-pdfstartlink>
* <https://tex.stackexchange.com/questions/63819/mysterious-error-pdfendlink-ended-up-in-different-nesting-level-than-pdfstart>
* <https://tex.stackexchange.com/questions/249579/pdfendlink-ended-up-in-different-nesting-level-than-pdfstartlink-error-with/>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/questions-and-answers/83-what-does-pdfendlink-ended-up-in-different-nesting-level-than-pdfstartlink-mean.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
