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}
\usetikzlibrary{fadings,calc,positioning,external}
\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]
\fill[purple, path fading=west]
(0,-.1) -- (5,-.1) -- (5,-.2) -- (5.5,0) -- (5,.2) -- (5,.1) -- (0,.1) -- (0,-.1);
\fill[blue!50, path fading=west]
(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.
figures/
. (I usedffigurau/
. The output is as expected withpdflatex --shell-escape
. No problem at all.