In addition to the calendarian month names, I added a calendarian week counter (week 1 up to week 52) into the title of a pgfgantt-chart.
Minimum Working Example (MWE):
\documentclass{standalone}
\usepackage{pgfgantt}
\newcounter{resetWeekNum}
\stepcounter{resetWeekNum}
\newcommand{\resetWeek}{ %
\theresetWeekNum
\stepcounter{resetWeekNum}
\ifnum\theresetWeekNum=53
\setcounter{resetWeekNum}{1}
\else\fi
}
\begin{document}
\setcounter{resetWeekNum}{27}
\ganttset{calendar week text=\scriptsize{\resetWeek{}}}
\begin{ganttchart}
[ time slot format = isodate,
x unit = 2mm,
vgrid = true,
] {2019-07-01}{2021-05-16}
\gantttitlecalendar{year, month=name,week=1 day} \\ % weekday=letter
\ganttbar{WP1}{2019-04-01}{2020-12-27} \\
\ganttbar{WP2}{2019-04-01}{2020-12-31} \\
\ganttbar{WP2}{2019-04-01}{2021-01-03} \\
\end{ganttchart}
\end{document}
Screenshot of the result (year 2019 - 2020):
Screenshot of the result (year 2020 - 2021):
Description of the issue:
While the current week counter works completely fine for years 2019 to 2020 (counting 52 weeks for 2019), there is some small failure from 2020 to 2021 (falsely counting 52 weeks instead of 53 weeks).
The problem:
According to international week counting standard ISO 8601, the first calendarian week of each year is the week that contains the first Thursday of the year. After that, the next counted week starts on Monday (= as the second calendarian week). Therefore: 2019 has 52 weeks while 2020 has 53 weeks.
From Wikipedia:
"ISO 8601 includes the ISO week date system, a numbering system for weeks – each week begins on a Monday and is associated with the year that contains that week's Thursday (so that if a year starts in a long weekend Friday–Sunday, week number one of the year will start after that). For example, week 1 of 2004 (2004W01) ran from Monday, 29 December 2003 to Sunday, 4 January 2004, because its Thursday was 1 January 2004, whereas week 1 of 2005 (2005W01) ran from Monday, 3 January 2005 to Sunday, 9 January 2005, because its Thursday was 6 January 2005 and so the first Thursday of 2005."
The question:
How can I display calendarian week numbers in consideration of the ISO 8601 standard counting scheme?






53? – Sep 30 '19 at 16:44