# Wrong page number in TOC for endnote

When I set the list heading of an endnote part to \chapter in order to have a page break, it occur a bad pagenumber of the endnote part in the TOC.

## MWE

\documentclass{book}
\usepackage{lipsum}
\usepackage{enotez}

\begin{document}

\lipsum[1]

\tableofcontents
\endnote{foo}

\printendnotes

\end{document}


## Rendering

So the Notes page is correctly begin in a new dedicated page as desired:

As you see, it is in this example set in the page 5.

But unfortunatly, the table of content mark it as in page 3:

## Guessess

My guesses it’s because the \\addcontentsline{toc} start immediatly at the \printendnotes call and doesn’t wait the \cleardoublepage takes effect.

So, how to make the Note page number apears at the TOC at his real beginning page?

• You can simply add a \cleardoublepage explicitly, right before \printendnotes. May 24 at 7:49
• Yes @Jinwen it’s the solution. If you write an answer, I can mark it as the solution. May 24 at 8:49
• I believe someone else might be able to come up with a more clever solution (or fix), since this is certainly not the expected behavior for this command. Adding \cleardoublepage is just my lucky guess. May 24 at 8:53

I should put \cleardoublepage before \\addcontentsline{toc} to ensure page number.

Not sure, if this is what you are looking for:

\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{enotez}

\begin{document}
\frontmatter% <<<
\tableofcontents

\mainmatter% <<<
\lipsum[1]

\endnote{foo}

\backmatter% <<<
\printendnotes
\end{document}