4

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

enter image description here

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

enter image description here

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,
    ignorehead,
    ignorefoot,
    includemp,
    marginparwidth=52mm,
    marginparsep=8mm,
    headsep=7mm,
    footskip=14mm,
    headheight=12.2pt,
]{geometry}

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

\setlength{\columnsep}{\marginparsep}

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

\newlength{\wholeWidth}
\setlength{\wholeWidth}{\textwidth}
\addtolength{\wholeWidth}{\wholeMargin}

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Hyper-references
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{hyperref}
\hypersetup{
    pdftoolbar=false,
    pdfmenubar=true,
    pdffitwindow=false,
    pdfborder={0 0 0},
    pdfcreator=LaTeX,
    colorlinks=true,
    linkcolor=black,
    linktoc=all,
    urlcolor=blue,
    citecolor=blue,
    filecolor=blue,
    breaklinks
}

\usepackage{lipsum}

\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\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} 
  • 1
    I just did and I get the same results. I am using XeLaTeX if that matters? – Joe Aug 9 '18 at 3:27
  • 1
    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
  • 1
    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
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}
\usetikzlibrary{fadings}

\definecolor{lightGrey}{gray}{0.94}

\pagestyle{empty}

\begin{document}

\pgfdeclarefading{fading2}
{\tikz \shade[left color=pgftransparent!0,
right color=pgftransparent!100] (0,0) rectangle (2,2);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (2,2);
\pgfsetfading{fading2}{\pgftransformshift{\pgfpoint{1cm}{1cm}}}
\fill [red] (0,0) rectangle (2,2);
\end{tikzpicture}


\pgfdeclarefading{fading2}
{\tikz \shade[left color=pgftransparent!0,
 right color=pgftransparent!100] (0,0) rectangle (4,4);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (4,4);
\pgfsetfading{fading2}{\pgftransformshift{\pgfpoint{2cm}{2cm}}}
\fill [red] (0,0) rectangle (4,4);
\end{tikzpicture}

\pgfdeclarefading{fading3}
{\tikz \shade[left color=pgftransparent!0,
 right color=pgftransparent!100] (0,0) rectangle (4,4);}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (4,4);
\pgfsetfading{fading3}{\pgftransformshift{\pgfpoint{2cm}{2cm}}}
\fill [red] (0,0) rectangle (4,4);
\end{tikzpicture}

\end{document}

enter image description here

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
\newcounter{shadowblurcount}
\tikzset{
  /tikz/render blur shadow/.code={
   \stepcounter{shadowblurcount}%
    \pgfbs@savebb
    \pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
    \pgfbs@compute@shadow@bbox
    \pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
    \pgfbs@apply@canvas@transform
    \colorlet{pstb@shadow@color}{white!\pgfbs@opacity!black}%
    \pgfdeclarefading{shadowfading\the\c@shadowblurcount}{\pgfbs@paint@fading}%
    \pgfsetfillcolor{black}%
    \pgfsetfading{shadowfading\the\c@shadowblurcount}%
       {\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
    \pgfbs@usebbox{fill}%
    \pgfbs@restorebb
  },
  }
\makeatother

enter image description here

  • 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
  • @marmot I think Norbert uploaded something to correct the problem. I don't think that it is related to your new problem, this looks more like a problem of correctly resetting colors. – Ulrike Fischer Sep 23 '18 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.