I'm using a counter to increment months in a journal and the datetime
package to turn the counter into months. The months then become chapter titles in the document, so I have something like this:
\documentclass{scrbook}
\usepackage[french]{babel}
\usepackage{datetime}
\usepackage{hyperref}
\usepackage{lipsum}
\newcounter{month}
\newcommand{\newmonth}{%
\addtocounter{month}{1}%
\chapter{\monthname[\themonth]}
}
\begin{document}
\newmonth
\lipsum
\newmonth
\lipsum
\end{document}
The month appears ok in the text, but not in the PDF index. I tracked down this problem to \addchaptertocentry
, since I can reproduce it by calling \addchaptertocentry{\monthname[\themonth]}
.
The .aux
file contains the command verbatim:
\@writefile{toc}{\contentsline {chapter}{\numberline {1}\monthname [1]}{1}{chapter.1}}
How can I make it so that the \monthname
command is expanded so that the PDF index looks right?
Edit:
My reason for using datetime here is to support multiple languages (French in this example), so I would rather avoid redefining the month list.
Best Answer
If you don't need the optional argument which are making it non-expandable you could do
This version with language tests and french