0

I am trying to create a flow chart with tikz using the interal storage symbol (http://www.smartdraw.com/flowchart/flowchart-symbols.htm). My first tries ended up in:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{shapes}
    \usetikzlibrary{arrows}
    \begin{document}
    \begin{tikzpicture}[auto]
    \tikzstyle{internalStorageTop} = [draw, thick, rectangle split, rectangle split horizontal,rectangle split parts=2]
    \tikzstyle{internalStorage} = [draw, thick, rectangle split, rectangle split horizontal,rectangle split parts=2, align=center]
    \tikzstyle{process} = [rectangle, draw, thick, align=center]
    \tikzstyle{line} = [draw, thick, -triangle 45];
    \matrix [column sep={10mm},row sep=10mm]{
    & \node [process] (generate) {process}; & \\
    & \node [internalStorageTop] (split) {\nodepart[text width=40mm]{two}\phantom{internal storage}}; & \\[-10.25mm]
    & \node [internalStorage] {\nodepart[text width=40mm]{two}{internal storage\\ internal storage}}; & \\
    };
    \tikzstyle{every path}=[line]
    \path (generate) -- (split);
    \end{tikzpicture}
    \end{document} 

But this looks a bit ugly. Do you have any suggestions how to generate this symbol properly?

2 Answers2

1

It's not exactly simpler, but it is a single node now:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,backgrounds}

\newlength{\tempdima}
\newlength{\tempdimb}

\tikzset{storage gap/.initial=1em}

\pgfdeclareshape{storage}{
\savedanchor{\northeast}{
    \setlength{\tempdima}{\pgfkeysvalueof{/tikz/storage gap}}
    \tempdima=0.5\tempdima
    \tempdimb=\tempdima
    \addtolength{\tempdima}{\pgfkeysvalueof{/pgf/inner xsep}}
    \addtolength{\tempdimb}{\pgfkeysvalueof{/pgf/inner ysep}}
    \pgfpoint{\dimexpr \tempdima + .5\wd\pgfnodeparttextbox}{\dimexpr \tempdimb + 0.5\ht\pgfnodeparttextbox +.5\dp\pgfnodeparttextbox}}
\savedanchor{\southwest}{
    \setlength{\tempdima}{\pgfkeysvalueof{/tikz/storage gap}}
    \tempdima=0.5\tempdima
    \tempdimb=\tempdima
    \addtolength{\tempdima}{\pgfkeysvalueof{/pgf/inner xsep}}
    \addtolength{\tempdimb}{\pgfkeysvalueof{/pgf/inner ysep}}
    \pgfpoint{\dimexpr -\tempdima -.5\wd\pgfnodeparttextbox}{\dimexpr -\tempdimb -.5\ht\pgfnodeparttextbox -.5\dp\pgfnodeparttextbox}}

\anchor{center}{\pgfpointorigin}  % within the node, (0,0) is the center

\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid west}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{south east}

\anchor{text} % this is used to center the text in the node
{\setlength{\tempdima}{\pgfkeysvalueof{/tikz/storage gap}}
    \pgfpoint{\dimexpr 0.5\tempdima -.5\wd\pgfnodeparttextbox}{\dimexpr -0.5\tempdima -.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox }}

\backgroundpath{% draw border etc
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgfextractx{\tempdima}{\southwest}
\pgfextracty{\tempdimb}{\southwest}
\addtolength{\tempdima}{\pgfkeysvalueof{/tikz/storage gap}}
\pgfpathmoveto{\pgfpoint{\tempdima}{\tempdimb}}
\pgfextracty{\tempdimb}{\northeast}
\pgfpathlineto{\pgfpoint{\tempdima}{\tempdimb}}
\addtolength{\tempdimb}{-\pgfkeysvalueof{/tikz/storage gap}}
\pgfextractx{\tempdima}{\southwest}
\pgfpathmoveto{\pgfpoint{\tempdima}{\tempdimb}}
\pgfextractx{\tempdima}{\northeast}
\pgfpathlineto{\pgfpoint{\tempdima}{\tempdimb}}
}}

\begin{document}

\begin{tikzpicture}[auto]
    \tikzstyle{process} = [rectangle, draw, thick, align=center]
    \tikzstyle{internalStorage} = [storage,draw, thick, align=center]
    \tikzstyle{line} = [draw, thick, -triangle 45];
    \matrix [column sep={10mm},row sep=10mm]{
    & \node [process] (generate) {process}; & \\
    & \node [internalStorage,fill=white,text width=1in] (split) {internal storage\\ internal storage}; & \\
    };
    \tikzstyle{every path}=[line]
    \path (generate) -- (split);
\begin{scope}[on background layer]
    \draw [draw=none,fill=green!15] ($(generate.north west)+(-1.2cm,0.4cm)$) node[anchor=north west] {Fig. 7}    rectangle ($(split.south east)+(0.8cm,-0.1cm)$);
\end{scope}    
\end{tikzpicture}
\end{document}

storage

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Hi awesome. That is what I want. Thank you very much. I have two more things. 1. Is there a way to incorporate a multiline text. 2. How to make the background white when the item is placed over a colored box. Here is my example: – user3528789 May 27 '15 at 11:41
0

That is what I want. Thank you very much. I have two more things. 1. Is there a way to incorporate a multiline text. 2. How to make the background white when the item is placed over a colored box. Here is my example:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,backgrounds}

\newlength{\tempdima}
\newlength{\tempdimb}

\tikzset{gap/.initial=1em}
\tikzset{linethickness/.initial=0.75pt}

\pgfdeclareshape{internalStorage}{
\savedanchor{\northeast}{
    \setlength{\tempdima}{\pgfkeysvalueof{/tikz/gap}}
    \tempdima=0.5\tempdima
    \tempdimb=\tempdima
    \addtolength{\tempdima}{\pgfkeysvalueof{/pgf/inner xsep}}
    \addtolength{\tempdimb}{\pgfkeysvalueof{/pgf/inner ysep}}
    \pgfpoint{\dimexpr \tempdima + .5\wd\pgfnodeparttextbox}{\dimexpr \tempdimb + .5\ht\pgfnodeparttextbox}}
\savedanchor{\southwest}{
    \setlength{\tempdima}{\pgfkeysvalueof{/tikz/gap}}
    \tempdima=0.5\tempdima
    \tempdimb=\tempdima
    \addtolength{\tempdima}{\pgfkeysvalueof{/pgf/inner xsep}}
    \addtolength{\tempdimb}{\pgfkeysvalueof{/pgf/inner ysep}}
    \pgfpoint{\dimexpr -\tempdima -.5\wd\pgfnodeparttextbox}{\dimexpr -\tempdimb -.5\ht\pgfnodeparttextbox}}

\anchor{center}{\pgfpointorigin}  % within the node, (0,0) is the center

\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid west}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{south east}

\anchor{text} % this is used to center the text in the node
{\setlength{\tempdima}{\pgfkeysvalueof{/tikz/gap}}
    \pgfpoint{\dimexpr 0.5\tempdima -.5\wd\pgfnodeparttextbox}{\dimexpr -0.5\tempdima -.5\ht\pgfnodeparttextbox}}

\backgroundpath{% draw border etc
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/linethickness}}
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgfextractx{\tempdima}{\southwest}
\pgfextracty{\tempdimb}{\southwest}
\addtolength{\tempdima}{\pgfkeysvalueof{/tikz/gap}}
\pgfpathmoveto{\pgfpoint{\tempdima}{\tempdimb}}
\pgfextracty{\tempdimb}{\northeast}
\pgfpathlineto{\pgfpoint{\tempdima}{\tempdimb}}
\addtolength{\tempdimb}{-\pgfkeysvalueof{/tikz/gap}}
\pgfextractx{\tempdima}{\southwest}
\pgfpathmoveto{\pgfpoint{\tempdima}{\tempdimb}}
\pgfextractx{\tempdima}{\northeast}
\pgfpathlineto{\pgfpoint{\tempdima}{\tempdimb}}
\pgfusepath{draw}
}}

\begin{document}

\begin{tikzpicture}[auto]
    \tikzstyle{process} = [rectangle, draw, thick, align=center]
    \tikzstyle{line} = [draw, thick, -triangle 45];
    \matrix [column sep={10mm},row sep=10mm]{
    & \node [process] (generate) {process}; & \\
    & \node [internalStorage,fill=white] (split) {internal storage\\ internal storage}; & \\
    };
    \tikzstyle{every path}=[line]
    \path (generate) -- (split);
\begin{scope}[on background layer]
    \draw [draw=none,fill=green!15] ($(generate.north west)+(-1.2cm,0.4cm)$) node[anchor=north west] {Fig. 7}    rectangle ($(split.south east)+(0.8cm,-0.1cm)$);
\end{scope}    
\end{tikzpicture}
\end{document}

I am grateful for any advice. Best regards

  • There are 2 ways to incorporate multiline text doe any node. Specify [text width=?] or use \parbox{?}{...} where ? represents the desired width. However, I had to fix a few bugs in the code first (circuitikz nodes are easier). – John Kormylo May 27 '15 at 13:21
  • I tried various methods, the one that does the job for me goes like:

    \node [internalStorage,align=center] (split) {internal storage\internal storage};

    for the multiline and an additional:

    \draw [draw=none,fill=white] ($(split.north west)+(0cm,0cm)$) node[anchor=north west] {} rectangle ($(split.south east)+(0.0cm,0.0cm)$);

    in the scope-part

    – user3528789 May 27 '15 at 13:30