抱歉标题太模糊,我不知道如何正确表述这个问题。
我想创建一个变量来跟踪我在课堂上讲课时完成课程笔记某一部分的日期。应该允许该变量在同一文档中多次更改,因此我不能使用\newcommand
或类似的东西,因为我希望它根据内容的覆盖时间出现在目录和每页的页眉中。
我甚至不知道如何开始。以下是一些预代码:
...
\newvariable{\datestamp} % This is the command I'm looking for.
\pagestyle{fancy}
\chead{\small{\datestamp}} % Variable is printed at the center of the header.
...
\begin{document}
\set{\datestamp}{Jan. 20} % From now until the next call of \datestamp the header will display "Jan. 20".
\section[Title of section 1 (current \datestamp - last \datestamp before following lecture)]{Title of section 1}
% The title of the section appears in the document without the variable but shows up with the variable in the TOC.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur est lectus, viverra nec felis at, tincidunt tincidunt tortor.
Mauris quis bibendum metus. Curabitur nulla arcu, tempus sit amet ultricies id, sodales non sapien.
Ut turpis nisi, tincidunt at viverra non, tincidunt a dolor.
In et urna elementum, elementum metus nec, dapibus ex.
Aenean ultrices arcu vitae felis vehicula, laoreet vestibulum mi iaculis.
Mauris nec ultricies neque, quis dapibus mi.
Quisque pharetra purus non lectus mollis, sit amet tempor tellus mattis.
Nunc porttitor porta nunc, non maximus lorem fringilla vitae.
Cras neque augue, interdum quis neque at, tristique pretium quam. Vivamus convallis venenatis accumsan.
\set{\datestamp}{Jan. 22} % Lecture is over, but the section is not. Header displays "Jan. 22".
Cras quis dapibus sem. Maecenas at mollis nisl, ac aliquet massa.
Maecenas eu erat libero. Nunc pharetra rhoncus augue, sit amet venenatis justo finibus nec.
Praesent ac velit ipsum. Proin aliquam mauris sit amet interdum feugiat.
Suspendisse gravida, lacus ut gravida pharetra, enim dolor tincidunt justo, vitae suscipit massa justo ac diam.
\section[Title of section 2 (current \datestamp - last \datestamp before following lecture)]{Title of section 2}
Cras mollis, risus id congue varius, quam quam luctus dui, et posuere neque magna et magna.
In nec tortor est. Ut ut diam rutrum, feugiat elit sed, bibendum arcu. ...
\end{document}
在目录中我们会看到:
1. Title of section 1 (Jan. 20 - Jan. 22)
2. Title of section 2 (Jan. 22 - ... )
3. ...
现在我很高兴能弄清楚如何让它\datestamp
发挥作用。