5

I've used the Beamer blocks transparent shadows hack for a long time now (more specifically, the last answer which provides two modified Beamer files to install locally). However, it seems that recently (probably after upgrading to TeX Live 2020; Beamer is now at 2020/07/22 v3.59), the hack broke.

From what I can tell, it seems that the first block gets correct shadows, but after that, the shadows geometry seems frozen, and any subsequent block get shadows of the size of the first one.

Here is the simplest example to reproduce the problem:

\documentclass{beamer}

\setbeamertemplate{blocks}[rounded][shadow=true]

\begin{document}

\begin{frame} \begin{columns}[t] \begin{column}{.25\textwidth} \begin{block}{First block} This is the first block. \end{block} \end{column} \begin{column}{.75\textwidth} \begin{block}{Second block} This is the second block. \end{block} \end{column} \end{columns} \end{frame}

\end{document}

and this is what I get from it now:

Wrong shadow geometry for second Beamer block

Any help appreciated! Log file is here.

2 Answers2

12

The problem is that pgf corrected a typo in its code.

\ifx \csname pgfsmaks@#1\endcsname \relax \pgf@sys@pdf@install@mask  % old working pgf
                   ^^^ typo

\ifx \csname pgfsmask@#1\endcsname \relax \pgf@sys@pdf@install@mask % new failing pgf

The typo had the side effect that if you declared two fadings or shadings with the same name you nevertheless got two shading objects in the pdf. With the correction this no longer works.

The beamer hack was relying on this side effect - it used the name bmb@shadowhorz and bmb@shadowvert for all the vertical shadings.

To correct this, unique names must be introduced, e.g. by adding a number

% this assumes that the local beamerbasebox.sty is used!!!!
\documentclass{beamer}
\makeatletter

\def\pgfutil@insertatbegincurrentpagefrombox#1{% \edef\pgf@temp{\the\wd\pgfutil@abb}% \global\setbox\pgfutil@abb\hbox{% \unhbox\pgfutil@abb% \hskip\dimexpr2in-2\hoffset-\pgf@temp\relax% changed #1% \hskip\dimexpr-2in-2\hoffset\relax% new }% }

\newcount\pgf@shadingboxcnt \def\endbeamerboxesrounded{% \end{minipage}\egroup% \bmb@temp=\dp\bmb@box% \advance\bmb@temp by.5pt% \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}% \dp\bmb@box=0pt% \bmb@boxwidth=\bmb@width% \bmb@boxheight=\ht\bmb@box% \advance\bmb@boxheight by4bp% \advance\bmb@boxheight by\bmb@prevheight% \ifbmb@shadow% \global\advance \pgf@shadingboxcnt by 1 \pgfdeclareradialshading{bmb@shadowball}{\pgfpointorigin} {% color(0bp)=(pgftransparent!50); color(4bp)=(pgftransparent!100) }% \pgfdeclareradialshading{bmb@shadowballlarge}{\pgfpointorigin} {% color(0bp)=(pgftransparent!0); color(8bp)=(pgftransparent!100) }% \pgfdeclarehorizontalshading{bmb@shadowhorz\the\pgf@shadingboxcnt}{\bmb@boxheight-6bp} {% color(0bp)=(pgftransparent!0); color(8bp)=(pgftransparent!100) }% \pgfdeclareverticalshading{bmb@shadowvert\the\pgf@shadingboxcnt}{\bmb@boxwidth-4bp} {% color(0bp)=(pgftransparent!100); color(8bp)=(pgftransparent!0) }% \pgfdeclarefading{bmb@shadowmask\the\pgf@shadingboxcnt} {% \begin{pgfpicture} \pgftext[at=\pgfpoint{4bp}{4bp}]{\pgfuseshading{bmb@shadowball}} \pgftext[at=\pgfpoint{\bmb@boxwidth}{8bp}]{\pgfuseshading{bmb@shadowballlarge}} \pgftext[at=\pgfpoint{\bmb@boxwidth+4bp}{\bmb@boxheight+2bp}]{\pgfuseshading{bmb@shadowball}} \pgftext[left, at=\pgfpoint{4bp}{4bp}]{\pgfuseshading{bmb@shadowvert\the\pgf@shadingboxcnt}} \pgftext[base, at=\pgfpoint{\bmb@boxwidth+4bp}{8bp}]{\pgfuseshading{bmb@shadowhorz\the\pgf@shadingboxcnt}} % % clipping is needed because shadow is typeset on top of box \begin{pgfscope} \pgfsetcolor{black} \pgfpathrectangle{\pgfpoint{4bp}{8bp}}{\pgfpoint{\bmb@boxwidth-0.2bp}{\bmb@boxheight-2bp}} \pgfusepath{fill} \end{pgfscope} \end{pgfpicture} }% \fi% \bmb@temp=\bmb@width% \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp% \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp% \hbox{% \begin{pgfpicture}{0bp}{0bp}{0bp}{0bp} \ifbmb@shadow% \begin{pgfscope} \pgfpathrectangle{\pgfpoint{0bp}{-7bp}} {\pgfpoint{\bmb@boxwidth+8bp}{\bmb@boxheight+6bp}} \pgfsetfading{bmb@shadowmask\the\pgf@shadingboxcnt}{% \pgftransformshift{\pgfpoint{0.5\bmb@boxwidth+6bp}{0.5\bmb@boxheight-4bp}}} \pgfusepath{fill} \end{pgfscope} \fi% \unhbox\bmb@colorbox% \pgfpathqmoveto{-4bp}{1bp} \pgfpathqcurveto{-4bp}{-1.2bp}{-2.2bp}{-3bp}{0bp}{-3bp} \pgfpathlineto{\pgfpoint{\the\bmb@temp}{-3bp}} \pgfpathcurveto% {\pgfpoint{\the\bmb@dima}{-3bp}}% {\pgfpoint{\the\bmb@dimb}{-1.2bp}}% {\pgfpoint{\the\bmb@dimb}{1bp}}% { \bmb@dima=\ht\bmb@box% \pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}} \pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}} \pgfusepath{fill} } \end{pgfpicture}% \box\bmb@box% }% \ifbmb@shadow% \vskip4bp minus 2bp% \else% \vskip2bp% \fi% \egroup% of \vbox\bgroup } \makeatother \setbeamertemplate{background canvas}{\includegraphics[height=\paperheight]{example-image}}

\setbeamertemplate{blocks}[rounded][shadow=true]

\begin{document} \begin{frame} \begin{columns}[t] \begin{column}{.25\textwidth} \begin{block}{First block} This is the first block. \end{block} \end{column} \begin{column}{.75\textwidth} \begin{block}{Second block} This is the second block. \end{block} \end{column} \end{columns} \end{frame} \end{document}

With this correction the style works in xelatex too, so it will probably be added to beamer in the not to far future.

Ulrike Fischer
  • 327,261
3

Here is the answer to that question, which was provided by Sam Carter somewhere else: the hack still works, provided that you remain at PGF version 3.1.5b or older. Those versions may be found here.

It would be nice if someone with the appropriate knowledge of PGF could update it to newer versions though.