My code is:
\begin{center}
\vspace{-20pt}
\begin{tikzpicture}[mybox/.style={rectangle, draw, minimum width=10mm, minimum height=10mm}]
\foreach \addr/\val [count=\x] in {$0$,$1$/$28$,$6$/$\infty$,$6$/$\infty$,$6$/$25$,$0$,$6$/$\infty$} {
\node (node\x) [mybox] at (\x,0) {\addr};
\node[above=5mm] at (\x,0) {\footnotesize \x};
\node[below=5mm] at (\x,0) {\val};
}
\node at (node1.south west-100mm,0) [below=5mm] {Edge Weight:};
\draw[ultra thick] (node1.south west) rectangle (node7.north east);
\end{tikzpicture}
\end{center}
I get an error on the line \node (lab) at (node1.south west-100mm,0) [below=5mm] {Edge Weight:};
pertaining to the section (node1.south west-100mm,0)
on using the anchor as a coordinate.
The error:
Package PGF Math Error: Unknown function 'node1' (in 'node1.south west-100mm'). \node at (node1.south west-100mm,0)
Package PGF Math Error: Unknown function 'node1' (in 'node1.south west-100mm'). …est-100mm,0) [below=5mm] {Edge Weight:};
I want the position of the node lab
to be at a distance of (-100pt,0) from the south west anchor of node0. How do I do this?
I even tried writing:
(node1.south west)+(-1,0)
But that doens't work either. How do I solve this issue?
P.S. I know writing \path (node1.south west) node at +(-35pt,-8pt) {Edge Weight:};
would solve the problem, but is there a way to do this directly without using the path command and simply using the node command?
Best Answer
You can use
xshift
:With this small tweak your code produces:
For what it's worth, to make the code easier to read I would replace the for-loop with