0

My document is divided into preface section and numbered sections (labelled as '# [Name of Chapter]' and so on). In all of these sections there are notes, which are placed at the end of the document (section 'NOTES'). I need to divide the 'NOTES' section into subsections each of them having list of notes from the respective section. I search this site for tips and found one solution that I put into the preamble of my latex file:

\documentclass{article}

\usepackage{graphicx}
\usepackage{setspace}\doublespacing
\usepackage{endnotes} \usepackage{natbib} \bibliographystyle{apalike} \usepackage{lipsum}

%--- Endnotes rules \counterwithin{endnote}{section} % Reset endnote numbering every new part \makeatletter \renewcommand\enoteheading{% \setcounter{secnumdepth}{-2} \section{\notesname} \addtocontents{toc}{\protect\addvspace{10pt}} % adjust to suit \addcontentsline{toc}{section}{\notesname} \mbox{}\par\vskip-\baselineskip \let@afterindentfalse@afterindenttrue } \makeatother \usepackage{xparse} \let\latexsection\section \RenewDocumentCommand{\section}{som}{% \IfBooleanTF{#1} {\latexsection*{#3}} {\IfNoValueTF{#2} {\latexsection{#3}} {\latexsection[#2]{#3}}% \addtoendnotes{\unexpanded{\subsection{#3}}} } } %--- ...end of the Endnotes rules

\begin{document}

\let\footnote=\endnote \pagenumbering{roman} {\let\bfseries\mdseries \tableofcontents} \newpage

\section*{Preface} \addcontentsline{toc}{section}{\uppercase{Preface}} \lipsum[1-3]\footnote{foo bar baz in Preface} \newpage

\pagenumbering{arabic} \section{Intro & Plan} \lipsum[1-2]\footnote{foo bar baz in Ch1} \newpage

\section{Literature Review} \lipsum[1-2]\footnote{foo bar baz in Ch2} \newpage

\theendnotes \addcontentsline{toc}{section}{\uppercase{Notes}}

\end{document}

The output pdf file produces this look of the 'Notes' section (see image below), which misses the title of 'PREFACE' section. In addition to that I need the titles of the numbered sections to contain 'CHAPTER # [Name of Chapter]'. Lastly, Table of Contents of the document must suppress the subsection ToC lines just after the ToC line of 'NOTES'.

enter image description here

Alex
  • 67
  • postnotes is able to handle the splitting of unnumbered sections with little fuss. If you could edit your question to include a MWE, I could take a look. Also, you'd need to be clearer on what the intended notes headings are. As the question is currently written, there's a lot of guess work to do. – gusbrs Oct 28 '23 at 11:01
  • @gusbrs -- thanks for recommendation. Now, it's edited. Please, take a look above. – Alex Oct 29 '23 at 10:58
  • Alex, Mhm, postnotes currently is not able to retrieve the section name/title for use in the notes section. I guess I'll add this eventually, but it will take some time. But I'll add an endnotes answer to have you covered. – gusbrs Oct 29 '23 at 13:20

1 Answers1

1

It seems you are trying to adapt one of @egreg's answers about this for the article class (https://tex.stackexchange.com/a/109566/105447 appears to be the closest to your use case). In the future, please report the sources of the code you are using, not only because credit is due, but also because it is much easier for anyone trying to help you if they know what the working version is supposed to be.

Anyway, here is a version of it for article:

\documentclass{article}

\usepackage{setspace} \doublespacing \usepackage{endnotes} \usepackage{lipsum}

%--- Endnotes % Adapted from https://tex.stackexchange.com/a/109566/105447

% Reset endnote numbering every section \counterwithin*{endnote}{section}

\makeatletter \NewCommandCopy\latexsection\section \renewcommand\enoteheading{% \setcounter{secnumdepth}{-2} \latexsection*{\notesname} \addtocontents{toc}{\protect\addvspace{10pt}} % adjust to suit \addcontentsline{toc}{section}{\MakeUppercase{\notesname}} % I don't think this is needed in this case, and you get excessive space % with it imho. % \mbox{}\par\vskip-\baselineskip \let@afterindentfalse@afterindenttrue } \makeatother

% It's no longer need to load xparse for \RenewDocumentCommand % \usepackage{xparse} \RenewDocumentCommand{\section}{som}{% \IfBooleanTF{#1} {\latexsection{#3}% \setcounter{endnote}{0}% \addtoendnotes{% \noexpand\enotedivision{\noexpand\subsubsection} {\unexpanded{#3}}}% } {\IfNoValueTF{#2} {\latexsection{#3}} {\latexsection[#2]{#3}}% \addtoendnotes{% \noexpand\enotedivision{\noexpand\subsubsection*} {\thesection. \unexpanded{#3}}}% }% } \makeatletter \def\enotedivision#1#2{@ifnextchar\enotedivision{}{#1{#2}}} \makeatletter %--- ...end of Endnotes

\let\footnote=\endnote

\begin{document}

\pagenumbering{roman}

% That's not a very LaTeX-y way to format your ToC, but you can have it your % way... {\let\bfseries\mdseries \tableofcontents} \newpage

\section*{Preface} \addcontentsline{toc}{section}{\MakeUppercase{Preface}} \lipsum[1-3]\footnote{foo bar baz in Preface} \newpage

\pagenumbering{arabic} \section{Intro & Plan} \lipsum[1-2]\footnote{foo bar baz in Ch1} \newpage

\section{Literature Review} \lipsum[1-2]\footnote{foo bar baz in Ch2}

\addtoendnotes{\unexpanded{\enotedivision{}{}}}

\newpage

\theendnotes

\end{document}

enter image description here

gusbrs
  • 13,740
  • This code of yours works fine with my original code (not MWE), if only the line \printacronyms is muted. Why is that? – Alex Oct 29 '23 at 14:28
  • @Alex Sorry, but there's no \printacronyms in your question. I don't see how they could interact. But, if you are finding a different problem, you can a new follow-up question (linking it to this one). Don't forget to add a MWE showing the new problem you are facing. – gusbrs Oct 29 '23 at 14:38
  • it's something wrong with my original code, I am trying to figure it out. It turned out that adding the acro package into your MWE code with printacronyms line works just fine! – Alex Oct 29 '23 at 15:07
  • could you, please, review my follow-up question? Your suggestions are very much appreciated. Link: https://tex.stackexchange.com/questions/699850/endnotes-section-divided-into-subsections-follow-up – Alex Oct 29 '23 at 16:48
  • @Alex I took a look, but I'm not really well acquainted with titlesec. There are plenty of experts around, let's hope some else can provide an answer. – gusbrs Oct 29 '23 at 17:58
  • Thanks very much indeed! – Alex Oct 29 '23 at 18:10
  • 1
    @Alex I don't have time to play with it right now, but I think I understand what is going on, and it is simple. The thing is (very probably) titlesec redefines \section and, thus, overrides what you did above. So, simply move your endnotes stuff to after the sectioning stuff (including that redefinition of \notesname). It should work. If it does, please add a self answer with that in the follow-up question. – gusbrs Oct 29 '23 at 18:14