如何关闭 PGF 中的绘制节点边框?

如何关闭 PGF 中的绘制节点边框?

我正在尝试创建一张图片瞬间疯狂问题。这是我的代码:

\begin{tikzpicture}
\matrix[nodes=draw]
{
; & \node{\LARGE R}; & ; & ;\\
\node{\LARGE R}; & \node[draw=white]{\LARGE B}; & \node{\LARGE G}; & \node{\LARGE W};\\
; & \node{\LARGE R}; & ; & ;\\
};
\end{tikzpicture}

问题是,包含 B 的节点边框相对较粗。这是由于边框与周围节点重叠造成的。如何关闭包含

答案1

我认为你需要手动画线:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix(m)[matrix of nodes,nodes={minimum width=2em,font=\LARGE}]
{
  & R & & \\
R & B & G & W\\
  & R & & \\
};
\draw (m-3-2.south west) rectangle (m-1-2.north east);
\draw (m-2-1.south west) rectangle (m-2-4.north east);
\draw (m-2-3.south east) -- (m-2-3.north east);
\end{tikzpicture}
\end{document}

TikZ 的矩阵库显然对于访问矩阵中的节点是必要的。

现在您可以将其作为宏的替换文本,这样就不必一遍又一遍地输入它。

答案2

使用\node[draw=none]。根据 TikZ 手册(v2.10 中的第 15.3 节“绘制路径”),

如果给出了特殊颜色名称none,此选项会导致绘图“关闭”。如果样式先前已打开绘图并且您希望在本地撤消此效果,则此功能很有用。

答案3

如果关闭绘制节点边框是愿望,Caramdir 的答案是正确的。我们应该使用draw=none或不包含draw在节点的选项中。

但从描述来看,OP的真正问题似乎是使用matrix每个节点都显示自己的边框,而相邻边框显示双倍宽度:

在此处输入图片描述

这个问题也可以通过选择方便的行和列分隔来解决。 row sep=-\pgflinewidthcolumn sep=-\pgflinewidth。但要注意,此解决方案仅在所有节点的边界都相等时才有效line width

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix(m)[matrix of nodes,nodes={draw, minimum width=2em,font=\LARGE}, 
column sep=-\pgflinewidth, row sep=-\pgflinewidth
]
{
  & R & & \\
R & B & G & W\\
  & R & & \\
};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容