As I haven't got answers to my questions here:
How to draw vertical lines using pgfgantt package, I decided to implement my own command that I added to the pgfgantt.sty
file (I have made a copy). I looked at pgfgantt.sty
and I came up with this code that works with only one problem:
\newcommand\drawverticalline[1]{%
\begingroup%
\begin{pgfinterruptboundingbox}%
\begin{scope}
\newif\ifgtt@includetitle
\ganttset{%
include title in canvas/.is if=gtt@includetitle,%
include title in canvas
}
\gtt@tsstojulian{#1}{\gtt@today@slot}
\gtt@juliantotimeslot{\gtt@today@slot}{\gtt@today@slot}%
\ifgtt@includetitle%
\def\y@upper{0}%
\else%
\pgfmathsetmacro\y@upper{%
\gtt@lasttitleline * \ganttvalueof{y unit title}%
}%
\fi%
\pgfmathsetmacro\y@lower{%
\gtt@lasttitleline * \ganttvalueof{y unit title}%
+ (\gtt@currentline - \gtt@lasttitleline - 1)%
* \ganttvalueof{y unit chart}%
}%
\pgfmathsetmacro\x@mid{%
(\gtt@today@slot - 1 + \ganttvalueof{today offset})%
* \ganttvalueof{x unit}%
}%
\draw [/pgfgantt/today rule]
(\x@mid pt, \y@upper pt) -- (\x@mid pt, \y@lower pt)
node [/pgfgantt/today label node] {\ganttvalueof{today label}};%
\end{scope}
\end{pgfinterruptboundingbox}%
\endgroup%
}
This is just an example to show that it works. Here's what I get with this code :
\documentclass{article}
\usepackage[frenchb]{babel}
\usepackage{pgfgantt}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture} % optional
\begin{ganttchart}[x unit=1.8mm,
y unit chart=0.87cm,
time slot format=isodate,
vgrid=*{5}{dotted},
]
{2014-04-14}{2014-07-11}
\gantttitlecalendar{month=name} \\
\ganttbar[progress=100]{title1}{2014-04-14}{2014-04-15} \\
\ganttbar[progress=100]{title2}{2014-04-15}{2014-04-17} \\
\drawverticalline{2014-05-07}
\end{ganttchart}
\end{tikzpicture}
\end{document}
Normally the line should be draw below the title bar. It's this code that define where we start drawing :
\ifgtt@includetitle%
\def\y@upper{0}%
\else%
\pgfmathsetmacro\y@upper{%
\gtt@lasttitleline * \ganttvalueof{y unit title}%
}%
\fi%
How \ifgtt@includetitle
works? It's defined like this :
\newif\ifgtt@includetitle
\ganttset{%
include title in canvas/.is if=gtt@includetitle,%
include title in canvas
}
\newif\ifgtt@includetitle
outside your command definition of\drawverticalline
. Then also, where do you set this conditional (true would be\gtt@includetitletrue
and false would be\gtt@includetitlefalse
)? It's default is false.\gantset{% ...}
is not part of the\newif
declaration:\newif\ifgtt@includetitle
creates the conditional, then, as in your earlier snippet, you have\ifgtt@include ...<true> ... \else ...<false> ... \fi
. You then can pick 'true' or 'false' with\gtt@includetitletrue
or\gtt@includetitlefalse
. Basically, it means: if\gtt@include
= true, do <true>; otherwise do <false>. Note that the default is false.mypgfgantt.sty
and useusepackage{mypgfgantt}
. This will not break your installation. And I just added a command I haven't modified any code of the original\RequirePackage{pgfgantt}