Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

enter image description here

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{
    head/.style={rectangle,%
                     draw=#1!70,% 
                     thick,%
                     minimum width=8mm,%
                     minimum height=7mm,% 
                     fill=#1!20,%
                    outer sep=0pt,%
                    anchor=center},
    head/.default=gray,
    info/.style={head=purple}
}

\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}
share|improve this question
    
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
add comment

1 Answer

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}
\tikzset{head/.style={rectangle,%
                     draw=#1!70,% 
                     thick,%
                     minimum width=8mm,%
                     minimum height=7mm,% 
                     fill=#1!20,%
                    outer sep=0pt,%
                    anchor=center},
         head/.default=gray,
         info/.style={head=purple}}

\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}

enter image description here

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.