Short answer: This is a feature of the latex
+dvips
+ps2pdf
workflow and cannot be avoided in connection with the recent (v3.1.6) release of PGF and its shadows
and fadings
TikZ libraries.
Long answer:
The shadows
library also loads the fadings
library.
Fadings, also known as transparency gradients or soft masks, are a PDF-only feature (as is basic, constant transparency too). Fadings have been made available for the DVI->PS->PDF route only recently (PGF-3.1.6). User- and pre-defined fadings were just ignored in previous PGF versions.
Defining a soft mask involves the creation of a so-called PDF-XObject, a self-sufficient, graphical object that is later used to mask (i.e. to add transparency to) other graphical objects, as shown in the example below.
Creating a soft mask takes place at the upper left corner on the page of its definition. Pre-defined soft masks of the fadings
library are created on the first document page. What you see in the intermediate PS output are the underlying graphical objects that are used in this process. They cannot be hidden, but disappear in the final PDF-making step (ps2pdf -dALLOWPSTRANSPARENCY ...
).
Since Fadings are a PDF-only feature, it does not make sense to publish/to release the intermediate PS version of a document containing these. You will have to produce (ps2pdf -dALLOWPSTRANSPARENCY ...
) and ship the PDF instead.
If you really need to send out PS, perhaps because the publisher wants it, convert the PDF back to Postscript, using pdf2ps
. The resulting Postscript is visually indistinguishable from its PDF precursor.
Example document ex.tex
with a user-defined soft mask. Typeset with
latex ex
latex ex
dvips ex
ps2pdf -dALLOWPSTRANSPARENCY ex.ps
(Note that processing documents relying on transparency features requires Ghostscript-9.52 or later.)
\documentclass{article}
\usepackage[a6paper,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
% define soft mask
\pgfdeclarefading{myFading}{%
\tikz\shade [left color=pgftransparent!0, right color=pgftransparent!100] (0,0) rectangle (2,2);
}%
%
\begin{tikzpicture}
% checkerboard background
\pattern [pattern=checkerboard, pattern color=black!30] (0,0) rectangle (9,4);
% blue rect with transparency gradient
\fill [color=blue, path fading=myFading] (1,1) rectangle (3,3);
% red rect with transparency gradient
\fill [color=red, path fading=myFading] (4,1) rectangle (8,3);
\end{tikzpicture}
\end{document}
Intermediate Postscript (as shown in gv
or GSview
or printed on paper):

Final PDF (after ps2pdf -dALLOWPSTRANSPARENCY ex.ps
):

Postscript, back-converted from PDF (pdf2ps ex.pdf ex2.ps
):
