2

I'm trying to create a blank line in Tikz's matrix by node without borders and filled white. But this node cut half of separation line of previous row like on picture. If I change height of key node (test-3-1) it impact on complete row. The property outer sep=\pgflinewidth doesn't work. Is it any way to add blank line?

enter image description here

MWE:

\documentclass[margin=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        minimum height=1em,%           This needed for alignment
        text depth=0pt,
        text height=1ex,
        nodes={
            rectangle,
            draw=black,
            align=center
        },
        every odd row/.style={%      This needed for working code
            nodes={fill=gray!20}
        },
        row 3 column 1/.style={
            nodes={fill=white, draw=none}
        },
    }
}
\begin{tikzpicture}
        \matrix (test) [table, text width=1em] {
            ~ & ~ & ~ & ~ \\
            ~ & ~ & ~ & ~ \\
            ~ &  &  &  \\
            ~ & ~ & ~ & ~ \\
        };
\end{tikzpicture}
\end{document}

1 Answers1

3

In this case, I think you just have to set fill=none in the third row.

\documentclass[margin=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\tikzset{
    table/.style={
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        minimum height=1em,%           This needed for alignment
        text depth=0pt,
        text height=1ex,
        nodes={
            rectangle,
            draw=black,
            align=center
        },
        every odd row/.style={%      This needed for working code
            nodes={fill=gray!20}
        },
        row 3 column 1/.style={
            nodes={draw=none,fill=none}    % <------- here
       },
    }
}
\begin{tikzpicture}
        \matrix (test) [table, text width=1em] {
            ~ & ~ & ~ & ~ \\
            ~ & ~ & ~ & ~ \\
       ~ &amp; &amp; &amp; &amp; \\
        ~ &amp; ~ &amp; ~ &amp; ~ \\
    };

\end{tikzpicture} \end{document}

fillnone

SebGlav
  • 19,186