创建甘特图时,pgfgantt 包的控制序列未定义

创建甘特图时,pgfgantt 包的控制序列未定义

我正在尝试使用 LaTeX 文档制作甘特图pgfgantt包。但是,当我尝试编译时,它在和\gantttitle之间给出了未定义的控制序列:{7}\\

\begin{ganttchart}{7}
  \gantttitle{2012}{7} \\ 
  \gantttitlelist{1,...,7}{1} \\
  \ganttgroup{Planning}{1}{1} \\
  \ganttbar{Write Wiki page}{1}{1} \\
  \ganttmilestone{Wiki page complete}{1} \\
  \ganttgroup{Coding}{2}{6} \\
  \ganttbar{Code new monitoring into the proxy}{2}{3} \\
  \ganttbar{Code new database changes}{4}{5} \\
  \ganttbar{Code new notifications{5}{6} \\
  \ganttmilestone{All new functionality complete}{6} \\
  \ganttgroup{Testing and Deployment}{6}{7} \\
  \ganttbar{Write tests}{6}{7} \\
  \ganttbar{Deploy system}{7}{7} \\
  \ganttmilestone{Complete system up and running}{7}
\end{ganttchart}

如果我注释掉\gantttitle,它只会给我一个错误\ganttitlelist。我\usepackage{pgfgantt}在开头包含了 。

有任何想法吗?

答案1

你需要包装ganttchart环境里面环境tikzpicture

在此处输入图片描述

\documentclass{article}
\usepackage{pgfgantt}% http://ctan.org/pkg/pgfgantt
\begin{document}
\begin{tikzpicture}
  \begin{ganttchart}{7}
    \gantttitle{2012}{7} \\ 
    \gantttitlelist{1,...,7}{1} \\
    \ganttgroup{Planning}{1}{1} \\
    \ganttbar{Write Wiki page}{1}{1} \\
    \ganttmilestone{Wiki page complete}{1} \\
    \ganttgroup{Coding}{2}{6} \\
    \ganttbar{Code new monitoring into the proxy}{2}{3} \\
    \ganttbar{Code new database changes}{4}{5} \\
    \ganttbar{Code new notifications}{5}{6} \\
    \ganttmilestone{All new functionality complete}{6} \\
    \ganttgroup{Testing and Deployment}{6}{7} \\
    \ganttbar{Write tests}{6}{7} \\
    \ganttbar{Deploy system}{7}{7} \\
    \ganttmilestone{Complete system up and running}{7}
  \end{ganttchart}
\end{tikzpicture}
\end{document}

编辑:(v2.1或更新版本)pgfgantt不需要嵌入到tikzpicture环境中。

相关内容