如何创建用户定义的时间表

如何创建用户定义的时间表

我必须创建一个为期三年的工作计划,但它仍然只显示我 4 个月,

我需要怎么做?

        \documentclass{article}       
    \usepackage{etoolbox}
    \usepackage{parskip}
    \usepackage{tikz}
    \usepackage{pgfgantt}
    \usepackage{ifthen}
    \newcounter{myWeekNum}
    \stepcounter{myWeekNum}

\begin{document}
    \newcommand{\myWeek}{\themyWeekNum
        \stepcounter{myWeekNum}
        \ifnum\themyWeekNum=53
        \setcounter{myWeekNum}{2}
        \else\fi
    }
    %
    %%% Begin document

        \setcounter{myWeekNum}{1}
        \ganttset{%
            calendar week text={\myWeek{}}%
        }
        %
        \begin{figure}[h!bt]
            \begin{center}
                \begin{ganttchart}[
                    vgrid={*{6}{draw=none}, dotted},
                    x unit=.08cm,
                    y unit title=.6cm,
                    y unit chart=.6cm,
                    time slot format=isodate,
                    time slot format/start date=2019-6-01]{2021-12-01}{2022-04-30}
                    \ganttset{bar height=1.6}
                    \gantttitlecalendar{year, month=name} \\
                    \ganttbar[bar/.append style={fill=blue}]{Task 1}{2019-6-01}{2021-12-01}\\
                    \ganttbar[bar/.append style={fill=blue}]{Task 2}{2019-6-01}{2021-12-01}\\
                    \ganttbar[bar/.append style={fill=blue}]{Task 3}{2019-6-01}{2021-12-01}\\
                    \ganttbar[bar/.append style={fill=red}]{Task 4}{2021-12-01}{2022-04-19}
                \end{ganttchart}
            \end{center}
                \caption{Time Plan}
            \end{figure}
    \end{document}

答案1

这是一个可能的解决方案。我不清楚你想要什么。

由于 3 年有 36 个月,因此宽度图像为太喔喔长。因此standalone将产生更宽的 pdf。

这只是来自 pdf 查看器的一部分。

在此处输入图片描述

\documentclass{standalone}
\usepackage{pgfgantt}
\usepackage{ifthen}
\newcounter{myWeekNum}
\stepcounter{myWeekNum}

\newcommand{\myWeek}{\themyWeekNum
    \stepcounter{myWeekNum}
    \ifnum\themyWeekNum=53
    \setcounter{myWeekNum}{2}
    \else\fi
}
\setcounter{myWeekNum}{1}
\ganttset{%
    calendar week text={\myWeek{}}%
}

\begin{document}

\begin{ganttchart}[
    vgrid={*{6}{draw=none}, dotted},
    x unit=.08cm,
    y unit title=.6cm,
    y unit chart=.6cm,
    time slot format=isodate,
    time slot format/start date=2019-1-01]{2019-1-01}{2022-12-31}
    \ganttset{bar height=.6}
    \gantttitlecalendar{year, month=name} \\
    \ganttbar[bar/.append style={fill=blue}]{Task 1}{2019-6-01}{2021-12-01}\\
    \ganttbar[bar/.append style={fill=blue}]{Task 2}{2019-6-01}{2021-12-01}\\
    \ganttbar[bar/.append style={fill=blue}]{Task 3}{2019-6-01}{2021-12-01}\\
    \ganttbar[bar/.append style={fill=red}]{Task 4}{2021-12-01}{2022-04-19}
\end{ganttchart}
\end{document}

相关内容