1

Let's say I have endnotes running with alpha structure: a, b, c, d, e, ...

Normally, I can run endnotes at every chapter, and reset the counter...

\documentclass{report}
\usepackage{endnotes}
\renewcommand*{\theendnote}{\alph{endnote}}
\begin{document}

\chapter{First}
Testing.\endnote{First test.}
\theendnotes

\setcounter{endnote}{0}

\chapter{Next}
Again.\endnote{Second test.}
\theendnotes

\end{document}

How would I run 1+ chapters within a part and then have \theendnotes print the endnotes, by chapter?

Would this require a more sophisticated counter ... an array counter \newcounter{endnotecounter}[chapter] ???

Maybe something like this?

\documentclass{report}
\usepackage{endnotes}
\renewcommand*{\theendnote}{\alph{endnote}}
\begin{document}
\part{Part I}

\chapter{First}
Testing.\endnote{First test.}


\setcounter{endnote}{0} % this needs to be cached so next chapter isn't purged

\chapter{Next}
Again.\endnote{Second test.}


NOTES for Part I:

\theendnotesbychapterinpart

\end{document}

2 Answers 2

2

This seems a fully functional implementation of your requirements.

\documentclass{book}
\usepackage{endnotes}
\usepackage{alphalph}

\renewcommand{\theendnote}{\alphalph{\value{endnote}}}
\newcommand{\resetendnotes}{%
  \setcounter{endnote}{0}%
  \addtoendnotes{%
    \par\protect\addvspace{\topsep}%
    \noindent\textbf{Chapter \thechapter}\par\nobreak
    \protect\addvspace{\topsep}%
  }%
}
\renewcommand{\notesname}{Notes for part \thepart}

\begin{document}

\part{First part}

\chapter{First chapter}
\resetendnotes

\count255=0
\loop\ifnum\count255<50
\advance\count255 by 1
x\endnote{x}
\repeat

\chapter{First chapter}
\resetendnotes

\count255=0
\loop\ifnum\count255<50
\advance\count255 by 1
y\endnote{y}
\repeat

\clearpage
\theendnotes

\part{Second part}

\chapter{Third chapter}
\resetendnotes

\count255=0
\loop\ifnum\count255<50
\advance\count255 by 1
a\endnote{a}
\repeat

\chapter{Fourth chapter}
\resetendnotes

\count255=0
\loop\ifnum\count255<50
\advance\count255 by 1
b\endnote{b}
\repeat

\clearpage
\theendnotes

\end{document}
0

The end notes only get purged if you use \theendnotes. Note: You can include \thechapter as part of \theendnote, but it looks better without.

\documentclass{report}
\usepackage{endnotes}
\renewcommand*{\theendnote}{\alph{endnote}}
\begin{document}
\part{Part I}

\chapter{First}
\addtoendnotes{\medskip\noindent\textbf{\normalsize\chaptername~\thechapter}\par\medskip}%

Testing.\endnote{First test.}

\setcounter{endnote}{0}%
\chapter{Next}
\addtoendnotes{\medskip\noindent\textbf{\normalsize\chaptername~\thechapter}\par\medskip}%

Again.\endnote{Second test.}

\clearpage
NOTES for Part I:
\theendnotes

\end{document}
6
  • I have a lot of notes. If I use \alph, the 26 notes create an overflow error (any given chapter has less than 26 notes, but overall across chapters, the overflow occurs. ! LaTeX Error: Counter too large. If I switch to \arabic (which is not my goal), it works as expected. If I add "\addtoendnotes", I then get a weird tex memory overflow error. !TeX capacity exceeded, sorry [input stack size=5000].
    – mshaffer
    Jan 6, 2020 at 20:41
  • I got it working without alpha for now ... it seems like the alphaalpha package doesn't directly apply to endnotes, only footnotes ...
    – mshaffer
    Jan 7, 2020 at 1:59
  • When I try to add a \newline or \newpage to the \addtoendnotes it doesn't like it... This would be nice to force a "widow or orphan" chapter heading onto the next "column" or page. I had wrapped it in my own command so I could pass it in, only when necessary {#1}
    – mshaffer
    Jan 7, 2020 at 2:03
  • So in the "last footnote" in the previous chapter, I can add \newpage and it works as expected. Applying to addtoendnotes as you suggested would be more effective. THoughts?
    – mshaffer
    Jan 7, 2020 at 2:24
  • \addtoendnotes uses \immediate\write, so you need to use \string\newpage or \protect\newpage. Actually, you should use \string on every macro you don't want to expand immediately.(unlike \thechapter, which needs to be expanded immediately). Jan 7, 2020 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .