0

This is a follow up from the question discussed here: Endnotes section divided into subsections

My original code being turned into a MWE as much as possible is (below). My document has an unnumbered 'PREFACE' section and a number of numbered sections (chapters). Each of these sections have footnotes. The latter must be placed at the very end of the document under 'ENDNOTES' title and grouped by respective section titles.

The issue is that my extended MWE code (see pics below) does not produce a desired look (the one that was obtained here). It must be, I suspect, due to my manipulations with sections rules (there is a section, in preamble, for that in my extended MWE code):

\documentclass[11pt]{article}
\usepackage{lipsum}

% Set the page margins as required \usepackage[left=1.25in,right=1in,top=1in,bottom=1in]{geometry} \usepackage{graphicx}
\usepackage{setspace} \doublespacing
\expandafter\def\expandafter\quote
\expandafter{\quote\small\singlespacing}

%--- Acronyms \usepackage{acro} \DeclareAcronym{fbb}{ short=FBB, long=foo bar baz, }

%--- Endnotes % Adapted from https://tex.stackexchange.com/a/109566/105447 \usepackage{endnotes}

% 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}} \let@afterindentfalse@afterindenttrue } \makeatother \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 \let\footnote=\endnote %--- ...end of Endnotes

%--- Sections % Managing sections \usepackage{titlesec} % To modify the section titles \renewcommand\thesection{\arabic{section}} % CHAPTER 1 [New Line] TITLE \titleformat{\section}[display] % each chapter has two lines... {\normalfont\Large\filcenter}{\MakeUppercase{Chapter~\thesection}}{0pt}{} \titlespacing{\section}{0pt}{0pt}{24pt} % {0pt}{0}{0pt} \titlespacing*{\subsection}{0pt}{12pt}{6pt} % 24pt before, 6pt after subsection % Capitalizing the titles of the respective sections: \renewcommand{\notesname}{\centering \MakeUppercase{Endnotes}} \renewcommand{\contentsname}{\centering \MakeUppercase{Contents}} \renewcommand{\refname}{\centering \MakeUppercase{References}} \renewcommand{\listfigurename}{\centering \MakeUppercase{List of Illustrations}} \renewcommand{\listtablename}{\centering \MakeUppercase{List of Tables}} \usepackage[titles]{tocloft} % <-- ...to modify ToC, LoF, and LoT \renewcommand{\cftdotsep}{4} % dots spacing \renewcommand{\cftsecdotsep}{4} % dots spacing for sections \renewcommand{\cftsubsecdotsep}{4}% dots spacing for subsections \renewcommand{\cfttoctitlefont}{\hfill\Large} % ToC = Table of Contents \renewcommand{\cftaftertoctitle}{\hfill} \renewcommand{\cftloftitlefont}{\hfill\Large} % LoF = List of Figures \renewcommand{\cftafterloftitle}{\hfill} \renewcommand{\cftlottitlefont}{\hfill\Large} % LoT = List of Tables \renewcommand{\cftafterlottitle}{\hfill} %--- ...end of Sections

% ----- Start of the document -------------------------------------------------- \begin{document}

\pagenumbering{roman}

{\let\bfseries\mdseries \tableofcontents} \newpage

\printacronyms[name=\MakeUppercase{List of Acronyms}] \addcontentsline{toc}{section}{\MakeUppercase{List of Acronyms}}

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

\pagenumbering{arabic} \section{\MakeUppercase{Intro &amp; Plan}} \subsection{Subsection} \lipsum[1-2]\footnote{foo bar baz in Ch1}\ac{fbb}

\newpage

\section{\MakeUppercase{Literature Review}} \subsection{Subsection} \lipsum[1-2]\footnote{foo bar baz in Ch2}\ac{fbb}

\newpage

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

\end{document} % ----- End of the document ----------------------------------------------------

Output file look

Alex
  • 67
  • What's the question exactly? What are you trying to change in the output? – cfr Oct 29 '23 at 20:46
  • Did you try the suggestion you received in comments on the earlier answer you got? That is, move the notes stuff after the titlesec stuff. If you did, please explain why that didn't work. – cfr Oct 29 '23 at 20:49
  • @cfr I am to write the answer in this thread. Moving the endnotes rules after the 'titlesec' did work for me. – Alex Oct 29 '23 at 22:31

1 Answers1

1

The answer to my question is in the following code (below). It produces the desired output with ENDNOTES section being organized under respective unnumbered/numbered sections (see screenshot at the bottom).

At its core, the issue was ordering of things in the preamble of the LaTeX file. It turned out that (a) package titlesec redefines \section and (b) our customization of endnotes to have split sections of the notes also requires a redefinition of \section. Thus, if (b) is placed ahead of (a) then the loading of titlesec would overwrite our redefinition. However, placing (b) after (a), ensuring our redefinition of \section is done after titlesec is loaded, produced the desired look of the ENDNOTES section.

\documentclass[11pt]{article}
\usepackage{lipsum}

% Set the page margins as required \usepackage[left=1.25in,right=1in,top=1in,bottom=1in]{geometry} \usepackage{endnotes} \usepackage{graphicx}
\usepackage{setspace} \doublespacing
\expandafter\def\expandafter\quote
\expandafter{\quote\small\singlespacing}

%--- Acronyms \usepackage{acro} \DeclareAcronym{fbb}{ short=FBB, long=foo bar baz, } \DeclareAcronym{zbb}{ short=ZBB, long=zoo bar baz, }

%--- ... end of Acronyms

\usepackage{natbib} \bibliographystyle{apalike} \usepackage{imakeidx} \makeindex[columns=2, title={INDEX}]

%--- Sections % Managing sections \usepackage{titlesec} % To modify the section titles \renewcommand\thesection{\arabic{section}} % CHAPTER 1 [New Line] TITLE \titleformat{\section}[display] % each chapter has two lines... {\normalfont\Large\filcenter}{\MakeUppercase{Chapter~\thesection}}{0pt}{} \titlespacing{\section}{0pt}{0pt}{24pt} % {0pt}{0}{0pt} \titlespacing*{\subsection}{0pt}{12pt}{6pt} % 24pt before, 6pt after subsection % Capitalizing the titles of the respective sections: \renewcommand{\notesname}{\centering \MakeUppercase{Endnotes}} \renewcommand{\contentsname}{\centering \MakeUppercase{Contents}} \renewcommand{\refname}{\centering \MakeUppercase{References}} \renewcommand{\listfigurename}{\centering \MakeUppercase{List of Illustrations}} \renewcommand{\listtablename}{\centering \MakeUppercase{List of Tables}} \usepackage[titles]{tocloft} % <-- ...to modify ToC, LoF, and LoT \renewcommand{\cftdotsep}{4} % dots spacing \renewcommand{\cftsecdotsep}{4} % dots spacing for sections \renewcommand{\cftsubsecdotsep}{4}% dots spacing for subsections \renewcommand{\cfttoctitlefont}{\hfill\Large} % ToC = Table of Contents \renewcommand{\cftaftertoctitle}{\hfill} \renewcommand{\cftloftitlefont}{\hfill\Large} % LoF = List of Figures \renewcommand{\cftafterloftitle}{\hfill} \renewcommand{\cftlottitlefont}{\hfill\Large} % LoT = List of Tables \renewcommand{\cftafterlottitle}{\hfill} %--- ...end of Sections

%--- 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 \let\footnote=\endnote %--- ...end of Endnotes

% ----- Start of the document -------------------------------------------------- \begin{document}

\pagenumbering{roman} {\let\bfseries\mdseries \tableofcontents} \newpage

%\printacronyms[pages={display=all,seq/use=false}, name=\MakeUppercase{List of Acronyms}] \printacronyms[name=\MakeUppercase{List of Acronyms}] %\printacronyms \addcontentsline{toc}{section}{\MakeUppercase{List of Acronyms}} \newpage

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

\pagenumbering{arabic} \section{\MakeUppercase{Intro &amp; Plan}} \subsection{Subsection} \lipsum[1-2]\footnote{foo bar baz in Ch1} And \ac{fbb} with \ac{zbb}...

\newpage

\section{\MakeUppercase{Literature Review}} \subsection{Subsection} \lipsum[1-2]\footnote{foo bar baz in Ch2} And \ac{fbb} with \ac{zbb}...

\newpage

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

\end{document} % ----- End of the document ----------------------------------------------------

enter image description here

gusbrs
  • 13,740
Alex
  • 67