2

If I want to put a line between nodes 1-1 and 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);

\end{tikzpicture}

I get:

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);
? 

Why?

If I supress the \draw line everything is OK.

Torbjørn T.
  • 206,688

1 Answers1

4

The reason for the error is the problem described in Compilation problem with tikz diagram. Here Is is an alternative approach using node styles to draw the dots and circles instead.

enter image description here

\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}
Torbjørn T.
  • 206,688
  • What is exactly what activate the possibility to call (magic-1-1)? – somenxavier Oct 06 '15 at 09:56
  • 2
    @somenxavier When you have a matrix of nodes or matrix of math nodes, and you only put some text in a cell, and not \path, \node etc. So for example in \matrix (m) [matrix of nodes] { a & \node{b}; \\ }; you will be able to use (m-1-1), but not (m-1-2). – Torbjørn T. Oct 06 '15 at 10:20