2

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 enter image description here

while in the output file it looks like this

enter image description here

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.

7
  • Are you using the same engine or first PDFLaTeX then XeLaTeX or something like that ?
    – percusse
    Commented Aug 27, 2016 at 14:49
  • Always PDFLaTeX Commented Aug 27, 2016 at 15:05
  • 1
    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
    Commented Aug 27, 2016 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. Commented Aug 27, 2016 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
    – aknott
    Commented Feb 14, 2020 at 9:13

2 Answers 2

1

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).

1
  • Thanks. The \shade workaround did the trick for me as well. - also using xelatex and externalize
    – aknott
    Commented Feb 13, 2020 at 18:33
1

I can confirm that \tikzfading[name=fadeout, bottom color=transparent!0, top color=transparent!100] may break tikzexternalize on some plattforms (with MikTeX on Windows 10 compilation never finishes). My (non-perfect) workaround is to place the shape on the lowest layer and to fade its color to white using \draw[bottom color=black, top color=white].

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .