I'm making a timetable where I draw rectangles with x-coordinates of the day and y-coordinates of the time. Centered inside these rectangles these is a node with some text. Because of several reasons, the fill color cannot be applied to the rectangle but has to be applied to the node itself. The problem is, that I cannot (or that I don't know how) apply a height to the node, so my fill color only spans around the text, but not around the entire time period of the entry.
How could I make the node as tall as the rectangle?
Here is some code of my project
\newcommand{\entry}[7]{
\draw
(#1, {time(#2)}) rectangle (#1+1, {time(#3)}) % {time(#2)} begin of the entry, {time(#3)} end of the entry
node [
rectangle split,
rectangle split parts=2,
pos = .5,
fill = #6,
text = #7,
text width = \entrytextwidth cm,
text centered
]
{\small{\textbf{#4}} \nodepart{second} \footnotesize{#5}};
}
Where time()
is:
\pgfmathdeclarefunction{time}{1}{%
\pgfmathparse{\firstH-(floor(#1)+(#1-floor(#1))/0.6)}%
}
The time is passed as a float in the format hh.mm
, \firstH
is the first hour present on the timetable, in my case 8:00 am: 08.00
.
The command is used as this: \calentry{1}{10.00}{10.45}{title}{location}{fillColor}{textColor}
where 1
defines the weekday (Monday), 10.00
the starting time of the appointment (10:00 am) and 10.45
the ending time of the appointment (10:45 am).
Full code of the project
Please see my Github Gist. Feel free to suggest improvements.
minimum height=time(#3)-time(#2)
? Untested though.minimum height
doesn't apply to a multipart node. I propose (not tested):\draw (#1, {time(#2)}) rectangle (#1+1, {time(#3)}) node [pos=.5, minimum height=time(#3)-time(#2), text width= \entrytextwidth cm, text centered, fill=#6]{\phantom{\small{\textbf{#4}}}\\\phantom{\footnotesize{#5}}} node [ rectangle split, rectangle split parts=2, pos = .5, text = #7, text width = \entrytextwidth cm, text centered ] {\small{\textbf{#4}} \nodepart{second} \footnotesize{#5}}; }