# Wrong colum sep between first two columns of a TikZ matrix

I don't know why but next code shows a different column sep between columns 1 and 2 from the other ones. This is what I get:

I'm using column sep=-\pgflinewidth so I hopped to see just one thick line between cells one and two but as you can see the right gray border of first cell is not complete covered by the left border of second cell. This just happens between first and second cell, you can look at others cells and see the desired behavior.

I thought it was a rendering problem but I've opened the resulting pdf with three different viewers and all of them show the same result.

I've been using similar TikZ matrices with no problems, so I'm missing something but I don't know what. Do you?

Next it's the code I'm using with CVS-TikZ.

\documentclass[tikz,border=2mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[catalan]{babel}
\usepackage{lmodern}
\usepackage{amsmath}

\usetikzlibrary{matrix,arrows,positioning,backgrounds,fit}

\tikzset{
draw=#1!70,%
thick,%
minimum width=8mm,%
minimum height=7mm,%
fill=#1!20,%
outer sep=0pt,%
anchor=center},
}

\begin{document}
\begin{tikzpicture}[font=\small\sffamily,>=stealth']

\matrix (AB) [matrix of nodes, column sep=-\pgflinewidth, outer sep=0pt, nodes={head}, nodes in empty cells] {
&|[info]|& $(S^a_n,R_n^b)$ & \\
};

\matrix (BA) [matrix of nodes,column sep=-\pgflinewidth,outer sep=0pt, below= of AB,nodes={head}, nodes in empty cells] {
& $(S_n^b,R_n^a)$ & |[info]| &\\
};

\end{tikzpicture}
\end{document}

-
Nodes are drawn via thick but the matrix is still using the default thin option. Use column sep=-0.8pt to see the effect. (Thin line is 0.4pt wide) –  percusse Nov 19 '12 at 17:01
@percusse Thanks! I understand my mistake but why this behavior is shown only between first and second column? –  Ignasi Nov 19 '12 at 17:17

It seems that pgflinewidthis recalculated between your cells. The following example shows what happens if a cell is empty as opposed to all cells being nonempty (I just filled them with a tilde).

\documentclass[tikz,border=2mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[catalan]{babel}
\usepackage{lmodern}
\usepackage{amsmath}
\usetikzlibrary{matrix,arrows,positioning,backgrounds,fit}
draw=#1!70,%
thick,%
minimum width=8mm,%
minimum height=7mm,%
fill=#1!20,%
outer sep=0pt,%
anchor=center},

\begin{document}
\begin{tikzpicture}[font=\small\sffamily,>=stealth']

\matrix (AB) [matrix of nodes, column sep=-\pgflinewidth,
outer sep=0pt, nodes={head}, nodes in empty cells] {
~ & ~& ~& ~\\
};

\matrix (AB1) [matrix of nodes, column sep=-\pgflinewidth,
outer sep=0pt, below=of AB, nodes={head}, nodes in empty cells] {
~ & ~&&\\
};

\end{tikzpicture}
\end{document}


Thus, a better solution would be to use a fixed value for the column sep.

-
In fact it seems that pgflinewidth is recalculated only after a 'really' empty cell, as soon as it contains something like ~ or |[new style]|, pgflinewidth is correct. –  Ignasi Nov 19 '12 at 20:26