答案1
您尚未共享 MWE。如果您提供有关所依赖的软件包和库的更多详细信息,我可能会为您创建更好的解决方案:例如使用库fit
或local bounding box
。
因此,只需从您所呈现的内容中选取一个片段并对您的包裹做出一些假设,以下就是创建您想要的盒子的一种方法:
其代码如下:
% 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}
然后,您可以在使用后从此继续构建current bounding box
。
或者,您可以使用该fit
库:
% 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}
代码:
% 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}