pgf add tag
Dr. Manuel Kuehner
* I assume that I do not see the obvious in the `pgfgantt` [user manual](https://ctan.org/pkg/pgfgantt) :).
* I want to **add annotations to some of the bars, either left of the bar or right of the bar** but I do not see an obvious solution for that in the manual or on https://tex.stackexchange.com.
* The motivation is to save some horizontal space in the label area ("One" and "Two" in the MWE below) - the idea is to provide more information about each bar using the annotations.

```
\documentclass{standalone}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
		hgrid,
		vgrid={*{11}{draw = none}, dotted},
		time slot format = isodate-yearmonth,
		time slot unit = month,
		x unit = 0.60mm,
		y unit title = 3.0ex,             
		y unit chart = 3.0ex,           
	]{2010-01}{2020-12}
	%
	\gantttitlecalendar{year} \\
	%	
	\ganttbar[bar/.append style = {fill = red}]{One}{2010-03}{2011-02} \\
	\ganttbar[bar/.append style = {fill = red}]{Two}{2016-03}{2020-02}
	%	
\end{ganttchart}

\end{document}
```
![sdsdd (1)_1.jpg](/image?hash=20540c5b48f8aab29937927030a4d95fa7283677572d80c71559ee5455fadd33)
Top Answer
frougon
You can use the Ti*k*Z `label` key (ultimately, `/tikz/label`) to create an additional node next to each `pgfgantt` bar node:

```
\documentclass{standalone}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
    hgrid,
    vgrid={*{11}{draw = none}, dotted},
    time slot format = isodate-yearmonth,
    time slot unit = month,
    x unit = 0.60mm,
    y unit title = 3.0ex,
    y unit chart = 3.0ex,
  ]{2010-01}{2020-12}
  %
  \gantttitlecalendar{year} \\
  %
  \ganttbar[bar/.append style={
             fill=red, label=right:{Annotation~1}}]
    {One}{2010-03}{2011-02} \\
  \ganttbar[bar/.append style={
             fill=red, label={[font=\footnotesize]left:{Annotation~2}}}]
    {Two}{2016-03}{2020-02}
\end{ganttchart}

\end{document}
```

![docu.png](/image?hash=e6fc7a2e6f03094347fdd4a1c90135f8614ac2c07d0fb6017d3573933655c421)

Here is a more evolved, and hopefully user-friendly, variant of the same technique. It implements a `/tikz/mylabel` key whose syntax is `mylabel={opts=..., angle=..., text=...}` with user-customizable defaults for `opts` and `angle` (the `text` key is mandatory; not giving it is an error).

```
\documentclass{standalone}
\usepackage{pgfgantt}

\makeatletter
\newcommand*{\manuelk@ganttlabel}[3]{%
  \tikzset{label={[{#1}]#2:{#3}}}% we want a ':' of catcode 12
}

\ExplSyntaxOn
\cs_new_eq:NN \manuelk_ganttlabel:nnn \manuelk@ganttlabel % simple alias

% Variant that feeds the “value” of each argument to \manuelk@ganttlabel
\cs_generate_variant:Nn \manuelk_ganttlabel:nnn { VVV }
\cs_new_eq:NN \myganttlabel \manuelk_ganttlabel:VVV
\ExplSyntaxOff

\let\manuelkganttlabelfont\empty % no font change by default

\tikzset{
  mylabel/.code={%
    \pgfqkeys{/manuelk/gantt/mylabel}{#1, @opts/.get=\manuelk@ganttlabel@opts}%
    \myganttlabel{\manuelk@ganttlabel@opts}
                 {\manuelk@ganttlabel@angle}
                 {\manuelk@ganttlabel@text}%
  },
  /manuelk/gantt/mylabel/.cd,
  opts/.style={/manuelk/gantt/mylabel/@opts/.append={,#1}},
  override opts/.style={/manuelk/gantt/mylabel/@opts={#1}},
  angle/.store in=\manuelk@ganttlabel@angle,
  text/.store in=\manuelk@ganttlabel@text,
  % Defaults (no default for 'text' so that a missing text triggers an error)
  @opts/.initial={font=\manuelkganttlabelfont},
  angle=right,
}
\makeatother

% User code starts here
\let\manuelkganttlabelfont\small % change the default font for 'mylabel' texts

\pgfkeys{
  /pgfgantt/bar/.append style={fill=red},
  % Users can change the defaults here
  /manuelk/gantt/mylabel/.cd,
  % angle=left,
  % You can use 'override opts' instead of 'opts' to *replace* the default
  % options in /manuelk/gantt/mylabel/@opts ('opts' only appends to them).
  opts={text=green},
}

\begin{document}

\begin{ganttchart}[
    hgrid,
    vgrid={*{11}{draw = none}, dotted},
    time slot format = isodate-yearmonth,
    time slot unit = month,
    x unit = 0.60mm,
    y unit title = 3.0ex,
    y unit chart = 3.0ex,
  ]{2010-01}{2020-12}
  %
  \gantttitlecalendar{year} \\
  %
  \ganttbar[bar/.append style={
              mylabel={opts={font=\manuelkganttlabelfont\bfseries, text=blue},
                       text=Annotation~1}}]
    {One}{2010-03}{2011-02} \\
  \ganttbar[bar/.append style={mylabel={angle=left, text=Annotation~2}}]
    {Two}{2016-03}{2020-02}
\end{ganttchart}

\end{document}
```

![docu2.png](/image?hash=0719b357a6a0f2b9c823a6a0414c1a10c97d92d4f6b4ba8c693ad8de9a4201e8)

Note that you can place annotations at arbitrary angles, using for instance `angle=45`.

# Even more fun

```
\documentclass{standalone}
\usepackage{pgfgantt}
\usetikzlibrary{decorations.pathmorphing, shadows}

(...)

\ganttbar[bar/.append style={
            mylabel={opts={circular drop shadow={shadow scale=1.05},
                           decorate, decoration=zigzag,
                           inner sep=0.5em, draw=blue, text=blue,
                           fill=gray!20, label distance=0.5em,
                           font=\manuelkganttlabelfont\bfseries},
                     text=Annotation~1}}]
  {One}{2010-03}{2011-02} \\
    
(...)
```

![docu2.png](/image?hash=15673919224fc5c14f59c0c554446da1b7af3701ae1866ed9f1823a89c27dccb)
Answer #2
samcarter
A bit hacky, but one can abuse the progress label to add custom texts:

```
\documentclass{standalone}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
  hgrid,
  vgrid={*{11}{draw = none}, dotted},
  time slot format = isodate-yearmonth,
  time slot unit = month,
  x unit = 0.60mm,
  y unit title = 3.0ex,             
  y unit chart = 3.0ex,           
]{2010-01}{2020-12}
%
\gantttitlecalendar{year} \\
%	
\ganttbar[
  bar/.append style = {fill = red},
  progress=100,
  progress label text={some annotation 1},
  bar progress label node/.append style={green!70!black}
]{One}{2010-03}{2011-02} \\
\ganttbar[
  bar/.append style = {fill = red},
  progress=100,
  progress label text={some annotation 2},
  bar progress label anchor=west,
  bar progress label node/.append style={green!70!black,anchor=east}
]{Two}{2016-03}{2020-02}
%	
\end{ganttchart}

\end{document}
```
![document.png](/image?hash=d7f68406c240242f71155c4526652d353693690b48712813cc1ebb2fd677a66c)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.