Changing the default calendar layout

An example how to modify the calendar drawing code so Sundays are drawn as the first day of the week; it also shows how to make your own conditions to be used with ifdate. In this example I use matrices to group the months.


changing-the-default-calendar-layout

Edit and compile if you like:

\documentclass{article}
% An example how to use the calendar library and modify the layout, i.e. put
% Sunday as the first week day.
%
% Author: Berteun Damman
\usepackage{tikz}
\usetikzlibrary{calendar}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\makeatletter
% This way you can define your own conditions, for example, you
% could make something as `full moon', `even week', `odd week',
% et cetera. In principle. The math in TeX could be hard.
\pgfkeys{/pgf/calendar/start of year/.code={%
\ifnum\pgfcalendarifdateday=1\relax%
\ifnum\pgfcalendarifdatemonth=1\relax\pgfcalendarmatchestrue\fi%
\fi%
}}%
% Define our own style
\tikzstyle{week list sunday}=[
% Note that we cannot extend from week list,
% the execute before day scope is cumulative
execute before day scope={%
\ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{
% On first of month, except when first date in calendar.
\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
\pgftransformyshift{-\pgf@y}
}}{}%
},
execute at begin day scope={%
% Because for TikZ Monday is 0 and Sunday is 6,
% we can't directly use \pgfcalendercurrentweekday,
% but instead we define \c@pgf@counta (basically) as:
% (\pgfcalendercurrentweekday + 1) % 7
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Click to download: changing-the-default-calendar-layout.texchanging-the-default-calendar-layout.pdf
Open in Overleaf: changing-the-default-calendar-layout.tex