2

I'm writing my own class logbook to organize my work with students along the year. Unfortunately, I encountered troubles to perform a weekly schedule :

  1. Because it'll cover all the year, I want to display only one week over two pages. So I need breakout just afterwards wednesday. But I can't stop the calendar and force it to continue on the next page. And repeating several times untill the end of the year... In the following MWE, i've interrupt after wednesday to begin a new calendar on thursday. Ideally, i do not want make those 52 breaks manually...

  2. Saturday and Sunday do not require grid and take much less space hence they should be displayed one above the other. The remaining space will be accorded for a dedicated "Mémo" space. But the option day list downward has no effect in a began calendar. I've to compute them in a third one...

  3. Monday has to point the schedule time for the corresponding lines. I've written what monday should be but i'm not able to make it works.

  4. On the lower right corner of the right pages (below Sunday) should be a quarter of a circle to cut it at the end of the week. Like a bookmark. I didn't tackle this issue yet.

Here is what I've written :

\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}

And here is the draft of the final project : output project

This question seems a very specifical problem and i understand that it'll touch nobody or near. But as it covers several points, i'm sure someone will be interested of how to deal with one or another problem. In particular, i've never seen some examples of tikz-calendar for several pages calendar which seems current in my opinion.

I'll be glad if you address only one point or suggest me some way to improve my code. I'm on the pgf manual but i didn't seen anything useful for me yet.

Thank you for any help.

1 Answer 1

2
+50

A first attempt to meet your requirements.

Important:

  • Each column/day must have the same height. Perhaps the last column (Saturday, Sunday and Memo) is not perfectly aligned because the column does not have the same fields as the other columns.

  • The Saturday, Sunday and Memo fields are created together on Saturday.

  • If you do not want the gap between Friday and the last column, comment out the appropriate hspace (see comment in the code). The same applies to the text (Journal de Classe de Piroooh (2022)) in the right margin.

  • I recommend choosing a time range that starts on Monday and ends on Sunday. Other start and end days are also possible, but the design is then of course not perfect. But try it out yourself if you need it.

% 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}

Two pages of the result.

4
  • 1
    Wow, I'll past some time to understand what you wrote. Let me some time to test if everything is ok. But anyway, you just adressed all the points. Thank you for helping me ! I'm very grateful to you. I'll be back as soon as I've past some time over it.
    – Piroooh
    Commented May 15, 2022 at 13:13
  • So i'm back and yes, thank you ! Many fine tuning with the dimensions and many functions to make everything coherent. 1) Smart to insert \newpage directly. Simple solutions are sometimes forgotten. 2) Is there a particular reason to not use ` \[4\rowHeight]` in saturday and sunday cell ? 3) The string on the right side of the odd page is very nice. I erased it but it's a tuto to place other stuff on the page with tikz and overlayfor which i'm not familiar. End : For years, this snippet code 'll follow me. Automate the dates was the last part. I'm very grateful to you. Thank you !
    – Piroooh
    Commented May 20, 2022 at 16:43
  • Is there an option to instead of making one to printed you could use it on the computer writing what ever you want, because I want something really similar to this this but it will take a lot to undo all de \ifdate. What I mean is if there is any example that you have to make each week manually, but with the option of been capable of typing on each day Commented Dec 1, 2022 at 22:04
  • @alvaritomendez: Please create a new question if you need this additional requirement.
    – Unknown
    Commented Feb 12, 2023 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .