I would do it completely with a matrix. If you set the nodes to
draw=gray, minimum size=+1cm, outer sep=+0pt, text depth=+-.5ex, text height=+1ex
you get a grid-like set of boxes. The column sep and row sep needs to bet set to -\pgflinewidth so that the nodes overlap.
The dots can then be added via two \foreach loops:
\foreach \row in {1,...,4}{
\foreach \column in {1,...,6}
\node at (m-\row-\column.north west) [dot]
[if={\row==4}{insert path=node at (m-\row-\column.south west) [dot]}{}];
\node at (m-\row-6.north east)[dot];
}
\node at (m-4-6.south east)[dot];
(This only adds one dot at each corner. Simpler loops can be constructed, they however add multiple dots at most corners.)
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[
dot/.style={fill,circle, inner sep=+0pt, minimum size=+4pt, node contents=},
]
\matrix[matrix of nodes, nodes in empty cells,
column sep=-\pgflinewidth, row sep=-\pgflinewidth,
nodes={draw=gray, minimum size=+1cm, outer sep=+0pt,
text depth=+-.5ex, text height=1ex}
] (m) {
0 & A & B & C & D & E \\
& & & & & \\
& & & & & \\
& & & & & \\
};
\foreach \row in {1,...,4}{
\foreach \column in {1,...,6}
\node at (m-\row-\column.north west) [dot]
[if={\row==4}{insert path=node at (m-\row-\column.south west) [dot]}{}];
\node at (m-\row-6.north east)[dot];
}
\node at (m-4-6.south east)[dot];
\end{tikzpicture}
\end{document}
If you are feeling more adventurous, you can add these dots as part of labels of the matrix’s nodes. This needs, however, two fixes:
- An override of the automatically selected anchor for the labels,
see How can I set the TikZ label anchor explicitly?
As labels are nodes themselved, they also get the every node style applied. If we add those dots as labels to the every node style we would get an infinite amount of recursion. (Every label would get labels which get labels …)
For this I introduce the not if label key which argument will only get applied if the node it is used in is not a label. (For a pin a similar key can be constructed.)
Unfortunately, the labels will count to a cell’s dimension, so you will either need to accommodate their sizes into the column sep and row sep or add overlay to the dot style. This might make them protrude outside of the picture if the inner seps of the matrix is smaller than half the size of the dots.
Again, the addition of the dots is done so that every dot is only drawn once.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix}
\makeatletter
\tikzset{not if label/.code={%
\pgfutil@ifundefined{tikz@save@last@fig@name}{\pgfkeysalso{#1}}{}}}
\makeatother
\tikzset{
label anchor/.style={tikz@label@post/.append style={anchor=#1}},
label dots/.style={label={[dot,label anchor=center]#1:}},
nw dots/.style={label dots=north west},
sw dots/.style={label dots=south west},
ne dots/.style={label dots=north east},
se dots/.style={label dots=south east}}
\begin{document}
\begin{tikzpicture}[
dot/.style={fill,circle, inner sep=+0pt, minimum size=+4pt, overlay},
]
\matrix[matrix of nodes, nodes in empty cells,
column sep=-\pgflinewidth, row sep=-\pgflinewidth,
nodes={not if label={
nw dots, draw=gray, minimum size=+1cm,
outer sep=+0pt, text depth=+-.5ex, text height=1ex}},
column 6/.style ={nodes={not if label=ne dots}},
row 4/.style ={nodes={not if label=sw dots}},
row 4 column 6/.style={nodes={not if label=se dots}},
]{
0 & A & B & C & D & E \\
& & & & & \\
& & & & & \\
& & & & & \\
};
\end{tikzpicture}
\end{document}
Output

column sep={2cm,between origins}? Isn't($(-3, \y) + (-2, \y)$)just(-5, 2*\y)? Can you complete your example to a full MWE and show what you want to achieve? I’d use onlymatrixfor this, though. – Qrrbrbirlbel Jun 03 '15 at 17:37every node/.style={anchor=base,text depth=-1cm,text height=1cm,text width=0cm}in\matrix[{INSERT HERE}]and it seems to be working. After further investigation it seems like what I needed wastext width=0cm(and also height) – tolog Jun 03 '15 at 18:17