![回忆录页注(尾注)的 id 都是一样的](https://linux22.com/image/480743/%E5%9B%9E%E5%BF%86%E5%BD%95%E9%A1%B5%E6%B3%A8%EF%BC%88%E5%B0%BE%E6%B3%A8%EF%BC%89%E7%9A%84%20id%20%E9%83%BD%E6%98%AF%E4%B8%80%E6%A0%B7%E7%9A%84.png)
我正在使用 memoir 包,特别是 memoir 的 endnote 功能(称为 pagenote 以避免命名冲突)创建文档。文档完成后,将为一年中的每一天添加一个条目。我正在使用 texdate 包自动生成日期字符串(两种不同的格式)。
为了方便读者阅读,我希望每个尾注的标签(或 ID)都是日期字符串(例如,1 月 1 日),而不仅仅是连续的整数。问题是(似乎)直到尾注页面写完后才会评估日期字符串,结果所有尾注条目都标记了相同的日期。
我怎样才能解决这个问题?
% pagenoteMWE.tex
\documentclass[12pt]{memoir}
% begin preamble * * * * * * * * * * * * *
\usepackage{calc}
\usepackage{texdate}
% The following is required in the preamble for using memoir's pagenote (endnote) capability
\makepagenote
\renewcommand*{\idtextinnotes}[1]{#1\space} % remove square brackets surrounding note id
\renewcommand{\prenoteinnotes}{\par\noindent\hangindent0.6in}
\renewcommand\prenotetext{\hskip-3.52pt}
% Create named date formats for texdate package
\nameddateformat{monthandday}{B e} % January 5
\nameddateformat{monandday}{b e} % Jan 5
% Custom command for using memoir's \pagenote command
\newcommand{\mypagenote}[2]{\small\pagenote[\hbox to 0.6in{#1\hfill}]{\small#2}}
% end preamble * * * * * * * * * * * * * *
\begin{document}
\title{A Passage for Each Day of the Year}
\date{\strut}
\maketitle
\initdate{2024}{12}{31} % initializes texdate's date
\vspace{-80pt}
%-- Jan01 ---------------------------------------------------------------------
\advancebydays{1} \begin{center} \Large \printfdate{monthandday}\par \end{center} \par\noindent
I do not doubt she had a choice pleasure in exhibiting what she called her
self-command, and her firmness, and her strength of mind, and her common sense
and the whole diabolical catalogue of her unamiable qualities, on such an
occasion.
\mypagenote{\small\printfdate{monandday}}{David Copperfield recalling his
interaction with the vile Miss Murdstone upon returning from school to his home
upon the death of his mother.}
\bigskip
%-- Jan02 ---------------------------------------------------------------------
\advancebydays{1} \begin{center} \Large \printfdate{monthandday}\par \end{center} \par\noindent
In the hierarchy of post-Civil War times was Mrs.\ Hamilton Fish, whose husband
became Secretary of State in Grant's Cabinet; she belonged to what was called
``the Faubourg St.\ Germain set'' of New York--families entrenched since
Colonial days in wealth and civic eminence, who could afford to live in
tarnished magnificence on outmoded Second Avenue, while ``swells'' eddied like
moths toward the luster of Fifth Avenue.
\mypagenote{\small\printfdate{monandday}}{Dixon Wecter, \emph{The Saga of
American Society: A Record of Social Aspiration, 1607-1937}, New York: Charles
Scribner's Sons, 1937.}
\bigskip
\printpagenotes
\end{document}
答案1
您可以将值存储在尾注内,这样\printfdate
命令就会选取正确的数据。
% pagenoteMWE.tex
\documentclass[12pt]{memoir}
% begin preamble * * * * * * * * * * * * *
\usepackage{calc}
\usepackage{texdate}
% The following is required in the preamble for using memoir's pagenote (endnote) capability
\makepagenote
\renewcommand*{\idtextinnotes}[1]{#1\space} % remove square brackets surrounding note id
\renewcommand{\prenoteinnotes}{\par\noindent\hangindent0.6in}
\renewcommand\prenotetext{\hskip-3.52pt}
% Create named date formats for texdate package
\nameddateformat{monthandday}{B\ e} % January 5
\nameddateformat{monandday}{b\ e} % Jan 5
% Custom command for using memoir's \pagenote command
\newcommand{\mypagenote}[2]{%
\small
\expanded{\noexpand\pagenote[\noexpand\dateinnote{\setdate\unexpanded{#1}}]}{#2}%
}
\newcommand{\dateinnote}[1]{\makebox[0.6in][l]{#1}}
\makeatletter
\let\texdmon\texd@mon\let\texdrdom\texd@rdom
\newcommand{\setdate}{\texdmon=\the\texd@mon\texdrdom=\the\texd@rdom\space}
\makeatother
% end preamble * * * * * * * * * * * * * *
\begin{document}
\title{A Passage for Each Day of the Year}
\date{\strut}
\maketitle
\initdate{2024}{12}{31} % initializes texdate's date
\vspace{-80pt}
%-- Jan01 ---------------------------------------------------------------------
\advancebydays{1} \begin{center} \Large \printfdate{monthandday}\par \end{center} \par\noindent
I do not doubt she had a choice pleasure in exhibiting what she called her
self-command, and her firmness, and her strength of mind, and her common sense
and the whole diabolical catalogue of her unamiable qualities, on such an
occasion.
\mypagenote{\printfdate{monandday}}{David Copperfield recalling his
interaction with the vile Miss Murdstone upon returning from school to his home
upon the death of his mother.}
\bigskip
%-- Jan02 ---------------------------------------------------------------------
\advancebydays{1} \begin{center} \Large \printfdate{monthandday}\par \end{center} \par\noindent
In the hierarchy of post-Civil War times was Mrs.\ Hamilton Fish, whose husband
became Secretary of State in Grant's Cabinet; she belonged to what was called
``the Faubourg St.\ Germain set'' of New York--families entrenched since
Colonial days in wealth and civic eminence, who could afford to live in
tarnished magnificence on outmoded Second Avenue, while ``swells'' eddied like
moths toward the luster of Fifth Avenue.
\mypagenote{\printfdate{monandday}}{Dixon Wecter, \emph{The Saga of
American Society: A Record of Social Aspiration, 1607-1937}, New York: Charles
Scribner's Sons, 1937.}
\bigskip
\advancebydays{120}
X\mypagenote{\printfdate{monandday}}{Something}
\advancebydays{120}
X\mypagenote{\printfdate{monandday}}{Something}
\printpagenotes
\end{document}
注意格式说明的变化,B\ e
因此b\ e
月份和日期之间会出现一个空格。
答案2
如果使用datenumber
,处理扩展问题会更直接(至少对我来说)。缺点是缺少用于生成短月份名称的现成宏。在这里,我修改了用于长月份名称的方法,采取了一些捷径,使代码特定于此用法和英语。更灵活的设施将很容易实现,但需要更多的代码。
文档中提供了两个宏供使用:
\passage[<integer>]
开始新条目。如果使用可选参数,日期将为<integer>
前一个日期之后(或之前)的几天。如果<integer>
省略,则1
使用的值,即第二天。- 这将创建标题并适当地设置日期计数器,因此应该可以直接在一个地方调整整个文档的格式。
\mypagenote{<text>}
<text>
使用当前日期为标签和正文创建页面注释。- 如果需要,可以提供一个可选参数来覆盖标签的默认内容。根据您的描述,这似乎没有必要,但添加起来很容易。
expl3
之所以使用,是因为它可以将扩展问题简化为语法问题。如果你不熟悉它,它看起来会很陌生。但一旦你看透了它那绿色的虫眼怪物的外表,它就是一个非常友好的外星人。
代码:
\documentclass[12pt]{memoir}
% ateb: https://tex.stackexchange.com/a/714287/ addaswyd o gwestiwn Paul Dulaney: https://tex.stackexchange.com/q/714093/
% BEGIN preamble * * * * * * * * * * * * *
\usepackage{datenumber}
% The following is required in the preamble for using memoir's pagenote (endnote) capability
\makepagenote
\renewcommand*{\idtextinnotes}[1]{#1\space} % remove square brackets surrounding note id
\renewcommand{\prenoteinnotes}{\par\noindent\hangindent0.6in}
\renewcommand\prenotetext{\hskip-3.52pt}
\ExplSyntaxOn
\cs_new_protected:Nn \pedy_mypagenote:nn
{
\small
\pagenote [ \hbox to 0.6in {\setdatebynumber { #1 } \myshortmonthname { \thedatemonth } ~ \thedateday \hfill } ]{ \small #2 }
}
\cs_generate_variant:Nn \pedy_mypagenote:nn { en }
\cs_new_protected:Npn \mypagenote #1
{
\pedy_mypagenote:en { \thedatenumber } { #1 }
}
% modified from datenumberenglish.ldf
\cs_new_protected_nopar:Nn \pedy_shortmonthnameenglish:n
{
\int_case:nn { #1 }
{
{ 1 } { Jan }
{ 2 } { Feb }
{ 3 } { Mar }
{ 4 } { Apr }
{ 5 } { May }
{ 6 } { Jun }
{ 7 } { Jul }
{ 8 } { Aug }
{ 9 } { Sep }
{ 10 } { Oct }
{ 11 } { Nov }
{ 12 } { Dec }
}
}
\cs_new_eq:NN \myshortmonthname \pedy_shortmonthnameenglish:n
\ExplSyntaxOff
\NewDocumentCommand \passage { O {1} }
{%
\addtocounter{datenumber}{#1}%
\setdatebynumber{\thedatenumber}%
\begin{center}
\Large
\datemonthname{} \thedateday{}
\end{center}
\par\noindent
}
% END preamble * * * * * * * * * * * * * *
\begin{document}
\title{A Passage for Each Day of the Year}
\date{\strut}
\maketitle
\setdatenumber{2024}{12}{31}
\vspace{-80pt}
%-- Jan01 ---------------------------------------------------------------------
\passage % or \passage[<n>] to advance by <n> days
I do not doubt she had a choice pleasure in exhibiting what she called her
self-command, and her firmness, and her strength of mind, and her common sense
and the whole diabolical catalogue of her unamiable qualities, on such an
occasion.
\mypagenote{%
David Copperfield recalling his
interaction with the vile Miss Murdstone upon returning from school to his home
upon the death of his mother.%
}
\bigskip
%-- Jan02 ---------------------------------------------------------------------
\passage
In the hierarchy of post-Civil War times was Mrs.\ Hamilton Fish, whose husband
became Secretary of State in Grant's Cabinet; she belonged to what was called
``the Faubourg St.\ Germain set'' of New York--families entrenched since
Colonial days in wealth and civic eminence, who could afford to live in
tarnished magnificence on outmoded Second Avenue, while ``swells'' eddied like
moths toward the luster of Fifth Avenue.
\mypagenote{%
Dixon Wecter, \emph{The Saga of
American Society: A Record of Social Aspiration, 1607-1937}, New York: Charles
Scribner's Sons, 1937.%
}
\bigskip
%-- Jan10
\passage[8]
Something later.
\mypagenote{%
Test skipping dates works.%
}
\printpagenotes
\end{document}