Calendars with Excel and pgfgantt, Part II

Since the last example of my pgfgantt-calendar generated a PDF with 1,60m width I decided to switch to a quarterly calendar. It took me quite a while to figure out the necessary Excel formulas (one may even find easier ways) but it works.

The green part contains some basic variables, e.g. when a quarter starts and ends. In the red part you just enter your dates. The violet part generates the entries for pgfgantt, the red box holds the copy&paste-ready entries for the TeX code. The code is able to handle events exceeding a single quarter.

23.01

Excel Code

final PDF

\documentclass{article}
\usepackage[landscape,a3paper,left=1cm,right=1cm,top=1cm,bottom=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfgantt}
\usetikzlibrary{calendar}
 
\protected\def\aaa#1{%
\pgfcalendarifdate{2012-12-31+#1}{weekend}% Test if it's a weekend
{\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color
{\pgfcalendarifdateday}% Or just the number
}
 
\protected\def\bbb#1{%
\pgfcalendarifdate{2013-03-31+#1}{weekend}% Test if it's a weekend
{\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color
{\pgfcalendarifdateday}% Or just the number
}
 
\protected\def\ccc#1{%
\pgfcalendarifdate{2013-06-30+#1}{weekend}% Test if it's a weekend
{\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color
{\pgfcalendarifdateday}% Or just the number
}
 
\protected\def\ddd#1{%
\pgfcalendarifdate{2013-09-30+#1}{weekend}% Test if it's a weekend
{\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color
{\pgfcalendarifdateday}% Or just the number
}
 
 
\begin{document}
\begin{flushright}
%\begin{tikzpicture}[scale=0.5, every node/.style={scale=0.25}]
\begin{ganttchart}[hgrid, vgrid, x unit=0.4cm]{90}
\gantttitle{1. Quartal}{90} \\
\gantttitlelist[
title list options={var=\y, evaluate=\y as \x using {"\aaa{\y}"}}
]{1,...,90}{1} \\
\ganttbar[bar/.style={fill=red}]{Neujahr}{1}{1}\\
\ganttbar[bar/.style={fill=yellow}]{Feiertag}{42}{42}\\
\ganttbar[bar/.style={fill=red}]{Feiertag}{88}{88}\\
\ganttbar[bar/.style={fill=green}]{Frühling}{79}{90}\\
\end{ganttchart}\vspace*{1cm}
 
\begin{ganttchart}[hgrid, vgrid, x unit=0.4cm]{91}
\gantttitle{2. Quartal}{91} \\
\gantttitlelist[
title list options={var=\y, evaluate=\y as \x using {"\bbb{\y}"}}
]{1,...,91}{1} \\
\ganttbar[bar/.style={fill=yellow}]{Feiertag}{1}{1}\\
\ganttbar[bar/.style={fill=red}]{Tag der Arbeit}{31}{31}\\
\ganttbar[bar/.style={fill=yellow}]{Herrentag}{39}{39}\\
\ganttbar[bar/.style={fill=green}]{Frühling}{1}{81}\\
\ganttbar[bar/.style={fill=yellow}]{Sommer}{82}{91}\\
\end{ganttchart}\vspace*{1cm}
 
\clearpage
 
\begin{ganttchart}[hgrid, vgrid, x unit=0.4cm]{92}
\gantttitle{3. Quartal}{92} \\
\gantttitlelist[
title list options={var=\y, evaluate=\y as \x using {"\aaa{\y}"}}
]{1,...,92}{1} \\
\ganttbar[bar/.style={fill=yellow}]{Sommer}{1}{83}\\
\ganttbar[bar/.style={fill=brown}]{Herbst}{84}{92}\\
\end{ganttchart}\vspace*{1cm}
 
\begin{ganttchart}[hgrid, vgrid, x unit=0.4cm]{92}
\gantttitle{4. Quartal}{92} \\
\gantttitlelist[
title list options={var=\y, evaluate=\y as \x using {"\aaa{\y}"}}
]{1,...,92}{1} \\
\ganttbar[bar/.style={fill=brown}]{Herbst}{1}{81}\\
\end{ganttchart}
 
\end{flushright}
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website