这是此处讨论的问题的后续内容:尾注部分分为小节
我的原始代码被尽可能地转换为 MWE(如下)。我的文档有一个未编号的“PREFACE”部分和许多编号的部分(章节)。这些部分中的每一个都有脚注。后者必须放在文档最末尾的“ENDNOTES”标题下,并按相应的部分标题分组。
问题是,我的扩展 MWE 代码(见下图)没有产生所需的外观(获得的外观这里)。我怀疑,这一定是由于我对章节规则的操作造成的(在我的扩展 MWE 代码的序言中有一个章节涉及此问题):
\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 ----------------------------------------------------
答案1
我的问题的答案在下面的代码中。它生成所需的输出,其中 ENDNOTES 部分被组织在相应的未编号/编号部分下(参见底部的屏幕截图)。
问题的核心在于订购LaTeX 文件序言中的内容。事实证明,(a) 包titlesec
重新定义了\section
,并且 (b) 我们自定义endnotes
以拆分注释部分也需要重新定义\section
。因此,如果将 (b) 放在 (a) 之前,则 的加载titlesec
将覆盖我们的重新定义。但是,将 (b) 放在 (a) 之后,确保 的重新定义在 加载\section
之后完成titlesec
,从而产生了 ENDNOTES 部分所需的外观。
\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 \& 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 ----------------------------------------------------