Many books have running headers from which you can conveniently find the endnotes and the pages to which they refer. They may be at the end of each chapter, or at the end of the book. The running headers have the form “Notes to pp. xx–yy” for the endnotes. The endheads package allows running headers of this form for the standard, komascript, and memoir classes. It worked for me some time ago with memoir, but now it is broken and gives error message, Undefined pagestyle. This mwe breaks when the endheads package (and its supporting commands) is activated. Can someone suggest what can be done when using memoir and the endheads package to make it work?
\documentclass[openany,oldfontcommands]{memoir}
\usepackage{endnotes}
\usepackage{ifthen}
\usepackage{endheads} % requires oldfontcommands option for memoir class
\setupendnoteheaders
\titleinnotestrue
\setstyleforchapternotebegin{\begin{flushleft}\begin{bf}\normalsize}
\setstyleforchapternoteend{\end{bf}\end{flushleft}}
\begin{document}
\chapter{One}
\resetendnotes
\setcounter{secnumdepth}{0}
Text for chapter one with an endnote. \endnote{chp 1 fn 1}
\chapter{Two}
\resetendnotes
\setcounter{secnumdepth}{0}
This is a second endnote. It is the first endnote of chp. 2.
\endnote{chp 2 fn 1 or second fn of the book}. Here is a second endnote of chp. 2. \endnote{chp2 fn 2}
\newpage
\addcontentsline{toc}{chapter}{\protect\numberline{} \the\notescontentsname}
\theendnotes
\end{document}