Tikzpicture blur show up incorrectly

In the code given below, the tikzpicture blur show up with an incomplete shadow:

Is there a way to show the shadow just like in the first box where the shadow encompasses the entire box like this:

Here is my code:

  \documentclass{report}

\RequirePackage{calc}
\RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}
\RequirePackage{amsmath, amsfonts, amssymb}
\RequirePackage{ragged2e}
\RequirePackage{eso-pic}
\RequirePackage{fancyhdr}
\RequirePackage{marginfix}
\RequirePackage{titletoc}
\RequirePackage{mdframed}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{changepage}

\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{\errmessage{Cannot patch \string\part}}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\setlength{\marginparpush}{1.5\baselineskip}

\RequirePackage[
xetex,
a4paper,
%   showframe,
twoside,
top=27mm,
bottom=27mm,
inner=20mm,
outer=20mm,
ignorefoot,
includemp,
marginparwidth=52mm,
marginparsep=8mm,
footskip=14mm,
]{geometry}

% Commands for changing the page layout mid-document
\newcommand{\symmetricalPage}{
\fancyhfoffset[OR, EL]{0mm}
\newgeometry{
top=20mm,
bottom=20mm,
inner=20mm,
outer=20mm,
ignorefoot,
nomarginpar,
footskip=10mm,
}
}
\newcommand{\asymmetricalPage}{
\restoregeometry
\fancyhfoffset[OR, EL]{\marginparsep + \marginparwidth}
}

\setlength{\columnsep}{\marginparsep}

% Saving some length as commands
\newlength{\wholeMargin}
\setlength{\wholeMargin}{\marginparwidth}

\newlength{\wholeWidth}
\setlength{\wholeWidth}{\textwidth}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Titling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoc}
\RequirePackage{titlesec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Hyper-references
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{hyperref}
\hypersetup{
pdftoolbar=false,
pdffitwindow=false,
pdfborder={0 0 0},
pdfcreator=LaTeX,
urlcolor=blue,
citecolor=blue,
filecolor=blue,
}

\usepackage{lipsum}

\usepackage{tikz}

\usepackage{titletoc}

\usepackage{calc}

\usepackage[]{titlesec}

\definecolor{lightGrey}{gray}{0.94}

\colorlet{chpnumbercolor}{blue}
\makeatletter
\let\oldl@chapter\l@chapter
\def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{black}{\textbf{#2}}}}

\let\old@dottedcontentsline\@dottedtocline
\def\@dottedtocline#1#2#3#4#5{%
\old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{black}{#5}}}}
\makeatother

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{%
\noindent\hspace{-2cm}%
\colorlet{chpnumbercolor}{white}%
\ifodd\value{page}
\begin{tikzpicture}[remember picture, overlay, transform shape]
\node[above left=\topmargin, anchor=north west, rounded corners, align=left, fill=lightGrey, blur shadow={shadow blur steps=5}, inner sep=5mm] at (current page.north west)
{%
\color{black}%
\begin{minipage}{8cm}%minipage trick
\scriptsize
\hfill\rule{\linewidth}{.5mm}
\printcontents[chapters]{}{1}{}
\hfill\rule{\linewidth}{.5mm}
\end{minipage}
};
\end{tikzpicture}
\else
\begin{tikzpicture}[remember picture, overlay, transform shape]
\node[xshift=10.5cm, yshift=0cm, above left=\topmargin, anchor=north west, rounded corners, align=left, fill=lightGrey, blur shadow={shadow blur steps=5}, inner sep=5mm] at (current page.north west)
{%
\color{black}%
\begin{minipage}{8cm}%minipage trick
\scriptsize
\hfill\rule{\linewidth}{.5mm}
\printcontents[chapters]{}{1}{}
\hfill\rule{\linewidth}{.5mm}
\end{minipage}
};
\end{tikzpicture}
\fi
}

\begin{document}

\chapter{Introduction}
\startcontents[chapters]
\printmyminitoc

\section{Lorem Ipsum Dolor}
\lipsum[2]
\subsection{Test Subsection}
\lipsum[1]

\section{Nam dui ligula}
\lipsum

\chapter{Content}
\startcontents[chapters]
\printmyminitoc

\lipsum[2]
\lipsum[3]

\section{First Section}
\subsection{Subsection}
\lipsum[2]

\section{Second Section}
\subsection{Subsection}
\lipsum[2]

\section{Third Section}
\subsection{Subsection}
\lipsum[3]

\section{Fourth Section}
\subsection{Subsection}
\lipsum[3]

\end{document}

• I just did and I get the same results. I am using XeLaTeX if that matters? – Joe Aug 9 '18 at 3:27
• Oh yes, this does matter. Does this post help you? Which TeXLive version are you using? Oh sorry, just realized that the issue is also there on TeXLive2018.... – user121799 Aug 9 '18 at 3:32
• That is indeed a problem. Seems that there is some strange interference between xelatex, atbegshi and shadows.blur. – user121799 Aug 9 '18 at 4:11

At the core of the problem is that with xelatex \pgfdeclarefading uses internally \pgfsys@fadingfrombox. And this means that it stores the fading in a box and reuses it if the fading is used again, and this fails if the fading should be used in different sizes. The problem can be shown also with a fading:

\documentclass{report}

\usepackage{tikz}

\definecolor{lightGrey}{gray}{0.94}

\pagestyle{empty}

\begin{document}

right color=pgftransparent!100] (0,0) rectangle (2,2);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (2,2);
\fill [red] (0,0) rectangle (2,2);
\end{tikzpicture}

right color=pgftransparent!100] (0,0) rectangle (4,4);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (4,4);
\fill [red] (0,0) rectangle (4,4);
\end{tikzpicture}

right color=pgftransparent!100] (0,0) rectangle (4,4);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (4,4);
\fill [red] (0,0) rectangle (4,4);
\end{tikzpicture}

\end{document}


The example shows also a possible solution: If the fading is redeclared with a new name it works.

So when using shadows.blur with xelatex (or latex and dvipdfmx) you can try this patch:

\makeatletter
\tikzset{
\pgfbs@savebb
\pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
\pgfbs@apply@canvas@transform

• That's really great! Is it correct that the issue has been fixed in the updated version of pgf-blur? And could you perhaps have a look at this question and try to find out if these issues are related? – user121799 Sep 22 '18 at 23:57