I am using the package pgfgantt
to create a table displaying people serving on a committee over a period of time. (Probably not what it was intended for but it produced a nice output for what I wanted.) The one issue I have run into was that I want the make the headings/title look like they would in my other tables. What I mean is that the "main" \gantttitle
would have a \toprule
etc. and the bottom of the table would have a \bottomrule
. I have tried entering this type of code into the ganttchart but it won't compile.
I have a MWE that has a the Gantt Chart as I have it set up (but with some irrelevant fun data in it) and a smaller table to show the format I hope to be able to put on the chart.
\documentclass[a4paper]{memoir}
\usepackage{libertine}
\usepackage{pgfgantt}
\usepackage[graphicx]{realboxes}
\begin{document}
\begin{table}
\centering
\caption{Members of the Intergalactic committee}
\label{IGC-Mem}
\resizebox{\textwidth}{!}{
\begin{ganttchart}[y unit title=0.65cm,y unit chart=0.80cm,vgrid={draw=none, draw=none, dotted},title height=1.00,bar/.append style={fill=gray!30},bar height=0.50,canvas/.style=%
{shape=rectangle, draw=black, dotted}]{1}{21}
\gantttitle{Members of IGC by delegation}{21}\\
\gantttitle{2525}{3}
\gantttitle{2526}{3}
\gantttitle{2527}{3}
\gantttitle{2528}{3}
\gantttitle{2529}{3}
\gantttitle{2530}{3}
\gantttitle{2531}{3}\\
%Member Details
\ganttbar{The Federation}{1}{1}
\ganttbar[inline]{Capt. Kirk}{1}{6}
\ganttbar[inline]{Mr.~ Spock}{7}{21} \\
\ganttbar{The Empire}{1}{1}
\ganttbar[inline]{Darth Vader}{1}{7}\\
\ganttbar{The Republic}{21}{21}
\ganttbar[inline]{Princess Leia}{8}{17}
\ganttbar[inline]{Han Solo}{18}{21}\\
\ganttbar{Earth}{1}{1}
\ganttbar[inline]{Buck Rodgers}{1}{21}\\
\ganttbar{Red Dwarf}{1}{1}
\ganttbar[inline]{D. Lister}{1}{3}
\ganttbar[inline]{A. Rimmer}{4}{9}
\ganttbar[inline]{Kryten}{10}{21}\\
\ganttbar{Romulan}{1}{1}
\ganttbar[inline]{Vreenak}{1}{21}\\
\ganttbar{Imaginationland}{21}{21}
\ganttbar[inline]{Leopold "Butters" Stotch}{12}{21}
\end{ganttchart}
}
\hrulefill
\end{table}
\begin{table}
\centering
\caption{Members of the Intergalactic committee}
\label{IGC-Mem1}
\resizebox{\textwidth}{!}{%
\begin{tabular}{@{}llllllll@{}}
\toprule
\multicolumn{8}{c}{\textbf{Members of the IGC by delegation}} \\ \midrule
& \multicolumn{1}{c}{{2525}} & \multicolumn{1}{c}{{2526}} & \multicolumn{1}{c}{{2527}} & \multicolumn{1}{c}{{2528}} & \multicolumn{1}{c}{{2529}} & \multicolumn{1}{c}{{2530}} & \multicolumn{1}{c}{{2531}} \\
\multicolumn{1}{l|}{The Federation} & \multicolumn{2}{c|}{Capt. Kirk} & \multicolumn{5}{c|}{Mr. Spock} \\ \cline{2-8}
\multicolumn{1}{l|}{The Empire} & \multicolumn{5}{c|}{Darth Vader} \\ \cline{2-8}
\multicolumn{1}{l|}{Earth} & \multicolumn{7}{c|}{Buck Rodgers} \\ \cline{2-8} \bottomrule
\end{tabular}
}
\end{table}
\end{document}
I tried editing the Canvas in the ganttchart settings but that has only got me as far as what is in the MWE above. If you need any more info please let me know in the comments. Effectively what I would like is the main heading in the Gantt Chart to look like a table heading.
Best Answer
Here's one possibility; you first box the Gantt chart and then place it inside a TikZ named
\node
; using\draw
and the node anchors you can now easily place the rules.\heaverulewidth
forline width
gives the thickness of\toprule
and\bottomrule
, and\lightrulewidth
gives the one from\midrule
; I also setinner xsep
to\tabcolsep
to have the usual horizontal padding for the contents of a table (you can set it to0pt
if you want to).The code:
A variation on the same idea, but this time just the midlle rule is
\drawn
: