4

I am using \gantttitlecalendar to generate my title block that consists of months and weeks.

The default behaviour of vgrid is to take each unit as a day, or if compress calendar is true, each unit is taken as a month.

I would like to have vertical grid lines to demarcate each week.

This is what I currently have

 % Minimal
\documentclass{article}
\usepackage{pgfgantt}

\begin{document}

\ganttset{calendar week text= \small {\startday/\startmonth}}

\begin{ganttchart}[
    hgrid,x unit=1.5mm,
    hgrid style/.style={draw=black!5, line width=.75pt},
    vgrid,
    time slot format=little-endian]{22-09-2014}{30-11-2014}
\gantttitlecalendar{ month=shortname,week=4} \\
\ganttgroup{Group A}{22-09-14}{28-11-14}\\
\ganttbar{Task A}{22-09-14}{10-11-14}
\end{ganttchart}

\end{document}

Which gives me Minimal example - vgird = days

How would one adjust the vgrid for weeks?

2
  • Can you change your example to something that compiles (it has errors now) and produces the same result as the image you show? I've spent 20 minutes messing with your code and I can't get to the same starting point shown in the image? May 23, 2015 at 23:39
  • Sorry Paul, I seem to have missed the following line time slot format=little-endian]{22-09-2014}{30-11-2014} have updated my code, should compile now to get to the same image I have.
    – Ash
    May 24, 2015 at 15:32

1 Answer 1

3

You can use a <style list> value for the vgrid key to draw a grid line only once per week, like this:

vgrid={*{6}{draw=none},dotted},

The <style list> is cycled through as we move left to right through the Gantt chart, and the *{<num>}{<style>} works just like in tabular preambles for repeating elements. So the line of code above makes the first 6 grid lines with style draw=none (so not visible at all) and the seventh is dotted style. This repeats, so it achieves the goal of one grid line per week.

Here's the full code and output:

\documentclass{standalone}
\usepackage{pgfgantt}

\begin{document}

\ganttset{calendar week text= \small {\startday/\startmonth}}

\begin{ganttchart}[
  hgrid,x unit=1.5mm,
  hgrid style/.style={draw=black!5, line width=.75pt},
  vgrid={*{6}{draw=none},dotted},
  time slot format=little-endian,
]{22-09-2014}{30-11-2014}
  \gantttitlecalendar{ month=shortname,week=4} \\
  \ganttgroup{Group A}{22-09-14}{28-11-14}\\
  \ganttbar{Task A}{22-09-14}{10-11-14}
\end{ganttchart}

\end{document}

enter image description here

I assumed you wanted the grid line to correspond to the week markers in the title block section, but if you want the line on a different day of the week, you can adjust the <style list> to include the required offset.

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.