我有一份包含章节和尾注的书籍文档。我希望尾注按章节分开,我已经实现了这一点,按照我之前问题的答案尾注中的章节编号
但是,下面这份文件存在两个问题:
(1)前言和结语,这两个没有编号的章节(即用 \chapter* 命令引入的章节),没有作为注释中的标题出现(“第 1 章”和其他章节的出现方式)。
(2) 最后的尾注不是编号为 1 并出现在单独的标题“结语”下(作为结语中的第一个尾注),而是编号为 2,并与第 3 章的尾注合并在一起。
如何解决这些问题?
\documentclass[12pt]{book}
\usepackage{endnotes,chngcntr}
\counterwithin*{endnote}{chapter} % Reset endnote numbering every new chapter
\makeatletter
\renewcommand\enoteheading{%
\setcounter{secnumdepth}{-2}
\chapter*{\notesname\markboth{NOTES}{}}
\mbox{}\par\vskip-\baselineskip
\let\@afterindentfalse\@afterindenttrue
}
\makeatother
\usepackage{xparse}
\let\latexchapter\chapter
\RenewDocumentCommand{\chapter}{som}{%
\IfBooleanTF{#1}
{\latexchapter*{#3}}
{\IfNoValueTF{#2}
{\latexchapter{#3}}
{\latexchapter[#2]{#3}}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\chaptername\ \thechapter. \unexpanded{#3}}}%
}%
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter
\begin{document}
\setcounter{tocdepth}{1}
\tableofcontents
\chapter*{Preface\markboth{PREFACE}{}}
\addcontentsline{toc}{chapter}{Preface}
This is the Prologue.\endnote{There is one endnote here, which should appear under the heading "Prologue" (it doesn't).}
\chapter{Amazing Story}
As I am describing this story, I make a note which should appear at
the end.\endnote{This the first endnote.} And then I make the second
note.\endnote{This is the second note.}
\chapter{Another Amazing Story}
In this chapter, there are no endnotes. So it should not appear in the
"Notes" at the end.
\chapter{Yet Another Amazing Story}
In this chapter, I have some notes again, which I want to go to the
end.\endnote{This note should appear at the end, under the heading
"Chapter 3. Yet Another Amazing Story", with the counter reset to 1,
since this is the first endnote of this chapter.}
\chapter*{Epilogue\markboth{EPILOGUE}{}}
\addcontentsline{toc}{chapter}{Epilogue}
This is the Epilogue.\endnote{One last endnote. It should have number
1 and should appear under the heading ``Epilogue''. But it
doesn't...}
\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\cleardoublepage
\addcontentsline{toc}{chapter}{Notes}
\theendnotes
\end{document}
答案1
您必须为调用添加一些代码\chapter*
(并更改\chapter*
定义以\enoteheading
使用原始宏)。
\documentclass[12pt]{book}
\usepackage{endnotes,chngcntr}
\counterwithin*{endnote}{chapter} % Reset endnote numbering every new chapter
\let\latexchapter\chapter
\makeatletter
\renewcommand\enoteheading{%
\setcounter{secnumdepth}{-2}
\latexchapter*{\notesname\markboth{NOTES}{}}
\mbox{}\par\vskip-\baselineskip
\let\@afterindentfalse\@afterindenttrue
}
\makeatother
\usepackage{xparse}
\RenewDocumentCommand{\chapter}{som}{%
\IfBooleanTF{#1}
{\latexchapter*{#3}%
\setcounter{endnote}{0}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\unexpanded{#3}}}%
}
{\IfNoValueTF{#2}
{\latexchapter{#3}}
{\latexchapter[#2]{#3}}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\chaptername\ \thechapter. \unexpanded{#3}}}%
}%
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter
\begin{document}
\setcounter{tocdepth}{1}
\tableofcontents
\chapter*{Preface\markboth{PREFACE}{}}
\addcontentsline{toc}{chapter}{Preface}
This is the Prologue.\endnote{There is one endnote here, which should appear under the heading "Prologue" (it doesn't).}
\chapter{Amazing Story}
As I am describing this story, I make a note which should appear at
the end.\endnote{This the first endnote.} And then I make the second
note.\endnote{This is the second note.}
\chapter{Another Amazing Story}
In this chapter, there are no endnotes. So it should not appear in the
"Notes" at the end.
\chapter{Yet Another Amazing Story}
In this chapter, I have some notes again, which I want to go to the
end.\endnote{This note should appear at the end, under the heading
"Chapter 3. Yet Another Amazing Story", with the counter reset to 1,
since this is the first endnote of this chapter.}
\chapter*{Epilogue\markboth{EPILOGUE}{}}
\addcontentsline{toc}{chapter}{Epilogue}
This is the Epilogue.\endnote{One last endnote. It should have number
1 and should appear under the heading ``Epilogue''. But it
doesn't...}
\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\cleardoublepage
\addcontentsline{toc}{chapter}{Notes}
\theendnotes
\end{document}
当然,现在的文字并没有说实话。:)
答案2
当章节标题中有尾注时,由 开发的解决方案egreg
会让您陷入麻烦。尾注将显示在上一章的节末,而尾注节中的章节标题将包含尾注标记,即使它可能具有没有尾注标记的不同目录标题。
这里讨论了该问题的解决方案:
尾注中的章节标题:未编号章节(在 KOMA 中)和章节标题中的尾注的问题
(还讨论了使用 KOMA 类中的特殊操作时出现的另一个问题)
简而言之,章节定义的解决方案可能如下所示:
\RenewDocumentCommand{\chapter}{som}{%
\IfBooleanTF{#1} % unnumbered chapters
{\latexchapter*{#3}%
\setcounter{endnote}{0}%
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\unexpanded{#3}}}%
}
{ % numbered chapters
\IfNoValueTF{#2}
{ % no separate TOC title
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\chaptername\ \the\numexpr\value{chapter}+1\relax: \unexpanded{#3}}}%
\latexchapter{#3}
}
{ % separate TOC title
\addtoendnotes{%
\noexpand\enotedivision{\noexpand\subsection}
{\chaptername\ \the\numexpr\value{chapter}+1\relax: \unexpanded{#2}}}%
\latexchapter[#2]{#3}
}%
}%
}