使用 calendar.sty 和循环创建年度训练日志

使用 calendar.sty 和循环创建年度训练日志

我对 LaTeX 还很陌生,只是在尝试学习新东西。所以我想创建一个 PDF,可以将其打印成一本书来记录我的训练,同时还能用笔写一些东西。它应该看起来像这样:训练日志仅针对所有月份,然后针对该月份内的周数进行单独处理。我创建的示例没有使用循环,但我觉得 calendar.sty 与循环包有某种交互。

这是不起作用的代码:

\documentclass[10pt]{article} 
\usepackage{calendar} 
\usepackage{parallel,enumitem}
\usepackage[landscape, a4paper, margin=1cm]{geometry} 
\usepackage{tikz}
\usepackage{pgffor} 
\usepackage{forloop} 
\usepackage{pgfmath}
%\usepackage{palatino} % Use the Palatino font

\begin{document}

\def\MonthArr{ % array for "index", "monthname", "blankdays" and "days of month"
{{"1","January","0","31"}},
{{"2","February","3","29"}},
%{{"3","March","4","31"}},
%{{"4","April","0","30"}},
%{{"5","May","2","31"}},
%{{"6","June","4","30"}},
%{{"7","July","0","31"}},
%{{"8","August","3","31"}},
%{{"9","September","1","30"}},
%{{"10","October","1","31"}},
%{{"11","November","3","30"}},
%{{"12","December","1","31"}}
}
\foreach \Month in \MonthArr {
  
    \StartingDayNumber=2 

    \begin{center}
       \textsc{\LARGE \pgfmathparse{\Month[2]}\pgfmathresult}\\ % Month
        \textsc{\large 2024} % Year
    \end{center}

    \begin{calendar}{\textwidth} 

    \newcounter{x} 
    \forloop{x}{0}{\value{x}<\pgfmathparse{\Month[2]}\pgfmathresult}{
        \BlankDay
    } 

    \setcounter{calendardate}{1} % Start the date counter at 1
    \newcounter{days}{0}
    \def\DayArr{
    {{"Level 8","easy non-crimp boulders of new set \eventskip chinups \eventskip stretching"}}, % day 1
    {{"Level 8","new set \dayheader{Notes:}{}"}}, % day 2
    {{"~","\vspace{2.5cm}"}},% day 3
    {{"Hangboard","\dayheader{Notes:}{}"}},% day 4
    {{"Strength","weighted Pullups \eventskip Deadlifts \eventskip Benchpulls \eventskip Flys \eventskip Muscleups"}},% day 5
    {{"~","\vspace{2.5cm}"}},% day 6
    {{"Kilterboard","Notes:"}},% day 7
    {{"~","\vspace{2.5cm}"}},% day 8
    {{"~","\vspace{2.5cm}"}},% day 9
    {{"~","\vspace{2.5cm}"}},% day 10
    {{"~","\vspace{2.5cm}"}},% day 11
    {{"~","\vspace{2.5cm}"}},% day 12
    {{"~","\vspace{2.5cm}"}},% day 13
    {{"~","\vspace{2.5cm}"}},% day 14
    {{"~","\vspace{2.5cm}"}},% day 15
    {{"~","\vspace{2.5cm}"}},% day 16
    {{"~","\vspace{2.5cm}"}},% day 17
    {{"~","\vspace{2.5cm}"}},% day 18
    {{"~","\vspace{2.5cm}"}},% day 19
    {{"~","\vspace{2.5cm}"}},% day 20
    {{"~","\vspace{2.5cm}"}},% day 21
    {{"~","\vspace{2.5cm}"}},% day 22
    {{"~","\vspace{2.5cm}"}},% day 23
    {{"~","\vspace{2.5cm}"}},% day 24
    {{"~","\vspace{2.5cm}"}},% day 25
    {{"~","\vspace{2.5cm}"}},% day 26
    {{"~","\vspace{2.5cm}"}},% day 27
    {{"~","\vspace{2.5cm}"}},% day 28
    {{"~","\vspace{2.5cm}"}},% day 29
    {{"~","\vspace{2.5cm}"}},% day 30
    %{{"~","\vspace{2.5cm}"}},% day 31
    %{{"~","\vspace{2.5cm}"}},% day 32
    %{{"~","\vspace{2.5cm}"}},% day 33
    %{{"~","\vspace{2.5cm}"}},% day 34
    %{{"~","\vspace{2.5cm}"}},% day 34
    %{{"~","\vspace{2.5cm}"}},% day 35
    %{{"~","\vspace{2.5cm}"}},% day 36
    %{{"~","\vspace{2.5cm}"}},% day 37
    }
    \foreach [count=\i] \dayarr in \DayArr { %body
            \day{\pgfmathparse{\dayarr[0]}\pgfmathresult}{\pgfmathparse{\dayarr[2]}\pgfmathresult}
            \ifnum \i=\pgfmathparse{\Month[3]}\pgfmathresult
                \breakforeach
            \fi    
            %\breakforeach
    }
    \finishCalendar
    \end{calendar}
    \newpage
} % closing bracket of the BIG foreach-loop
\end{document}

这是错误:

  1. 未定义控制序列。\pgfmath@catcodes ...`\|=12 \catcode `\&=12 \let " \pgfmath@char@quote
  2. 不完整 \iffalse;第 131 行之后的所有文本都被忽略。
                \fi 
<*> template.tex 

我目前使用 Overleaf 来创建它,当我注释掉月初空白天数的 forloop 时出现的错误消息是:

  1. 额外},或者被遗忘的\endgroup。
  2. 缺少插入的 \endgroup。
  3. 缺少} 插入。
  4. 缺失数字,视为零。
  5. 缺少插入 \cr。
  6. 缺少{ 插入。
  7. 放错了 \cr。
  8. 缺少插入 \cr。

如果我注释掉内部循环,我会得到一个 pdf,但 calendar.sty 需要 \day 命令来用天数填充月度布局,而该循环不起作用。此外,出于某种原因,我得到的所有错误都被推送到大 for 循环的结束括号中。

我认为它与 calendar.sty 内的控制结构有关。遗憾的是,我找不到足够的文档来了解为什么会发生这种情况... 任何帮助都值得感激 :)

相关内容