3

Does anybody know how can I put several milestones in the same line? The only way I figured out is like in the picture (different lines) and so I did in the code below but it would be better to have all the milestones as one single line.

The code has been modified as I put more commands to be compiled correctly. For those who try you will need the file gantt.sty from http://www.martin-kumm.de/wiki/doku.php?id=05Misc:A_LaTeX_package_for_gantt_plots.

enter image description here

\documentclass{article}
  \usepackage{tikz}
  \usepackage{gantt}
  \begin{document}
   \begin{flushleft}
   \scalebox{0.7}{
    \begin{gantt}{10}{18}
    \begin{ganttitle}
     \titleelement{\textbf{2016}}{18}
     \end{ganttitle}
    \begin{ganttitle} 
       \titleelement{\textbf{April}}{2}
     \titleelement{\textbf{May}}{2}
  \titleelement{\textbf{June}}{2}
  \titleelement{\textbf{July}}{2}
  \titleelement{\textbf{August}}{2}
  \titleelement{\textbf{September}}{2}
   \titleelement{\textbf{October}}{2}
  \titleelement{\textbf{November}}{2}
   \titleelement{\textbf{December}}{2}
\end{ganttitle}
  \begin{ganttitle}

   \titleelement{01-15}{1}
  \titleelement{16-30}{1}
  \titleelement{01-15}{1}
  \titleelement{16-31}{1}
  \titleelement{01-15}{1}
  \titleelement{16-30}{1}
  \titleelement{01-15}{1}
  \titleelement{16-31}{1}
  \titleelement{01-15}{1}
  \titleelement{16-31}{1}
  \titleelement{01-15}{1}
  \titleelement{16-30}{1}
  \titleelement{01-15}{1}
  \titleelement{16-31}{1}
  \titleelement{01-15}{1}
  \titleelement{16-30}{1}
  \titleelement{01-15}{1}
  \titleelement{16-31}{1}
  \end{ganttitle}
 \ganttgroup{\textsc{\textbullet\ Internal Organization}}{0}{8}
\ganttbar[pattern=crosshatch,color=blue]{\textsf{- Responsible}}{2}{1}
\ganttbar[pattern=crosshatch,color=blue]{\textsf{- Work spaces}}{2}{1}
\ganttbar[pattern=crosshatch,color=red]{- \textbf{Inventory}}{2}{6}
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{Checkpoint}}}}{4} 
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{Checkpoint}}}}{5} 
\ganttgroup{\textsc{\textbullet\ Kick-Off}}{10}{6}
 \end{gantt}
  }
\end{flushleft}
\end{document}

Thank to all!

  • Can you make a complete, compilable example? Where does the ganttitle environment and \titlelement macro come from, for example? Also, the main environment defined by pgfgantt is called ganttchart, not just gantt. – Torbjørn T. May 11 '16 at 11:52
  • I used the package gantt available with an auxiliar file called gantt.sty – José May 11 '16 at 14:26
  • And where did you find gantt.sty? It's not on CTAN, so not in TeX Live or MikTeX. – Torbjørn T. May 11 '16 at 14:35
  • Here: martin-kumm.de/wiki/… – José May 11 '16 at 14:40
  • Note that the link has changed to martin-kumm.de/wiki/…. – Marijn Feb 9 '18 at 15:36
4

The package stores the row number in a counter called ganttnum. You can manually adjust this counter with \addtocounter{ganttnum}{n}to set the row where you want the next plot element (e.g., milestone) to appear. Positive numbers are up, negative numbers are down. If you want multiple elements on one line then you should leave the description blank for all but the first element, otherwise Tikz will draw them slightly shifted at the same position.

Example:

\ganttgroup{\textsc{\textbullet\ Internal Organization}}{0}{8}
\ganttbar[pattern=crosshatch,color=blue]{\textsf{- Responsible}}{2}{1}
\ganttbar[pattern=crosshatch,color=blue]{\textsf{- Work spaces}}{2}{1}
\ganttbar[pattern=crosshatch,color=red]{- \textbf{Inventory}}{2}{6}
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{Checkpoint}}}}{4} 
\addtocounter{ganttnum}{1}
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{}}}}{5}
\ganttgroup{\textsc{\textbullet\ Kick-Off}}{10}{3}
\addtocounter{ganttnum}{2}
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{}}}}{13}
\addtocounter{ganttnum}{-1}
\ganttgroup{\textsc{\textbullet\ Prototype}}{13}{2}
\addtocounter{ganttnum}{3}
\ganttmilestone[color=red]{\sffamily{\textit{\textcolor{red}{}}}}{15}

Result:

enter image description here

|improve this answer|||||
  • Great! It worked perfectly. Cheers!!! – José May 11 '16 at 21:42

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.