我想要在菱形节点旁边添加两个标签。右边的一条写着“Ja”,位于道路上方,另一条写着“Nein”,位于道路旁边。目前看来创建了两个新节点。我认为我使用选项列表的方式不对。另一个问题是,我想要一个第一列和第二列之间的间隔更大这样路径就不会越过“]”符号。最后,我想改变节点之间的水平距离,这样整个图片就会更纤细。
标签现在位于菱形节点下方。
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,shapes.geometric}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture} [
every matrix/.style ={matrix of nodes,
nodes in empty cells,
font=\tiny,
row sep =3mm,
column sep=0mm,
inner sep =2mm,
outer sep =0mm},
every node/.style ={text centered,
anchor=center},
kontrollpunkt/.style ={draw,
rounded corners,
text width=2cm,
text centered},
operation/.style ={draw,
text width=2cm,
text centered},
bemerkung/.style ={inner sep=0pt},
datenio/.style ={draw,
trapezium,
trapezium left angle=120,
trapezium right angle=60,
shape aspect=2,
text width=2cm},
verzweigung/.style ={draw,
diamond,
shape aspect=2,
inner sep=0pt,
text width=2cm},
verbindungsstelle/.style={draw,
circle,
inner sep=0pt,
minimum width=2mm},
pfeil/.style ={draw,
->,
shorten <=0pt,
>=stealth',
-latex',
shorten >=0pt},
linie/.style ={draw,
dashed,
midway}]
\matrix (pap) % pap = Programmablaufplan
{
& & |[kontrollpunkt]| {Start} & & \\
& & |[operation]| {Initialisierungs-schritt} & & \\
|[bemerkung]| {1]} & & |[datenio]| {Betriebsarten-auswahl} & & \\
|[bemerkung]| {2]} & & |[verzweigung]| {Prozessauswahl} & & \\
& & |[operation]| {Produktion} & & |[operation]| {Wartung} \\
& & |[verbindungsstelle]| & & \\
& |[operation]| {Bauteil einlegen} & & |[operation]| {Einfahrt Roboter leer} & \\
& & |[verbindungsstelle]| & & \\ |[bemerkung]| {3]} & & |[verzweigung,label={[xshift=3mm]below:Nein},label={[yshift=3mm]below:Ja}]| {Produktion ohne Teile} & & \\
& & |[operation]| {Arbeitsstellung} & & \\
& & |[operation]| {Falzen} & & \\
& & |[operation]| {Grundstellung} & & \\
& & |[verbindungsstelle]| & & \\
& |[operation]| {Bauteil entnehmen} & & |[operation]| {Ausfahrt Roboter leer} & \\
& & |[verbindungsstelle]| & & \\
};
\begin{scope} [every path/.style=pfeil]
\path (pap-1-3) -- (pap-2-3);
\path (pap-2-3) -- (pap-3-3);
\path (pap-3-3) -- (pap-4-3);
\path (pap-4-3) -- (pap-5-3);
\path (pap-4-3.east) -| (pap-5-5.north);
\path (pap-5-5.south) -- ([yshift=-1.5mm]pap-5-5.south) -- ([shift={(1.5mm,-1.5mm)}]pap-5-5.south east) |- ([yshift=-1.5mm]pap-2-3.south);
\path (pap-5-3) -- (pap-6-3);
\path (pap-6-3.west) -| (pap-7-2.north);
\path (pap-6-3.east) -| (pap-7-4.north);
\path (pap-7-2.south) |- (pap-8-3.west);
\path (pap-7-4.south) |- (pap-8-3.east);
\path (pap-8-3) -- (pap-9-3);
\path (pap-9-3.east) -- ([xshift=1.5mm]pap-9-3.east) |- ([yshift=-1.5mm]pap-12-3.south);
\path (pap-9-3) -- (pap-10-3);
\path (pap-10-3) -- (pap-11-3);
\path (pap-11-3) -- (pap-12-3);
\path (pap-12-3) -- (pap-13-3);
\path (pap-13-3.west) -| (pap-14-2.north);
\path (pap-13-3.east) -| (pap-14-4.north);
\path (pap-14-2.south) |- (pap-15-3.west);
\path (pap-14-4.south) |- (pap-15-3.east);
\path (pap-15-3.south) -- ([yshift=-1.5mm]pap-15-3.south) -| ([shift={(-1.5mm,-1.5mm)}]pap-14-2.south west) |- ([yshift=-1.5mm]pap-2-3.south);
\end{scope}
\begin{scope} [every path/.style=linie]
\path (pap-3-1) -- (pap-3-3);
\path (pap-4-1) -- (pap-4-3);
\path (pap-9-1) -- (pap-9-3);
\end{scope}
\end{tikzpicture}
\end{document}
抱歉,当我粘贴代码时,它看起来和我之前组织的方式不一样。无论如何它都应该能工作。
答案1
- 为了改变第一列和第二列之间的距离,我将选项
[2mm]
纳入了第二个单元格。 为了向路径添加标签,我在路径操作中包含了一个节点,例如:
\path (pap-9-2)--(pap-10-2) **node [near start, right] {Your Text here};
这会在near start
路径的右侧添加一个节点,连接第 2 列的第 9 个和第 10 个单元格。
- 为了改变距离,我去掉了列,这样最后就只剩下两列了,而且我能够在操作中设置第一列和第二列之间的距离
every matrix/.style
。此外,我在一个单元格中添加了两个节点,例如:
... \usetikzlibrary{...,定位,...} ... \begin{tikzpicture}[每个矩阵/.style ={column sep=2mm}] ... \matrix (矩阵名称) { ... & \node (produktion) [操作] {Produktion}; \node (wartung) [operation,right=3mm of produktion] {Wartung}; \\\\}; ...
以下是一个例子:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,matrix}
\begin{document}
\begin{tikzpicture}[
every matrix/.style={matrix of nodes,nodes in empty cells,column sep=1cm,row sep=1cm},
every node/.style ={text centered,anchor=center},
arrow/.style ={draw,->},
line/.style ={draw,dashed}]
\matrix (matrix)
{
& |[draw]| {Cell 1-2}\\
Cell 2-1] & \node (A) [draw,anchor=east,xshift=-2mm,text width=2cm] {Node A in Cell 2-2}; \node (B) [draw,right=2mm of A,,text width=2cm] {Node B in Cell 2-2};\\
& |[draw]| {Cell 3-2}\\
};
\begin{scope} [every path/.style=arrow]
\path (matrix-1-2)-| (A) node [near start,below] {1};
\path (matrix-1-2)-| (B) node [near start,below] {2};
\path (A) |- (matrix-3-2) node [near end,above]{3};
\path (B) |- (matrix-3-2) node [near end,above]{4};
\path (matrix-3-2)-- ([yshift=-2mm]matrix-3-2.south)-|([xshift=-2mm]A.west)|-([yshift=2mm]matrix-1-2.north) --(matrix-1-2) node [near end,above=2mm] {5};
\end{scope}
\begin{scope} [every path/.style=line]
\path(matrix-2-1)--(A);
\end{scope}
\end{tikzpicture}
\end{document}