在多页上显示 tikz 日历以实现每年的每周计划日志

在多页上显示 tikz 日历以实现每年的每周计划日志

我正在编写自己的班级日志,以便整理我全年与学生的工作。不幸的是,我在执行每周计划时遇到了麻烦:

  1. 因为它会覆盖全年,所以我只想在两页上显示一周。所以我需要在星期三之后中断。但我无法停止日历并强制它在下一页继续。并重复几次直到年底......在接下来的 MWE 中,我在星期三之后中断,以便在星期四开始新的日历。理想情况下,我不想手动进行这 52 次中断......

  2. 周六和周日不需要网格,占用的空间也小得多,因此它们应该一个接一个地显示。剩余的空间将用于专用的“备忘录”空间。但该选项day list downward在已开始的日历中无效。我必须在第三个日历中计算它们……

  3. 星期一必须指出相应线路的时间表。我已经写了星期一应该是什么,但我无法让它发挥作用。

  4. 在右侧页面的右下角(星期日下方)应该有一个四分之一圆,以便在周末时将其剪下来。就像书签一样。我还没有解决这个问题。

以下是我所写的内容:

\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{calendar}
\pagestyle{empty}

\usepackage{colortbl}
\usepackage[margin=1cm]{geometry}

%%To modify width of the days easier
\newlength{\WeekWidth}
\setlength{\WeekWidth}{6cm}

%%To define start and end of the calendar easier
\def\firstday{2022-09-01}
\def\lastday{2022-09-30}

%%To display the week numbers. I want to restart it after christmas holiday but I'll achieve that later by simply \setcounter for such special dates
\newcounter{SchoolWeek}
\setcounter{SchoolWeek}{0}

%%Command to make the cells for a "normal" working day aka (Tuesday and Friday)
\newcommand\weekday{%
    \renewcommand{\arraystretch}{5.6}
    \begin{tabular}{|p{\WeekWidth}|}
        \hline
        \rowcolor{gray!20}\raisebox{30pt}{\centering \%wt - \%d0/\%m0/\%y0} \\[-1.5cm]
        \hline
        \hline
        \rowcolor{white}\\ \hline
        \\ \hline\hline
        \\ \hline
        \\ \hline
        \\ \hline
        \rowcolor{gray!20}\\ \hline
        \\ \hline
        \\ \hline
        \\ \hline\hline
        \rowcolor{gray!20}\\ \hline
    \end{tabular}
}

%%Command for Monday. As the first day of the week, it begins with a title - week number and the schedule of each cell for the next days
%% --- Currently, there is a node in the calendar code  for the title. It doesn't match with a two column cells for the schedule time....
%% --- I'm not able to achieve a two column cells for monday with the node. So i don't use it.
\newcommand\monday{%
    \renewcommand{\arraystretch}{5.6}
    \begin{tabular}{|p{1cm}|p{\WeekWidth}|}
        \hline
                                                            &\rowcolor{gray!20}\raisebox{30pt}{\centering \%wt - \%d0/\%m0/\%y0} \\[-1.5cm]
        \hline\hline
        \parbox{1cm}{8h25\\ 1\\ 9h15}                       &\rowcolor{white}\\ \hline
        \parbox{1cm}{9h20\\ 2\\ 10h05}                      &\\ \hline\hline
        \parbox{1cm}{10h20\\ 3\\ 11h05}                     &\\ \hline
        \parbox{1cm}{11h10\\ 4\\ 11h55}                     &\\ \hline
        \parbox{1cm}{12h00\\ 5\\ 12h45}                     &\\ \hline
        \rowcolor{gray!20} \parbox{1cm}{12h50\\ 6\\ 13h35} &\\ \hline
        \parbox{1cm}{13h40\\ 7\\ 14h25}                     &\\ \hline
        \parbox{1cm}{14h30\\ 8\\ 15h15}                     &\\ \hline
        \parbox{1cm}{15h20\\ 9\\ 16h05}                     &\\ \hline\hline
                                                            & \rowcolor{gray!20}\\ \hline
    \end{tabular}
}

\newcommand\wednesday{%
    \renewcommand{\arraystretch}{5.6}
    \begin{tabular}{|p{\WeekWidth}|}
        \hline
        \rowcolor{gray!20}\raisebox{30pt}{\centering \%wt - \%d0/\%m0/\%y0} \\[-1.5cm]
        \hline
        \hline
        \rowcolor{white}\\ \hline
        \\ \hline\hline
        \\ \hline
        \\ \hline
        \\ \hline\hline
        \rowcolor{gray!20}\rule{0pt}{11.14cm}\\ \hline
    \end{tabular}
}

%%Command to make special cells for saturday
\newcommand\saturday{%
    \renewcommand{\arraystretch}{5.6}
    \begin{tabular}{|p{\WeekWidth}|}
        \hline
        \rowcolor{red!50!gray!20!white}\raisebox{30pt}{\centering \%wt - \%d0/\%m0/\%y0} \\[-1.5cm]
        \hline
        \hline
        \rowcolor{white}\rule{0pt}{9.4cm} \\
        \hline
    \end{tabular}
}

%%Command to make special cells for sunrday
\newcommand\sunday{%
    \renewcommand{\arraystretch}{5.6}
    \begin{tabular}{|p{\WeekWidth}|}
        \hline
        \rowcolor{red!50!gray!20!white}\raisebox{30pt}{\centering \%wt - \%d0/\%m0/\%y0} \\[-1.5cm]
        \hline
        \hline
        \rowcolor{white}\rule{0pt}{10cm} \\
        \hline
        \hline
        \parbox{\WeekWidth}{\textbf{\large Mémo :}\\
            \rule{0pt}{2.4cm}}\\\hline
    \end{tabular}
}


\begin{document}
%%% Expected code but it doesn't break automatically (and dimension too large, of course)
\def\firstday{2022-09-05}
\def\lastday{2022-09-11}
\begin{tikzpicture}
    \calendar (cal)
    [dates=\firstday to \lastday,
    day list right,
    day xshift={\WeekWidth+0.5cm},
    day text={\weekday}]
    %%% To write the text "Semaine XX - 1st date to last date 
    %%%       --- I've problem to access the last day of the week... aka sunday
    if (Monday) {\node at (-1.6,13.5) [anchor=north] {\stepcounter{SchoolWeek} \bfseries \Large \raisebox{-5pt}{\rule{3pt}{20pt}} Semaine \arabic{SchoolWeek} - \%d0/\%m0/\%y0 au \%d0/\%m0/\%y0};}
    %%% To cut the noon of Wednesday
    %%%      --- I've inserted a try-and-see space left to align Wednesday with Tuesday
    if (Wednesday) [day text={\wednesday}];
%   %%% To write "Important cette semaine : ..............."
%   %%%        --- I don't have problem here
%   if (Thursday) {\node at (1.2,13.5) [anchor=north] {\bfseries \large Important cette semaine : \makebox[10cm]{\em\dotfill}};}
%   %%% To write special column for weekend.
%   %%%     ---- Saturday is a simple box and
%   %%%     ---- Sunday should be followed by a small box : "Mémo :"
%   %%%     ---- " day list downward" option does not work
%   if (Saturday) [day list downward, day text={\saturday}];
%   if (Sunday) [day list downward, day text={\sunday}];
\end{tikzpicture}



%%%Expected left page but dates written manually and monday do not have the first column with the schedule time.
\def\firstday{2022-09-12}
\def\lastday{2022-09-14}
\begin{tikzpicture}
    \calendar (cal)
    [dates=\firstday to \lastday,
    day list right,
    day xshift={\WeekWidth+0.5cm},
    day text={\weekday}]
    %%% To write the text "Semaine XX - 1st date to last date 
    %%%       --- I've problem to access the last day of the week... aka sunday
    if (Monday) {\node at (-1.6,13.5) [anchor=north] {\stepcounter{SchoolWeek} \bfseries \Large \raisebox{-5pt}{\rule{3pt}{20pt}} Semaine \arabic{SchoolWeek} - \%d0/\%m0/\%y0 au \%d0/\%m0/\%y0};}
    %%% To cut the noon of Wednesday
    %%%      --- I've inserted a try-and-see space left to align Wednesday with Tuesday
    if (Wednesday) [day text={\wednesday}];
    %%% To write "Important cette semaine : ..............."
    %%%        --- I don't have problem here
%   if (Thursday) {\node at (1.2,13.5) [anchor=north] {\bfseries \large Important cette semaine : \makebox[10cm]{\em\dotfill}};}
%   %%% To write special column for weekend.
%   %%%     ---- Saturday is a simple box and
%   %%%     ---- Sunday should be followed by a small box : "Mémo :"
%   %%%     ---- " day list downward" option does not work
%   if (Saturday) [day list downward, day text={\saturday}];
%   if (Sunday) [day list downward, day text={\sunday}];
\end{tikzpicture}


%%%Expected right page for Thursday and Friday
%%%Expected left page but dates written manually
\def\firstday{2022-09-15}
\def\lastday{2022-09-16}
\begin{tikzpicture}
    \calendar (cal)
    [dates=\firstday to \lastday,
    day list right,
    day xshift={\WeekWidth+0.5cm},
    day text={\weekday}]
    %%% To write the text "Semaine XX - 1st date to last date 
    %%%       --- I've problem to access the last day of the week... aka sunday
    if (Monday) {\node at (-1.6,13.5) [anchor=north] {\stepcounter{SchoolWeek} \bfseries \Large \raisebox{-5pt}{\rule{3pt}{20pt}} Semaine \arabic{SchoolWeek} - \%d0/\%m0/\%y0 au \%d0/\%m0/\%y0};}
    %%% To cut the noon of Wednesday
    %%%      --- I've inserted a try-and-see space left to align Wednesday with Tuesday
    if (Wednesday) [day text={\wednesday}];
    %%% To write "Important cette semaine : ..............."
    %%%        --- I don't have problem here
    if (Thursday) {\node at (1.2,13.5) [anchor=north] {\bfseries \large Important cette semaine : \makebox[10cm]{\em\dotfill}};}
    %   %%% To write special column for weekend.
    %   %%%     ---- Saturday is a simple box and
    %   %%%     ---- Sunday should be followed by a small box : "Mémo :"
    %   %%%     ---- " day list downward" option does not work
    %   if (Saturday) [day list downward, day text={\saturday}];
    %   if (Sunday) [day list downward, day text={\sunday}];
\end{tikzpicture}

%%%Expected weekend. It should be aside of friday
\def\firstday{2022-09-17}
\def\lastday{2022-09-18}
\begin{tikzpicture}
    \calendar (cal)
    [dates=\firstday to \lastday,
    day list downward,  % <----  This line is modified
    day xshift={\WeekWidth+0.5cm},
    day yshift={12.9cm}, % <--- This line is added to shift Sunday. Otherwise it'll erase Saturday
    day text={\saturday}] % <----- This line is modified, without, i've weekday boxes although it's weekend....
    %%% To write the text "Semaine XX - 1st date to last date 
    %%%       --- I've problem to access the last day of the week... aka sunday
%   if (Monday) {\node at (-1.6,13.5) [anchor=north] {\stepcounter{SchoolWeek} \bfseries \Large \raisebox{-5pt}{\rule{3pt}{20pt}} Semaine \arabic{SchoolWeek} - \%d0/\%m0/\%y0 au \%d0/\%m0/\%y0};}
    %%% To cut the noon of Wednesday
    %%%      --- I've inserted a try-and-see space left to align Wednesday with Tuesday
%   if (Wednesday) [day text={\wednesday}];
    %%% To write "Important cette semaine : ..............."
    %%%        --- I don't have problem here
    %   if (Thursday) {\node at (1.2,13.5) [anchor=north] {\bfseries \large Important cette semaine : \makebox[10cm]{\em\dotfill}};}
    %%% To write special column for weekend.
    %%%     ---- Saturday is a simple box and
    %%%     ---- Sunday should be followed by a small box : "Mémo :"
    %%%     ---- " day list downward" option does not work
%   if (Saturday) [day text={\saturday}];
    if (Sunday) [day text={\sunday}];
\end{tikzpicture}
\end{document}

以下是最终项目的草稿: 输出项目

这个问题似乎是一个非常具体的问题,我知道它不会触及任何人或接近任何人。但由于它涵盖了几个要点,我相信有人会对如何处理一个或另一个问题感兴趣。特别是,我从未见过 tikz-calendar 的一些多页日历示例,在我看来这似乎是最新的。

如果您能指出一个问题或建议我改进代码的方法,我将非常高兴。我看过 pgf 手册,但还没有发现对我有用的内容。

感谢您的任何帮助。

答案1

第一次尝试满足您的要求。

重要的:

  • 每列/天必须具有相同的高度。最后一列(星期六、星期日和备忘录)可能没有完全对齐,因为该列没有与其他列相同的字段。

  • 星期六、星期日和备忘录字段在星期六一起创建。

  • 如果您不想在星期五和最后一列之间留空隙,请注释掉相应的内容hspace(参见代码中的注释)。这同样适用于文本(Piroooh 班级杂志 (2022)) 位于右边距。

  • 我建议选择从周一开始到周日结束的时间范围。其他开始和结束日期也是可以的,但设计当然不是完美的。但如果您需要,请自己尝试一下。

% start and end date
\def\firstday{2022-09-12}
\def\lastday{2022-10-09}

% week number
\newcounter{schoolWeek}
\setcounter{schoolWeek}{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{scrbook}
\renewcommand*{\pagemark}{}% remove page number

% page margin
\usepackage[margin=.9cm]{geometry}

% french week day names
\usepackage[french]{babel}
\usepackage[french]{translator}

% calendar and bookmark
\usepackage{tikz}
\usetikzlibrary{calendar}

% rowcolor
\usepackage{colortbl}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% column width
\newlength{\columhWidth}
\setlength{\columhWidth}{32.75ex}

% column height
\newlength{\rowHeight}
\setlength{\rowHeight}{12.5ex}

% time slot width
\newlength{\timeSlotWidth}
\setlength{\timeSlotWidth}{6.5ex}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% colors
\colorlet{weekdayBackgroundColor}{gray!20}
\colorlet{weekendBackgroundColor}{red!50!gray!20!white}
\colorlet{freetimeBackgroundColor}{gray!20}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% styling of a time slot
\newcounter{timeSlotCounter}
\newcommand\timeSlot[2]{%
    \stepcounter{timeSlotCounter}%
    {%
        \centering\large\bfseries%
        \vspace{.85ex}
        #1\\[1ex]%
        {\Large\arabic{timeSlotCounter}}\\[1ex]%
        #2%
    }%
}

% styling of a column title
\newcommand\columnTitle[1]{%
    \vspace{.25ex}%
    {%
        \large\bfseries #1%
    }%
    \vspace{1.25ex}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\timeslots{%
    \begin{tabular}{|>{\centering\arraybackslash} p{\timeSlotWidth}|}
        \hline
        \vspace{.25ex}%
        \
        \vspace{1.25ex}%
        \\
        \hline
        \timeSlot{ 8:25}{ 9:15}\\[\rowHeight]
        \hline
        \timeSlot{ 9:20}{10:05}\\[\rowHeight]
        \hline
        \timeSlot{10:20}{11:05}\\[\rowHeight]
        \hline
        \timeSlot{11:10}{11:55}\\[\rowHeight]
        \hline
        \timeSlot{12:00}{12:45}\\[\rowHeight]
        \hline
        \timeSlot{\quad}{\quad}\\[\rowHeight]
        \hline
        \timeSlot{13:40}{14:25}\\[\rowHeight]
        \hline
        \timeSlot{14:30}{15:15}\\[\rowHeight]
        \hline
        \timeSlot{15:20}{16:05}\\[\rowHeight]
        \hline
        \\[\rowHeight]
        \hline
    \end{tabular}%
    \setcounter{timeSlotCounter}{0}%
}

\newcommand\weekday{%
    \begin{tabular}{>{\centering\arraybackslash} p{\columhWidth}|}
        \hline
        \rowcolor{weekdayBackgroundColor}%
        \columnTitle{\%wt - \%d0/\%m0/\%y0}\\
        \hline
        \rowcolor{white}%
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
    \end{tabular}%
}

\newcommand\wednesday{%
    \begin{tabular}{>{\centering\arraybackslash} p{\columhWidth}|}
        \hline
        \rowcolor{weekdayBackgroundColor}%
        \columnTitle{\%wt - \%d0/\%m0/\%y0}\\
        \hline
        \rowcolor{white}%
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
    \end{tabular}%
}

\newcommand\thursday{%
    \begin{tabular}{|>{\centering\arraybackslash} p{\columhWidth}|}
        \hline
        \rowcolor{weekdayBackgroundColor}%
        \columnTitle{\%wt - \%d0/\%m0/\%y0}\\
        \hline
        \rowcolor{white}%
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \\[\rowHeight] \hline
        \rowcolor{freetimeBackgroundColor}%
        \\[\rowHeight] \hline
    \end{tabular}%
}

\newcommand\saturdaySundayMemo{%
    \begin{tabular}{|>{\centering\arraybackslash} p{\columhWidth}|}
        \hline
        \rowcolor{weekendBackgroundColor}%
        \columnTitle{\%wt - \%d0/\%m0/\%y0}\\
        \hline
        \rowcolor{white}%
        \\[\rowHeight]
        \\[\rowHeight]
        \\[\rowHeight]
        \\[\rowHeight]
        \\
        \hline\hline
        \rowcolor{weekendBackgroundColor}%
        \columnTitle{\pgfcalendarweekdayname{6} - \printSundayDate{\%y0-\%m0-\%d0}}\\
        \hline
        \rowcolor{white}%
        \\[\rowHeight]
        \\[\rowHeight]
        \\[\rowHeight]
        \\[\rowHeight]
        \\
        \hline\hline
        \multicolumn{1}{|l|}{\parbox{2cm}{\ \\[.5ex]\Large\bfseries Mémo:}}
        \\[14.45ex]
        \hline
    \end{tabular}%
}

\newcommand*{\printSundayDate}[1]{%
    % determine julian day number
    \newcount\julianday%
    \pgfcalendardatetojulian{\%y0-\%m0-\%d0}{\julianday}%
    % compute week day (monday=0, ..., sunday=6)
    \newcount\julianweekday%
    \pgfcalendarjuliantoweekday{\julianday}{\julianweekday}%
    % compute value to add
    \newcount\toAdd%
    \pgfmathsetcount{\toAdd}{-\julianweekday + 6}%
    % compute date of sunday
    \pgfcalendardatetojulian{\%y0-\%m0-\%d0+\toAdd}{\julianday}%
    \pgfcalendarjuliantodate{\julianday}{\thisyear}{\thismonth}{\thisday}%
    % print date
    \thisday/\thismonth/\thisyear%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\let\%=\pgfcalendarshorthand%
\pgfcalendar{cal}{\firstday}{\lastday}{%
    \ifdate{Monday,equals=\firstday}{%
        \newpage
        % heading
        {%
            \Large\bfseries
            \raisebox{-5pt}{\rule{3pt}{20pt}}
            Semaine~\arabic{schoolWeek} - \%d0/\%m0/\%y0 au \printSundayDate{\%y0-\%m0-\%d0}
        }\\[.25cm]
        % time slots
        \timeslots%
    }{}%
    \ifdate{Thursday}{%
        \newpage
        \begin{tikzpicture}[remember picture, overlay]
            % bookmark circle with school week
            \draw[dashed, gray] (current page.south east) circle (1.5cm);
            \node[xshift=-.6cm, yshift=.6cm] at (current page.south east) [font=\Large, text=gray] {\arabic{schoolWeek}};
            % title on the right side
            \node[xshift=-1.15cm, rotate=-90] at (current page.east) [font=\Huge, text=gray] {Journal de Classe de Piroooh (\%y0)};
        \end{tikzpicture}%
        \stepcounter{schoolWeek}
        % heading
        {%
            \Large\bfseries
            Important cette semaine: \makebox[10.5cm]{\em\dotfill}
            \raisebox{-5pt}{\color{white}\rule{3pt}{20pt}}% to get the same height as Semaine on the left page
        }\\[.25cm]
        % column
        \thursday%
    }{%
        \ifdate{Wednesday}{%
            % column
            \wednesday%
        }{%
            \ifdate{Sunday}{}{%
                \ifdate{Saturday}{%
                    % on saturday we include also sunday and the memo box
                    \hspace*{.25cm}% remove this if you want no space between friday and the last column
                    \saturdaySundayMemo%
                }{%
                    % column of monday, tuesday and friday
                    \weekday%
                }%
            }%
        }%
    }%
}
\end{document}

两页结果。

相关内容