我正在尝试编译一个 tex 文件,该文件应显示在 pgfgantt 包的帮助下制作的甘特图。
在编译过程中我得到了加载 MPS 至 PDF 转换器(版本 2006.09.02)之后 tex 似乎停止了编译(即使它仍处于编译模式)。 我的代码是对此处其他一些用户发帖者的代码进行了轻微改动:甘特图包
澄清一下:我想在同一任务行中显示多个条形图。我想指示重复任务。
这是我的代码:
\documentclass{article}
\usepackage{pgfgantt}
\begin{document}
\begin{figure}[ftbp]
\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,
group peaks={}{}{.2}]{24}
%labels
\gantttitle{Work Plan}{24}\\
\gantttitle{Year 1}{4}
\gantttitle{Year 2}{4}
\gantttitle{Year 3}{4}
\gantttitle{Year 4}{4}
\gantttitle{Year 5}{4}
\gantttitle{Year 6}{4}\\
%tasks
\ganttbar{Task9}{1}{2}
\ganttbar{}{5} \\
\ganttbar{Task8}{2}
\ganttbar{}{4}
\ganttbar{}{6}
\ganttbar{}{8}
\ganttbar{}{10}
\ganttbar{}{12}
\ganttbar{}{14}
\ganttbar{}{16}
\ganttbar{}{18}
\ganttbar{}{20}\\
\ganttbar{Task7}{7} \\
\ganttbar{Task6}{8}
\ganttbar{}{16}
\ganttbar{}{20} \\
\ganttbar{Task5}{9}{10} \\
\ganttbar{Task4}{15}
\ganttbar{19} \\
\ganttbar{Task3}{17}{18} \\
\ganttbar{Task2}{19}{24}\\
\ganttbar{Task1}{21}{23}
\end{ganttchart}
\end{center}
\caption{Gantt Chart}
\end{figure}
\end{document}
谢谢你的帮助!
答案1
在循环之前,你会收到错误消息
! Use of \\ganttbar doesn't match its definition.
最好不要忽略 TeX 错误,默认恢复通常会出现错误。
\gantbar
需要三个参数,但大多数情况下你只给了两个。虽然我编造了数字,但运行起来没有错误。没有f
浮点数选项,所以我也删除了它。
\documentclass{article}
\usepackage{pgfgantt}
\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,
group peaks={}{}{.2}]{24}
%labels
\gantttitle{Work Plan}{24}\\
\gantttitle{Year 1}{4}
\gantttitle{Year 2}{4}
\gantttitle{Year 3}{4}
\gantttitle{Year 4}{4}
\gantttitle{Year 5}{4}
\gantttitle{Year 6}{4}\\
%tasks
\ganttbar{Task9}{1}{2}
\ganttbar{}{4}{5} \\
\ganttbar{Task8}{1}{2}
\ganttbar{}{2}{4}
\ganttbar{}{5}{6}
\ganttbar{}{7}{8}
\ganttbar{}{9}{10}
\ganttbar{}{11}{12}
\ganttbar{}{13}{14}
\ganttbar{}{15}{16}
\ganttbar{}{17}{18}
\ganttbar{}{19}{20}\\
\ganttbar{Task7}{6}{7} \\
\ganttbar{Task6}{7}{8}
\ganttbar{}{15}{16}
\ganttbar{}{19}{20} \\
\ganttbar{Task5}{9}{10} \\
\ganttbar{Task4}{14}{15}
\ganttbar{19}{19}{19} \\
\ganttbar{Task3}{17}{18} \\
\ganttbar{Task2}{19}{24}\\
\ganttbar{Task1}{21}{23}\\
\end{ganttchart}
\end{center}
\caption{Gantt Chart}
\end{figure}
\end{document}