0

I have encountered the following issue (details are) after previously I had successfully customized the endnotes for my needs. My MWE code is below. Basically, I am replying on these packages: acro for acronyms, endnotes for notes, and titlesec for section titles.

There are these three lines of code that produce a kind of trade off...

\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter

...if not muted, my output file has 'ENDNOTES' section being divided nicely into chapters, while my 'CONTENTS' and 'LIST OF ACRONYMS' pages either (a) contain no tables, respectively, of contents and of used acronyms or (b) tables are there but it is list of acronyms that loses the pages information (but it must have it). It's on the 1st picture placed just after the MWE code.

However, if muted, now the 'ENDNOTES' page has wrong look, while 'CONTENTS' and 'LIST OF ACRONYMS' are just fine. It's depicted on the 2nd picture at the very bottom or after the 1st picture.

How can I avoid this trade off? This is the 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{endnotes} \usepackage{graphicx}
\usepackage{setspace} \doublespacing
\expandafter\def\expandafter\quote
\expandafter{\quote\small\singlespacing}

%--- 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}} \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

%--- Acronyms \usepackage{acro} \DeclareAcronym{fbb}{ short=FBB, long=foo bar baz, } \DeclareAcronym{zbb}{ short=ZBB, long=zoo bar baz, } \acsetup{ list/name = \MakeUppercase{List of Acronyms}, pages/display = all, pages/seq/use = false } %--- ... end of Acronyms

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

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

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

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

1st picture

2nd pciture

Alex
  • 67

1 Answers1

1

Thanks to this bit of info borrowed from How to Remove Redundant Chapter Labels from Both the Chapter Endnotes and TOC, I have solved this question. Now, my MWE code and screenshots of the required look of the output file are following below. The key issue was sequencing of the commands within the code block (lines ## 40-68) that customizes the sections in the ENDNOTES section. In particular, this line...

\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}

...must be placed before these two lines...

\makeatother    
\RenewDocumentCommand{\section}{som}{%

...and not at the end of that block or before this line:

\let\footnote=\endnote

Below are correct screenshots and MWE.

enter image description here

\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}

%--- 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 % Reset endnote numbering every section \counterwithin{endnote}{section} \let\latexsection\section \makeatletter %changes the catcode of @ to 11 \renewcommand\enoteheading{ \setcounter{secnumdepth}{-2} \latexsection{\notesname\markboth{NOTES}{}} \mbox{}\par\vskip-\baselineskip \let@afterindentfalse@afterindenttrue } \def\enotedivision#1#2{@ifnextchar\enotedivision{}{#1{#2}}} \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}}}% }% } \let\footnote=\endnote %--- ...end of Endnotes

%--- Acronyms \usepackage{acro} \DeclareAcronym{fbb}{ short=FBB, long=foo bar baz, } \DeclareAcronym{zbb}{ short=ZBB, long=zoo bar baz, } \acsetup{ list/name = \MakeUppercase{List of Acronyms}, pages/display = all, pages/seq/use = false } %--- ... end of Acronyms

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

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

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

\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 \addcontentsline{toc}{section}{\MakeUppercase{Endnotes}}

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

Alex
  • 67