30

I am very new to the TikZ package, and I need to draw some flow chars by using the following shapes.

However I couldn't figure out how to draw the 4th and and 6th ones below. It would be very nice (for completeness) to help with all of the shapes in the list below.

enter image description here

Your help will be greatly appreciated.

Note: I have visited Node shapes TikZ but it contains some other shapes.

1

1 Answer 1

37

Following your list, here are a bunch of TikZ-styles to draw the nodes: feel free to customize colors and dimensions as needed. They are very basic styles, something one could write just by having a vague idea of the shapes present in pgfmanual. There are comments when special libraries should be loaded in the preamble.

Code:

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,shapes.geometric,shapes.symbols,shapes.misc}

\tikzset{
    start-end/.style={
        draw,
        rectangle,
        rounded corners,
    },
    input/.style={ % requires library shapes.geometric
        draw,
        trapezium,
        trapezium left angle=60,
        trapezium right angle=120,
    },
    operation/.style={
        draw,
        rectangle
    },
    loop/.style={ % requires library shapes.misc
        draw,
        chamfered rectangle,
        chamfered rectangle xsep=2cm
    },
    decision/.style={ % requires library shapes.geometric
        draw,
        diamond,
        aspect=#1
    },
    decision/.default=1,
    print/.style={ % requires library shapes.symbols
        draw,
        tape,
        tape bend top=none
    },
    connection/.style={
        draw,
        circle,
        radius=5pt,
    },
    process rectangle outer width/.initial=0.15cm,
    predefined process/.style={
        rectangle,
        draw,
        append after command={
        \pgfextra{
          \draw
          ($(\tikzlastnode.north west)-(0,0.5\pgflinewidth)$)--
          ($(\tikzlastnode.north west)-(\pgfkeysvalueof{/tikz/process rectangle outer width},0.5\pgflinewidth)$)--
          ($(\tikzlastnode.south west)+(-\pgfkeysvalueof{/tikz/process rectangle outer width},+0.5\pgflinewidth)$)--
          ($(\tikzlastnode.south west)+(0,0.5\pgflinewidth)$);
          \draw
          ($(\tikzlastnode.north east)-(0,0.5\pgflinewidth)$)--
          ($(\tikzlastnode.north east)+(\pgfkeysvalueof{/tikz/process rectangle outer width},-0.5\pgflinewidth)$)--
          ($(\tikzlastnode.south east)+(\pgfkeysvalueof{/tikz/process rectangle outer width},0.5\pgflinewidth)$)--
          ($(\tikzlastnode.south east)+(0,0.5\pgflinewidth)$);
        }  
        },
        text width=#1,
        align=center
    },
    predefined process/.default=1.75cm,
    man op/.style={ % requires library shapes.geometric
        draw,
        trapezium,
        shape border rotate=180,
        text width=2cm,
        align=center,
    },
    extract/.style={
        draw,
        isosceles triangle,
        isosceles triangle apex angle=60,
        shape border rotate=90
    },
    merge/.style={
        draw,
        isosceles triangle,
        isosceles triangle apex angle=60,
        shape border rotate=-90
    },
}

\begin{document}
\begin{tikzpicture}
\node[start-end] (start) {Start/End};
\node[below of=start,input](inp){Input};
\node[below of=inp,operation] (op) {Operation};
\node[below of=op,loop] (lp) {Loop};
\node[right= 10pt of lp,loop=1.6] (lp2) {Preparation};
\node[below= 5pt of lp,decision] (dec) {Decision};
\node[right= 10pt of dec,decision=1.6] (dec2) {Decision};
\node[right= 10pt of dec2,decision=2.5] (dec3) {Decision};
\node[below= 5pt of dec,print] (pr) {Print};
\node[below= 10pt of pr,predefined process] (prproc) {Predefined process};
\node[below= 10pt of prproc,man op] (manop) {Manual Operation};
\node[below of=manop,connection, label=below:Connection] (con) {};
\node[below of=con,extract, label=below:Extract] (extr) {};
\node[below of=extr,merge, label=below:Merge] (mrg) {};
\end{tikzpicture}
\end{document}

The result:

enter image description here

Version 22/07/2013: contains a small fix according to @Qrrbrbirlbel's comment. Small in the sense that solves the problem of shrinking the text width, but as the line width changes in the base rectangle path, the outside rectangles' path do not. This solution indeed is the right occasion to understand how to pass options to a late operation while having \pgfextra active.

2
  • 2
    May I suggest a improvement of predefined process? Instead of the current append after command style, I’d use two lines that are dependent of inner xsep so that they never cross the text box. The factor 0.15 may give surprising results for different text widths. Jul 21, 2013 at 1:40
  • @Qrrbrbirlbel: you're right, thanks for the suggestion. I'll have a look as soon as possible :) Jul 21, 2013 at 17:07

You must log in to answer this question.

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