# pgfgantt start on fractional unit (half month)

I'm building a Gantt chart with pgfgantt.

I'm almost satified with the result but it seems that fractional values are not supported. For example the Today milestone is set on 2018-12-15 but it is shown at the end of December. The Test milestone is set on 2019-03-01 but it is shown at the end of March.

Is there a way/workaround to place it at the right, fractional x value?

I've found a similar question in this answer.

Is there a way to achieve the same with months instead of numbers?

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[
vgrid,
hgrid,
x unit=2cm,
y unit chart=8mm,
milestone/.append style={xscale=0.2},
time slot format=isodate,
time slot unit=month
]{2018-12-01}{2019-06-30}
\gantttitlecalendar{year, month} \\
\ganttmilestone{Today}{2018-12-15} \\
\ganttmilestone{Test}{2019-03-01}
\end{ganttchart}
\end{document}


I also have tried to use time slot unit=day, but then I'm unable to properly align the vgrid lines with the months.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[
vgrid={*{29}{draw=none}, dotted}, % how to align with months?
hgrid,
x unit=0.8mm,
y unit chart=8mm,
milestone/.append style={xscale=5.5},
time slot format=isodate,
time slot unit=day
]{2018-12-01}{2019-06-30}
\gantttitlecalendar{year, month} \\
\ganttmilestone{Today}{2018-12-15} \\
\ganttmilestone{Test}{2019-02-28}
\end{ganttchart}
\end{document}


Here is a proposal, which comes with a new option fractional xshift that can be added to the options. If you want to shift by half a month (or, more generally, by half a x unit, say fractional xshift=1/2, and if you want to shift by a day, use fractional xshift=1/30, and so on. (I also dropped the parts of your MWE that are not directly related to the problem.)

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[fractional xshift/.style={%
/tikz/xshift=#1*\pgfkeysvalueof{/pgfgantt/x unit},
milestone label node/.append style={xshift=-#1*\pgfkeysvalueof{/pgfgantt/x unit}}
},
vgrid,
hgrid,
x unit=2cm,
y unit chart=8mm,
milestone/.append style={xscale=0.2},
time slot format=isodate,
time slot unit=month
]{2018-12-01}{2019-06-30}
\gantttitlecalendar{year, month} \\
\ganttmilestone{Today}{2018-12-15} \\

• Thanks! It's a good workaround but still a workaround. I've edited my question to add another trial where I use time slot unit=day. It works out of the box, but then I am unable to properly align the vgrid with the months. Is there a way to achieve this? (I've also edited the question to use your MWE template) – thibautg Dec 15 '18 at 16:53
• @thibautg I do not know if that is so easy (but I am not an expert). Judging from \def\gtt@vgrid@draw#1#2\relax... on p. 55 of the manual it might be difficult because, if I understand correctly, the grid is drawn in a loop n which the horizontal distance is constant. Drawing the vgrid by hand would just be another workaround. It is quite possible that there is already a built in possibility that takes care of that. – marmot Dec 15 '18 at 17:17
• OK thanks. I've been able to do it by drawing a few \ganttvrule manually, but it is not very elegant. I will let the question open for a few days, and will then accept your answer if nobody provides a better solution ;-) I've already upvoted it though ;-) – thibautg Dec 15 '18 at 17:21
• @thibautg Yes, please wait. I am not at all an expert on pgfgantt. I just read the title of your question and thought that it is possible to create a style that does the fractional shift. Of course, I agree that your proposal is much more to the point. (But the fractional shift style may still be useful here and there, so I plan not to delete my answer at this point. And thanks for the upvote, I upvoted your question at the very moment you had an MWE.) – marmot Dec 15 '18 at 18:20