如果我添加rounded corners
到every path/.style
,该选项也会影响节点边界。为什么?
创建一种在环境中使用的样式是scope
避免这种情况的正确方法吗?(当然,实际的流程图\draw
比 MWE 更多)。
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{
shapes.geometric,
matrix,
arrows.meta}
\begin{document}
\begin{tikzpicture}[
basenode/.style={
draw=gray, align=center,
text=black, very thick,
anchor=center,
align=center,
},
block/.style={
basenode, text width=7em,
minimum height=8ex,
inner sep=0pt,
},
decision/.style={
basenode,
minimum width=12em,
minimum height=16ex,
diamond,
anchor=center,
shape aspect=2,
text width=5em,
inner sep=0pt,
},
%myarrow/.style={
every path/.style={
gray,
very thick,
rounded corners,
-{Triangle[width=5pt]}
},
]
\matrix[
matrix of nodes, row sep=5ex, column sep=-2em,
] {
|[decision](a)| A \\
& |[block](b)| B \\
};
%\begin{scope}[myarrow]
\draw (a) -| (b);
%\end{scope}
\end{tikzpicture}
\end{document}
答案1
\node
是 的缩写\path[node]
,参见手册中的第 15.1 节,所以我认为这并不奇怪。
另一种方法是添加
every node/.append style={sharp corners}
到tikzpicture
选项。这似乎不会覆盖rounded corners
节点样式。
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{
shapes.geometric,
matrix,
arrows.meta}
\begin{document}
\begin{tikzpicture}[
basenode/.style={
draw=gray, align=center,
text=black, very thick,
anchor=center,
align=center,
},
block/.style={
basenode, text width=7em,
minimum height=8ex,
inner sep=0pt,
},
decision/.style={
basenode,
minimum width=12em,
minimum height=16ex,
diamond,
anchor=center,
shape aspect=2,
text width=5em,
inner sep=0pt,
},
%myarrow/.style={
every path/.style={
gray,
very thick,
rounded corners,
-{Triangle[width=5pt]}
},
% addition:
every node/.append style={sharp corners}
]
\matrix[
matrix of nodes, row sep=5ex, column sep=-2em,
] {
|[decision](a)| A \\
& |[block](b)| B \\
};
%\begin{scope}[myarrow]
\draw (a) -| (b);
%\end{scope}
\end{tikzpicture}
\end{document}