现在我需要将尾注附加到第 16 节开头的编号上,像这样的简单操作\section{\endnote{$\pi=3.14$}}
会使数字 16(自动生成)和尾注标记之间产生很大的差距,因此我将其更改为,\section*{16\endnote{$\pi=3.14$}}
从而使下一节(即第 17 节)的编号为 16。我不想手动调整以下章节的标题,那么有没有办法附加尾注/脚注?或者一般来说有没有办法控制标题的编号顺序?
一个最小的例子
\documentclass{article}
\begin{document}
\section*{1\footnote{In this section we take $c=0$}}%This one being the title of the first section.
This is the material of the first section.
\section{}%This is the title of the supposedly second section
This is what is contained in the second section.
\end{document}
答案1
这是一个解决方案,其中\@seccntformat
被劫持以添加尾注标记。尾注文本作为 的尾随可选参数提供\Section
。
\documentclass{article}
\usepackage{xparse,endnotes}
\NewDocumentCommand{\Section}{somo}{%
\gdef\thissectionnote{}% reinitialize
\IfValueT{#4}{\gdef\thissectionnote{#4}}% set up the endnote
\IfBooleanTF{#1}
{\section*{#3}} % starred section
{\IfNoValueTF{#2} % unstarred section
{\section{#3}} % no optional argument
{\section[#2]{#3}}% optional argument
}%
}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
\csname the#1\endcsname
\ifcsname #1@seccntformat\endcsname
\ifx\thissectionnote\@empty
\else
\unexpanded{\makebox[0pt][l]{\endnotemark}}%
\noexpand\endnotetext{\unexpanded\expandafter{\thissectionnote}}%
\fi
\fi
\quad
}
\def\section@seccntformat{}
\makeatother
\begin{document}
\Section{A title}
This is a normal section
\Section{Another title}[In this section we take $c=0$]
This section has an endnote.
\Section[Short title]{Long title}
This is another section.
\theendnotes
\end{document}
如果需要使用,\section
因为文本是自动生成的,你可以保存:的含义,只是需要更改的\section
部分。\NewDocumentCommand
\let\latexsection\section
\RenewDocumentCommand{\section}{somo}{%
\gdef\thissectionnote{}% reinitialize
\IfValueT{#4}{\gdef\thissectionnote{#4}}% set up the endnote
\IfBooleanTF{#1}
{\latexsection*{#3}} % starred section
{\IfNoValueTF{#2} % unstarred section
{\latexsection{#3}} % no optional argument
{\latexsection[#2]{#3}}% optional argument
}%
}