4

I would like to change the shape of a node for a flow chart. Here is a code what I have so far:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}


\begin{document}
    \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
    \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
    \tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]

\begin{tikzpicture}[node distance=2cm]
    \node (start) [startstop] {Start MCL};
    \node (pro1)  [process, below of=start] {Process};
    \node (pro3)  [process, below of=pro1] {Process};
    \node (dec1)  [decision,right of=pro3, yshift=-2cm, xshift=2cm] {Stable?};
    \node (stop)  [startstop, right of=dec1, xshift=2cm] {Stop};
    \draw [->] (start) -- (pro1);
    \draw [->] (pro1) -- (pro3);        
    \draw [->] (pro3) |- (dec1);
    \draw [->] (dec1) -- node[anchor=south] {no} (stop);
    \draw [->] (dec1) |- node[anchor=west] {yes} (pro1);
\end{tikzpicture}   

\end{document}

One of those nodes should have a shape like this:

\documentclass{article}
\pagestyle{empty}% zum freistellen
\usepackage{tikz}
\newcommand\einheit[1][]{\tikz{
  \draw (0,0) -- (0,2) -- (2,2) -- (2,0) to[out=90, in=-60] (0,0);
  \node[text width=2cm,align=center] at (1,1) {#1};
}}
\begin{document}

\einheit\
\einheit[Checkliste]
\end{document}
2
  • See if shape tape (pgfmanual, page 714) is what you looking for.
    – Zarko
    Jul 17, 2016 at 18:48
  • 1
    Please don't edit your question in a way which is designed only to make sense to somebody who has read your comment on their answer. I have no idea what the 'addendum' is about and it seems totally unrelated to anything. I gather from your comment, that this is probably a new question. If so, please remove the addendum and ask a new question. And please accept the answer to this one which provided the most useful solution to your original question.
    – cfr
    Aug 27, 2016 at 0:35

2 Answers 2

6

Well, I will convert my comment to one of possible solutions ...

See, if the following is what you looking for:

enter image description here

Code (Minimal Working Example: MWE) -- I took opportunity and changes obsolete \tikzstyle for nodes styles to option of tikzpicture, correct wrong syntax in positioning of nodes and add TikZ library chains and with this slightly make code shorter -- is:

\documentclass[tikz,
               border=3mm]{standalone}
\usetikzlibrary{arrows, chains, positioning, shapes.geometric, shapes.symbols}

\begin{document}
    \begin{tikzpicture}[
   node distance = 1cm and 2cm,
     start chain = going below,
     base/.style = {draw=black, minimum width=3cm, minimum height=1cm,
                    align=center, on chain},
 decision/.style = {diamond, base, fill=green!30},
     list/.style = {tape, tape bend top=none, base},%<-- new    
 myarrows/.style = {-stealth, thick},% <-- added on request in comment
  process/.style = {rectangle, base},
startstop/.style = {rectangle, base, rounded corners, fill=red!30},
                    ]
\node (start) [startstop]   {Start MCL};
\node (pro1)  [process]     {Process};
\node (pro3)  [list]        {List ?};
\node (dec1)  [decision,below right=of pro3] {Stable?};
\node (stop)  [startstop, right=of dec1]     {Stop};
%
\draw [->] (start) -- (pro1);
\draw [->] (pro1) -- (pro3);
\draw [->] (pro3) |- (dec1);
\draw [->] (dec1) -- node[anchor=south] {no} (stop);
\draw [->] (dec1) |- node[anchor=west] {yes} (pro1);
    \end{tikzpicture}
\end{document}

Since I didn't figured out, where you like to have new shape, I replace second "process" node with it and for content wrote "list".

Addendum (1): Any new style you can add to existing one, for example for myarrows:

\myarrows/.style = {-stealth, thick},

Also you can all localy defined styles colect in \tikzset as:

\tikzset{%
     base/.style = {draw=black, minimum width=3cm, minimum height=1cm,
                    align=center, on chain},
 decision/.style = {diamond, base, fill=green!30},
     list/.style = {tape, tape bend top=none, base},%<-- new
 myarrows/.style = {-stealth, thick},% <-- added on request in comment
  process/.style = {rectangle, base},
startstop/.style = {rectangle, base, rounded corners, fill=red!30},
    }

and put it in preamble. In this case it is available to all TikZ pictures. In this case the complete MWE is:

\documentclass[tikz,
               border=5mm]{standalone}
\usetikzlibrary{arrows, chains, positioning, shapes.geometric, shapes.symbols}

\tikzset{%
     base/.style = {draw=black, minimum width=3cm, minimum height=1cm,
                    align=center, on chain},
 decision/.style = {diamond, base, fill=green!30},
     list/.style = {tape, tape bend top=none, base},%<-- new
 myarrows/.style = {-stealth, thick},% <-- added on request in comment
  process/.style = {rectangle, base},
startstop/.style = {rectangle, base, rounded corners, fill=red!30},
    }
\begin{document}
    \begin{tikzpicture}[
   node distance = 1cm and 2cm,
     start chain = going below,
                    ]
\node (start) [startstop]   {Start MCL};
\node (pro1)  [process]     {Process};
\node (pro3)  [list]        {List ?};
\node (dec1)  [decision,below right=of pro3] {Stable?};
\node (stop)  [startstop, right=of dec1]     {Stop};
%
\draw[myarrows] (start) edge (pro1)
                (pro1)  edge (pro3)
%
                (dec1)  to  node[anchor=south] {no} (stop);
\draw [myarrows] (pro3) |- (dec1);
\draw [myarrows] (dec1) |- node[anchor=west] {yes} (pro1);
    \end{tikzpicture}
\end{document}

This MWE gives equal result as (suplement) first MWE.

Addendum (2): Instead to define style myarrows you can define (in TikZ picture options):

every path/.style = {-stealth, thick}

(since all lines in your graph ends with arrow) and than for connection lines simply write:

\draw (start) edge (pro1)
      (pro1)  edge (pro3)
%
      (dec1)  to  node[anchor=south] {no} (stop);
\draw (pro3) |- (dec1);
\draw (dec1) |- node[anchor=west] {yes} (pro1);
5
  • Thank you so much. This is what I was looking for. Also a big thanks for your adjustments to make the code even prettier :)
    – Christine
    Jul 17, 2016 at 20:08
  • I have 1 more question. Can you pls show me how I integrate: \tikzstyle{myarrows} = [thick,->,>=stealth]
    – Christine
    Jul 17, 2016 at 21:12
  • Similarly as other styles. See addendum to my answer.
    – Zarko
    Jul 17, 2016 at 21:15
  • Hi Zarko, first of all thank you so much for your help. With your help I nearly finished the diagram as I wish. However, there is one more problem, that may need your help. I need a arrow that has a break line (I attached it in my post). How can I integrated this edge from "Start" to "Pro1" (using \tikzset)?
    – Christine
    Aug 27, 2016 at 0:09
  • 1
    @Christine You will need to use a separate path (or part of a path - not an edge) to add the pic en route from Start to Pro1. You already have the \tikzset bit which defines the pic, so I'm not sure what you mean by that. But this should probably be a new question and it certainly shouldn't be here if it depends on a change to your question which makes no sense to anybody who just reads the question. Remember that questions and answers are supposed to address users other than the person asking. They should make sense to everyone and not just those you've let in on the secret!
    – cfr
    Aug 27, 2016 at 0:41
4

One solution, as pointed out by Zarko in his answer would be to use the tape style if it's applicable. Another solution would be to use a pic, where you can draw arbitrary shapes that can conveniently be reused.

Your souce with the added tikz pic:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}


\begin{document}
    \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
    \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
    \tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]

\begin{tikzpicture}[node distance=2cm,%
    pic shift/.store in=\shiftcoord,%
    pic shift={(0,0)},%
    einheit/.pic={
        \begin{scope}[shift={\shiftcoord}]
            \draw (0,0) -- (0,2) -- (2,2) -- (2,0) to[out=90, in=-60] (0,0);
            \node[text width=2cm,align=center] at (1,1) {\tikzpictext};
        \end{scope}
    }]
    \node (start) [startstop] {Start MCL};
    \node (pro1)  [process, below of=start] {Process};
    \node (pro3)  [process, below of=pro1] {Process};
    \node (dec1)  [decision,right of=pro3, yshift=-2cm, xshift=2cm] {Stable?};
    \node (stop)  [startstop, right of=dec1, xshift=2cm] {Stop};
    \draw [->] (start) -- (pro1);
    \draw [->] (pro1) -- (pro3);        
    \draw [->] (pro3) |- (dec1);
    \draw [->] (dec1) -- node[anchor=south] {no} (stop);
    \draw [->] (dec1) |- node[anchor=west] {yes} (pro1);


    \draw pic at (12,0){einheit};
    \draw pic[pic text={Text}] at (12,3){einheit};
\end{tikzpicture}   

\end{document}

Which results in:

enter image description here

1
  • My deepest apologies, that my question was not precise enough. Zarkos solution is was the answer of my question. Still thank you, maybe others will need your solution too :)
    – Christine
    Jul 17, 2016 at 20:10

You must log in to answer this question.

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