# TikZ Externalize breaks path fading

I'm using the \usetikzlibrary{external} command because my document has a lot of resource hogging TikZ pictures and with this command typesetting is much faster. The problem is that with the External Library, the fading draws disappear from the compiled pdf. To use the library I compile with the --shell-escape option.

It's very strange because in pictures folder where External saves the single pdf files, there is the faded picture correctly rendered, but the same picture has no fading at all in the main pdf file.

Of course, disabling the External library commenting the line \tikzexternalize[prefix=figures/] the picture is rendered correctly.

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage[italian]{babel}
\tikzexternalize[prefix=figures/]

\newcommand{\dd}[1]{\mathrm{d}{#1}\;}

\begin{document}

\tikzset{
cone_inverted/.pic={
\shade[bottom color=blue!5!white,top color=blue!40!white,opacity=0.3] (-1,-3) arc (180:360:.5cm and .25cm) -- (0,0) -- cycle;
\draw (-1,-3) arc (180:360:.5cm and .25cm) -- (0,0) -- cycle;
\draw[dashed] (-1,-3) arc (180:0:.5cm and 0.25cm);
\node (n) at (-.6, -3.7) {$\dd{N}$};
\node (o) at (.3, -1) {$\dd{\Omega}$};
},
rect/.pic = {
\fill[gray!50] (0,-1) --(0.3,-1) -- (0.3,1)--(0,1) -- cycle;
}
}

\begin{tikzpicture}[scale=0.7]

(0,-.1) -- (5,-.1) -- (5,-.2) -- (5.5,0) -- (5,.2) -- (5,.1) -- (0,.1) -- (0,-.1);

(7,-.1) -- (12,-.1) -- (12,-.2) -- (12.5,0) -- (12,.2) -- (12,.1) -- (7,.1) -- (7,-.1);
\node at (2.5,-0.5) {$\Phi_0 = \frac{\text{fotoni}}{\SI{}{\second\centi\meter\squared}}$};
\node at (9.5,-0.5) {$\Phi\ped{T}$};

\coordinate (a) at (6,0);
\path (a)+(20:.5) pic[rotate=120] {cone_inverted};
\path (a)+(0:-0.2) pic {rect};

\end{tikzpicture}

\end{document}


The picture figures/document_title-figure0.pdf is correctly displayed and looks like

while in the output file it looks like this

Any idea how to solve this strange behaviour?

Edit: I've also noticed that if I replace the line

  \fill[blue!50, path fading=west]


with

 \shade[left color=white, right color= blue!50]


there is the same issue. Instead if I use a different color instead of white, for example

 \shade[left color=red, right color= blue!50]


it works as expected. The mystery deepens.

• Are you using the same engine or first PDFLaTeX then XeLaTeX or something like that ? – percusse Aug 27 '16 at 14:49
• Always PDFLaTeX – johnnyparafango Aug 27 '16 at 15:05
• I can't reproduce the issue using the posted code and pdfLaTeX. The only thing I changed was to use an existing sub-directory rather than figures/. (I used ffigurau/. The output is as expected with pdflatex --shell-escape. No problem at all. – cfr Aug 27 '16 at 15:15
• Interesting.. I use Texpad with MacTex 2015 and all packages updated and the issue appears always with different documents, different tikz pictures and different PDF viewers. Maybe the are some problems with my configuration. Fortunately I solved with answer below. However thanks for the check. – johnnyparafango Aug 27 '16 at 15:23
• This seems to be still an issue. I'm trying to report it as a bug. github.com/pgf-tikz/pgf/issues/833 – letsfetz Feb 14 '20 at 9:13

After some experiments I found a workaround replacing the line

\fill[blue!50, path fading=west]


with

\shade[left color=blue!0, right color= blue!50]


Other methods seem not work (using External Library of course).

• Thanks. The \shade workaround did the trick for me as well. - also using xelatex and externalize – letsfetz Feb 13 '20 at 18:33