在下面的例子中,我希望有垂直和水平的倾斜边缘。我的目标是获得如下图所示的边缘(圆边不是必须的):
这是我的最小工作示例:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning, shapes.symbols,shapes.callouts,patterns}
\begin{document}
\begin{tikzpicture}[
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick}
]
\node[draw](start){start};
\node[draw, right=of start] (split) {+}
edge[pre](start);
\node[draw, right=of split](pricedb){PriceDB}
edge[pre](split);
\node[draw, below=of pricedb](stockdb){StockDB}
edge[pre](split);
\node[draw, above=of pricedb](orderpage){OrderPage}
edge[pre](split);
\node[draw,right=of pricedb](join){+}
edge[pre](pricedb)
edge[pre](stockdb)
edge[pre](orderpage);
\node[draw, right=of join](invoice){invoiceservice}
edge[pre](join);
\node(silent)[right=of invoice]{}
edge[<-,shorten <=1pt,>=stealth',semithick, dashed](invoice);
\end{tikzpicture}
\end{document}
答案1
使用 draw 很简单
\documentclass{文章} \usepackage{tikz} \usetikzlibrary{箭头、定位、形状.符号、形状.标注、图案} \开始{文档} \开始{tikzpicture}[ pre/.style={=stealth',semithick}, post/.style={->,shorten >=1pt,>=stealth',semithick} ] \node[draw](开始){开始}; \node[draw, right=of start] (分割) {+} 边[前](开始); \node[draw, right=of split](pricedb){PriceDB} 边[预](分割); \node[draw, below=of pricedb](stockdb){StockDB}; \node[draw, above=of pricedb](orderpage){OrderPage}; \node[draw,right=of pricedb](join){+} 边[pre](pricedb); \node[draw, right=of join](invoice){invoiceservice} 边[预](连接); \draw[post,rounded corners=5pt] (订单页面)-|(加入) ; \draw[post,圆角=5pt] (stockdb)-|(连接) ; \draw[post,rounded corners=5pt] (split) |- (orderpage); \draw[post,rounded corners=5pt] (split) |- (stockdb); \node(silent)[发票权利]{} 边缘[=隐形',半厚,虚线](发票); \结束{tikzpicture} \结束{文档}
答案2
实际上你可以用以下方法edge
代替\draw
:只需添加
\tikzset{
-|/.style={to path={-| (\tikztotarget)}},
|-/.style={to path={|- (\tikztotarget)}},
}
某处,那么你就可以使用edge[-|]
和edge[|-]
。(当然,如果你仍然想在某处使用-|
/|-
箭头,你可以用其他名称替换它们,例如“hv”或“vh”(表示“水平-垂直”等)。
您的代码将如下所示:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.symbols,shapes.callouts,patterns}
\begin{document}
\tikzset{
-|/.style={to path={-| (\tikztotarget)}},
|-/.style={to path={|- (\tikztotarget)}},
}
\begin{tikzpicture}[
pre/.style={<-,shorten <=1pt,>=stealth',semithick},
post/.style={->,shorten >=1pt,>=stealth',semithick}
]
\node[draw](start){start};
\node[draw, right=of start] (split) {+}
edge[pre](start);
\node[draw, right=of split](pricedb){PriceDB}
edge[pre](split);
\node[draw, below=of pricedb](stockdb){StockDB}
edge[pre,-|](split);
\node[draw, above=of pricedb](orderpage){OrderPage}
edge[pre,-|](split);
\node[draw,right=of pricedb](join){+}
edge[pre](pricedb)
edge[pre,|-](stockdb)
edge[pre,|-](orderpage);
\node[draw, right=of join](invoice){invoiceservice}
edge[pre](join);
\node(silent)[right=of invoice]{}
edge[<-,shorten <=1pt,>=stealth',semithick, dashed](invoice);
\end{tikzpicture}
\end{document}