如何让 pgfgantt today 设置为 \today 宏

如何让 pgfgantt today 设置为 \today 宏

我希望pgfgantt图表自动更新“今天”线,以便它\today在编译时始终显示。

问题是,虽然我正在使用time slot format=isodate并将文档日期格式设置为\yyyymmdddate来自datetime带有日期分隔符“-”的包。如果我输入\today文本,日期将按预期显示,但是当我在环境中设置today=\today或时:{\today}pgfgantt

\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}

我收到错误:

! 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}

有任何想法吗?

答案1

而不是today=\today使用today={\the\year-\the\month-\the\day}。完整的例子:

\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} 

在此处输入图片描述

相关内容