1

Consider the following Minimum Working Example (MWE):

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfgantt}

\begin{document}
    \begin{ganttchart}[time slot format=isodate]{2019-01-01}{2019-02-15}
        \gantttitle{TITLE}{30} \\
        \gantttitlecalendar{year, month=name}\\
    \end{ganttchart}
\end{document}

Screenshot of the result:

Screenshot of the result


The question:

How can I automatically adjust the width of the \gantttitle to the same width as the chart itself? Messing around with absolute (incremental) values like 30 does not seem to make a big sense - I guess there is some better solution available?

Screenshot of the desired state

1

You can define a command that returns the range, and use it.

\documentclass{standalone}
\usepackage{pgfgantt}
\makeatletter
\def\ganttrange{\the\numexpr1+\the\gtt@endjulian-\the\gtt@startjulian\relax}
\makeatother
\begin{document}
    \begin{ganttchart}[time slot format=isodate]{2019-01-01}{2019-02-15}
        \gantttitle{TITLE}{\ganttrange} \\
        \gantttitlecalendar{year, month=name}\\
    \end{ganttchart}
\end{document}

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.