6

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.

0

2 Answers 2

6

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}
1
  • good idea to make shadow invisible :-). i will wait for some time if more answers are received.
    – Zarko
    Commented Mar 23, 2018 at 14:26
5

OK, I didn't know you don't like the \makeatletter stuff. In this case, I think that Torbjørn T.'s solution is the best. Here is an alternative, which has the advantage that the shadow can be switched off locally (no every shadow), but the big disadvantage that it will put a white box on top of other things that may exist. I have checked that this version can also be appended to every label.

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

\begin{document}
    \begin{tikzpicture}[
every node/.style = {draw, fill=white, drop shadow},
no shadows/.style = {drop shadow={fill=white,opacity=1,shadow scale=1.01}}, % should remove drop shadow, but not
%no shadows/.code = {\pgfextra{\tikzset{general shadow/.style=}}}, % should remove drop shadow, but not
every label/.append style = {label distance=1em, font=\scriptsize}
]

%\tikzset{general shadow/.style=}                        ]
\node[label=how to remove label shadow?] (A)  {node with shadow};
\node[right=1cm  of A, label={[no shadows]shadow removed from label?}] (B) {node with shadow};
    \end{tikzpicture}
\end{document}

enter image description here

I'd like to argue that it might be advantageous to switch off shadows locally if needed, as described here.

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows}
\makeatletter % from https://tex.stackexchange.com/a/129322/121799
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\makeatother

\begin{document}
    \begin{tikzpicture}[
every node/.style = {draw, fill=white, drop shadow},
every label/.append style = {
     label distance=1em,
     font=\scriptsize,
  }
                        ]
\node [label={[no shadows]foobar}]  {node with shadow};
    \end{tikzpicture}
\end{document}

enter image description here

And here a special for Zarko, which yields the same output:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows}
\makeatletter % from https://tex.stackexchange.com/a/129322/121799
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\tikzset{every label/.append code=\let\tikz@preactions\pgfutil@empty}
\makeatother

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

Hoping to resolve the issues discussed in the comments (after carefully(?) reading this answer ;-):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{shadows}
\makeatletter % from https://tex.stackexchange.com/a/129322/121799
\tikzset{no shadows/.code=\let\tikz@preactions\pgfutil@empty}
\makeatother

\begin{document}
    \begin{tikzpicture}[
every node/.style = {draw, fill=white, drop shadow},
every label/.append style = {
     label distance=1em,
     font=\scriptsize,
     fill=blue,
     no shadows
  }
                        ]
\node [label=foobar]  {node with shadow};
    \end{tikzpicture}
\end{document}

enter image description here

6
  • i looked this solution, but other (used in my test) was declared that also work :-(. do you test, if it work inside every label/.append stale ...?
    – Zarko
    Commented Mar 23, 2018 at 15:45
  • @Zarko I added a solution. Neither every label/.append stale nor every label/.append style works, but append code does.
    – user121799
    Commented Mar 23, 2018 at 15:55
  • i managed to include it in qvery label/.append ..., however, now i remember, why i didn't select this solution on the first lace: for some reason i like to have no shape definition placed between tikzpicture options at other styles definition. is there a way to do this? so far my experiments fails :-(
    – Zarko
    Commented Mar 23, 2018 at 15:56
  • @Zarko What do the ... stand for in qvery label/.append ...? Could you perhaps add the complete experiment that fails?
    – user121799
    Commented Mar 23, 2018 at 16:00
  • ups, mistyping: every label/.append and .... stand for `style = <style definitions>}. sorry disorder.
    – Zarko
    Commented Mar 23, 2018 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .