# Shading apply to label unexpected in matrix environment

I am trying to add shadow to node. For normal node, the shade will not impact the label. However, for nodes inside a matrix, the labels are shadowed too.

MWE below

\documentclass[border=5mm, convert]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[auto]
\tikzset{myrect/.style={draw, rectangle, font=\ttfamily, fill=white, drop shadow}}
\tikzset{mylabel/.style={color=blue, font=\tiny \ttfamily}}
\node[myrect, label={[mylabel]above:normal label}] (ele) {Single Element};

\matrix (layer) [matrix of nodes, nodes={myrect, anchor=center}, column sep = 1cm, below = of ele] {
|[label={[mylabel]:matrix label 1}]|matrix element 1 &
|[label={[mylabel]:matrix label 2}]|matrix element 2 &
|[label={[mylabel]:matrix label 3}]|matrix element 3 \\
};
\end{tikzpicture}
\end{document}


The output is as the following:

How this happen and is there way to avoid it?

• The nodes= key for the matrix is like a shortcut for every node/.style= and since labels are also nodes, they also get the drop shadow. I suspect that some keys, like draw are reset within a label, but others like drop shadow are not. – Max Jan 11 at 9:54
• You could use the no shadows key from solution B from this answer and add it to your mylabel style. That would delete all preactions added to the labels, including the drop shadow. – Max Jan 11 at 10:06

One way is to adjust the your style-set definitions (as done by @marmot):

 \documentclass[tikz, margin=3mm]{standalone}
\makeatletter % from https://tex.stackexchange.com/a/129322/121799
\makeatother
\begin{document}
\begin{tikzpicture}[
every node/.style = {font= \ttfamily, draw, fill=white, drop shadow},
every label/.append style = {
font=\tiny \ttfamily,
color = blue,
}
]
\matrix (layer) [no shadows, matrix of nodes, draw = none, column sep = 1cm, below = of ele] {
|[label={[no shadows]:matrix label 1}]|matrix element 1 &
|[label={[no shadows]:matrix label 2}]|matrix element 2 &
|[label={[no shadows]:matrix label 3}]|matrix element 3 \\
};
\end{tikzpicture}
\end{document}


This should give you:

• Thank you, both you and @Max point me to solution of disable preactions. I am still wondering if there can be options in matrix to avoid polluting the label – Eric Sun Jan 11 at 10:26
• @EricSun Also, as far as not to pollute the matrix environment, I dont know. May be I can look it up. – Raaja Jan 11 at 10:30
• Don't mark accepted because I am afraid people may stop entering this post when they find there has already been an answer. Anyway I have checked it now :) – Eric Sun Jan 11 at 10:31