Please consider the following mwe:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,
nodes={draw, font=\footnotesize, minimum size=1em,
anchor=center,inner sep=0pt},
column sep=-\pgflinewidth,
row sep=-\pgflinewidth,
every even column/.style={column sep=2pt},
every even row/.style={row sep=2pt},% doesn't insert row separation
inner sep=1pt,
left delimiter={[},right delimiter={]},
]
{
\alpha & \beta & \gamma & \delta \\
\alpha & \beta & \gamma & \delta \\
\alpha & \beta & \gamma & \delta \\
\alpha & \beta & \gamma & \delta \\
};
\end{tikzpicture}
\end{document}
However every even column/.style={column sep=2pt},
yields the expected result, say, introducing additional column separation after each second column, the every even row/.style={row sep=2pt},
doesn't. Did I do something wrong or this is a bug in TikZ v3.1 (I've never tested this before, so I don't know if the same thing happens in v3.0.1)?
edit:
The same thing happens with, for example,
row 2/.style = {row sep=2pt}
thus it might mean that every even row/.style=...
and row <row number>
work fine only if one wants to change some properties of cells inside row, for example, the color of nodes borders:
every even row/.style={draw red},
but not if one aims to change row separation (see @AndréC's comment below). However it is interesting, that this is possible to do in every column sep
…
Of course, the (temporary) workaround terminates each second row of the matrix with for example [2pt]
, but this is annoying when the matrix is huge like here.
Best Answer
This is from a bug in the
matrix
library. The bug was reported in issue #504 in the PGF bug tracker.The problem is the scope where
\pgfmatrixrowsep
is set (the value you pass torow sep
) ends before that value is actually used.Henri Menke submitted a fix to this issue which will be in the next release of PGF.
Meanwhile, the following patch will work:
MWE: