A little while ago, I asked How can I make drop shadows appear with their nodes in a Forest tree in Beamer? At the time, I just eliminated the shadows and went with a shodowless tree. Later, however, I found a very awkward method which worked. A while after that, I received Symbol 1 provided a real answer.
Now I am trying to adapt that solution for my real uses. First, I wanted to make the code conditional on the loading of the appropriate library, so that I can include it in my standard Beamer configuration files.
\makeatletter
\pgfkeysifdefined{/tikz/shadow scale}{%
% ateb Symbol 1: https://tex.stackexchange.com/a/357412/
\def\tikzopacityregister{1}%
\tikzset{
opacity/.append code={
\pgfmathsetmacro\tikzopacityregister{#1*\tikzopacityregister}%
},
opacity aux/.code={% this is the original definition of opacity
\tikz@addoption{\pgfsetstrokeopacity{#1}\pgfsetfillopacity{#1}}
},
every shadow/.style={opacity aux=\tikzopacityregister}
}%
}{}
\makeatother
I couldn't find something like \if@tikzlibrary@loaded, so I went with testing for the existence of a PGF key. If there's a way of testing whether a library is loaded, that would obviously be preferable.
Second, I want to make the code work with shadows.blur, so I can use blur shadow as well as drop shadow. The following seems to work, but I'm not sure if it is even vaguely reasonable as a method.
opacity/.append code={
\pgfmathsetmacro\tikzopacityregister{#1*\tikzopacityregister}%
\pgfmathsetmacro\pgfbs@opacity{\tikzopacityregister}% cfr: added for blur shadows
},
I tried to append something to, say shadow opacity or to set this when opacity is set. However, I couldn't get this to work and ended up with the above. Again, not great as it relies on an internal implementation detail rather than just the public interface.
I also still get thin outlines of the shadows in this case, but that may be a viewer artefact. (They are still there at 1600% magnification, however, which is the most Okular provides.)
What is the correct way to do this?
\documentclass{beamer}
\usepackage{forest}
\tikzset{% set up for transitions using tikz with beamer overlays - developed by Daniel (https://tex.stackexchange.com/a/55849/) and, in earlier form, by Matthew Leingang (https://tex.stackexchange.com/a/6155/) and modified for this use, I think by Qrrbrbirlbel (https://tex.stackexchange.com/a/112471/)
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\forestset{%
visible with edge from/.style={% based on visible on, developed by Qrrbrbirlbel (https://tex.stackexchange.com/a/112471/)
/tikz/visible on=<#1->,
/tikz/every label/.append style={visible on=<#1->},
edge={/tikz/visible on=<#1->},
},
}
\usetikzlibrary{shadows.blur}
\makeatletter
\pgfkeysifdefined{/tikz/shadow scale}{%
% ateb Symbol 1: https://tex.stackexchange.com/a/357412/
\def\tikzopacityregister{1}%
\tikzset{
opacity/.append code={
\pgfmathsetmacro\tikzopacityregister{#1*\tikzopacityregister}%
\pgfmathsetmacro\pgfbs@opacity{\tikzopacityregister}% cfr: added for blur shadows
},
opacity aux/.code={% this is the original definition of opacity
\tikz@addoption{\pgfsetstrokeopacity{#1}\pgfsetfillopacity{#1}}
},
every shadow/.style={opacity aux=\tikzopacityregister}
}%
}{}
\makeatother
\begin{document}
\begin{frame}
\begin{forest}
for tree={
draw,
fill=white,
blur shadow,
},
before typesetting nodes={
for tree={
tempcounta/.option=level,
tempcounta'+=1,
visible with edge from/.register=tempcounta,
}
}
[first slide
[second slide[third slide][third slide]]
[second slide]
]
\end{forest}
\end{frame}
\end{document}

tikz.code.texline 5317 and 18. – Symbol 1 Mar 23 '17 at 03:13