1

I need to draw a gantt chart in my LaTex document and found the pgfgantt package that does just that. Unfortunately, it requires the TikZ` package, and it looks like I'm having trouble with it, and I can't tell why because I never used it.

Here's my code :

\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel} 
\usepackage{tikz}
\usepackage{pgfgantt}
\usetikzlibrary{arrows,backgrounds,calc,patterns,shapes,positioning,shadows,trees}
\usepackage{pgfcalendar}
\begin{document}
\begin{figure}[ht!]
\begin{ganttchart}{1}{15}
    \gantttitle{Du 1er Février au 9 Mai}{15} \\
    \gantttitlelist{1,...,15}{1} \\
    \ganttgroup{Préparation}{1}{3} \\
    \ganttbar{Recherche de ressources}{1}{3} \\
    \ganttbar{Définition des contraintes}{1}{3} \\
    \ganttbar{Recherche de méthode d'archivage}{1}{1} \\
    \ganttlinkedbar{Mise en place archivage}{2}{3} \\
\end{ganttchart}
\caption{Diagramme de Gantt pour le projet SN3D}
\end{figure}
\end{document}

And here are the error messages :

!Package tikz Error : + or - expected (line of the \ganttlinkedbar command)

!Package tikz Error : Giving up on this path. Did you forget a semicolon? (same line)

I went through the pgfgantt documentation but couldn't find anything about that. I also searched google and didn't find anything that could help me.

Thanks for your help !

EDIT : I tried to use TikZ babel library but in created several errors in another part of my code using TikZ` that didn't have any problem earlier.

Here's my complete code :

\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel} 
\usepackage{graphicx}
\usepackage{stmaryrd}
\usepackage{amssymb}
\usepackage{dsfont}
%Pour les images (gantt, WBS)
\usepackage{tikz}
%Pour délimiter les flottants
\usepackage{placeins}
\usepackage{pgfgantt}

\usetikzlibrary{arrows,backgrounds,calc,patterns,shapes,positioning,shadows,trees}
\usepackage{pgfcalendar}

\tikzset{
  basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=green!30},
  level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
                   text width=8em},
  level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}
\title{Plan de développement}
\author{Groupe PEI n\textsuperscript{o}44 \\ \\ Entreprise SN3D}
\date{le 3 Février 2016}
\begin{document}
\maketitle
\tableofcontents
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                              PARTIE 1                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Définition du projet}
\subsection{Contexte du projet}
\subsection{Objectifs de la mission}
\subsection{Livrables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                              PARTIE 2                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Modalités d'exécution}
\subsection{Cycle de vie}
\subsection{Work Breakdown Structure du projet}
L'objectif fixé est de rendre au client un livrable recensant une sélection de capteurs intégrés ou modules assortie de cas d'utilisation précis. \`A cette fin, le travail sera décomposé de la manière suivante : \newline
%%%%%%%%%%% WBS %%%%%%%%%%%%%%%
\FloatBarrier
\begin{figure}[ht!]
%makebox pour centrer les figures trop larges
\makebox[\textwidth][c]{
\begin{tikzpicture}[level 1/.style={sibling distance=40mm},
edge from parent/.style={->,draw},>=latex]
% root of the the initial tree, level 1
\node[root] {Projet SN3D}
% The first level, as children of the initial tree
  child {node[level 2] (c1) {Choix des outils de travail}}
  child {node[level 2] (c2) {Recherche des capteurs}}
  child {node[level 2] (c3) {Définition de cas d'usage}}
    child {node[level 2] (c4) {Synthèse et mise en forme}};

% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Archivage};
\node [below of = c11] (c12) {Sources};
\node [below of = c12] (c13) {Mise en forme};

\node [below of = c2, xshift=15pt] (c21) {Intensive};
\node [below of = c21] (c22) {Veille};


\node [below of = c3, xshift=15pt] (c31) {Scénari};
\node [below of = c31] (c32) {Aspects techniques};
\node [below of = c32] (c33) {Illustrations};

\node [below of = c4, xshift=15pt] (c41) {Livrable};
\node [below of = c41] (c42) {Rapport};
\node [below of = c42] (c43) {Poster};
\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \value in {1,2,3}
  \draw[->] (c1.195) |- (c1\value.west);

\foreach \value in {1,...,2}
  \draw[->] (c2.195) |- (c2\value.west);

\foreach \value in {1,...,3}
  \draw[->] (c3.195) |- (c3\value.west);

\foreach \value in {1,...,3}
  \draw[->] (c4.195) |- (c4\value.west);
\end{tikzpicture}
}
\caption{WBS du projet}
\end{figure}
\FloatBarrier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Planning (diagramme de Gantt)}
Les différentes tâches s'enchaînent assez naturellement du fait de leur forte dépendance. Le planning initialement prévu que l'on donne ci-après a une forme simple. Le projet en tant que tel démarrera le 1er Février pour une durée de 15 semaine.
\begin{figure}[ht!]
\begin{ganttchart}{1}{15}
    \gantttitle{Du 1er Février au 9 Mai}{15} \\
    \gantttitlelist{1,...,15}{1} \\
    \ganttgroup{Préparation}{1}{3} \\
    \ganttbar{Recherche de ressources}{1}{3} \\
    \ganttbar{Définition des contraintes}{1}{3} \\
    \ganttbar{Recherche de méthode d'archivage}{1}{1} \\
    \ganttlinkedbar{Mise en place archivage}{2}{3} \\
\end{ganttchart}
\caption{Diagramme de Gantt pour le projet SN3D}
\end{figure}
\subsection{Ressources}
Le groupe de travail est constitué de cinq membres : Telem Avidor, Léo En terme d'exécution, il est prévu que tous les membres de l'équipe jouent des rôles interchangeables en fonction de la situation.
\subsection{Communication}
\end{document}
  • Welcome to TeX.SX. The problem is babel and the option for French, see tikz declare function and babel french option. Adding \usetikzlibrary{babel} fixes it. – Torbjørn T. Jan 28 '16 at 11:44
  • It works for the example I gave, but when I put it in my actual file that contains other lines of code including other uses of TiKZ, I got several errors like "Paragraph ended before \pgffor@next was complete" or "missing \endgroup inserted". Should I post my complete code here or is it a problem with an obvious solution ? – Experience111 Jan 28 '16 at 14:28
2

You're missing the textcomp package I think, at least I needed to add that. After adding that and the babel library for TikZ I also had to add braces around the \draw in the \foreach. Not entirely sure why that is that case, but going from

\foreach \value in {1,2,3}
  \draw[->] (c1.195) |- (c1\value.west);

\foreach \value in {1,...,2}
  \draw[->] (c2.195) |- (c2\value.west);

\foreach \value in {1,...,3}
  \draw[->] (c3.195) |- (c3\value.west);

\foreach \value in {1,...,3}
  \draw[->] (c4.195) |- (c4\value.west);

to

\foreach \myvalue in {1,2,3}{
  \draw[->] (c1.195) |- (c1\myvalue.west);
  \draw[->] (c3.195) |- (c3\myvalue.west);
  \draw[->] (c4.195) |- (c4\myvalue.west);
}

\foreach \myvalue in {1,...,2}{
  \draw[->] (c2.195) |- (c2\myvalue.west);
}

solved it.

Using \value may be a bad idea as that is an existing macro. Complete code.

\documentclass[a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel} 
\usepackage{graphicx}
\usepackage{stmaryrd,textcomp}
\usepackage{amssymb}
\usepackage{dsfont}
%Pour les images (gantt, WBS)
\usepackage{tikz}
%Pour délimiter les flottants
\usepackage{placeins}
\usepackage{pgfgantt}

\usetikzlibrary{arrows,backgrounds,calc,patterns,shapes,positioning,shadows,trees,babel}
\usepackage{pgfcalendar}

\tikzset{
  basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=green!30},
  level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
                   text width=8em},
  level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}
\title{Plan de développement}
\author{Groupe PEI n\textsuperscript{o}44 \\ \\ Entreprise SN3D}
\date{le 3 Février 2016}
\begin{document}
\maketitle
\tableofcontents
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                              PARTIE 1                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Définition du projet}
\subsection{Contexte du projet}
\subsection{Objectifs de la mission}
\subsection{Livrables}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                              PARTIE 2                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Modalités d'exécution}
\subsection{Cycle de vie}
\subsection{Work Breakdown Structure du projet}
L'objectif fixé est de rendre au client un livrable recensant une sélection de capteurs intégrés ou modules assortie de cas d'utilisation précis. \`A cette fin, le travail sera décomposé de la manière suivante : \newline
%%%%%%%%%%% WBS %%%%%%%%%%%%%%%
\FloatBarrier
\begin{figure}[ht!]
%makebox pour centrer les figures trop larges
\makebox[\textwidth][c]{
\begin{tikzpicture}[level 1/.style={sibling distance=40mm},
edge from parent/.style={->,draw},>=latex]
% root of the the initial tree, level 1
\node[root] {Projet SN3D}
% The first level, as children of the initial tree
  child {node[level 2] (c1) {Choix des outils de travail}}
  child {node[level 2] (c2) {Recherche des capteurs}}
  child {node[level 2] (c3) {Définition de cas d'usage}}
    child {node[level 2] (c4) {Synthèse et mise en forme}};

% The second level, relatively positioned nodes
\begin{scope}[every node/.style={level 3}]
\node [below of = c1, xshift=15pt] (c11) {Archivage};
\node [below of = c11] (c12) {Sources};
\node [below of = c12] (c13) {Mise en forme};

\node [below of = c2, xshift=15pt] (c21) {Intensive};
\node [below of = c21] (c22) {Veille};


\node [below of = c3, xshift=15pt] (c31) {Scénari};
\node [below of = c31] (c32) {Aspects techniques};
\node [below of = c32] (c33) {Illustrations};

\node [below of = c4, xshift=15pt] (c41) {Livrable};
\node [below of = c41] (c42) {Rapport};
\node [below of = c42] (c43) {Poster};
\end{scope}

% lines from each level 1 node to every one of its "children"
\foreach \myvalue in {1,2,3}{
  \draw[->] (c1.195) |- (c1\myvalue.west);
  \draw[->] (c3.195) |- (c3\myvalue.west);
  \draw[->] (c4.195) |- (c4\myvalue.west);}

\foreach \myvalue in {1,...,2}{
  \draw[->] (c2.195) |- (c2\myvalue.west);
}
\end{tikzpicture}
}
\caption{WBS du projet}
\end{figure}
\FloatBarrier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Planning (diagramme de Gantt)}
Les différentes tâches s'enchaînent assez naturellement du fait de leur forte dépendance. Le planning initialement prévu que l'on donne ci-après a une forme simple. Le projet en tant que tel démarrera le 1er Février pour une durée de 15 semaine.
\begin{figure}[ht!]
\begin{ganttchart}{1}{15}
    \gantttitle{Du 1er Février au 9 Mai}{15} \\
    \gantttitlelist{1,...,15}{1} \\
    \ganttgroup{Préparation}{1}{3} \\
    \ganttbar{Recherche de ressources}{1}{3} \\
    \ganttbar{Définition des contraintes}{1}{3} \\
    \ganttbar{Recherche de méthode d'archivage}{1}{1} \\
    \ganttlinkedbar{Mise en place archivage}{2}{3} \\
\end{ganttchart}
\caption{Diagramme de Gantt pour le projet SN3D}
\end{figure}
\subsection{Ressources}
Le groupe de travail est constitué de cinq membres : Telem Avidor, Léo En terme d'exécution, il est prévu que tous les membres de l'équipe jouent des rôles interchangeables en fonction de la situation.
\subsection{Communication}
\end{document}
  • Thanks a lot. I don't have any idea as to why, but including the \usepackage[babel=true, kerning=true]{microtype} that I randomly found on the internet solved it too. Your answer is more comprehensive though. – Experience111 Jan 28 '16 at 14:59
  • babel set the ":" and "!" as active caracters and it interfere with tikz. An other way disable them with \shorthandoff{:,!} – Alain Remillard Jan 28 '16 at 16:16
  • @JeremyDiallo Alain's comment was for you I believe. – Torbjørn T. Jan 28 '16 at 16:20
  • @JeremyDiallo By the way, if you get useful answers consider upvoting and/or accepting them. Accepting an answer marks the question as solved. – Torbjørn T. Feb 8 '16 at 11:45
  • Sorry, I'm not used to this site. Upvoted. – Experience111 Feb 9 '16 at 12:15

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.