I am baffled by some Jedi Master code. This impressive calendar code would be nice to grasp. I can manipulate it by trial and error, but I would like to move to the next level and understand it. Obviously, the LaTeX3 / expl3 code is lengthy and probably too much for an answer to handle, but an explanation of the following questions and the pgf code used in alignment would be an acceptable answer.
What are the following:
\pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}
\pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}
Why is this code used instead of minimum height and minimum width of nodes:
\pgfkeys{/tikz/day xshift=\cellwidth+2mm+2mm} % Set width of days
\pgfkeys{/tikz/day yshift=\cellheight+2mm+2mm} % Set height of days
Why is there:
\pgfkeys{/tikz/inner sep = 0pt}
yet day code node contains inner sep=1mm
and adding \pgfkeys{/tikz/outer sep = 0pt}
has no affect.
What defines the vertical spacing above the calendar? What if I have multiple rows for the day labels (multiple languages for the day names)? How do I ensure no overlap with the month name and calendar?
Confusing Code
I added the comments, so if they are incorrect, you will know why. These two code blocks seem to make the magic happen:
%% Adapted from https://tex.stackexchange.com/a/10199/4771
\makeatletter%
\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
execute before day scope={ \ifdate{day of month=1}{%
\pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
\pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%tikz@lib@cal@width effectively a multiple of day xshift
\pgftransformyshift{-\pgf@ya}
\foreach \d/\l in {0/Mantig,1/Dienstig,2/Mittwoch,3/Pfingstig,% Translate weekday names (start of week: Monday)
4/Freitig,5/Samstig,6/Sunntig} {
\pgf@xa=\d\pgf@xa%
\pgftransformxshift{\pgf@xa-\cellwidth/2}% Spread weekdays horizontally across calendar
\pgftransformyshift{\pgf@ya}% Drop other weeks vertically so that first week is on first line.
\node[above=-0.5ex,day heading]{\l};%
}
}{}%
}%
]
\makeatother%
Or
\makeatletter
\tikzstyle{month label above centered}=[% Formatting of Month Name Location on Page
execute before day scope={%
\ifdate{day of month=1}{% Alignment of first day
{
\pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}% Grab total width
\pgf@xb=\tikz@lib@cal@width\pgf@xa% Set @xb to total width
\advance\pgf@xb by-\pgf@xa% Subtract full width from xb?
\pgf@xb=.5\pgf@xb% Get half of xb?
\pgftransformxshift{\pgf@xb}%
\pgftransformxshift{-\cellwidth/2}%
\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
\pgftransformyshift{0.333\pgf@y}
\tikzmonthcode%
}
}{}},
every month/.append style={anchor=base}
]
\makeatother
/tikz/day code (slightly more understandable)
This fit business does not seem so elegant.
\pgfkeys{/tikz/day code =
{
\node (lower right) at (0,0) [above left,font=\Huge] {\tikzdaytext}; % Date label on each day
\node (upper left) at (-\cellwidth,\cellheight) [below right,align=left,text width=\cellwidth-\pgflinewidth,font=\tiny,black] {\showtext}; % Adds week numbers
\node (lower left) at (-\cellwidth,0) {};
\node[draw, % day node
fit=(lower right) (upper left) (lower left),
inner sep=1mm,outer sep=0pt] {};
}
}
If I replace all the day code nodes with just this node:
\node[draw,minimum width=\cellwidth,minimum height=\cellheight,outer sep=0pt,inner sep=0pt] {}; % Day Box
the boxes seem to be shifted horizontally by some space. Why is that? How can I make the distance between nodes 0pt such that the calendar looks like:
Full Code
See https://tex.stackexchange.com/a/170474/13552