2

The following code has been modified from an answer posted by egreg in https://tex.stackexchange.com/questions/ask:

\documentclass[12pt,openany]{book}

\usepackage{endnotes,chngcntr}
\counterwithin*{endnote}{chapter}  % Reset endnote numbering every new chapter


\let\latexchapter\chapter
\makeatletter
\renewcommand\enoteheading{%
  \setcounter{secnumdepth}{-2}
  \latexchapter*{\notesname\markboth{NOTES}{}}
  \mbox{}\par\vskip-\baselineskip
  \let\@afterindentfalse\@afterindenttrue
}
\makeatother

\usepackage{xparse}


\RenewDocumentCommand{\chapter}{som}{%
\IfBooleanTF{#1}
  {\latexchapter*{#3}%
   \setcounter{endnote}{0}%
   \addtoendnotes{%
     \noexpand\enotedivision{\noexpand\subsection}
       {\unexpanded{#3}}}%
  }
  {\IfNoValueTF{#2}
     {\latexchapter{#3}}
     {\latexchapter[#2]{#3}}%
   \addtoendnotes{%
     \noexpand\enotedivision{\noexpand\subsection}
       {\chaptername\ \thechapter. \unexpanded{#3}}}%
  }%
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter


\begin{document}
\chapter*{Chapter I}
This is Chapter I.\endnote{First endnote.} This is a sentence in Chapter I.\endnote{Second note.}

\chapter*{Chapter II}
In this Chapter II.\endnote{The only endnote in Chapter II.}

\chapter*{Chapter III}
This is Chapter III.\endnote{This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote.} This is a sentence in Chapter III.\endnote{This is part of another long endnote. This is part of another long endnote. This is part of another long endnote. This is part of another long endnote. This is part of another long endnote.}

%\cleardoublepage
\theendnotes
\end{document}

And gives the Endnotes list:

enter image description here

If I wanted to adjust the spacing between the actual endnotes within each chapter (which in this case appears to be none), how could I specify such a vertical spacing?

Also, as an aside, the command \cleardoublepage is commented out in the code. If I include it, for some strange reason to me, I get an extra page inserted before the Endnotes list. Why might this be?

1 Answer 1

3

Set \setlength{\skipnote}{<length>} to add more space between notes.

a

\documentclass[12pt,openany]{book}

\usepackage{endnotes,chngcntr}
\counterwithin*{endnote}{chapter}  % Reset endnote numbering every new chapter


\newlength{\skipnote}
\setlength{\skipnote}{2ex} % set inter notes vertical space <<<<<<<<<<<

\let\latexchapter\chapter
\makeatletter
\renewcommand\enoteheading{%
    \setcounter{secnumdepth}{-2}
    \latexchapter*{\notesname\markboth{NOTES}{}}
    \mbox{}\par\vskip-\baselineskip
    \let\@afterindentfalse\@afterindenttrue
}
% **************** added <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
\def\@endanenote{\par\vskip\skipnote\endgroup}%
% ****************  

\makeatother

\usepackage{xparse}

\RenewDocumentCommand{\chapter}{som}{%
    \IfBooleanTF{#1}
    {\latexchapter*{#3}%
        \setcounter{endnote}{0}%
        \addtoendnotes{%
            \noexpand\enotedivision{\noexpand\subsection}
            {\unexpanded{#3}}}%
    }
    {\IfNoValueTF{#2}
        {\latexchapter{#3}}
        {\latexchapter[#2]{#3}}%
        \addtoendnotes{%
            \noexpand\enotedivision{\noexpand\subsection}
            {\chaptername\ \thechapter. \unexpanded{#3}}}%
    }%
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}\vskip0pt}}
\makeatletter


\begin{document}
    \chapter*{Chapter I}
    This is Chapter I.\endnote{First endnote.} This is a sentence in Chapter I.\endnote{Second note.}
    
    \chapter*{Chapter II}
    In this Chapter II.\endnote{The only endnote in Chapter II.}
    
    \chapter*{Chapter III}
    This is Chapter III.\endnote{This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote. This is part of a long endnote.} This is a sentence in Chapter III.\endnote{This is part of another long endnote. This is part of another long endnote. This is part of another long endnote. This is part of another long endnote. This is part of another long endnote.}
    
    %\cleardoublepage
    \theendnotes
\end{document}

\cleardoublepage or \clearpage are unnecessary.

\theendnote behaves like a chapter and thus starts a new page.

1
  • Thank you. This seems to work quite nicely.
    – DDS
    Commented Feb 4, 2022 at 20:46

You must log in to answer this question.

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