我试图在两处断线,以实现这样的目标:
示例中的断点是圆形的,但这就是我的想法。我有以下代码,它只生成一个断点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,arrows,arrows.meta,shapes,decorations.pathreplacing,fit,calc}
\usetikzlibrary{automata,positioning,arrows,shapes,decorations.pathreplacing,fit,calc}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{decorations.pathreplacing,calc}
\begin{document}
% Define block styles
\tikzstyle{decision} = [diamond, draw,
text width=4.8em, text centered, node distance=2cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw,
text width=7em, text centered, rounded corners, minimum height=2em]
\tikzstyle{arrow} = [draw, -latex']
\tikzstyle{line} = [draw]
\tikzstyle{invisible4} = [rectangle]
\tikzstyle{invisible5} = [rectangle]
\tikzstyle{circular} = [draw, circle, radius=1.0cm,]
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance = 2cm, auto, scale=1.0]
\node [block] (pulse) {\small P};
\node [invisible4, below of=pulse] (aux2) {};
\node [block, left of=aux2] (fp) {\small FP};
\node [block, right of=aux2] (rp) {\small FP};
\node [circular, below of=aux2] (minus) {\small -};
\node [decision, below of=minus] (threshold) {\small $\le T$ ?};
\node [invisible4, below of=threshold] (aux3) {};
\node [block, left of=aux3] (fp2) {\small FP};
\node [block, right of=aux3] (rp2) {\small RP};
\node [invisible4, below of=aux3, node distance=1.0cm] (aux) {};
\node [invisible5, draw=none, below of=aux, node distance=1.0cm] (aux4) {};
\path [arrow] (pulse) |- (fp);
\path [arrow] (pulse) |- (rp);
\path [arrow] (fp) |- (minus);
\path [arrow] (rp) |- (minus);
\path [arrow] (minus) -- (threshold);
\path [arrow] (threshold) -| node [above, near start] {yes} (fp2);
\path [arrow] (threshold) -| node [near start] {no} (rp2);
\path [line] (fp2) |- (aux);
\path [line] (rp2) |- (aux);
\end{tikzpicture}
\end{figure}
\end{document}
此代码生成此图:
我试图在连接 P 和 FP、P 和 RP 的箭头中创建两个断点,以及从底部连接并指向下方的 FP 和 RP 的箭头。我试图在它们之间创建一个辅助的不可见节点,但这个节点仍然占据空间(在图像中可以看到,线条之间的间隙)。
我怎样才能打破这些界限?
谢谢你!
答案1
选择中间的一个点并再次“断开”。rounded corners
如果您不想要尖角,请使用选项。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,calc,arrows}
\begin{document}
% Define block styles
\tikzstyle{decision} = [diamond, draw,
text width=4.8em, text centered, node distance=2cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw,
text width=7em, text centered, rounded corners, minimum height=2em]
\tikzstyle{arrow} = [draw, -latex',rounded corners]
\tikzstyle{line} = [draw]
\tikzstyle{invisible4} = [rectangle]
\tikzstyle{invisible5} = [rectangle]
\tikzstyle{circular} = [draw, circle, radius=1.0cm,]
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance = 2cm, auto, scale=1.0]
\node [block] (pulse) {\small P};
\node [invisible4, below of=pulse] (aux2) {};
\node [block, left of=aux2] (fp) {\small FP};
\node [block, right of=aux2] (rp) {\small FP};
\node [circular, below of=aux2] (minus) {\small -};
\node [decision, below of=minus] (threshold) {\small $\le T$ ?};
\node [invisible4, below of=threshold] (aux3) {};
\node [block, left of=aux3] (fp2) {\small FP};
\node [block, right of=aux3] (rp2) {\small RP};
\node [invisible4, below of=aux3, node distance=1.0cm] (aux) {};
\node [invisible5, draw=none, below of=aux, node distance=1.0cm] (aux4) {};
\path [arrow] (pulse) |- ($(pulse)+(0,-1)$) -| (fp);
\path [arrow] (pulse) |- ($(pulse)+(0,-1)$) -| (rp);
\path [arrow] (fp) |- (minus);
\path [arrow] (rp) |- (minus);
\path [arrow] (minus) -- (threshold);
\path [arrow] (threshold) -| node [above, near start] {yes} (fp2);
\path [arrow] (threshold) -| node [near start] {no} (rp2);
\path [line] (fp2) |- (aux);
\path [line] (rp2) |- (aux);
\end{tikzpicture}
\end{figure}
\end{document}