Pgfgantt: table or formatting for the task names and extra information

pgfgantt

Problem: I am trying to include more information on the task name on a Gantt chart made with pgfgantt, in the form: ID, task name, duration and perhaps more information such as start/end dates. I am planning on making fortnightly and summary Gantt charts for specific periods so I need to include ID's so that they can be referenced.

My current method: I am using a custom command with \parbox's so that the information can be included and spaced correctly but I could not see a way to include a heading above it to specify what the information means e.g. "ID", "Task Name", "Duration". Nor could I find a way to include formatting like boundaries so it resembles a table.

What I would like: Preferably, if there is a way to put information in a table to the left of the Gantt chart that would be ideal, but if that is not possible or difficult (I do not know TikZ well and I read that is what pgfgantt uses) then a way of introducing boundaries ("1 | Example task name | 3 days ") and/or a heading above the first entry would be nice. I am open to other methods then using \parbox but that is a back-up method if needed. I obtained most of the code in the MWE from the pgfgantt manual, I think it was an example.

MWE:

\documentclass{article}
\usepackage{pgfgantt}
\usepackage[landscape]{geometry}

\newcommand\TEF[3]{\textbf{[#1]}\hspace{0.2cm}\parbox{3cm}{#2}\hspace{0.2cm}\parbox{1cm}{#3}}

\begin{document}
\begin{ganttchart}[ %
    vgrid, hgrid,
    y unit title=0.6cm,
    y unit chart=0.5cm,
    title label font=\tiny,
    bar label font=\tiny,
    group label font=\tiny,
    milestone label font=\tiny,
    today label font=\tiny,
    vrule label font=\tiny]{1}{24}
\gantttitle{2011}{24} \\
\gantttitlelist{1,...,24}{1} \\
\ganttgroup{\TEF{3}{Text to see if it puts it in right}{14 days}}{1}{7} \\
\ganttbar{\TEF{3}{Text to see if it puts it in right}{2 days}}{1}{2} \\
\ganttlinkedbar{\TEF{3}{Text to see if it puts it in right}{2 days}}{3}{7} \ganttnewline
\ganttmilestone{\TEF{3}{Text to see if it puts it in right}{2 days}}{7} \ganttnewline
\ganttbar{\TEF{3}{Text to see if it puts it in}{2 days}}{8}{12}
\ganttlink{elem2}{elem3}
\ganttlink{elem3}{elem4}

\end{ganttchart}
\end{document}

How it currently looks:

enter image description here

Any help would be appreciated, I am not sure why there is such a gap between the "# days" and the chart either.

Best Answer

One possibility is to style the bar-, group- and milestone- label node keys using rectangle split to make 3 columns. Then you can use a modified version of your \TEF command to place the content in each nodepart. Each of those nodeparts can then be formatted for the necessary width, alignment and so on. The column headers are just a ganttbar that does not draw a bar.

% https://tex.stackexchange.com/q/612214/
\documentclass{article}
\usepackage{pgfgantt}
\usepackage[landscape]{geometry}
\usetikzlibrary{shapes.multipart}
\newcommand\TEF[3]{\nodepart[text width=0.75cm,align=center]{one}\textbf{[#1]} 
                   \nodepart[text width=3cm]{two}{#2} 
                   \nodepart[text width=1.0cm,align=right]{three}{#3}
                   }

\begin{document}

\begin{ganttchart}[ %
    vgrid, hgrid,
    y unit title=0.6cm,
    y unit chart=0.75cm,
    title label font=\tiny,
    bar label font=\tiny,
    bar label node/.append style={rectangle split, rectangle split parts=3,rectangle split horizontal,draw,},
    group label font=\tiny,
    group label node/.append style={rectangle split, rectangle split parts=3,rectangle split horizontal,draw},
    milestone label font=\tiny,
    milestone label node/.append style={rectangle split, rectangle split parts=3,rectangle split horizontal,draw},
    today label font=\tiny,
    vrule label font=\tiny]{1}{12}
\gantttitle{2011}{12} \\
\gantttitlelist{1,...,12}{1} \\
\ganttbar{\TEF {ID} {Task Name} {Duration}}{1} {0} \\
\ganttgroup{\TEF {1} {Text to see if it puts it in right} {14 days}} {1} {7} \\
\ganttbar{\TEF {2} {Text to see if it puts it in right} {2 days}} {1} {2} \\
\ganttlinkedbar{\TEF {3} {Text to see if it puts it in right} {2 days}} {3} {7} \ganttnewline
\ganttmilestone{\TEF {4} {Text to see if it puts it in right} {2 days}} {7} \ganttnewline
\ganttbar[bar/.append style={fill=green}]{\TEF {5} {Text to see if it puts it in} {2 days}} {8} {12}
\ganttlink{elem2}{elem3}
\ganttlink{elem3}{elem4}
\end{ganttchart}

\end{document}

Which gives this: enter image description here

Related Question