Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Hi bkarpuz. :) Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Claudio Fiandrino Dec 22 '12 at 14:12
add comment

1 Answer

up vote 25 down vote accepted

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.

share|improve this answer
    
Thank you so much Claudio Fiandrino. –  bkarpuz Dec 22 '12 at 22:04
    
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. –  Qrrbrbirlbel Jul 21 '13 at 1:40
    
@Qrrbrbirlbel: you're right, thanks for the suggestion. I'll have a look as soon as possible :) –  Claudio Fiandrino Jul 21 '13 at 17:07
add comment

Your Answer

 
discard

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.