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 & 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 ----------------------------------------------------


titlesecstuff. If you did, please explain why that didn't work. – cfr Oct 29 '23 at 20:49endnotesrules after the 'titlesec' did work for me. – Alex Oct 29 '23 at 22:31