[Tex/LaTex] How to get pgfgantt today to be set to the \today macro

datetimeisodatemacrospgfgantt

I want the pgfgantt chart to automatically update the "today" line so that it always shows \today when compiled.

The problem is that though I am using time slot format=isodate and have set the document date format to \yyyymmdddate from the datetime package with the date separator '-'.
If I put \today in the text the date is shown as expected but when I set today=\today or {\today} in the pgfgantt environment:

\documentclass[paper=a4]{article}
\usepackage{pgfgantt}
\usepackage{datetime}
\renewcommand{\dateseparator}{-}
\begin{document}
\yyyymmdddate
\today
\begin{ganttchart}[
vgrid={*{6}{draw=none}, dotted},
x unit=.5cm,
y unit title=.6cm,
y unit chart=.6cm,
time slot format=isodate,
time slot format/start date=2015-03-02,
today=\today ,
today offset=.5]{2015-03-02}{2015-03-22}
\ganttset{bar height=.6}
\gantttitlecalendar{year, month=name, week, day} \\
\ganttbar[bar/.append style={fill=blue}]{Goal Document}{2015-03-02}{2015-03-20}\\
\end{ganttchart}
\end{document}

I get the errors:

! Missing number, treated as zero.<to be read again>\protect l.19 today offset=.5]{2015-03-02}{2015-03-22}
! Dimension too large.<to be read again>\relax l.27 \end{ganttchart}
! Dimension too large.<recently read> \pgfmath@x l.27 \end{ganttchart}
! Dimension too large.<argument> \pgf@x l.27 \end{ganttchart}
! Dimension too large.<recently read> \pgf@x l.27 \end{ganttchart}
! Dimension too large.\pgfusepath ...@x by.5\pgflinewidth \ifdim \pgf@x>\pgf@picmaxx \global \pgf... l.27 \end{ganttchart}
! Dimension too large.\pgfsys@typesetpicturebox ... \wd #1=\pgf@picmaxx\dp #1=0pt\leavevmode \pgf... l.27 \end{ganttchart}

Any ideas?

Best Answer

Instead of today=\today use today={\the\year-\the\month-\the\day}. A complete example:

\documentclass{article} 
\usepackage{pgfgantt} 
\usepackage{datetime} 

\renewcommand{\dateseparator}{-} 

\begin{document} 
\yyyymmdddate \today 

\begin{ganttchart}[ 
  vgrid={*{6}{draw=none}, dotted}, 
  x unit=.5cm, 
  y unit title=.6cm, 
  y unit chart=.6cm, 
  time slot format=isodate, 
  time slot format/start date=2015-03-02, 
  today={\the\year-\the\month-\the\day}, 
  today offset=.5
  ]{2015-03-02}{2015-03-22} 
\ganttset{bar height=.6} 
\gantttitlecalendar{year, month=name, week, day} \\ \ganttbar[bar/.append style={fill=blue}]{Goal Document}{2015-03-02}{2015-03-20}\\ 
\end{ganttchart} 

\end{document} 

enter image description here

Related Question