我希望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}