1

I'd like to position the first element of my chart just above the x axis to make the first line like a "L" shape. Here is what I have now:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning, fit, arrows}
\begin{document}
    \begin{tikzpicture}[>=stealth,
        mymatrix/.style={
            matrix of nodes,
            nodes={typetag},
            row sep=1em,
            align=center
            },
        mycontainer/.style={draw=gray, inner sep=1ex},
        typetag/.style={draw=gray, inner sep=1ex, anchor=base,fill=green!50},
        title/.style={draw=none, color=gray, inner sep=0pt,fill=blue!10}
        ]

        \matrix[mymatrix,fill=blue!10] (ext) at (0,0) {
            |[title]|Externalisation? \\[.7em]
        };

        \matrix[mymatrix,fill=blue!10,right=45pt of ext] (source) {
            |[title]|Donnée source \\
            Chercher \\
            Transférer \\
            Stocker \\
        };
        \draw[->] (ext.south) |- node [above] {choix} node [below] {effectué} ++(1.5,0) |- (source.west) ;
        \matrix[mymatrix,fill=blue!10,right=75pt of source, nodes in empty cells,
    row 3/.style = {nodes={draw=none,fill=blue!10}}] (trans) {
            |[title]|Transformation \\
            Spécification \\
            \\
            Développement \\
        };
        \path[<->]
            (trans-2-1) edge node [midway,align=center] {enrichissement \\ mutuel} (trans-4-1);

        \draw[->] (source.east) -- node [above] {donnée source} node [below] {récupérée} ++(2.5,0) -- (trans.west);
        \matrix[mymatrix,fill=blue!10,right=75pt of trans] (int) {
            |[title]|Intégration \\
            Tests \\
            Bascule \\
        };

        \draw[double,<->] (trans.east) -- node [above] {enrichissement} node [below] {mutuel} ++(2.5,0) -- (int.west);
    \end{tikzpicture}
\end{document}

And the picture: chart

You see that the first arrow is ugly... Thanks in advance :)

  • 1
    It is difficult to understand what you mean by "L" shape. Do you want the "Externalisation?" block to be above left of all the others? – Bibi Feb 11 at 14:23
2

Welcome to TeX.sx!

To get the accents and the typography right (e.g. a space before the ?), use:

\usepackage[utf8]{inputenc}
\usepackage[french]{babel}

Be careful, you have several places where you left a space before \\. LaTeX sees this space, and adds an extra space inside the node (this is why the text is not exactly centered, you can see it in the Externalisation ?<space> node for example. I removed the extra spaces that I saw in the code below.

To place the second matrix below right of the second one, use

        \matrix[mymatrix,fill=blue!10,below right=45pt of ext] (source) {

You can change the x and y distances independently as follows (the dimensions here are 5pt on the y axis and 45pt on the x axis):

        \matrix[mymatrix,fill=blue!10,below right=5pt and 45pt of ext] (source) {

Note that the distance is measured from edge to edge (or in this shape from corner to corner). If you want to measure the y position of the first matrix relative to the position where the arrow arrives in the second matrix, use anchor=west so that the second matrix hangs at the desired position from its west node (I use 1.5\baselineskip to have a 1.5× interline instead of messing with pt by trial-and-error):

        \matrix[mymatrix,fill=blue!10,below right=1.5\baselineskip and 45pt of ext, anchor=west] (source) {

I used a dirty hack to place the text correctly. The chx is above the corner, to the right, and I place an eff node that is at the wrong place horizontally (but make it phantom so that it does not appear in the result). Then, I use (chx |- eff) to use the x of (the center of) chx, and the y of eff (since eff and the actual effectué nodes have the same height, they are aligned as expected, but note that by default it will use the .west anchor on eff and the .center anchor on effectué).

        \draw[->] (ext.south) |- node (chx) [above right] {choix} node (eff) [below right] {\phantom{effectué}} (source.west) ;
        \node at (chx |- eff) {effectué};

I find this nice (with the choix in the corner, and the effectué hanging slightly below), but if you wanted to have the left edge of effectué just below the corner, you could swap the phantom and the nodes on either side of the |-, as follows (then the chx is phantom, and the real choix is placed relative to chx's y and eff's y):

        \draw[->] (ext.south) |- node (chx) [above right] {\phantom{choix}} node (eff) [below right] {effectué} (source.west) ;
        \node at (eff |- chx) {choix};

The full source:

\documentclass{minimal}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning, fit, arrows}
\begin{document}
    \begin{tikzpicture}[>=stealth,
        mymatrix/.style={
            matrix of nodes,
            nodes={typetag},
            row sep=1em,
            align=center
            },
        mycontainer/.style={draw=gray, inner sep=1ex},
        typetag/.style={draw=gray, inner sep=1ex, anchor=base,fill=green!50},
        title/.style={draw=none, color=gray, inner sep=0pt,fill=blue!10}
        ]

        \matrix[mymatrix,fill=blue!10] (ext) at (0,0) {
            |[title]|Externalisation?\\[.7em]
        };

        \matrix[mymatrix,fill=blue!10,below right=1.5\baselineskip and 45pt of ext, anchor=west] (source) {
            |[title]|Donnée source\\
            Chercher\\
            Transférer\\
            Stocker\\
        };
        \draw[->] (ext.south) |- node (chx) [above right] {choix} node (eff) [below right] {\phantom{effectué}} (source.west) ;
        \node at (chx |- eff) {effectué};
        \matrix[mymatrix,fill=blue!10,right=75pt of source, nodes in empty cells,
    row 3/.style = {nodes={draw=none,fill=blue!10}}] (trans) {
            |[title]|Transformation\\
            Spécification\\
            \\
            Développement\\
        };
        \path[<->]
            (trans-2-1) edge node [midway,align=center] {enrichissement \\ mutuel} (trans-4-1);

        \draw[->] (source.east) -- node [above] {donnée source} node [below] {récupérée} ++(2.5,0) -- (trans.west);
        \matrix[mymatrix,fill=blue!10,right=75pt of trans] (int) {
            |[title]|Intégration\\
            Tests\\
            Bascule\\
        };

        \draw[double,<->] (trans.east) -- node [above] {enrichissement} node [below] {mutuel} ++(2.5,0) -- (int.west);
    \end{tikzpicture}
\end{document}
  • Merci Georges. I changed it a bit to make it closer: below right=0pt and 25pt of ext – djcaesar9114 Feb 11 at 14:38
  • @djcaesar9114 I noticed that there were some extra spaces in your code (before `\`), which are small but visible. I finished adding some more explanations, and gave a slightly better way to position the second matrix (below right=1.5\baselineskip and 45pt of ext, anchor=west). Bon courage! :) – Georges Dupéron Feb 11 at 14:58

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .