如何重置部分和章节的尾注计数器

如何重置部分和章节的尾注计数器

我在书籍类中有一个文档(书籍类,请参阅下面的简明工作示例),其中有一些尾注(额外的注释,保存到文档末尾,而不是打印在当前或最近的右侧页面的底部)。我还有脚注,我希望它们保持独立;我已经做到了这一点,并让它们重置每一页,并让尾注重置每个新的章节或部分。

现在,当我打电话时\theendnotes,我会得到一份按顺序排列的文档中所有尾注的列表,并带有正确的编号(即重置了每个章节/部分的计数器)。我希望部分/章节的划分分别显示为节/小节标题,并且这些标题不会干扰我的目录。

我正在与尾注包只是现在,但如果其他想法能够解决我的问题而又不让我弄得太脏(在 LaTeX 黑客方面我不是专业人士),我愿意听取他们的意见。我之所以有脚注和尾注,是因为我正在翻译一篇旧的学术文本,我需要 [合理地] 忠实于原始格式。下面的工作示例:

\documentclass{book}
\usepackage{endnotes}
    \renewcommand\enoteheading{\chapter*{\notesname}\mbox{}\par\vskip-\baselineskip}
    \makeatletter
        \@addtoreset{footnote}{page}    % Reset footnote "numbering" (symbols) every new page
        \@addtoreset{endnote}{part}     % Reset endnote numbering every new part
        \@addtoreset{endnote}{chapter}  % Reset endnote numbering every new chapter
    \makeatother
\usepackage{footmisc}
    \renewcommand{\thefootnote}{\fnsymbol{footnote}}%
\begin{document}
        Some text,\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
        not in any structural part of the document.
    \part{Part One}
        Some\footnote{This is the first footnote, symbolised by a star.}
        text,\footnote{Second footnote, a pair of stars.}
        not\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
        part\footnote{Third footnote, a solitary dagger.}
        of any chapter.
    \chapter{Chapter 1}
        This\footnote{A footnote, should be a single star (symbol \#1), not a pair of daggers (\#4) because of reset footnote numbering at new page.} 
        is chapter one.\endnote{This endnote should be numbered 1, since it's the first of a chapter.}
    \part{Part Two}
        Text.\endnote{This should also be numbered 1, since it's the first in its part.}
    \theendnotes
\end{document}

答案1

这是一个自动版本:

\documentclass{book}
\usepackage{endnotes,chngcntr}
\usepackage[perpage,symbol*]{footmisc}

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

\makeatletter
\renewcommand\enoteheading{%
  \setcounter{secnumdepth}{-2}
  \chapter*{\notesname}
  \addtocontents{toc}{\protect\addvspace{10pt}} % adjust to suit
  \addcontentsline{toc}{chapter}{\notesname}
  \mbox{}\par\vskip-\baselineskip
  \let\@afterindentfalse\@afterindenttrue
}
\makeatother

\usepackage{xparse}
\let\latexpart\part
\let\latexchapter\chapter

\RenewDocumentCommand{\part}{som}{%
  \IfBooleanTF{#1}
    {\latexpart*{#3}}
    {\IfNoValueTF{#2}
       {\latexpart{#3}}
       {\latexpart[#2]{#3}}%
     \addtoendnotes{\unexpanded{\section{#3}}}
    }
}
\RenewDocumentCommand{\chapter}{som}{%
  \IfBooleanTF{#1}
    {\latexchapter*{#3}}
    {\IfNoValueTF{#2}
       {\latexchapter{#3}}
       {\latexchapter[#2]{#3}}%
     \addtoendnotes{\unexpanded{\subsection{#3}}}
    }
}



\begin{document}
Some text,\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
not in any structural part of the document.

\part{Part One}
Some\footnote{This is the first footnote, symbolised by a star.}
text,\footnote{Second footnote, a pair of stars.}
not\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
part\footnote{Third footnote, a solitary dagger.}
of any chapter.

\chapter{Chapter 1}

This\footnote{A footnote, should be a single star (symbol \#1), not a pair of daggers (\#4) 
because of reset footnote numbering at new page.}
is chapter one.\endnote{This endnote should be numbered 1, since it's the first of a chapter.}

\part{Part Two}
Text.\endnote{This should also be numbered 1, since it's the first in its part.}


\theendnotes

\end{document}

首先,我说过\usepackage[perpage,symbol*]{footmisc}要按页对脚注进行编号。请参阅文档以了解如何更改符号的顺序。我还对命令做了一些修改\enoteheading

实质性部分是重新定义\part\chapter将其标题写入尾注文件中。保留原始含义,并xparse用于轻松重新定义它们。


这是一个略有不同的版本,如果章节(小节)中没有尾注,则避免在尾注中打印章节(小节)标题。部分(节)标题始终会打印。

\documentclass{book}
\usepackage{endnotes,chngcntr}
\usepackage[perpage,symbol*]{footmisc}

\counterwithin*{endnote}{part}     % Reset endnote numbering every new part
\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\latexpart\part
\let\latexchapter\chapter

\RenewDocumentCommand{\part}{som}{%
  \IfBooleanTF{#1}
    {\latexpart*{#3}}
    {\IfNoValueTF{#2}
       {\latexpart{#3}}
       {\latexpart[#2]{#3}}%
     \addtoendnotes{\unexpanded{\enotedivision{\section}{#3}}\relax}
    }
}
\RenewDocumentCommand{\chapter}{som}{%
  \IfBooleanTF{#1}
    {\latexchapter*{#3}}
    {\IfNoValueTF{#2}
       {\latexchapter{#3}}
       {\latexchapter[#2]{#3}}%
     \addtoendnotes{\unexpanded{\enotedivision{\subsection}{#3}}}
    }
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter


\begin{document}
Some text,\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
not in any structural part of the document.

\part{Part One}
Some\footnote{This is the first footnote, symbolised by a star.}
text,\footnote{Second footnote, a pair of stars.}
not\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
part\footnote{Third footnote, a solitary dagger.}
of any chapter.

\chapter{Chapter 1}
This\footnote{A footnote, should be a single star (symbol \#1), not a pair of daggers (\#4) 
because of reset footnote numbering at new page.}
is chapter one.\endnote{This endnote should be numbered 1, since it's the first of a chapter.}

\chapter{Chapter 2}
No endnotes

\part{Part Two}
Text.\endnote{This should also be numbered 1, since it's the first in its part.}

\chapter{Chapter 3}
No endnotes.


\addtoendnotes{\unexpanded{\enotedivision{}{}}}
\theendnotes

\end{document}

答案2

这是第一次尝试手动插入信息。我相信它可以自动化,但这需要确保您使用的每个部分/章节都有尾注,以避免输出没有任何尾注的章节标题:

在此处输入图片描述

\documentclass{book}
\usepackage{endnotes}% http://ctan.org/pkg/endnotes
    \renewcommand\enoteheading{\chapter*{\notesname}\mbox{}\par\vskip-\baselineskip}
    \makeatletter
        \@addtoreset{footnote}{page}    % Reset footnote "numbering" (symbols) every new page
        \@addtoreset{endnote}{part}     % Reset endnote numbering every new part
        \@addtoreset{endnote}{chapter}  % Reset endnote numbering every new chapter
    \makeatother
\usepackage{footmisc}% http://ctan.org/pkg/footmisc
    \renewcommand{\thefootnote}{\fnsymbol{footnote}}%
\begin{document}
        Some text,\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
        not in any structural part of the document.
    \part{Part One}
        \makeatletter
        \addtoendnotes{\protect\section*{\thepart{} Part One}\protect\@afterindenttrue}
        \makeatother
        Some\footnote{This is the first footnote, symbolised by a star.}
        text,\footnote{Second footnote, a pair of stars.}
        not\endnote{This endnote will naturally be numbered 1, as the first endnote in the document.}
        part\footnote{Third footnote, a solitary dagger.}
        of any chapter.
    \chapter{First chapter}
        \makeatletter
        \addtoendnotes{\protect\subsection*{\thechapter{} First chapter}\protect\@afterindenttrue}
        \makeatother
        This\footnote{A footnote, should be a single star (symbol \#1), not a pair of daggers (\#4) because of reset footnote numbering at new page.} 
        is chapter one.\endnote{This endnote should be numbered 1, since it's the first of a chapter.}
    \part{Part Two}
        \makeatletter
        \addtoendnotes{\protect\section*{\thepart{} Part Two}\protect\@afterindenttrue}
        \makeatother
        Text.\endnote{This should also be numbered 1, since it's the first in its part.}
    \theendnotes
\end{document}

endnotes提供\addtoendnotes{<stuff>}写入<jobname>.ent-结束注释文件。里面的脆弱命令<stuff>需要\protect编辑:

\makeatletter
\addtoendnotes{\protect\section*{\thepart{} Part One}\protect\@afterindenttrue}
\makeatother

我使用了\section*进行\part分类,以及\subsection*进行\chapter分类,因为带星号的版本不会出现在目录中(默认情况下)。 可以为尾注全局设置\@afterindenttrue,但目前我将其保留在每个插入的本地(例如,全局设置它会删除\makeatletter...\makeatother要求)。

相关内容