我想用 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-15} \\
\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}
实际上,我原本以为Task 1
酒吧会营业到 10 月中旬(2018-10-15
)。为什么整个 10 月都爆满?
我设定time slot unit=day,x unit=.4mm
并成功获得:
缺点是vgrid
没有这个。使用它就会造成混乱:
也许可以限制垂直线的数量?
答案1
您可以为网格设置一个样式列表(参见手册第 9 页),例如每 11 条线只绘制 1 条。
梅威瑟:
\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[hgrid,vgrid={*{10}{draw=none},*1{black, dotted}},time slot format=isodate,time slot unit=day,x unit=.4mm
]{2018-09-01}{2019-06-31} \gantttitlecalendar{year, month=shortname} \\
\ganttbar{Task 1 }{2018-09-01}{2018-10-15} \\
\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}
结果: