The following code produces chapter endnotes at the end the end of each chapter and rename "Notes" as "Chapter I. Endnotes" and "Chapter II Endnotes," respectively:
\documentclass[openany]{book}
\usepackage{endnotes}
\usepackage{chngcntr}
\counterwithin*{endnote}{chapter} % Reset endnote numbering everyv%new chapter
\let\latexchapter\chapter
\makeatletter %changes the catcode of @ to 11
\renewcommand\enoteheading{
\setcounter{secnumdepth}{-2}
\latexchapter*{\notesname\markboth{NOTES}{}}
\mbox{}\par\vskip-\baselineskip
\let@afterindentfalse@afterindenttrue
}
\makeatother %changes the catcode of @ back to 12
\usepackage{xparse}
\RenewDocumentCommand {\chapter}{som}{%
\IfBooleanTF{#1}
{\latexchapter*{#3}%
\setcounter{endnote}{0}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\unexpanded{#3}}}%
}
{\IfNoValueTF{#2}
{\latexchapter{#3}}
{\latexchapter[#2]{#3}}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\chaptername\ \thechapter. \unexpanded{#3}}}%
}%
}
\makeatletter
\def\enotedivision#1#2{@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter
\begin{document}
\LARGE
\renewcommand\contentsname{Table of Contents.}
\tableofcontents
\chapter*{Chapter I}
\addtocontents{toc}{\vskip 4pt}
\addcontentsline{toc}{chapter}{\textbf{Chapter I.}}
Some words.\endnote{an endnote.} Some words.\endnote{an endnote.} Some words.\endnote{an endnote.}
\newpage
\addtocontents{toc}{\vskip 4pt}
\addcontentsline{toc}{chapter}{\textbf{Chapter I. Endnotes.}}
\renewcommand{\notesname}{Chapter I. Endnotes}
\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\theendnotes
\chapter*{Chapter II}
\addtocontents{toc}{\vskip 4pt}
\addcontentsline{toc}{chapter}{\textbf{Chapter II.}}
Some words.\endnote{An endnote.} Some words.\endnote{An endnote.} Some words.\endnote{An endnote.} Some words.\endnote{An endnote.} Some words.\endnote{An endnote.}
\newpage
\addtocontents{toc}{\vskip 4pt}
\addcontentsline{toc}{chapter}{\textbf{Chapter II. Endnotes.}}
\renewcommand{\notesname}{Chapter II. Endnotes}
\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\theendnotes
\end{document}
which produces the TOC:
And the two Endnote pages are:
and
The "Chapter I" and "Chapter II" headings which appear after the Endnotes titles in both the Endnotes sections and in the TOC are redundant and I would like to remove them.
If it matters, I compile the code with lualatex.
QUESTION: How may I remove the unwanted "Chapter I" and "Chapter II" labels in the Endnotes sections, as well as in the TOC, keeping only the two which I have manually inserted into the TOC by the commands \addcontentsline{toc}{chapter}{\textbf{Chapter I. Endnotes.}} and \addcontentsline{toc}{chapter}{\textbf{Chapter I. Endnotes.}}?
Thank you.






\pretocmd{\@makeschapterhead}{\setcounter{endnote}{0}}{}{} % reset counter– Simon Dispa Feb 26 '22 at 20:29