I'm trying to write a macros for converting day time to a format, which the pgfgrantt package can understand. Here it is:



% \gantthbar{test}{11:15}{12:00} -> \ganttbar{test}{12.25}{12.0}

Compilation failed with an error, I can't resolve:

! Use of \\ganttbar doesn't match its definition.
\kernel@ifnextchar ...rved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.37   \gantthbar{test}{11:15}{12:00}


This one compiles without errors:

  \ganttbar{#1 \from \to}{12.25}{12.0}

Thanks for your help.

Very minimal working example I wrote after reading comments:

\documentclass[a4paper, 12pt]{report}


  \pgfmathsetmacro\from{\hoursfrom + \minutesfrom / 60 + 1}
  \pgfmathsetmacro\to{\hoursto + \minutesto / 60}

  • Welcome to TeX-SX! Have a look at our starter page for a quick intro if you wish to familiarize yourself with our format. – Claudio Fiandrino Jul 29 '13 at 14:48
  • Please provide a minimal working example (MWE). Guessing from what you have there: Neither \from nor \to are fully expandable (they contain xstring macros and \pgfmathparse). Another approach is needed, e.g. let \htime assign a variable like \pgfmathsetmacro\myFrom{…} or use \pgfmathresult directly in the parameters to \ganttbar. – Qrrbrbirlbel Jul 29 '13 at 15:04
  • That being said, pgfgantt only understands integer values for the time slots (slots being the important word here). You might be interested in my answer to Gantt chart with title list in minutes and hours which could be customized in the same way so that you can use the h:mm format for the input, too. – Qrrbrbirlbel Jul 29 '13 at 15:24

Your Answer

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

Browse other questions tagged or ask your own question.