TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add two labels next to the diamond shaped node. One to the right saying "Ja" above the path and the other one below saying "Nein" right next to the path. Currently it seems like that two new nodes are created. I think I am using the option list wrong. The other problem is, that I want a bigger seperation between the first and second column so that the path doesn't cross the "]" symbol. And the last thing is, that I would like to change the horizontal distance between the nodes so that the whole picture will be slimmer.

wrong path creation and labels The labels are now below the diamond shaped node.

The code:


  \begin{tikzpicture}               [
                every matrix/.style         ={matrix of nodes,
                                              nodes in empty cells,
                                              row sep   =3mm,
                                              column sep=0mm,
                                              inner sep =2mm,
                                              outer sep =0mm},
                every node/.style           ={text centered,
            kontrollpunkt/.style            ={draw,
                                              rounded corners,
                                              text width=2cm,               
    text centered},
            operation/.style                ={draw,
                                                                text width=2cm,
                                                                text centered},
            bemerkung/.style                ={inner sep=0pt},
            datenio/.style                  ={draw,
                                                                trapezium left angle=120,
                                                                trapezium right angle=60,
                                                                shape aspect=2,
                                                                text width=2cm},
            verzweigung/.style          ={draw,
                                                                shape aspect=2,
                                                                inner sep=0pt,
                                                                text width=2cm},
                                                                inner sep=0pt,
                                                                minimum width=2mm},
            pfeil/.style                        ={draw,
                                                                shorten <=0pt,
                                                                shorten >=0pt},
            linie/.style                        ={draw,

            \matrix (pap)                       %   pap = Programmablaufplan
                                                            &                                                                       &   |[kontrollpunkt]|           {Start}                                                                                                                                                 &                                                                               &                                                       \\
                                                            &                                                                       &   |[operation]|                   {Initialisierungs-schritt}                                                                                                          &                                                                               &                                                       \\
                    |[bemerkung]|   {1]}    &                                                                       &   |[datenio]|                     {Betriebsarten-auswahl}                                                                                                                 &                                                                               &                                                       \\
                    |[bemerkung]|   {2]}    &                                                                       &   |[verzweigung]|             {Prozessauswahl}                                                                                                                                &                                                                               &                                                       \\
                                                            &                                                                       &   |[operation]|                   {Produktion}                                                                                                                                        &                                                                               &   |[operation]|   {Wartung}       \\
                                                            &                                                                       &   |[verbindungsstelle]|                                                                                                                                                                   &                                                                               &                                                       \\
                                                            &   |[operation]|   {Bauteil einlegen}  &                                                                                                                                                                                                               &   |[operation]|   {Einfahrt Roboter leer} &                                                       \\
                                                            &                                                                       &   |[verbindungsstelle]|                                                                                                                                                                   &                                                                               &                                                       \\
                    |[bemerkung]|   {3]}    &                                                                       &   |[verzweigung,label={[xshift=3mm]below:Nein},label={[yshift=3mm]below:Ja}]| {Produktion ohne Teile}     &                                                                               &                                                       \\
                                                            &                                                                       &   |[operation]|                   {Arbeitsstellung}                                                                                                                               &                                                                               &                                                       \\
                                                            &                                                                       &   |[operation]|                   {Falzen}                                                                                                                                                &                                                                               &                                                       \\
                                                            &                                                                       &   |[operation]|                   {Grundstellung}                                                                                                                                 &                                                                               &                                                       \\
                                                            &                                                                       &   |[verbindungsstelle]|                                                                                                                                                                   &                                                                               &                                                       \\
                                                            &   |[operation]|   {Bauteil entnehmen} &                                                                                                                                                                                                               &   |[operation]|   {Ausfahrt Roboter leer} &                                                       \\
                                                            &                                                                       &   |[verbindungsstelle]|                                                                                                                                                                   &                                                                               &                                                       \\

            \begin{scope}   [every path/.style=pfeil]   
                    \path   (pap-1-3)                   --  (pap-2-3);
                    \path   (pap-2-3)                   --  (pap-3-3);
                    \path   (pap-3-3)                   --  (pap-4-3);
                    \path   (pap-4-3)                   --  (pap-5-3);
                    \path   (pap-4-3.east)      -|  (pap-5-5.north);
                    \path   (pap-5-5.south)     --  ([yshift=-1.5mm]pap-5-5.south)  --  ([shift={(1.5mm,-1.5mm)}]pap-5-5.south east)    |-  ([yshift=-1.5mm]pap-2-3.south);
                    \path   (pap-5-3)                   --  (pap-6-3);
                    \path   (pap-6-3.west)      -|  (pap-7-2.north);
                    \path   (pap-6-3.east)      -|  (pap-7-4.north);
                    \path   (pap-7-2.south)     |-  (pap-8-3.west);
                    \path   (pap-7-4.south)     |-  (pap-8-3.east);
                    \path   (pap-8-3)                   --  (pap-9-3);
                    \path   (pap-9-3.east)      --  ([xshift=1.5mm]pap-9-3.east)    |-  ([yshift=-1.5mm]pap-12-3.south);
                    \path   (pap-9-3)                   --  (pap-10-3);
                    \path   (pap-10-3)              --  (pap-11-3);
                    \path   (pap-11-3)              --  (pap-12-3);
                    \path   (pap-12-3)              --  (pap-13-3);
                    \path   (pap-13-3.west)     -|  (pap-14-2.north);
                    \path   (pap-13-3.east)     -|  (pap-14-4.north);
                    \path   (pap-14-2.south)    |-  (pap-15-3.west);
                    \path   (pap-14-4.south)    |-  (pap-15-3.east);
                    \path   (pap-15-3.south)    --  ([yshift=-1.5mm]pap-15-3.south) -|  ([shift={(-1.5mm,-1.5mm)}]pap-14-2.south west)  |-  ([yshift=-1.5mm]pap-2-3.south);

            \begin{scope}   [every path/.style=linie]
                \path   (pap-3-1)   --  (pap-3-3);
                \path   (pap-4-1)   --  (pap-4-3);
                \path   (pap-9-1)   --  (pap-9-3);



I'm sorry but when I paste the code it never looks the way how I organized it before. It should work anyway.

share|improve this question
I figgured out how to add the labels I wanted by including: \path (pap-9-3.east) -- ([xshift=1.5mm]pap-9-3.east) node [near start,above] {Ja} |- ([yshift=-1.5mm]pap-12-3.south); \path (pap-9-3) -- (pap-10-3) node [near start, right] {Nein}; – Phil Jul 1 '13 at 12:05
strictly speaking, this isn't what most mathematicians would think of as a "matrix". i'd call it a "flow diagram", but that may not be the best term either. in any event, i've added tikz to the labels. ([matrices] should go, but until the title is modified, i didn't want to do that.) – barbara beeton Jul 1 '13 at 12:22
@barbarabeeton I created this flow chart using the matrix library that's why I thought it should be mentioned. I changed the titel and deleted the matrices-tag. – Phil Jul 1 '13 at 12:30
much better. one last tiny niggle -- the singular of "matrices" is "matrix", not "matrice". – barbara beeton Jul 1 '13 at 12:34
@Qrrbrbirlbel I found the solution I was looking for to get the wanted results. I will write an answer for my own question. – Phil Jul 1 '13 at 13:06
up vote 4 down vote accepted
  • To change the distance between the first and second column I included the option [2mm] into the second cell.
  • To add a label to the path I included a node to the path operation e.g.:

    \path (pap-9-2)--(pap-10-2) **node [near start, right] {Your Text here};

This adds a node at the near start at the right side of a path, which connects the 9th and 10th cell in the 2nd column.

  • To change the distance I got rid of columns so that I ended up with only tow columns and I was able to set the distance between the first and second column into the every matrix/.style operation. Further I added two nodes in one cell, e.g.:



    \begin{tikzpicture}[every matrix/.style  ={column sep=2mm}]


    \matrix (matrix name) {


    &  \node (produktion)   [operation] {Produktion};   \node   (wartung)   [operation,right=3mm of produktion] {Wartung}; \\\\};


Here is an example:



  every matrix/.style={matrix of nodes,nodes in empty cells,column sep=1cm,row sep=1cm},
  every node/.style  ={text centered,anchor=center},
  arrow/.style       ={draw,->},
  line/.style        ={draw,dashed}]

\matrix (matrix)
               &   |[draw]|   {Cell 1-2}\\                                                                                                                  
   Cell 2-1]   &   \node   (A)   [draw,anchor=east,xshift=-2mm,text width=2cm]   {Node A in Cell 2-2};   \node   (B)   [draw,right=2mm of A,,text width=2cm]   {Node B in Cell 2-2};\\
               &   |[draw]|   {Cell 3-2}\\

\begin{scope}   [every path/.style=arrow]
\path   (matrix-1-2)-|  (A) node    [near start,below]  {1};
\path   (matrix-1-2)-|  (B) node    [near start,below]  {2};
\path   (A)     |-  (matrix-3-2)    node    [near end,above]{3};
\path   (B)     |-  (matrix-3-2)    node    [near end,above]{4};
\path   (matrix-3-2)--  ([yshift=-2mm]matrix-3-2.south)-|([xshift=-2mm]A.west)|-([yshift=2mm]matrix-1-2.north) --(matrix-1-2) node [near end,above=2mm] {5};

\begin{scope}   [every path/.style=line]



And this is how it look like:

Using a matrix to create a flow chart

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.