如何直接从 datetime 输入当前日期到 pgfgantt

如何直接从 datetime 输入当前日期到 pgfgantt

我想将从“datetime”获取的当前日期输入到“pgfgantt”包中,以便在编译时自动更新日期栏。

日期似乎是正确的格式,但是当输入到 pgfgantt 时,它会引发错误:

! Use of \\ganttchart doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.23 ]{2014-06-01}{2014-07-30}

工作代码在这里(将“today=2014-06-02”替换为“today=\dashdate\today”以重现错误):

\documentclass[a4paper,10pt]{report}

\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\usepackage{ifthen}
\usepackage{datetime}

\newdateformat{dashdate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}
%\dashdate\today

\begin{document}
\begin{preview}

\begin{ganttchart}[x unit=.3cm, hgrid,vgrid={dotted},time slot format=isodate,
today=
2014-06-02, %replace "2014-06-02" with "\dashdate\today" to reproduce error
today offset=.5,
today label=Current Date,
today label node/.append style={anchor=north west},
today label font=\itshape\color{red},today rule/.style={draw=blue, ultra thick}
]{2014-06-01}{2014-07-30}
\gantttitlecalendar{year, month=name, week} \\
\ganttbar{Task-1.1}{2014-06-01}{2014-06-03} \\
\ganttbar{Task-1.2}{2014-06-03}{2014-06-06} \\
\ganttmilestone{Milestone 1}{2014-06-06} 

\end{ganttchart}
\end{preview}
\end{document}

有什么想法我可以让它工作吗?

答案1

您可以使用today=\the\year-\the\month-\the\day

相关内容