![尾注无法正确调用计数器](https://linux22.com/image/403235/%E5%B0%BE%E6%B3%A8%E6%97%A0%E6%B3%95%E6%AD%A3%E7%A1%AE%E8%B0%83%E7%94%A8%E8%AE%A1%E6%95%B0%E5%99%A8.png)
我正在尝试将编号的观察结果发送到最后一页,如下面的 MWE 所示。如何获取要在最后一页显示的正确数字?谢谢!
\documentclass{article}
\usepackage{endnotes}
\newcounter{thought}
\def\mythought{%
\refstepcounter{thought}
\noindent
\textbf{Thought \#\thethought:}
}
%-> Defining the environment for the OBSERVATIONS @ the footnote
\newcommand{\myfnobs}[1]{%
\let\thefootnote\relax %... suppresses the footnote numbering
\footnote{\textbf{Observation on thought \#\thethought-} #1}
}
%-> Redefine the ENDOTES page title:
\renewcommand{\notesname}{My observations}
%-> Defining the environment for the OBSERVATIONS @ last page
\newcommand{\mylpobs}[1]{%
\let\theendnote\relax %... suppresses the \endnote numbering
\endnote{\textbf{Observation on thought \#\thethought-} #1}
}
\begin{document}
\begin{abstract}
In this MWE I show that the \texttt{endnotes} package doesn't read each \texttt{thought} counter value, but only the last one.
\end{abstract}
\section{Introduction}
The \texttt{endnotes} package is based on the \texttt{\textbackslash footnote} command. The difference: it sends the content to the last page. I created two commands in the preable, as described below
\begin{itemize}
\item \texttt{\textbackslash myfnobs}, which receives one argument, is the command that places my observations in the footnote of the page where it occurs.
\item \texttt{\textbackslash mylpobs}, which receives one arguement, is the command that places my observation in the last page of the document.
\end{itemize}
I also defined the macro \texttt{\textbackslash mythought}, where I want to express my thoughts. This is numbered sequentially. For examples, see next section.
\section{Thoughts placed at the footnote}
I want to express three thoughts of mine.
\mythought
Everyday is a good day to start something new in our lives.%
\myfnobs{This may not be true if we still didn't accomplish what we started last.}
\mythought
It is never late to learn new things.%
\myfnobs{I believe this has no exception}
\mythought
Tolerance is the key to achieve better world.%
\myfnobs{Intolerance causes violence, war, and death.}
\section{Thoughts placed at the last page}
Please, let me repeat my three thoughts, but changing the command from \texttt{\textbackslash myfnobs} to \texttt{\textbackslash mylpobs}:
\mythought
Everyday is a good day to start something new in our lives.%
\mylpobs{This may not be true if we still didn't accomplish what we started last.}
\mythought
It is never late to learn new things.%
\mylpobs{I believe this has no exception}
\mythought
Tolerance is the key to achieve better world.%
\mylpobs{Intolerance causes violence, war, and death.}
\section{Final considerations}
Let's finish this issue by adding new page and calling the \texttt{\textbackslash theendnotes} command. Observe that at such page, all the \textbf{Observation on thought \#} receive the value 6 (six), instead of the intended value, differently from what happened to when I called the \texttt{\textbackslash myfnobs}
\newpage
\theendnotes
\end{document}
答案1
您需要扩展\thethought
:脚注文本会立即扩展,因此没有问题,但\endnote
只是保存文本而不进行解释。
\documentclass{article}
\usepackage{endnotes}
\newcounter{thought}
\newcommand\mythought{%
\refstepcounter{thought}%
\noindent
\textbf{Thought \#\thethought:}%
}
%-> Defining the environment for the OBSERVATIONS @ the footnote
\newcommand{\myfnobs}[1]{%
\let\thefootnote\relax %... suppresses the footnote numbering
\footnote{\textbf{Observation on thought \#\thethought-} #1}
}
%-> Redefine the ENDOTES page title:
\renewcommand{\notesname}{My observations}
%-> Defining the environment for the OBSERVATIONS @ last page
\newcommand{\mylpobs}[1]{%
\let\theendnote\relax %... suppresses the \endnote numbering
\begingroup
\edef\x{\endgroup
\noexpand\endnote{\noexpand\textbf{Observation on thought \noexpand\#\thethought-} \unexpanded{#1}}%
}\x
}
\begin{document}
\begin{abstract}
In this MWE I show that the \texttt{endnotes} package doesn't read each \texttt{thought} counter value, but only the last one.
\end{abstract}
\section{Introduction}
The \texttt{endnotes} package is based on the \texttt{\textbackslash footnote} command. The difference: it sends the content to the last page. I created two commands in the preable, as described below
\begin{itemize}
\item \texttt{\textbackslash myfnobs}, which receives one argument, is the command that places my observations in the footnote of the page where it occurs.
\item \texttt{\textbackslash mylpobs}, which receives one arguement, is the command that places my observation in the last page of the document.
\end{itemize}
I also defined the macro \texttt{\textbackslash mythought}, where I want to express my thoughts. This is numbered sequentially. For examples, see next section.
\section{Thoughts placed at the footnote}
I want to express three thoughts of mine.
\mythought
Everyday is a good day to start something new in our lives.%
\myfnobs{This may not be true if we still didn't accomplish what we started last.}
\mythought
It is never late to learn new things.%
\myfnobs{I believe this has no exception}
\mythought
Tolerance is the key to achieve better world.%
\myfnobs{Intolerance causes violence, war, and death.}
\section{Thoughts placed at the last page}
Please, let me repeat my three thoughts, but changing the command from \texttt{\textbackslash myfnobs} to \texttt{\textbackslash mylpobs}:
\mythought
Everyday is a good day to start something new in our lives.%
\mylpobs{This may not be true if we still didn't accomplish what we started last.}
\mythought
It is never late to learn new things.%
\mylpobs{I believe this has no exception}
\mythought
Tolerance is the key to achieve better world.%
\mylpobs{Intolerance causes violence, war, and death.}
\section{Final considerations}
Let's finish this issue by adding new page and calling the \texttt{\textbackslash theendnotes} command. Observe that at such page, all the \textbf{Observation on thought \#} receive the value 6 (six), instead of the intended value, differently from what happened to when I called the \texttt{\textbackslash myfnobs}
\newpage
\theendnotes
\end{document}
顺便说一句,重复 是没用的\let\thefootnote\relax
,除非你把它隐藏在组内。第一次调用\myfnobs
将设置\thefootnote
为\relax
全球. 对于 也类似\theendnote
。