2

I have looked at PgfGantt: Customization of canvas to mark Vacations and implemented a version of it to draw rectangles starting at one date and ending at another which works fine. The problem is that i would like to have the label centered below the rectangle but i gets bound to the bottom right corner.

I was trying to solve this by drawing a line from that corner to the center by: \draw (stop) -- ($ (stop) - ((stop)-(start))*(0.5,0) $);

Most parts of this equation work but the times sign is not recognized.

How can I persuade LaTeX to do this calculation?

1 Answer 1

3

The usual linear interpolation calculations uses !<num>! syntax and for your example it is simply (via calc library)

\draw (stop) -- ($(stop)!0.5!(start)$);

But for the fun of it, if you want to do a multiplication operation via coordinates then you need to nest the calc indicator (because multiplication of two coordinates is undefined if we can shut up our inner mathematician)

\begin{tikzpicture}
\draw[style=help lines] (0,0) grid[step=1cm] (3,2);
\coordinate (a);
\coordinate (b) at (1,1);
\coordinate (c) at (5,2);
\draw (a) -- ($0.5*($(c) - (b)$)$); % Difference is (4,1) --> (2,0.5) should come out
\end{tikzpicture}

enter image description here

You must log in to answer this question.

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