I'm modifying a calendar by Robert Krause (TeXample) and I'm searching for a method to get this calendar work dynamically. See also my original post here.
As nobody has answered on that oruginal post, I'm asking this new question, which is probably helpful for many other users and diverese uses. How can I define an associative array in Tikz and loop through it?
In my case this array should look like this:
\exams = [
{Chemistry}{2017-05-13},
{Maths}{2017-06-26},
{Physics}{2017-03-11}
]
In my calendar code, where the cells are defined, I have to loop through this array to check, if there are any exams to display:
% Tikzpicture environment for the first six month of the year
\foreach{\exams as \exam => \date}{
\if{\date <= \year-06-30}{
\exam{\date}{\exam}
}
}
% Tikzpicture environment for the last six month of the year
\foreach{\exams as \exam => \date}{
\if{\date > \year-06-30}{
\exam{\date}{\exam}
}
}
This little makro is used to write the name into the field:
\def\exam#1#2{
\node [
anchor=north west,
text width= 3.4cm,
text=red,
font=\bf
] at
($(cal-#1.north west)+(3em, -0.2em)$) {\scriptsize{#2}};
}
It is called like this:
\exam{2017-06-23}{Physical Chemistry}
The loop should call this makro and insert the date and name.

2017-06-23what is the intention ofcal-2017-06-23.north westwhere is that node defined? – David Carlisle Dec 28 '16 at 17:29