I am having problems to implement a loop that runs over the months of the year and the days of each month. A simple representative example of my current approach is shown below.
\documentclass{article}
\usepackage{pgffor}
\usepackage{ifthen}
\newcommand\Ndays[1]{\ifthenelse{\equal{#1}{February}}{28}%
{\ifthenelse{\equal{#1}{March}}{31}{30}}}
\begin{document}
\foreach \m in {February,March,April}
{
month:\m \par
\newcommand\Nd{\Ndays{\m}}
ndays: \Nd \par
\foreach \n in {1,...,31}
{
day:\n \par
}
}
\end{document}
Evidently, each month has a different number of days, so I decided to define a dictionary associating each month with the number of days through the "Ndays" macro. Now, I need to include the correct number of days for each month in the example above. If I naively substitute "31" by "\Nd" in the inner loop, an error is found when I compile this code with pdflatex:
! Undefined control sequence.
<argument> \equal
{\m }{February}
l.23 }
I played around with different macro definitions and \expandafter-s, without success. Moreover, if I define the macro as:
\newcommand\Nd{28}
the naive substitution does not raise errors. Is there any simple solution and explanation to this?