使用 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 中的控制結構有關。遺憾的是,我無法找到足夠的文件來理解為什麼會發生這種情況...任何幫助表示讚賞:)

相關內容