I'm doing calendars for all the family, and I have a problem automating the process. I'm using the calendar
tikz library.
I need to include the moon phase in the calendar. I can do it with this code
\documentclass{scrartcl}
\usepackage{mathabx}
\usepackage{tikz}
\usetikzlibrary{calendar}
\usepackage{etoolbox}
\newcount\mooncounter
\mooncounter=1
\def\moon{%
\ifnum\mooncounter=1%
$\newmoon$\global\advance\mooncounter by 1\else
\ifnum\mooncounter=2%
$\rightmoon$\global\advance\mooncounter by 1\else
\ifnum\mooncounter=3%
$\fullmoon$\global\advance\mooncounter by 1\else
\ifnum\mooncounter=4%
$\leftmoon$\global\mooncounter=1
\fi%
\fi%
\fi%
\fi%
}
\begin{document}
\begin{tikzpicture}
\calendar [
dates = 2012-12-1 to 2012-12-last,
week list,
day xshift = 3em
] if (equals = 2012-12-27,
equals = 2012-12-2,
equals = 2012-12-7,
equals = 2012-12-6,
equals = 2012-12-8,
equals = 2012-12-9,
equals = 2012-12-12) [day text = \moon\%d-];
\end{tikzpicture}
\end{document}
First of all, I don't know how \newcount
works (just copied the code from other site), but I use it because I can't find the way of doing it with \newcounter
or \pgfmathtruncatemacro
(I can't make them work in the \calendar
). That's why I have this first question: Why the command doesn't work out of the \calendar
? I mean. If I write
\begin{document}
\moon \moon
\end{document}
it doesn't work as I expected. I want it to be cyclic but it shows me two consecutive \newmoon
s.
Anyway, I want to be able to input the days which have a moon, and then let LaTeX do the rest.
I tried with this:
\newcommand*{\listofmoons}[1]{%
\edef\listmoons{#1}%
\def\moons{}%
\foreach \l in \listmoons {%
\xappto\moons{if (equals = 2012-12-\l) [day text=\moon\%d-]}
}%
}
and then use
\begin{tikzpicture}
\listofmoons{2,6,7,8,9,12,27}
\calendar [
dates = 2012-12-1 to 2012-12-last,
week list,
day xshift = 3em
] \moons;
\end{tikzpicture}
but it doesn't work. Again it doesn't cycle correctly (that's why I'm suspicious about \newcount
).
Which is the best way to achieve this? May be another completely different method?
By the way, is there any big question/community wiki about calendars? May be it would be good to open one.