尾注中的章节编号/标题:虚假标题

尾注中的章节编号/标题:虚假标题

此问题与一些有关格式化尾注以包含章节标题和编号的现有条目有关。相关条目如下:

尾注中的章节编号

出现在尾注中的章节名称

问题:即使文档中没有尾注,尾注也会包含文档的最后一章。也就是说,文档中有许多章节;有些有尾注,有些没有。最后一章没有不是有尾注。但是尾注似乎总是包含最后一章的章节标题。

以下是一个例子:

\documentclass{scrreprt}

\usepackage{endnotes,chngcntr}

\counterwithin*{endnote}{chapter}  % Reset endnote numbering every new chapter

\makeatletter
\renewcommand\enoteheading{%
  \setcounter{secnumdepth}{-2}
  \chapter*{\notesname}
  \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}
\chapter{The first chapter}
Here text relating to an endnote.\endnote{This endnote contains some text}
\chapter{The next chapter}
Here is another piece of text that needs an endnote.\endnote{This endnote contains more text}
\chapter{The third chapter}
Here is the last bit of text that needs an endnote.\endnote{This endnote contains a whole lot more text}
\chapter{Fourth chapter}
Stuff here
\chapter{Conclusion}
Some more stuff

\newpage

\begingroup
\def\enotesize{\normalsize}
\theendnotes
\endgroup

\end{document}

谢谢您的指点! 尾注图片

答案1

问题的解决方案实际上在帖子中尾注中的章节编号,在问题中被引用。

解决方法是包含上面的一行代码(\addtoendnotes{\unexpanded{\enotedivision{}{}}}\theendnotes

上面的例子就变成:

\documentclass{scrreprt}

\usepackage{endnotes,chngcntr}

\counterwithin*{endnote}{chapter}  % Reset endnote numbering every new chapter

\makeatletter
\renewcommand\enoteheading{%
  \setcounter{secnumdepth}{-2}
  \chapter*{\notesname}
  \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}
\chapter{The first chapter}
Here text relating to an endnote.\endnote{This endnote contains some text}
\chapter{The next chapter}
Here is another piece of text that needs an endnote.\endnote{This endnote contains more text}
\chapter{The third chapter}
Here is the last bit of text that needs an endnote.\endnote{This endnote contains a whole lot more text}
\chapter{Fourth chapter}
Stuff here
\chapter{Conclusion}
Some more stuff

\newpage

\begingroup
\def\enotesize{\normalsize}
\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\theendnotes
\endgroup

\end{document}

这使得尾注的格式如下:

在此处输入图片描述

相关内容