1

I found this guide on making a flowchart with tizk, but there is no option for the subprocess box.

How could I create a box like this, with the writing in between the two lines on the inside? Subprocess symbol

Thanks in advance! :)

Edit: So far, the closest I have gotten is

\tikzstyle{subprocess} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30, double distance=

\node (subpro1) [subprocess, below of=start] {Failed subprocess box};

but this produces 2 lines on every side, whilst I want the double line on only the two vertical sides. It also puts the coloured background only on the inside one whilst I want it to be on the outermost rectangle.

enter image description here

  • 1
    Can you edit your question to include a minimal example with what you've got so far? – cfr Apr 23 '17 at 22:18
  • I've not really gotten very far at all, but I added what I attempted to do. I think it's completely wrong though haha – M. Salman Khan Apr 24 '17 at 23:13
  • Thanks. Could you make it compilable? Maybe with a single example of a node you've got which does work as you want. I am not sure you can do this easily with a node. You might be able to use a pic, but I'm not sure if that would fit. – cfr Apr 25 '17 at 0:02
  • @cfr Well someone has given an answer that works now, but would adding a compilable example be a good idea to make it easier for other people who might have the same problem as me and find this question or should I leave it as it is now? – M. Salman Khan Apr 26 '17 at 20:23
  • I think it helps other users, so I would add one. However, I wouldn't do this if your example would invalidate the existing answer for some reason. (I can't think why it would do that, but I guess there might be such cases.) – cfr Apr 27 '17 at 0:03
4

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
     \newcommand\ppbb{path picture bounding box}

\begin{document}
    \begin{tikzpicture}[ 
subprocess/.style = {rectangle, draw=black, fill=orange!30,
                     minimum width=3cm, minimum height=1cm,inner xsep=3mm,
                     text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                     align=flush center,
                     path picture={\draw 
    ([xshift =2mm] \ppbb.north west) -- ([xshift= 2mm] \ppbb.south west)
    ([xshift=-2mm] \ppbb.north east) -- ([xshift=-2mm] \ppbb.south east);
                                  },% end of path picture
                    }
                      ]
\node (subpro1) [subprocess] {Failed subprocess box};
    \end{tikzpicture}
\end{document}

Addendum (1): Style for subprocess you can enclose to \tikzset as follows:

\tikzset{
    subprocess/.style = {rectangle, draw=black, fill=orange!30,
                         minimum width=3cm, minimum height=1cm, inner xsep=3mm,
                         text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                         align=flush center,
                         path picture={\draw 
        ([xshift =2mm] \ppbb.north west) -- ([xshift= 2mm] \ppbb.south west)
        ([xshift=-2mm] \ppbb.north east) -- ([xshift=-2mm] \ppbb.south east);
                                      },% end of path picture
                        }
}

and put it in preamble of a document.

Addendum (2): In the case, that you wish to have text only on one line, than the code for subprocess can be simplified to:

\documentclass[tikz, margin=3mm]{standalone}
     \newcommand\ppbb{path picture bounding box}
\tikzset{
subprocess/.style = {rectangle, draw=black, fill=orange!30,
                     minimum width=3cm, minimum height=1cm, inner xsep=3mm,
                     align=flush center,
                     path picture={\draw
    ([xshift =2mm] \ppbb.north west) -- ([xshift= 2mm] \ppbb.south west)
    ([xshift=-2mm] \ppbb.north east) -- ([xshift=-2mm] \ppbb.south east);
                                  },% end of path picture
                    }
        }% end of tikzset

\begin{document}
    \begin{tikzpicture}
\node (subpro1) [subprocess] {Failed subprocess box};
    \end{tikzpicture}
\end{document}

enter image description here

Addendum (3): In the case, that you wish to manualy prescribed "minimal/maximal width" of shape, then might the following example can help you:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

     \newcommand\ppbb{path picture bounding box}
\tikzset{
subprocess/.style = {rectangle, draw=black, semithick, fill=orange!30,
                     minimum width=#1, minimum height=1cm, inner xsep=3mm, % <-- changed
                     text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
                     align=flush center,
                     path picture={\draw
    ([xshift =2mm] \ppbb.north west) -- ([xshift= 2mm] \ppbb.south west)
    ([xshift=-2mm] \ppbb.north east) -- ([xshift=-2mm] \ppbb.south east);
                                  },% end of path picture
                    },
subprocess/.default = 24mm % <-- added 
        }% end of tikzset

\begin{document}
    \begin{tikzpicture}
\node (subpro1) [subprocess] {subprocess};% <-- use default width
\node (subpro2) [subprocess=33mm, below=of subpro1] {very long subprocess};% <-- use locally prescribed width
\node (subpro3) [subprocess=44mm, below=of subpro2] {very long subprocess};% <-- use locally prescribed width
\draw   (subpro1) edge[->] (subpro2)
        (subpro2) edge[->] (subpro3);
    \end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much! Is there any way that I can place this in the document preamble instead of in each new tikz picture I create? I'm going to have a lot of diagrams, so it'd be better to not have to repeat the same thing several times haha. Also, could you possibly explain what the two lines starting with xshift do? I don't think I fully understand... – M. Salman Khan Apr 26 '17 at 20:20
  • @Xhaerithius, of course! enclose definition in \tikzset{ ... }. See addendum to my answer. – Zarko Apr 26 '17 at 20:25
  • Thank you very much! I feel kinda silly now ¬,¬ \tikzset was right there in the documentation--I don't know how I missed it haha. Thanks again for your help! :) – M. Salman Khan Apr 26 '17 at 22:10
  • hmmm one more thing: So if I want the box to stretch to fit longer text, I just need to remove the text width, correct? If I do that, is there any way to add some extra padding against the two sides with the lines so that the text is not right up against the lines? – M. Salman Khan Apr 26 '17 at 22:57
  • @Xhaerithius, this can be tricky. text width is calculated from minimum width and on this way the text limited to bi inside vertical lines. For possible solution see addendum to answer (it will appear soon) – Zarko Apr 26 '17 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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