我正在尝试绘制一个简单的 ER 图。但是,以下代码不会在节点周围产生边框:
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows, calc, positioning, shapes.geometric}
\begin{document}
\ttfamily
\begin{tikzpicture}[draw=black, thick, ->, >=stealth,
entity/.style={ellipse, text centered}
field/.style={rectangle, text centered}
relation/.style={diamond, text centered}
]
\node (pilot) [entity] {Pilot};
\end{tikzpicture}
\end{document}
添加draw=black
样式没有帮助。只能通过指定draw
节点选项本身,例如
\node (pilot) [draw] {Pilot};
有效。这是为什么呢?
答案1
节点不会自动继承全局选项中输入的每个键。手册(第 128 页左右)说,提供全局选项的正确方法是使用键every...
。例如,在选项中使用
every node/.style={draw=black, thick},
会做你想做的事。
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows, calc, positioning, shapes.geometric}
\begin{document}
\ttfamily
\begin{tikzpicture}[draw=black, thick, ->, >=stealth, red,
every node/.style={draw=black, thick},
entity/.style={ellipse, text centered}
field/.style={rectangle, text centered}
relation/.style={diamond, text centered}
]
\node (pilot) [entity] {Pilot};
\end{tikzpicture}
\end{document}