1

It seems that pgfgantt is vertically aligning inline label by automatically taking into account the space for descenders:

\documentclass{article}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
    inline,
]{1}{4}
\ganttbar{XX}{2}{3}
\end{ganttchart}

\end{document}

enter image description here enter image description here

The same can also be seen in the examples in the pgfgantt's manual. How can I force it to vertically center labels if there are no descenders? I achieved this by setting bar inline label node/.append style={text depth=.5ex}, but I don't want to manually set a magical number every time.

1
  • pgfgatt.sty hardcoded several \strut in the value of various xxx label text keys. Removing them need patch internals of pgfgatt.sty. Commented Sep 22, 2020 at 15:18

1 Answer 1

1

To remove the \strut auto-inserted in bar label text, use

\ganttset{bar label text=#1}

To remove every \strut auto-inserted in similar areas, use

\documentclass{article}
\usepackage{pgfgantt}
\usepackage{xpatch}

\ganttset{
  title label text=#1,
  bar label text=#1,
  group label text=#1,
  milestone label text=#1,
}

\makeatletter
\xpatchcmd\@newganttchartelement@definekeys
  {\strut}
  {}
  {}{\fail}
\makeatother


\begin{document}

\begin{ganttchart}[inline]{1}{4}
  \ganttbar{XX}{2}{3}
\end{ganttchart}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .