![ToC、‘acro’ 和尾注定制之间的冲突](https://linux22.com/image/470447/ToC%E3%80%81%E2%80%98acro%E2%80%99%20%E5%92%8C%E5%B0%BE%E6%B3%A8%E5%AE%9A%E5%88%B6%E4%B9%8B%E9%97%B4%E7%9A%84%E5%86%B2%E7%AA%81.png)
在我之前成功定制了尾注以满足我的需求后,我遇到了以下问题(详情如下)。我的 MWE 代码如下。基本上,我正在回复这些包:acro
用于首字母缩略词、endnotes
用于注释和titlesec
用于章节标题。
这三行代码产生了一种权衡……
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter
...如果没有静音,我的输出文件有“ENDNOTES”部分,被很好地划分为章节,而我的“CONTENTS”和“LIST OF ACRONYMS”页面要么 (a) 不包含目录和所用缩写词的表格,要么 (b) 有表格,但缩写词列表丢失了页面信息(但必须有)。它位于 MWE 代码之后的第一张图片上。
然而,如果静音,现在“ENDNOTES”页面看起来不对,而“CONTENTS”和“LIST OF ACRONYMS”则没问题。它显示在最底部的第二张图片上或第一张图片之后。
我怎样才能避免这种权衡?这是 MWE 代码:
\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 \& 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 ----------------------------------------------------
答案1
感谢借用以下信息如何从章节尾注和目录中删除多余的章节标签,我已经解决了这个问题。现在,我的MWE代码和截图必看输出文件如下所示。关键问题是代码块(第 40-68 行)中命令的排序,这些命令自定义了 ENDNOTES 部分中的部分。特别是这一行...
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
...必须放置前这两行...
\makeatother
\RenewDocumentCommand{\section}{som}{%
...并且不在该块的末尾或在此行之前:
\let\footnote=\endnote
以下是正确的截图和 MWE。
\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 \& 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 ----------------------------------------------------