\gantttitle 项目之间的额外空间

\gantttitle 项目之间的额外空间

以下是我目前所写内容的 MWE:

\documentclass[12pt, a4paper]{article}
\usepackage{pgfgantt}

\begin{document}
\begin{ganttchart}[
hgrid,
vgrid,
bar/.style={fill=blue}]{1}{21}
\gantttitle{Timeline}{21}\ganttnewline
\gantttitle{2019}{9}
\gantttitle{2020}{12}\\                     % title 3
\gantttitle{Q2}{3}
\gantttitle{Q3}{3}
\gantttitle{Q4}{3}
\gantttitle{Q1}{3}
\gantttitle{Q2}{3}
\gantttitle{Q3}{3} 
\gantttitle{Q4}{3}\\
\ganttgroup{First Visit}{1}{10}\\
\end{ganttchart}
\end{document}

结果是,在标题中,第一行是一个单元格(时间轴),一个空行,第三行是两个单元格(2019、2020),另一个空行,最后一行是 8 个单元格(Q1、Q2、...)。我应该如何更改代码以从标题中删除空行?

答案1

就像减少 pgfgantt 中标题和栏之间的空间,您可以使用title height=1,然后修改y unit title来设置标题栏的高度。

enter image description here

\documentclass[12pt, a4paper]{article}
\usepackage{pgfgantt}

\begin{document}
\begin{ganttchart}[
hgrid,
vgrid,
bar/.style={fill=blue},
y unit title=0.6cm,
title height=1
]{1}{21}
\gantttitle{Timeline}{21}\ganttnewline
\gantttitle{2019}{9}
\gantttitle{2020}{12}\\                     % title 3
\gantttitle{Q2}{3}
\gantttitle{Q3}{3}
\gantttitle{Q4}{3}
\gantttitle{Q1}{3}
\gantttitle{Q2}{3}
\gantttitle{Q3}{3} 
\gantttitle{Q4}{3}\\
\ganttgroup{First Visit}{1}{10}\\
\end{ganttchart}
\end{document}

相关内容