# pgfgantt: Named links in order to maintain relationship between bars

I have a pretty complex pgfgantt chart. Several people are collaboratively working on it and it is subject to frequent change.

In this chart the individual \ganttbar items are linked with the \ganttlink command. The ganttbar items are referred to by elem0, elem1, ..., elemn.

To illustrate my problem consider this minimal pgfgantt example:

\begin{ganttchart}{3}{1}
\end{ganttchart}


Now lets assume that "Task 2" is removed:

\begin{ganttchart}{3}{1}
\end{ganttchart}


Of course I have to remove \ganttlink {elem0}{elem1}. However I also have to change all subsequent links as well in order to maintain the correct relationships. In the example above \ganttlink {elem2}{elem3} had to be changed to \ganttlink {elem1}{elem2}. In a complex gantt chart this quickly becomes tedious and very error prone .

So my question is: Is it possible to reference a \ganttbar rather by a custom name than by elemn, e.g. \ganttlink{mytask1}{mytask2}?

The option name to ganttbar allows you to change the name of the element to whatever you want. Use this as

\ganttbar[name=myname]{Title}{1}{3}


and thereafter refer to this element as myname.

\documentclass{article}

\usepackage{pgfgantt}

\begin{document}
\begin{ganttchart}[x unit=2cm,vgrid]{1}{4}
\end{ganttchart}

\medbreak

\begin{ganttchart}[x unit=2cm,vgrid]{1}{4}