# pgfgantt - adjust vgrid with \gantttitlecalendar

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}\\
\end{ganttchart}

\end{document}


Which gives me

How would one adjust the vgrid for weeks?

• 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

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}\\

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.