我正在尝试在节点内绘制多个节点并连接外部节点以创建流程图。由于我是 Tikz 新手,所以我使用了示例并尝试操纵它们来解决我的问题。如果有一种方法可以以适当的方式(非硬编码)对齐各个部分,我也会很高兴看到这些改进。主要问题是,如何将外框连接到下面的同一张图片。
\documentclass[ngerman]{scrbook}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß}}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{isodate}
\usepackage{mathtools}
\usepackage{sansmath}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{verbatim} %comment Befehl
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols,fit,backgrounds,shadows,intersections,through,shapes.multipart}
\tikzstyle{noframe} = [minimum width=2cm, minimum height=1cm,text centered, draw=white, opacity=0, text opacity=1]
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{ell} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[nodes=draw, inner frame sep=.5cm]
\node[noframe] (leer) {};
\node[ell, fill=green!30, left of=leer, xshift=-1cm] (variation) {Variation der Geometrie};
\node[fill=red!30, above of=leer, xshift=-4cm, yshift=1cm] (head) {\textbf{Geometrie}};
\node[noframe, right of=leer, align=center, xshift=3cm] (nsim) {$n_{sim}$\\ Durchläufe};
\begin{scope}[on background layer]
\node[fit=(leer), minimum width=.75\textwidth, minimum height=4cm] {};
\end{scope}
\draw [arrow, dashed, thick, bend angle=45, bend right] (nsim) to (variation);
\draw [arrow, dashed, bend angle=45, bend right] (variation) to (nsim);
\end{tikzpicture}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[nodes=draw, inner frame sep=.5cm]
\node[noframe] (leer) {};
\node[ell, fill=green!30, left of=leer, xshift=-1cm] (variation) {Variation der Geometrie};
\node[fill=red!30, above of=leer, xshift=-4cm, yshift=1cm] (head) {\textbf{Geometrie}};
\node[noframe, right of=leer, align=center, xshift=3cm] (nsim) {$n_{sim}$\\ Durchläufe};
\begin{scope}[on background layer]
\node[fit=(leer), minimum width=.75\textwidth, minimum height=4cm] {};
\end{scope}
\draw [arrow, dashed, thick, bend angle=45, bend right] (nsim) to (variation);
\draw [arrow, dashed, bend angle=45, bend right] (variation) to (nsim);
\end{tikzpicture}
\end{figure}
\end{document}
(编辑)我添加了第二张图片。这两张图片应该用箭头连接起来。
当然,它可以在一张 tikzpicture 中进行编码,但我没有能力做到。
问候
答案1
尝试引用节点(name)
并仅在环境中制作您的图片tikzpicture
。
在这种情况下,我复制了环境中的第二个图形scope
(因为它是相同的,你的情况确实应该有所不同)并将其命名为外节点和。(node1)
然后(node2)
很容易将它们连接起来。
\documentclass[ngerman]{scrbook}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß}}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{isodate}
\usepackage{mathtools}
\usepackage{sansmath}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{verbatim} %comment Befehl
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols,fit,backgrounds,shadows,intersections,through,shapes.multipart}
\tikzstyle{noframe} = [minimum width=2cm, minimum height=1cm,text centered, draw=white, opacity=0, text opacity=1]
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{ell} = [ellipse, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[nodes=draw, inner frame sep=.5cm]
\node[noframe] (leer) {};
\node[ell, fill=green!30, left of=leer, xshift=-1cm] (variation) {Variation der Geometrie};
\node[fill=red!30, above of=leer, xshift=-4cm, yshift=1cm] (head) {\textbf{Geometrie}};
\node[noframe, right of=leer, align=center, xshift=3cm] (nsim) {$n_{sim}$\\ Durchläufe};
\begin{scope}[on background layer]
\node[fit=(leer), minimum width=.75\textwidth, minimum height=4cm] (node1) {};
\end{scope}
\draw [arrow, dashed, thick, bend angle=45, bend right] (nsim) to (variation);
\draw [arrow, dashed, bend angle=45, bend right] (variation) to (nsim);
\begin{scope}[yshift=-6cm]
\node[noframe] (leer) {};
\node[ell, fill=green!30, left of=leer, xshift=-1cm] (variation) {Variation der Geometrie};
\node[fill=red!30, above of=leer, xshift=-4cm, yshift=1cm] (head) {\textbf{Geometrie}};
\node[noframe, right of=leer, align=center, xshift=3cm] (nsim) {$n_{sim}$\\ Durchläufe};
\begin{scope}[on background layer]
\node[fit=(leer), minimum width=.75\textwidth, minimum height=4cm] (node2) {};
\end{scope}
\draw [arrow, dashed, thick, bend angle=45, bend right] (nsim) to (variation);
\draw [arrow, dashed, bend angle=45, bend right] (variation) to (nsim);
\end{scope}
\draw[blue,thick,->] (node1) -- (node2);
\end{tikzpicture}
\end{figure}
\end{document}