I am trying to make a two sided holiday calendar (DIN A4, two pages for one school year). For this I started with an example from Robert Krause and tried to modify it. Here is how it looks so far:
% DIN-A4 doublesided year calendar
% Author: Robert Krause
% License : Creative Commons attribution license
% Submitted to TeXample.net on 13 July 2018
% Modified by julia 2018
\documentclass[a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz,xparse} % Use the calendar.sty style
\usepackage{translator} % German Month and Day names
\usepackage{fancyhdr} % header and footer
\usepackage{fix-cm} % Large year in header
\usepackage[ headheight = 0.8cm, hmargin=.5cm,
top = 1.7cm, nofoot,bottom=0cm]{geometry}
\usetikzlibrary{calc}
\usetikzlibrary{calendar}
\renewcommand*\familydefault{\sfdefault}
\makeatletter
\long\def\ifnodedefined#1#2#3{%
\@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
\makeatother
% Names of Holidays are inserted by employing this macro
\def\termin#1#2{
\ifnodedefined{cal-#1}{
\node [anchor=north west, text width= 3.4cm] at
($(cal-#1.north west)+(3em, 0em)$) {\tiny{#2}};
}{}
}
\newcounter{week}
\setcounter{week}{1}
\newcommand\woche[2]{
\node [anchor=north east, align=right] at
($(#1.north east)+(0em, 0em)$) {\tiny{SW #2}.};}
\newcommand{\holidays}{
between=2018-10-29 and 2018-11-04,
between=2019-02-28 and 2019-02-28,
between=2019-03-01 and 2019-03-08,
between=2019-04-15 and 2019-04-26,
between=2019-06-10 and 2019-06-02,
between=2019-07-29 and 2019-09-01,
}
%Header
\renewcommand{\headrulewidth}{0.0pt}
\setlength{\headheight}{0.8cm}
\chead{
\Huge 2018/2019
\Large\textbf{Termine}\hfill
}
\cfoot{}
\newcommand{\kheight}{0.82}
\newcommand{\kwidth}{3.0}
\newcommand{\kshift}{3.4}
\newcommand{\calstartdate}{2018-09-10}
\newcommand{\kal}[2]{
\vspace*{-1cm}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=#1,
name=cal,
day yshift = 3em,
day code=
{
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= \kheight cm, text width = \kwidth cm, draw =
gray]{\tikzdaytext \enskip
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
\ifdate{Monday}{
}{}
},
execute before day scope=
{
\ifdate{day of month=1}
{
% Shift right
\pgftransformxshift{\kshift cm}
% Print month name
\draw (0,0)node [shape=rectangle, minimum height= \kheight cm,
text width = \kwidth cm, fill = red, text= white, draw = red, text centered]
{\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
}{}
\ifdate{workday}
{
% normal days are white
\tikzset{every day/.style={fill=white}}
% Vacation (Germany, Baden-Wuerrtemberg) gray background
\ifdate{#2}{%
\tikzset{every day/.style={fill=gray!30}}
}{}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
% % Sundays and full holidays
\ifdate{Sunday}{\tikzset{every day/.style={fill=red!20}}}{}
%Tag der Arbeit
\ifdate{equals=2018-10-03}{\tikzset{every
day/.style={fill=red!20}}}{}
% Christi Himmelfahrt
\ifdate{equals=2019-05-30}{\tikzset{every
day/.style={fill=red!20}}}{}
},
execute at begin day scope=
{
% each day is shifted down according to the day of month
\pgftransformyshift{-\kheight*\pgfcalendarcurrentday cm}
}
];
% % Some Dates
\termin{2018-10-03}{Tag der dt. Einheit}
\termin{2019-01-01}{Neujahr}
\termin{2019-01-06}{Heilige Drei Könige}
\termin{2019-04-19}{Karfreitag}
\termin{2019-04-21}{Ostersonntag}
\termin{2019-04-22}{Ostermontag}
\termin{2019-05-01}{Tag der Arbeit}
\termin{2019-05-30}{Christi Himmelfahrt}
\termin{2019-06-09}{Pfingstsonntag}
\termin{2019-06-20}{Pfingstmontag}
\end{tikzpicture}
}
\begin{document}
\pagestyle{fancy}
\begin{center}
\kal{2018-09-10 to 2019-02-28}{
between=2018-10-03 and 2018-10-05,
between=2018-10-29 and 2018-11-04,
between=2019-02-28 and 2019-02-28,
between=2019-03-01 and 2019-03-08,
between=2019-04-15 and 2019-04-26,
between=2019-06-10 and 2019-06-02,
between=2019-07-29 and 2019-09-01,
}
\kal{2019-03-01 to 2019-08-30}{
between=2018-10-03 and 2018-10-05,
between=2018-10-29 and 2018-11-04,
between=2019-02-28 and 2019-02-28,
between=2019-03-01 and 2019-03-08,
between=2019-04-15 and 2019-04-26,
between=2019-06-10 and 2019-06-02,
between=2019-07-29 and 2019-09-01,
}
\pagebreak
%\kal{2019-03-01 to 2019-08-30}{\holidays}
\end{center}
\end{document}
There are some points where I need help:
- The school weeks should be numbered automatically, so in my example on Mo. 2018-09-10 there should be a small "SW 1" in the upper right corner of the day node. In Mo. 2018-09-17 there should be "SW 2" etc, Mo. 2018-10-01 would be "SW 4" and on Mo. 2018-10-29 there should be no mark since it is in the holidays, so "SW 8" would be on Mo. 2018-11-05 (and not "SW 9" since the SW counter shouldn't increment in the holidays).
If at least one day in a week is not a holiday day it should count as a "school week" and a particular "SW x" should be placed in the upper right corner of the first day in this week which is not a holiday day (in my example this would be always a Monday, but for a general solution it might be the case that for example Monday and Tuesday are holiday days but Wednesday, Thursday and Friday are not, in this case "SW x" should be printed on the Wednesday).
I tried the following code inside the day code, but it seems to be nonsense.
\ifdate{Monday}{
\tikzset{
loop over item/.code args={####1/####2/####3}{%
\ifdate{between=####1 and ####2}{%
}{
\woche{\pgfcalendarsuggestedname}{\theweek}
\stepcounter{week}
}},
loop over item/.list/.expanded=\ferien
}
}{}
where the week command is defined as:
\newcounter{week}
\setcounter{week}{1}
\newcommand\woche[2]{
\node [anchor=north east, align=right] at
($(#1.north east)+(0em, 0em)$) {\tiny{SW #2}.};}
The calender week number should be on each monday in the right lower corner.
The code redundancy should be reduced and the syntax for giving dates and holidays simplified as much as possible, in particular I want to give the list of holidays globally in just one place and another list of special dates in another global place (instead of writing
\termin
each time). However it should be possible to define several categories of dates (with different lists and styles).
You may have noticed that for example the date "Heilige Drei Könige" is printed on 2019-01-06 and as well in 2019-06-06 (which is wrong) since I specified the date once for both calendars. This should in particular be fixed (I know that I can fix it by duplicating the calendar code and set the date in the first part of the calendar only, but as written above I want to reduce the code redudancy and not increase it).