# [Tex/LaTex] Tikz fill color

colorloopsmatricespreambletikz-pgf

At the moment I'm using this command in the preamble to fill the color of the specified row with grey:

 row 2/.style={
nodes={fill=gray!10}
}


Unfortunately I have to write this for every line.
Can't I say something like

 row 1-10/.style={
nodes={fill=gray!10}
}


Thanks for your answers. Though I'm not sure what's not clear in my example the problem is that I wanted to use the row option (within \tikzset{} before \begin{document} ) because (maybe I don't know how else to do it) I only want certain rows to be colored that way not everything. Other rows have a different color such that everything looks nice and colorful as it should be. Since I'm very new to tikz I solved this in an awkward way by writing

\tixset{
row 2/.style={
nodes={fill=gray!10}
},
row 3/.style={
nodes={fill=gray!10}
},
row 4/.style={
nodes={fill=gray!10}
},
column 1/.style={
nodes={text width=14em}
},
column 3/.style={
nodes={text width=9em}
},
column 4/.style={
nodes={text width=9em}
}
}


Here I also specified different widths for the columns. Probably as well this one can solve better by not writing the entire ./style every time…
@last: myrowstyle is just a name or? so my new definition to later call it am I right?

# MWE [copied from deleted answer by cfr]

\documentclass[table]{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
draw=black,
align=center,
},
%baseline={([yshift=-0.5ex]current bounding box.center)},
minimum height=1.5em,
text depth=0.5em,
text height=1em,
text centered,
nodes in empty cells,
%%
row 1/.style={
nodes={
fill=black,
text=white,
%font=\bfseries
}
},
myrowstyle/.style={
row #1/.style={nodes={fill=gray!10}}
},
column 1/.style={
nodes={text width=14em}
},
column 3/.style={
nodes={text width=9em}
},
column 4/.style={
nodes={text width=9em}
}
}
}

\begin{document}

\begin{frame}
\begin{tikzpicture}
\matrix (first) [table,text width=4em, myrowstyle/.list={1,2,3}, row 2/.style={text depth=1.5em}, ampersand replacement=\&]
{
... \& \# ...\& \# ... \& ... \\
01.06.-02.06. \break (hello world) \& 1 \& 2 \& \\
02.06.-03.06. (hello) \& 3 \& 3 \& \\
};
\end{tikzpicture}
\end{frame}

\end{document}


You can use the /.list handler.

\tikzset{myrowstyle/.style = {row #1/.style={nodes={fill=gray!10}}}


and later in the picture you can then use

myrowstyle/.list={1,...,10}


or any other argument list.