0

I have to create a three years work plane, but it still only shows me 4 months,

How do I need to do?

        \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}
  • 2
    I think you have to change dates here {2021-12-01}{2022-04-30}. – Sigur Nov 16 '18 at 22:55
  • 1
    Use start date=2019-1-01 and {2019-1-01}{2022-12-31} for years 2019-2022. – Sigur Nov 16 '18 at 22:58
1

Here is a possible solution. It is not clear to me what you want.

Since 3 years has 36 months, the width image is tooooo long. So a standalone will produce a wider pdf.

Here is only a piece from pdf viewer.

enter image description here

\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}
  • I only want to creat a three years plane in A4 page. can we change the size of the value of width for every month? – acsdaswe Nov 16 '18 at 23:09
  • I am not expert and never used this tool. Maybe, take a look at its documentation at ctan.org/pkg/pgfgantt – Sigur Nov 16 '18 at 23:11
  • is there other package to do such works? – acsdaswe Nov 16 '18 at 23:34
  • I don't know. Sorry. – Sigur Nov 16 '18 at 23:40
  • no, I have to say "thank you very much" – acsdaswe Nov 16 '18 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.