[Tex/LaTex] labels of nodes with drop shadow

labelsshadowstikz-styles

in cases, that all nodes in some tikz pictures have shadow. this can be done for example by:

every node/.style = {draw, fill=white, drop shadow},

problem arise, if i like to some of this nodes add labels. this labels also have shadows, which i not like to have. i try remove them with

no shadows/.style = {general shadow/.style=},

but this doesn't work (as i expected):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows}

\begin{document}
    \begin{tikzpicture}[
every node/.style = {draw, fill=white, drop shadow},
no shadows/.style = {general shadow/.style=}, % should remove drop shadow, but not
every label/.append style = {label distance=1em, font=\scriptsize, no shadows}
                        ]
\node[label=how to remove label shadow?]  {node with shadow};
    \end{tikzpicture}
\end{document}

enter image description here

edit:
to make question and mwe more clear:

  • no shadows/.style = {general shadow/.style=}, is taken from Qrrbrbirlbel answer on question here described in code A
  • his solution in code B i didn't test since it require (as i understood code) that

    \makeatletter
    \tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
    \makeatother

    should be in preamble, what for some reasons not like to have

  • the solution should be applied to all labels, i.e. it can be used as styles options in every label/.append style = {<other style's definitions>, no shadows}
    -now i wonder why solution of [Qrrbrbirlbel] works in code example A where no shadows is option of child and not of node. in case, that i move it to node, also this code doesn't work correctly.

so far elegant solution provided by Torbjørn T., which make label shadow invisible, fulfill all my expectations. in time of this writing the solution of marmot is still in progress/evolution.

Best Answer

You could to modify the every shadow style, inside the every label style. E.g. add every shadow/.style={opacity=0} to every label to make the shadow invisible.

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows}

\begin{document}
    \begin{tikzpicture}[
every node/.style = {draw, fill=white, drop shadow},
every label/.append style = {
     label distance=1em,
     font=\scriptsize,
     every shadow/.style={opacity=0} % <- add this
  }
                        ]
\node [label=foobar]  {node with shadow};
    \end{tikzpicture}
\end{document}