我想用 Latex 制作甘特图,因此我正在学习http://mirrors.ctan.org/graphics/pgf/contrib/pgfgantt/pgfgantt.pdf,到目前为止我可以做到:
通过编码:
\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[hgrid,vgrid,time slot format=isodate,time slot unit=month,x unit=10mm
]{2018-09-01}{2019-06-31} \gantttitlecalendar{year, month=shortname} \\
\ganttbar{Task 1 }{2018-09-01}{2018-10-31} \\
\ganttbar{Task 2 - Do something}{2018-11-01}{2018-12-31} \\
\ganttbar{Something else }{2019-01-01}{2019-02-28} \\
\ganttbar{Another task }{2019-03-01}{2019-04-30}
\end{ganttchart}
\end{document}
我希望有 的\ganttbar{Task 1}{2018-09-01}{2}
替代方案\ganttbar{Task 1}{2018-09-01}{2018-10-31}
。如何实现此解决方案?
动机:好吧,这样就没有必要考虑一个月是否有 30、31 或 28 天(同时指定结束日期)。
答案1
您可以指定以下日期:⟨year⟩-⟨month⟩-last
\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[hgrid,vgrid,time slot format=isodate,time slot unit=month,x unit=10mm
]{2018-09-01}{2019-06-last} \gantttitlecalendar{year, month=shortname} \\
\ganttbar{Task 1 }{2018-09-01}{2018-10-last} \\
\ganttbar{Task 2 - Do something}{2018-11-01}{2018-12-last} \\
\ganttbar{Something else }{2019-01-01}{2019-02-last} \\
\ganttbar{Another task }{2019-03-01}{2019-04-last}
\end{ganttchart}
\end{document}