[Tex/LaTex] Getting gantt chart week to show week number

pgfgantt

I am using ganttchart to make a time plan for my master thesis but when I set the calendar week text to \currentweek it does not "reset" on new year but just keeps going. The fist week number is correct but in January I have week 54 instead of 2.

How can i solve this?

Best Answer

I have solved the problem using a new command. Probably not the optimal solution but I added a new counter and command and set the week text to show the counter value.

%%% Preamble
\documentclass[paper=a4, fontsize=11pt]{scrartcl}   % Article class of KOMA-script with 11pt font and a4 format
\usepackage[pdftex]{graphicx}   %Enable pdflatex
\usepackage{pgfgantt}
\newcounter{myWeekNum}
\stepcounter{myWeekNum}
%
\newcommand{\myWeek}{\themyWeekNum
    \stepcounter{myWeekNum}
    \ifnum\themyWeekNum=53
         \setcounter{myWeekNum}{1}
    \else\fi
}
%
%%% Begin document
\begin{document}
\setcounter{myWeekNum}{49}
\ganttset{%
calendar week text={\myWeek{}}%
}
%
\begin{figure}[h!bt]
\begin{center}
\begin{ganttchart}[
vgrid={*{6}{draw=none}, dotted},
x unit=.08cm,
y unit title=.6cm,
y unit chart=.6cm,
time slot format=isodate,
time slot format/start date=2014-12-01]{2014-12-01}{2015-04-30}
\ganttset{bar height=.6}
\gantttitlecalendar{year, month=name, week} \\
\ganttbar[bar/.append style={fill=blue}]{Task 1}{2014-12-01}{2015-01-19}\\
\ganttbar[bar/.append style={fill=red}]{Task 2}{2015-03-10}{2015-04-19}
\end{ganttchart}
\end{center}
\caption{Time Plan}
\end{figure}
\end{document}

This gives me the correct week numbers.Time plan

Related Question