% Graphes - Paramétrage
\colorlet{commentcol}{red!70!violet}

% Changement des longueurs pour éviter un conflit avec celles du chapitre TikZ (création de diagrammes)
\newlength{\blocksep}
\addtolength{\blocksep}{2.8cm}

\newlength{\blockwh}
\addtolength{\blockwh}{4cm}

\newlength{\blockht}
\addtolength{\blockht}{2cm}

% Création des styles
\tikzset{
	node distance = \blocksep, 
	bloc/.style = {draw = cyan!50!blue, fill = cyan!50!blue, text = white, rounded corners, minimum width = \blockwh, minimum height = \blockht, text width = \blockwh - 2mm, align = center},
	dossier/.style = {bloc, draw = orange!70!yellow, fill = orange!70!yellow},
	fin/.style = {bloc, draw = Green, fill = Green},
	arrow/.style = {line width = 4pt, ->, > = Stealth},
	comment/.style = {text width = \blocksep, align = center, font = \itshape}
}

\begin{tikzpicture}
% Création des blocs
\node[bloc, fill = white, text = black, font = \bfseries, line width = 3pt] (source) {Fichier source \\ \texttt{main.tex}};
\node[dossier, left = of source] (images) {Dossier \og Images \fg{} \linebreak \texttt{.eps} \quad \texttt{.jpg} \quad \texttt{.pdf} \quad \texttt{.png}};
\node[dossier, draw = commentcol, very thick, above = of images] (fichierstex) {Fichiers \texttt{.tex} \\ (préambule, chapitres, schémas, etc.)};
\node[dossier, below = of images] (biblioA) {Bibliographie \\ \texttt{main-biblio.bib}};

\node[bloc, below = of source, xshift = \blockwh/2+\blocksep/2] (dvi) {DVI};
\node[bloc, right = of source] (ps) {PostScript (PS)};
\node[bloc, right = of ps] (output) {Fichiers annexes \\ (générés par \LaTeX{})};
\node[fin, above = of output] (pdfA) {PDF généré \\ \texttt{main.pdf}};

\node[bloc, right = of pdfA] (biblioB) {Mise en forme de la bibliographie \\ \texttt{main.bbl}};
\node[bloc, below = of biblioB, yshift = -\blockht-\blocksep] (index) {Création index \\ \texttt{.ind}};
\node[fin, right = of biblioB, yshift = -\blockht-\blocksep] (pdfB) {PDF fini ! \\ (bibliographie et/ou index)};

% Séparateur
\draw[dash pattern = on 13pt off 13pt, commentcol, line width = 3pt] ([xshift = \blockwh/2+\blocksep/4]pdfA.north) node[comment, text width = \blockwh, font = \itshape\Large, anchor = south, above, yshift = 7pt] {OPTIONNEL} -- ([xshift = -\blockwh/2-3\blocksep/4]index.south);

% Liens entre les blocs et commentaires
\draw[arrow] (source) -- (images);
\path (source) -- (images) coordinate [midway] (nfictA);
\draw[arrow] (source) -- (nfictA) node[comment, align = left, right, yshift = \blocksep] {appel} |- (fichierstex);
\node[comment, text = commentcol, minimum width = \blockwh, above] (renvoi) at (fichierstex.north) {cf. \autoref{structure-docs} \og \nameref{structure-docs} \fg{}};
\draw[arrow] (source) -- (nfictA) node[comment, align = left, right, yshift = -\blocksep] {appel} |- (biblioA);

\draw[arrow, brown] (source) |- node[comment, font = \rmfamily, align = left, anchor = south west] {\pdfLaTeX{} \\ \XeLaTeX{} \\ \LuaLaTeX{}} node[comment, text width = \blockwh, font = \rmfamily, align = left, anchor = north west] {(\texttt{.jpg}, \texttt{.pdf}, \texttt{.png} \\ \texttt{.eps} toléré)} ([yshift = \blockht/4]pdfA.west);
\draw[arrow, gray] (source) |- node[comment, align = left, font = \rmfamily, right, yshift = \blocksep] {\LaTeX{} \\ (\texttt{.eps})} (dvi);
\draw[arrow, gray] (dvi) -| node[comment, below] {\texttt{dvi2ps}} (ps);
\draw[arrow, gray] (ps) |- node[comment, align = right, left] {\texttt{ps2pdf}} ([yshift = -\blockht/4]pdfA.west);

\path (pdfA) -- (output) coordinate [midway] (nfictB);
\node[draw, circle, line width = 2pt, font = \bfseries\huge] at (nfictB) {+};

\draw[arrow] ([yshift = \blockht/4]pdfA.east) -- ([yshift = \blockht/4]biblioB.west);
\path ([yshift = -\blockht/4]pdfA.east) -- ([yshift = -\blockht/4]biblioB.west) coordinate [midway] (nfictC);
\draw[arrow] ([yshift = -\blockht/4]pdfA.east) -- (nfictC) |- node[comment, align = left, font = \rmfamily, text width = \blockwh, right, yshift = 1.5\blocksep] {\texttt{index.idx} \\ moteur MakeIndex} (index);
\draw[arrow] (biblioB) -| node[comment, text width = \blockwh, align = right, anchor = south east] {Moteur initial $\times 2$} (pdfB);
\draw[arrow] (index) -| node[comment, align = right, anchor = north east] {Moteur initial ?} (pdfB);
\end{tikzpicture}