# memoir endnote: remove Notes chapters, reset endnote numbering for each chapter

Like many of you I've used memoir's endnote features to generate notes at the end of a document without using the endnote package directly (i.e., without loading the endnote package). But now I'm having problems trying to generate notes at the end of each chapter, without generating a new page and a separate Notes chapter.

I want endnotes at the end of each chapter, but the Notes section should start just after the final text of a chapter. Any following chapter should also have its Notes section follow the final text, with its reset notes.

The MWE demonstrates the problem I'm having. The endnotes are generated after the final text in the chapter, there is no break to another page, and there is a Notes section -- all good. But the endnote numbers are not reset! Can anyone help? I think I need to access the pagenote counter, trigger it when the chapter changes, and thus avoid starting a new Notes chapter''.

\documentclass[openany]{memoir}
\makepagenote
%\notepageref % issues label that refers back to page on which note occurs. nice
\renewcommand*{\notenumintext}[1]{\,[#1]} % thinspace[num] -- bracket instead of superscript
\renewcommand\notesname{Notes} % change Notes to References, etc.
%\renewcommand*{\notedivision}{\chapter{\notesname}} % newpage, notesname, resets endnote nums
\renewcommand*{\notedivision}{\section*{\notesname}} % notesname, cont. nums
\renewcommand*{\pagenotesubhead}[3]{} % #1-chapname, #2-chapnum, #3-chaptitle removed

\begin{document}
\tableofcontents*
\chapter{Numbered chapter}
Test note for a numbered chapter.\pagenote{numbered test.}
Second test note for a numbered chapter.\pagenote{numbered test two.}. Notice there are no superscripts.
\printpagenotes*

\chapter*{Starred chapter}
Another test note, but from a starred chapter.\pagenote{starred test}
\printpagenotes*

\chapter{Numbered chapter without note}
No notes for a numbered chapter.
\end{document}


This is what I get. But the endnote number should restart at (1) in the starred and succeeding chapters that have endnotes.

The problem is that the pagenote counter is bonded to changes in the chapter counter, and \chapter* does not touch the chapter counter.

Either use

\newcommand\resetPagenotes{
\setcounter{pagenote}{0}
}


and

\chapter*{...}
\resetPagenotes


or somehow hook into starred chapters to add it automatically.

• daleif@ much simpler solution than I was pursuing, since I thought "every" chapter had to be addressed, rather than just starred chapters (\chapter*). Not automatic, but it works!
– zun
Apr 16 '15 at 9:47