Latex 中的甘特图

Latex 中的甘特图

我在 Latex 中创建的甘特图似乎无法编译?

\documentclass[final]{nbsreport}
\begin{sideways}
\newganttchartelement{voidbar}{
    voidbar/.style={
        draw=black,
        top color=black!25,
        bottom color=black!23
    }}
    \begin{ganttchart}[x unit=0.42cm, 
        y unit title=0.7cm,
        y unit chart=0.7cm, vgrid, title label font=\footnotesize,
        canvas/.style={draw=black, dotted}]{1}{28}
        \gantttitle{Days}\\
        \gantttitlelist{0,5,10,15,20,25,30,35,40,45,50,55,60,65}{2} \\

        \ganttbar{A.Project Assigned}{1}{2}     \\ 
        \ganttbar{B. Create Plan}{3}{6}    \\   
        \ganttbar{C. Ambassador Requirements}{7}{8}              \\ 
        \ganttbar{D. Contact Possible Ambassadors} {9}{12} \\
        \ganttbar{E. Recruit Ambassadors} {13}{16} \\
        \ganttbar{F. Communicate with Ambassadors } {17}{20} \\
        \ganttbar {G. Set Marketing Objectives} {7}{8} \\
        \ganttbar {H. Design, publish \& evaluate survey} {9}{12} \\
        \ganttbar {I. Design Marketing Comms} {13}{16} \\
        \ganttbar {J. Execute Plan} {16}{21} \\
        \ganttbar {K. Set Webpage Objectives} {7}{7} \\
        \ganttbar {L. Website Research} {8}{11} \\
        \ganttbar {M. Website Prototype} {12}{14} \\
        \ganttbar {N. Approve design/develop} {15}{16} \\
        \ganttbar {O. Test \& evaluate} {17}{20} \\
        \ganttbar {P. Venue \& theme} {21}{24} \\
        \ganttbar {Q. Choose Catering \& Entertainment } {25}{28} \\
        \ganttbar {R. Final Presentation} {28}{28} \\
    \end{ganttchart}
\end{sideways}

答案1

不,因为你的语法错误\gantttitle。如果你查看手册,你会发现正确的语法是

\gantttitle[<options>]{<label>}{<number of time slots>}

即它有强制参数,而您只提供了一个,即<label>。第二个强制参数是标题应跨越的时间段数,假设您希望它跨越整个图表,并且您有 28 个时间段,因此您应该有

\gantttitle{Days}{28}\\

完整代码(我会减少y unit chart一点):

\documentclass{article}
\usepackage{pgfgantt,rotating}
\begin{document}
\begin{sideways}
\newganttchartelement{voidbar}{
    voidbar/.style={
        draw=black,
        top color=black!25,
        bottom color=black!23
    }}
    \begin{ganttchart}[x unit=0.42cm, 
        y unit title=0.7cm,
        y unit chart=0.5cm, vgrid, title label font=\footnotesize,
        canvas/.style={draw=black, dotted}]{1}{28}
        \gantttitle{Days}{28}\\
        \gantttitlelist{0,5,10,15,20,25,30,35,40,45,50,55,60,65}{2} \\

        \ganttbar{A.Project Assigned}{1}{2}     \\ 
        \ganttbar{B. Create Plan}{3}{6}    \\   
        \ganttbar{C. Ambassador Requirements}{7}{8}              \\ 
        \ganttbar{D. Contact Possible Ambassadors} {9}{12} \\
        \ganttbar{E. Recruit Ambassadors} {13}{16} \\
        \ganttbar{F. Communicate with Ambassadors } {17}{20} \\
        \ganttbar {G. Set Marketing Objectives} {7}{8} \\
        \ganttbar {H. Design, publish \& evaluate survey} {9}{12} \\
        \ganttbar {I. Design Marketing Comms} {13}{16} \\
        \ganttbar {J. Execute Plan} {16}{21} \\
        \ganttbar {K. Set Webpage Objectives} {7}{7} \\
        \ganttbar {L. Website Research} {8}{11} \\
        \ganttbar {M. Website Prototype} {12}{14} \\
        \ganttbar {N. Approve design/develop} {15}{16} \\
        \ganttbar {O. Test \& evaluate} {17}{20} \\
        \ganttbar {P. Venue \& theme} {21}{24} \\
        \ganttbar {Q. Choose Catering \& Entertainment } {25}{28} \\
        \ganttbar {R. Final Presentation} {28}{28} \\
    \end{ganttchart}
\end{sideways}
\end{document}

相关内容