Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
I placed an "old" (2009) copy of memoir.cls into the job folder, and this worked! It's not apparent to me what the conflict is between current versions of endheads and memoir. –  zun Sep 1 '12 at 17:38
    
In this case it seems a good measure to make a bug report to the maintainer of memoir. –  Keks Dose Sep 2 '12 at 20:07
    
@keks I made a report to the author of endheads, but not yet to the maintainer of memoir. –  zun Sep 3 '12 at 10:36
add comment

2 Answers

up vote 5 down vote accepted

There is a bug in the style file endheads. It contains these lines:

\@ifclassloaded{memoir}{
\makepagestyle{endnotesstyle}
\makeevenhead{endnotesstyle}{{\small\textrm{\thepage}}}{{\small{\em \the\notesheadername~\mymarks}}}{}
\makeoddhead{endnotesstyle}{}{{\small{\em \the\notesheadername~\mymarks}}}{{\small\textrm{\thepage}}}
\makeevenfoot{}{}{}
\makeoddfoot{}{}{}

This is clearly wrong, as \makeevenfoot and \makeoddfoot take four arguments just like \makeevenhead and \makeoddhead, the first being the name of the pagestyle.

I can't understand why this works with an older version of memoir ;-)

To be honest, I assume the bug was always in endheads but memoir is recently checking whether the pagestyle exists. As emptiness is the default it doesn't do much wrong if the commands are not properly executed.

Anyway, you should report to the maintainer of endheads.

As a quick fix, you can disable the wrong calls to \makeevenfoot and \makeoddfoot before loading endheads and afterwards call the correct ones like this:

\let\origmakeevenfoot\makeevenfoot
\def\makeevenfoot#1#2#3{}
\let\origmakeoddfoot\makeoddfoot
\def\makeoddfoot#1#2#3{}
\usepackage{endheads} % requires oldfontcommands option for memoir class    
\let\makeevenfoot\origmakeevenfoot
\let\makeoddfoot\origmakeoddfoot
\makeevenfoot{endnotesstyle}{}{}{}
\makeoddfoot{endnotesstyle}{}{}{}

Unfortunately there is no cleaner patch as the declarations are directly called in the package, not as part of a command which could be patched.

Be sure to take this quickfix out as soon as a correct version of the package is released.

Alternatively, you can make a local copy of the style file and replace the wrong declarations immediately there. Again, remember to delete the local copy as soon as a fixed version of the style is released.

share|improve this answer
    
@stephan.lehmke excellent sleuthing on your part! Earlier versions of endheads have four arguments when it determines if memoir is used, but still have only three arguments for later lines of makeevenfoot... as you point out. The quickfix works fine. I think I'll patch a local file. Earlier, I alerted the author of endheads of the problem, and will also alert him of your fix. –  zun Sep 3 '12 at 10:52
add comment

I've fixed the bug, and a new version of endheads has been sent to CTAN. It should be up in a day or so. Thanks everybody for your help!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.