0

Could you please help me how to draw a dotted box and name the box around the nodes in the middle column..?

Thanks in advance.

enter image description here

enter image description here

  • 2
    Please paste the source code of your figure in the text of your question. You can apply code formatting to maintain clarity – BambOo Oct 12 '18 at 13:56
  • Just load the fit library and add \node[draw,dashed,fit=(start)(ini)(stop)]{}; – user121799 Oct 12 '18 at 14:04
1

You've not shared a MWE. If you provide more details about packages and libraries you're depending on, I could possible create a much better solution for you: such as using the fit library or local bounding box.

So, just taking a snippet of what you've presented and making a few assumptions about your packages, here's one approach to creating the box you want:

enter image description here

The code for this:

% arara: pdflatex
% arara: open
\documentclass[tikz,border=6pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\begin{document}

\begin{tikzpicture}[node distance=2cm]

  \node[draw,ellipse] (start)                 {Start SIMPACK};
  \node[draw]         (ini)  [below of=start] {Set a reference system};
  \node[draw]         (pro1) [below of=ini]   {Creating/importing the bodies};

  \draw (pro1.east) -- ++ (1,0) |- (ini.east);

  \draw[dotted,red] ($(current bounding box.south east)+(6pt,-6pt)$) rectangle ($(current bounding box.north west)+(-6pt,6pt)$);

\end{tikzpicture}

\end{document}

Then you can continue building from this after using the current bounding box.

Alternatively, you can use the fit library:

enter image description here

% arara: pdflatex
% arara: open
\documentclass[tikz,border=6pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{shapes}
\begin{document}

\begin{tikzpicture}[node distance=2cm]

  \node[draw,ellipse] (start)                 {Start SIMPACK};
  \node[draw]         (ini)  [below of=start] {Set a reference system};
  \node[draw]         (pro1) [below of=ini]   {Creating/importing the bodies};

  \draw (pro1.east) -- ++ (1,0) |- (ini.east);

  \node [fit=(ini) (pro1),draw,dotted,blue] {};

  \draw[dotted,red] ($(current bounding box.south east)+(6pt,-6pt)$) rectangle ($(current bounding box.north west)+(-6pt,6pt)$);

\end{tikzpicture}

\end{document}

enter image description here

Code:

% arara: pdflatex
% arara: open
\documentclass[tikz,border=6pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{shapes}
\begin{document}

\begin{tikzpicture}[node distance=2cm]

  \node[draw,ellipse] (start)                 {Start SIMPACK};
  \node[draw]         (ini)  [below of=start] {Set a reference system};
  \node[draw]         (pro1) [below of=ini]   {Creating/importing the bodies};

  \draw (pro1.east) -- ++ (1,0) |- (ini.east);

  \node [fit=(ini) (pro1),draw,dotted,blue] {};

  \draw[dotted,red] ($(current bounding box.south east)+(6pt,-6pt)$) rectangle ($(current bounding box.north west)+(-6pt,6pt)$);

  \node[draw] (pro2) [below of=pro1] {Outside previous bounding box calculations};

  \draw (pro2.north) -- (pro1.south);
\end{tikzpicture}

\end{document}

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.