2

I'm trying to produce a Gantt chart on a landscape page as part of a larger document. However, I when I compile the MWE below the last month unit (2020-06) seems to drop off the chart (image included below as well).

This seems unaffected by x unit but I've had to use it so that the chart fits on a page.

MWE:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{pgfgantt}

\begin{document}
\begin{landscape}

\begin{ganttchart}[
  x unit=0.5mm,
  time slot format={isodate-yearmonth}
  ]{2019-07}{2020-06}
  \gantttitlecalendar{year, month} \\
  \ganttbar{Test}{2019-07}{2020-03}
\end{ganttchart}

\end{landscape}
\end{document}

Image: Example output

1 Answer 1

1

In pgfgantt a time slot is usualy one day. With the option compress calendar it can be changed to one month. Adding this option solves your problem. But if you want to be able to have \ganttbars, which start/end in the middle of a month, you have to use time slot format={isodate} and give complete dates (with day).

Edit:

The option compress calendar was introduced in version 4.0. Now version 5.0 is out. Here compress calednar is replaced by time slot unit, which can have the values day, month or year. The old option is no longer available.

Example code:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{pgfgantt}

\begin{document}
\begin{landscape}

\begin{ganttchart}[
  x unit=15mm,
  time slot format={isodate-yearmonth},
  % use for pgfgantt version 4.0
  %compress calendar
  % use for pgfgantt version 5.0
  time slot unit=month
  ]{2019-07}{2020-06}
  \gantttitlecalendar{year, month} \\
  \ganttbar{Test}{2019-07}{2020-03}
\end{ganttchart}

\vspace{1cm}
\begin{ganttchart}[
  x unit=0.5mm,
  time slot format={isodate},
  ]{2019-07-01}{2020-06-30}
  \gantttitlecalendar{year, month} \\
  \ganttbar{Test}{2019-07-01}{2020-03-15}
\end{ganttchart}

\end{landscape}
\end{document}

The result:

enter image description here

3
  • I found that the 'compress calendar' option gave me an error when compiling. But using the full isodate has worked perfectly. Thank you. Commented May 2, 2018 at 10:10
  • @ChasNelson: I just checked, compress calendar was introduced in version 4.0. So if you are using an earlier one, you have to update. But then you get version 5.0, and there this option is replaced by time slot unit, which can have the values day, month or year.
    – Mike
    Commented May 2, 2018 at 19:45
  • @ChasNelson: I updated my answer.
    – Mike
    Commented May 2, 2018 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .