I'm trying to apply a style for a submatrix of a matrix and ended up by passing arguments through two .list-handlers. Things don't work as I expected, again I'm just able to set either rows or columns but not both.
What's the problem? Do you have another idea?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\tikzset{
rows/.style 2 args={
@/.style={row ##1 column #2/.style={nodes={rectangle,draw=black}}},
@/.list={#1}
},
box/.style 2 args={
@/.style={rows={#1}{##1}},
@/.list={#2}
}
}
\tikzset{square matrix/.style={
matrix of nodes,
column sep=-\pgflinewidth, row sep=-\pgflinewidth,
nodes={
minimum height=#1,
anchor=center,
text width=#1,
align=center,
inner sep=0pt
},
},
square matrix/.default=1.2cm
}
\begin{document}
\begin{tikzpicture}[]
\matrix[square matrix,
box={1,...,3}{3,2} % apply the style to cells {1,3},{2,3},{3,3},{1,2},{2,2},{3,2}
]
{
& x & x & & & \\
& & x & & x & \\
x & x & x & x & x & \\
& & x & & & \\
};
\end{tikzpicture}
\end{document}
