受递归编程影响的页码

受递归编程影响的页码

我问了这个问题如何用latex编写递归程序并得到了@JosephWright 的以下出色回答

\documentclass{article}
\usepackage{advdate}

% Set the first practice date
\ThisDay{7}
\ThisMonth{2}
\ThisYear{2019}

%... the number of days between lectures
\newcommand*{\lecturegap}{7}

\makeatletter
\newcounter{holiday}
\newcommand*\addholiday[3]{%
  \stepcounter{holiday}%
  \@namedef{holiday\arabic{holiday}}{%
    \def\holidayDay{#1}%
    \def\holidayMonth{#2}%
    \def\holidayYear{#3}%
  }%
}
\makeatother
\newcommand*{\holidayDay}{0}
\newcommand*{\holidayMonth}{0}
\newcommand*{\holidayYear}{0}
\addholiday{3}{3}{2019}  % ter Carnaval
\addholiday{18}{4}{2019} % qui Atividade complementar
\addholiday{19}{4}{2019} % sex Santa
\addholiday{21}{4}{2019} % dom Tiradentes/Páscoa
\addholiday{1}{5}{2019}  % qua Trabalhador
\addholiday{19}{6}{2019} % qua Aniv. Rib. Preto

\newif\ifholiday
\newcommand*{\groupA}{}
\makeatletter
\newcommand*{\nextprac}{%
  \holidayfalse
  \count0=1 %
  \loop
    \ifnum\count0>\value{holiday}\else
      \@nameuse{holiday\number\count0 }%
      \ifnum 0%
        \ifnum\holidayDay=\day1\else0\fi
        \ifnum\holidayMonth=\month1\else0\fi
        \ifnum\holidayYear=\year1\else0\fi
        =111 %
        \holidaytrue
        \count0=\value{holiday}%
        \else
      \fi
    \advance\count0 by 1 %
  \repeat
  \ifholiday
    \AdvanceDate[\lecturegap]%
    \expandafter\nextprac
  \else
    \ifx\groupA\empty
      \edef\groupA{%
        {\day=\the\day\month=\the\month\year=\the\year\relax\noexpand\today}}%
      \expandafter\expandafter\expandafter\nextprac
    \else
      \AdvanceDate[\lecturegap]%
      \section*{\groupA\space$\parallel$ \today}%
      \def\groupA{}%
      \AdvanceDate[\lecturegap]%
    \fi
  \fi
}

\begin{document}

  \nextprac
  Practice one

  \nextprac
  Practice two

  \nextprac
  Practice three

  \nextprac
  Practice four

  \nextprac
  Practice five

  \nextprac
  Practice six

  \nextprac
  Practice seven

  \nextprac
  Practice eight

  \nextprac
  Practice nine

  \nextprac
  Practice ten

\end{document}

然而几个月后,我意识到这个代码会影响页码。但我不明白它是如何受到影响的,也不知道如何修复它。

我唯一意识到的是页码变成了\addholiday命令创建的假期的确切数量。

我的问题是:如何在不保留当前代码的情况下恢复页码?

答案1

您在野外使用\count0包含页码的内容。

\count0将所有出现的改为\@tempcnta

相关内容