[Tex/LaTex] Two-line labels in ganttchart

line-breakingline-spacingpgfgantt

Is there any possibility to set up ganttchart with two-lines labels?

\begin{ganttchart}[inline]{1}{12}
    \gantttitlelist{1,...,12}{1} \\
    \ganttbar{two\\lines}{1}{2} 
\end{ganttchart}

Two-line labels in ganttchart

Best Answer

As described in Manual/automatic line breaks and text alignment in TikZ nodes there are various ways of having line breaks in nodes. The first suggestion, with tabular, will work directly in your case I'd think. If you want to use the second or third method, you need to modify the bar inline label node style, as you're using the inline option. (Otherwise it would be bar label node.)

I think you need to change the bar height manually though, if you want the bar to be taller, so use

\ganttbar[bar height=1]{two\\lines}{1}{2} \\

bar label with two lines

\documentclass{book}
\usepackage{pgfgantt}
\begin{document}
\begin{ganttchart}[
  inline,
  bar inline label node/.append style={
    align=center,
   },
]{1}{12}
    \gantttitlelist{1,...,12}{1} \\
    \ganttbar[bar height=1]{two\\lines}{1}{2} \\
\end{ganttchart}
\end{document}