Tikz 矩阵不允许我在节点之间画线

Tikz 矩阵不允许我在节点之间画线

如果我想在节点 1-1 和 2-2 之间画一条线:

\begin{tikzpicture}
\matrix (magic) [matrix of math nodes, left delimiter=\lvert, right delimiter=\rvert,column sep=4pt,row sep=4pt]
{
   \draw (0,0) circle (5pt); & \fill (0,0) circle (2pt); & \fill (0,0) circle (2pt);\\
   \fill (0,0) circle (2pt); & \draw (0,0) circle (5pt); & \fill (0,0) circle (2pt);\\
   \fill (0,0) circle (2pt); & \fill (0,0) circle (2pt); & \draw (0,0) circle (5pt);\\
};
%\draw[thick,red,->] (magic-1-1) |- (magic-2-2);

\结束{tikzpicture}

我得到:

generic/fonts/otf/lmroman12-bold.luc)(load luc: /home/xan/.texlive/texmf-var/lua
tex-cache/generic/fonts/otf/lmroman12-bold.luc) [13] [14]
Capítol 1.
(compiling luc: /var/lib/texmf/luatex-cache/generic/fonts/otf/lmroman12-italic.l
uc)(load luc: /home/xan/.texlive/texmf-var/luatex-cache/generic/fonts/otf/lmroma
n12-italic.luc)(compiling luc: /var/lib/texmf/luatex-cache/generic/fonts/otf/lmr
oman10-bolditalic.luc)(load luc: /home/xan/.texlive/texmf-var/luatex-cache/gener
ic/fonts/otf/lmroman10-bolditalic.luc) [15](compiling luc: /var/lib/texmf/luatex
-cache/generic/fonts/otf/lmsans10-bold.luc)(load luc: /home/xan/.texlive/texmf-v
ar/luatex-cache/generic/fonts/otf/lmsans10-bold.luc)

! Package pgf Error: No shape named magic-1-1 is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.100     \draw[thick,red,->] (magic-1-1)
                                        |- (magic-2-2);
? 

为什么?

如果我抑制 \draw line,一切都正常。

答案1

错误原因是tikz 图表的编译问题。这是使用节点样式来绘制点和圆圈的另一种方法。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[
  dot/.style={inner sep=0pt,minimum size=2pt,fill=black,circle},
  ring/.style={inner sep=0pt,minimum size=5pt,draw,circle}]
\matrix (magic) [matrix of math nodes,
                 left delimiter=\lvert,
                 right delimiter=\rvert,
                 column sep=4pt,row sep=4pt]
{
|[ring]| & |[dot]| & |[dot]| \\
|[dot]| & |[ring]| & |[dot]| \\
|[dot]| & |[dot]| & |[ring]| \\
   };
\draw[thick,red,->] (magic-1-1) |- (magic-2-2);
\end{tikzpicture}
\end{document}

相关内容