甘特图标题超过一行

甘特图标题超过一行

我想绘制甘特图。但是,我需要表示 15 周,一页纸放不下,所以我想将其除以 3,每部分代表 5 周。

    \documentclass{article}
    \usepackage{pgfgantt}
    \usepackage{lscape}
    
    \begin{document}
    
    
    
    \begin{figure}[tbp]
    \begin{center}
    
    
    
    
    \begin{ganttchart}[y unit title=0.4cm,
    y unit chart=0.5cm,
    vgrid,hgrid, 
    title label anchor/.style={below=-1.6ex},
    title left shift=.05,
    title right shift=-.05,
    title height=1,
    bar/.style={fill=gray!50},
    incomplete/.style={fill=white},
    progress label text={},
    bar height=0.7,
    group right shift=0,
    group top shift=.6,
    group height=.3]{1}{25}
    \gantttitle{Period}{25} \\
    
    \gantttitle{Week 1}{5} 
    \gantttitle{Week 2}{5} 
    \gantttitle{Week 3}{5} 
    \gantttitle{Week 4}{5} 
    \gantttitle{Week 5}{5} \\
    
    \ganttbar{first task}{1}{2} \\
    
    \gantttitle{Week 6}{5}
    \gantttitle{Week 7}{5} 
    \gantttitle{Week 8}{5} 
    \gantttitle{Week 9}{5} 
    \gantttitle{Week 10}{5} \\
    
    \ganttbar{second task}{1}{2} \\
    
    \gantttitle{Week 11}{5} 
    \gantttitle{Week 12}{5}
    \gantttitle{Week 13}{5} 
    \gantttitle{Week 14}{5} 
    \gantttitle{Week 15}{5} \\
    
    \ganttbar{third task}{1}{2} \\
    
    \end{ganttchart}
    
    \end{center}
    \caption{Gantt Chart}
    \end{figure}
    
    
    
    \end{document}

结果并不如我所料。

在此处输入图片描述

我想要的图形显示:

  • 第一周
  • 第一个任务
  • 空行
  • 第 6 周
  • 第二项任务
  • 空行
  • 第 11 周
  • 第三个任务
  • 空行

空行用于添加更多任务。布局如下:

在此处输入图片描述

另一个解决方案是在横向模式下在一行中显示整个句点,但我无法实现。

答案1

我不完全确定我是否理解了整个问题,但我注意到的一件事是y unit titley unit chart必须都具有相同的值,在这种情况下我选择了.6cm

另外,bar height可以将设置为低(甚至是负值!),但是,在这里,我将其设置为.7

这个参数title height也是一个很有趣的参数。不幸的是,我无法驯服它。

根据 OP 的澄清进行了编辑。关键似乎是知道何时添加额外的内容\\

\documentclass{article}
\usepackage{pgfgantt}
\usepackage{lscape}

\begin{document}

\begin{figure}[tbp]
\begin{center}

\begin{ganttchart}[y unit title=.6cm,
y unit chart=.6cm,
vgrid,hgrid, 
title label anchor/.style={below=-1.6ex},
title left shift=.05,
title right shift=-.05,
title height=1,
bar/.style={fill=gray!50},
incomplete/.style={fill=white},
progress label text={},
bar height=.7,
group right shift=0,
group top shift=.6,
group height=.3]{1}{25}
\gantttitle{Period}{25} \\

\gantttitle{Week 1}{5} 
\gantttitle{Week 2}{5} 
\gantttitle{Week 3}{5} 
\gantttitle{Week 4}{5} 
\gantttitle{Week 5}{5} \\

\ganttbar{first task}{1}{2} \\

\\

\gantttitle{Week 6}{5}
\gantttitle{Week 7}{5} 
\gantttitle{Week 8}{5} 
\gantttitle{Week 9}{5} 
\gantttitle{Week 10}{5} \\

\ganttbar{second task}{2}{6} \\

\ganttbar{third task}{5}{15} \\

\\

\gantttitle{Week 11}{5} 
\gantttitle{Week 12}{5}
\gantttitle{Week 13}{5} 
\gantttitle{Week 14}{5} 
\gantttitle{Week 15}{5} \\

\ganttbar{fourth task}{14}{25} \\


\end{ganttchart}

\end{center}
\caption{Gantt Chart}
\end{figure}

\end{document}

在此处输入图片描述

相关内容