3

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}

not-quite ideal output, but close

closed as off-topic by user36296, Troy, Bobyandbob, user31729, Stefan Pinnow Mar 18 '18 at 17:04

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • If I recall correctly, blur is eventually overlapping lines with various width. In case there is opacity≠1, you have to make a transparency group for those lines. – Symbol 1 Mar 23 '17 at 2:56
  • @Symbol1 Hmmm. Thanks. I think I'll live with the lines then as I have no idea how to apply a transparency group here. – cfr Mar 23 '17 at 2:59
  • Or maybe I should stick to sharp shadows here. – cfr Mar 23 '17 at 3:01
  • As for checking library, you probably want to see tikz.code.tex line 5317 and 18. – Symbol 1 Mar 23 '17 at 3:13
  • 4
    I'm voting to close this question as issue of the pdf viewer – user36296 Mar 18 '18 at 16:13