Latex:故障树中元素叠加
Latex: elements are superimposed in fault tree
我有以下代码,但元素 31 叠加在元素 27 上。
我该如何解决这个问题?
\documentclass[border=10pt]{standalone}
\usepackage{tikz,rotating}
\usetikzlibrary{trees,calc,shadings,shapes.gates.logic.US,positioning,arrows}
\usetikzlibrary{shapes,snakes}
\begin{document}
\begin{turn}{-90}
\begin{tikzpicture}[
% Gates and symbols style
and/.style={and gate US,thick,draw,fill=red!60,rotate=90,
anchor=east,xshift=-2mm},
or/.style={or gate US,thick,draw,fill=blue!60,rotate=90,
anchor=east,xshift=-1mm},
be/.style={circle,thick,draw,fill=green!60,anchor=north,
minimum width=0.7cm},
tr/.style={buffer gate US,thick,draw,fill=purple!60,rotate=90,
anchor=east,minimum width=0.8cm},
% Label style
label distance=-3mm,
every label/.style={blue,rotate=90},
% Event style
event/.style={rectangle,thick,draw,fill=yellow!20,text width=0.7cm,
text centered,font=\sffamily,anchor=north},
% Children and edges style
edge from parent/.style={very thick,draw=black!70},
edge from parent path={(\tikzparentnode.south) -- ++(0,-1.05cm)
-| (\tikzchildnode.north)},
level 1/.style={sibling distance=7cm,level distance=1.4cm,
growth parent anchor=south,nodes=event},
level 2/.style={sibling distance=5cm},
level 3/.style={sibling distance=1cm},
level 4/.style={sibling distance=3cm}
]
\node (g1) {}
child{node (g2) {\rotatebox{90}{Final}}
child {node (g3) {\rotatebox{90}{1}}
child {node (g4) {\rotatebox{90}{11}}}
}
child {node (g5) {\rotatebox{90}{2}}
child {node (S1) {\rotatebox{90}{21}}}
child {node (S2) {\rotatebox{90}{22}}}
child {node (S3) {\rotatebox{90}{23}}}
child {node (S4) {\rotatebox{90}{24}}}
child {node (S5) {\rotatebox{90}{25}}}
child {node (S6) {\rotatebox{90}{26}}}
child {node (S7) {\rotatebox{90}{27}}}
}
child {node (g6) {\rotatebox{90}{3}}
child {node (R1) {\rotatebox{90}{31}}}
child {node (R2) {\rotatebox{90}{32}}}
child {node (R3) {\rotatebox{90}{33}}}
child {node (R4) {\rotatebox{90}{34}}}
}
};
\node [and] at (g2.south) [label=-100:AND] {};
\node [or] at (g3.south) [label=-100:OR] {};
\node [or] at (g5.south) [label=-100:OR] {};
\node [or] at (g6.south) [label=-100:OR] {};
\end{tikzpicture}
\end{turn}
\end{document}
如你所见,元素相互叠加。当我更改代码中的某些参数时,图形会转到文档末尾。
您可以将简单的 xshift
添加到第二个 child(由于旋转,它在 x 上)。如果您满意,请尝试此版本:
\documentclass[border=10pt]{standalone}
\usepackage{tikz,rotating}
\usetikzlibrary{trees,calc,shadings,shapes.gates.logic.US,positioning,arrows}
\usetikzlibrary{shapes,snakes}
\begin{document}
\begin{turn}{-90}
\begin{tikzpicture}[
% Gates and symbols style
and/.style={and gate US,thick,draw,fill=red!60,rotate=90,
anchor=east,xshift=-2mm},
or/.style={or gate US,thick,draw,fill=blue!60,rotate=90,
anchor=east,xshift=-1mm},
be/.style={circle,thick,draw,fill=green!60,anchor=north,
minimum width=0.7cm},
tr/.style={buffer gate US,thick,draw,fill=purple!60,rotate=90,
anchor=east,minimum width=0.8cm},
% Label style
label distance=-3mm,
every label/.style={blue,rotate=90},
% Event style
event/.style={rectangle,thick,draw,fill=yellow!20,text width=0.7cm,
text centered,font=\sffamily,anchor=north},
% Children and edges style
edge from parent/.style={very thick,draw=black!70},
edge from parent path={(\tikzparentnode.south) -- ++(0,-1.05cm)
-| (\tikzchildnode.north)},
level 1/.style={sibling distance=7cm,level distance=1.4cm,
growth parent anchor=south,nodes=event},
level 2/.style={sibling distance=5cm},
level 3/.style={sibling distance=1cm},
level 4/.style={sibling distance=3cm}
]
\node (g1) {}
child{node (g2) {\rotatebox{90}{Final}}
child {node (g3) {\rotatebox{90}{1}}
child {node (g4) {\rotatebox{90}{11}}}
}
child {node (g5) {\rotatebox{90}{2}}
child {node (S1) {\rotatebox{90}{21}}}
child {node (S2) {\rotatebox{90}{22}}}
child {node (S3) {\rotatebox{90}{23}}}
child {node (S4) {\rotatebox{90}{24}}}
child {node (S5) {\rotatebox{90}{25}}}
child {node (S6) {\rotatebox{90}{26}}}
child {node (S7) {\rotatebox{90}{27}}}
}
child {node[xshift=1cm] (g6) {\rotatebox{90}{3}} % <--- EDIT!
child {node (R1) {\rotatebox{90}{31}}}
child {node (R2) {\rotatebox{90}{32}}}
child {node (R3) {\rotatebox{90}{33}}}
child {node (R4) {\rotatebox{90}{34}}}
}
};
\node [and] at (g2.south) [label=-100:AND] {};
\node [or] at (g3.south) [label=-100:OR] {};
\node [or] at (g5.south) [label=-100:OR] {};
\node [or] at (g6.south) [label=-100:OR] {};
\end{tikzpicture}
\end{turn}
\end{document}
P.S. 可能这样的问题更适合 Tex Site
我有以下代码,但元素 31 叠加在元素 27 上。 我该如何解决这个问题?
\documentclass[border=10pt]{standalone}
\usepackage{tikz,rotating}
\usetikzlibrary{trees,calc,shadings,shapes.gates.logic.US,positioning,arrows}
\usetikzlibrary{shapes,snakes}
\begin{document}
\begin{turn}{-90}
\begin{tikzpicture}[
% Gates and symbols style
and/.style={and gate US,thick,draw,fill=red!60,rotate=90,
anchor=east,xshift=-2mm},
or/.style={or gate US,thick,draw,fill=blue!60,rotate=90,
anchor=east,xshift=-1mm},
be/.style={circle,thick,draw,fill=green!60,anchor=north,
minimum width=0.7cm},
tr/.style={buffer gate US,thick,draw,fill=purple!60,rotate=90,
anchor=east,minimum width=0.8cm},
% Label style
label distance=-3mm,
every label/.style={blue,rotate=90},
% Event style
event/.style={rectangle,thick,draw,fill=yellow!20,text width=0.7cm,
text centered,font=\sffamily,anchor=north},
% Children and edges style
edge from parent/.style={very thick,draw=black!70},
edge from parent path={(\tikzparentnode.south) -- ++(0,-1.05cm)
-| (\tikzchildnode.north)},
level 1/.style={sibling distance=7cm,level distance=1.4cm,
growth parent anchor=south,nodes=event},
level 2/.style={sibling distance=5cm},
level 3/.style={sibling distance=1cm},
level 4/.style={sibling distance=3cm}
]
\node (g1) {}
child{node (g2) {\rotatebox{90}{Final}}
child {node (g3) {\rotatebox{90}{1}}
child {node (g4) {\rotatebox{90}{11}}}
}
child {node (g5) {\rotatebox{90}{2}}
child {node (S1) {\rotatebox{90}{21}}}
child {node (S2) {\rotatebox{90}{22}}}
child {node (S3) {\rotatebox{90}{23}}}
child {node (S4) {\rotatebox{90}{24}}}
child {node (S5) {\rotatebox{90}{25}}}
child {node (S6) {\rotatebox{90}{26}}}
child {node (S7) {\rotatebox{90}{27}}}
}
child {node (g6) {\rotatebox{90}{3}}
child {node (R1) {\rotatebox{90}{31}}}
child {node (R2) {\rotatebox{90}{32}}}
child {node (R3) {\rotatebox{90}{33}}}
child {node (R4) {\rotatebox{90}{34}}}
}
};
\node [and] at (g2.south) [label=-100:AND] {};
\node [or] at (g3.south) [label=-100:OR] {};
\node [or] at (g5.south) [label=-100:OR] {};
\node [or] at (g6.south) [label=-100:OR] {};
\end{tikzpicture}
\end{turn}
\end{document}
如你所见,元素相互叠加。当我更改代码中的某些参数时,图形会转到文档末尾。
您可以将简单的 xshift
添加到第二个 child(由于旋转,它在 x 上)。如果您满意,请尝试此版本:
\documentclass[border=10pt]{standalone}
\usepackage{tikz,rotating}
\usetikzlibrary{trees,calc,shadings,shapes.gates.logic.US,positioning,arrows}
\usetikzlibrary{shapes,snakes}
\begin{document}
\begin{turn}{-90}
\begin{tikzpicture}[
% Gates and symbols style
and/.style={and gate US,thick,draw,fill=red!60,rotate=90,
anchor=east,xshift=-2mm},
or/.style={or gate US,thick,draw,fill=blue!60,rotate=90,
anchor=east,xshift=-1mm},
be/.style={circle,thick,draw,fill=green!60,anchor=north,
minimum width=0.7cm},
tr/.style={buffer gate US,thick,draw,fill=purple!60,rotate=90,
anchor=east,minimum width=0.8cm},
% Label style
label distance=-3mm,
every label/.style={blue,rotate=90},
% Event style
event/.style={rectangle,thick,draw,fill=yellow!20,text width=0.7cm,
text centered,font=\sffamily,anchor=north},
% Children and edges style
edge from parent/.style={very thick,draw=black!70},
edge from parent path={(\tikzparentnode.south) -- ++(0,-1.05cm)
-| (\tikzchildnode.north)},
level 1/.style={sibling distance=7cm,level distance=1.4cm,
growth parent anchor=south,nodes=event},
level 2/.style={sibling distance=5cm},
level 3/.style={sibling distance=1cm},
level 4/.style={sibling distance=3cm}
]
\node (g1) {}
child{node (g2) {\rotatebox{90}{Final}}
child {node (g3) {\rotatebox{90}{1}}
child {node (g4) {\rotatebox{90}{11}}}
}
child {node (g5) {\rotatebox{90}{2}}
child {node (S1) {\rotatebox{90}{21}}}
child {node (S2) {\rotatebox{90}{22}}}
child {node (S3) {\rotatebox{90}{23}}}
child {node (S4) {\rotatebox{90}{24}}}
child {node (S5) {\rotatebox{90}{25}}}
child {node (S6) {\rotatebox{90}{26}}}
child {node (S7) {\rotatebox{90}{27}}}
}
child {node[xshift=1cm] (g6) {\rotatebox{90}{3}} % <--- EDIT!
child {node (R1) {\rotatebox{90}{31}}}
child {node (R2) {\rotatebox{90}{32}}}
child {node (R3) {\rotatebox{90}{33}}}
child {node (R4) {\rotatebox{90}{34}}}
}
};
\node [and] at (g2.south) [label=-100:AND] {};
\node [or] at (g3.south) [label=-100:OR] {};
\node [or] at (g5.south) [label=-100:OR] {};
\node [or] at (g6.south) [label=-100:OR] {};
\end{tikzpicture}
\end{turn}
\end{document}
P.S. 可能这样的问题更适合 Tex Site