# Reledmac: Add chapter into endnotes

I have a book containing letters. After all the letters i want to print the endnotes containing commentary. So the endnotes should look like this:

Letter 1

p. 4) Word: This is a comment

Letter 2

p. 6) Another word: Another comment

(If it's easier to achieve, it could also be that the separators have page references)

A problem is, that the chapter-title is not in the numbered area. There is a function in reledmac where you can achieve this with \doendnotesbysection but this would be tedious, as i have more than 500 letters to attend to.

Is there a simple way to just change the \chapter-command to immediately write it's name into the endnotes file?

This is what I got so far:

 \documentclass{scrbook}
\usepackage{reledmac}

\begin{document}
\chapter{Letter 1}

\beginnumbering
\pstart This is the first letter, containing a critical \edtext{note}{\Aendnote{This is what it's all about}}.
\pend
\endnumbering

\chapter{Letter 2}

\beginnumbering
\pstart This is the second letter, containing another critical \edtext{comment}{\Aendnote{This should be separated from the note above with a line containing "Letter 2"}}.
\pend
\endnumbering

\newpage
\doendnotes{A}

\end{document}

• sorry, I have read two time you question and I don't understand well. What do you mean to "Is there a simple way to just change the \chapter-command to immediately write it's name into the endnotes file?" ? – Maïeul Jan 12 '16 at 8:37
• Sorry for not being able to make myself clear. I imagine something like: \newcommand{\chapterendnotes}[1]{\chapter{#1}\addtoendnotes{A}{#1}} would do. But i'm not able to get this to work. – Martin Mueller Jan 12 '16 at 8:39
• ok, but what do you want to add? what is the problem exactly? – Maïeul Jan 12 '16 at 8:43
• Say I would want to edit this page in print with notes: law2.umkc.edu/faculty/projects/ftrials/wilde/… first i would write \chapter{Letter 1} then in the numbered text: Your \edtext{sonnet}{\Aendnote{A type of poetry}} ... and then the next: \chapter{Letter 2} where in \beginnumbering would start again and the text would be: \pstart March 1893, \edtext{Savoy Hotel}{\Aendnote{A hotel in ..}} and so on. The Endnotes would now contain the Letter 1 and Letter 2 so that i can easily now to which letter the comment of Savoy Hotel belongs. – Martin Mueller Jan 12 '16 at 8:56
• oh, I saw. not actually possible but open an issue on github. I could look on it. – Maïeul Jan 12 '16 at 9:00

The version 2.12.0 of reledmac, just uploaded on CTAN, add a toendnotes command which allow you to insert any arbitrary code inside the endnote auxiliary file, arbitrary code which will executed when typesetting the endnotes.

For example, you can do

\documentclass{scrbook}
\usepackage{reledmac}

\begin{document}
\chapter{Letter 1}

\beginnumbering \toendnotes{\chapter{Letter 1}}
\pstart This is the first letter, containing a critical \edtext{note}{\Aendnote{This is what it's all about}}.
\pend
\endnumbering

\chapter{Letter 2}

\beginnumbering \toendnotes{\chapter{Letter 2}}
\pstart This is the second letter, containing another critical \edtext{comment}{\Aendnote{This should be separated from the note above with a line containing "Letter 2"}}.
\pend
\endnumbering

\newpage
\doendnotes{A}

\end{document}


However, in your case, as you use a \beginnumbering for each chapter, you can just use the already existing command \doendnotesbysection.

\documentclass{scrbook}
\usepackage{reledmac}

\begin{document}
\chapter{Letter 1}

\beginnumbering
\pstart This is the first letter, containing a critical \edtext{note}{\Aendnote{This is what it's all about}}.
\pend
\endnumbering

\chapter{Letter 2}

\beginnumbering
\pstart This is the second letter, containing another critical \edtext{comment}{\Aendnote{This should be separated from the note above with a line containing "Letter 2"}}.
\pend
\endnumbering

\newpage
\chapter{Letter 1}
\doendnotesbysection{A}
\chapter{Letter 2}
\doendnotesbysection{A}

\end{document}