我在图片顶部设置了所有可以立即设置的节点和坐标TikZ
。但是,一条线可能会遮挡节点。如果节点位于线之后,我可以使用fill = white
它将线的该部分变白。我可以在不移动有问题的线下方的节点的情况下实现类似的效果吗?我知道我们可以建议移动节点,但在某些情况下,情况并非如此。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
every label/.append style = {font = \small},
dot/.style = {outer sep = +0pt, inner sep = +0pt,
shape = circle, draw = black, label = {#1}},
dot/.default =,
small dot/.style = {minimum size = .1cm, dot = {#1}},
small dot/.default =,
big dot/.style = {minimum size = .15cm, dot = {#1}},
big dot/.default =
]
\node[scale = .75, fill = black, big dot = {below: \(F\)}]
(F) at (2.5, 0) {};
\draw (2.5, 1) -- (2.5, -1);
\end{tikzpicture}
\end{document}
答案1
您可以使用该backgrounds
库将线放在“背景层”上,然后用白色填充节点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds} % use backgrounds library
\begin{document}
\begin{tikzpicture}[
every label/.append style = {font = \small},
dot/.style = {outer sep = +0pt, inner sep = +0pt,
shape = circle, draw = black, label = {#1}},
dot/.default =,
small dot/.style = {minimum size = .1cm, dot = {#1}},
small dot/.default =,
big dot/.style = {minimum size = .15cm, dot = {#1}},
big dot/.default =
]
\node[scale = .75, fill = black, big dot = {below,fill=white: \(F\)}]
(F) at (2.5, 0) {};
% put line on background layer
\begin{scope}[on background layer]
\draw (2.5, 1) -- (2.5, -1);
\end{scope}
\end{tikzpicture}
\end{document}