不久前我问过如何使阴影及其节点在 Beamer 的森林树中出现?当时我只是消除了阴影,用了一棵没有阴影的树。但后来,我发现了一个非常巧妙的方法,而且很管用。不久之后,我收到了符号 1 给出了真实答案。
现在,我正在尝试将该解决方案调整为适合我的实际用途。首先,我想使代码以加载适当的库为条件,以便我可以将其包含在我的标准 Beamer 配置文件中。
\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
我找不到类似的东西\if@tikzlibrary@loaded
,所以我开始测试 PGF 密钥是否存在。如果有一种方法可以测试库是否已加载,那显然是更好的选择。
其次,我想让代码与 一起工作shadows.blur
,这样我就可以使用blur shadow
以及drop shadow
。下面的方法似乎有效,但我不确定它作为一种方法是否合理。
opacity/.append code={
\pgfmathsetmacro\tikzopacityregister{#1*\tikzopacityregister}%
\pgfmathsetmacro\pgfbs@opacity{\tikzopacityregister}% cfr: added for blur shadows
},
我尝试在设置shadow opacity
时附加一些内容,比如说或设置它opacity
。但是,我无法让它工作,最终得到了上面的结果。同样,这不是很好,因为它依赖于内部实现细节,而不仅仅是公共接口。
在这种情况下,我仍然可以得到阴影的细轮廓,但这可能是观看者造成的。(然而,在 1600% 的放大倍数下,它们仍然存在,这是 Okular 提供的最大放大倍数。)
正确的方法是什么?
\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}