16

I've recently upgraded (on Ubuntu 18.04 LTS) TexLive 2016 to 2017. The problem that came up is that the opacity of tikz (pgf) and of pstricks pictures is not working in .ps and .pdf files after rendering (Latex to dvi to ps to pdf).

I've tried in Texstudio, Texmaker, and Kile and the problem occurred with all three editors. I've tried evince and okular and the problem occurred in both viewers. On the other hand in Qtikz and in Texstudio's preview, opacity is working fine for tikz.

I didn't had this problem with all previous TexLive versions.

Here is a minimal example with one tikz and one pstricks image:

\documentclass[10pt]{article}
\usepackage[english,greek]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{pstricks, pstricks-add}
\usepackage{graphicx, color}
\usepackage{pgf,tikz}

\begin{document}    

\begin{tikzpicture}[line cap=round,line join=round,x=0.5cm,y=0.5cm]
\clip(-3.6008835336224467,-3.8322994902133702) rectangle     (3.6645946388488806,2.9075908995685467);
\draw [line width=1.2pt,color=gray,fill=gray,fill opacity=0.25] (0.,0.) circle (0.75cm);
\fill[line width=1.6pt,color=blue,fill=blue,fill opacity=0.25] (0.,1.) -- (0.,-1.) -- (2.,-1.) -- (2.,1.) -- cycle;
\draw [line width=1.6pt,color=blue] (0.,1.)-- (0.,-1.);
\draw [line width=1.6pt,color=blue] (0.,-1.)-- (2.,-1.);
\draw [line width=1.6pt,color=blue] (2.,-1.)-- (2.,1.);
\draw [line width=1.6pt,color=blue] (2.,1.)-- (0.,1.);
\end{tikzpicture}


\bigskip    


\psset{xunit=0.5cm,yunit=0.5cm,algebraic=true,dimen=middle,dotstyle=o,dotsize=5pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(-3.6008835336224467,-3.8322994902133702)(3.6645946388488806,2.9075908995685467)
\pscircle[linewidth=1.2pt,linecolor=gray,fillcolor=gray,fillstyle=solid,opacity=0.25](0.,0.){0.75}
\pspolygon[linewidth=1.6pt,linecolor=blue,fillcolor=blue,fillstyle=solid,opacity=0.25](0.,1.)(0.,-1.)(2.,-1.)(2.,1.)
\psline[linewidth=1.6pt,linecolor=blue](0.,1.)(0.,-1.)
\psline[linewidth=1.6pt,linecolor=blue](0.,-1.)(2.,-1.)
\psline[linewidth=1.6pt,linecolor=blue](2.,-1.)(2.,1.)
\psline[linewidth=1.6pt,linecolor=blue](2.,1.)(0.,1.)
\end{pspicture*}


\end{document}

The result (in both) should be

enter image description here

but I receive

enter image description here

Any ideas on how to handle this issue?

P.S. Because I have tikz and pstricks in the same document, pfdlatex isn't appropriate to compile.

1

2 Answers 2

26

Ghostscript-9.52 introduced new operators for setting fill and stroke opacity (.setconstantfillopacity, .setconstantstrokeopacity), deprecating the hitherto existing .setopacityalpha. Starting with GS version 9.53, warning messages are produced if the old operator is used.

Furthermore, a new gs commandline option for activating opacity features was introduced:

ps2pdf -dALLOWPSTRANSPARENCY myfile.ps myfile.pdf

TikZ/pgf example:

enter image description here

\documentclass[border=3pt,varwidth]{standalone}

\usepackage{tikz}
\usetikzlibrary {patterns,shapes.symbols}

\begin{document}
%\begin{preview}
  \begin{tikzpicture}[thick,fill opacity=0.5]
    \filldraw[fill=red] (0:1cm) circle (12mm);
    \filldraw[fill=green] (120:1cm) circle (12mm);
    \filldraw[fill=blue] (-120:1cm) circle (12mm);
  \end{tikzpicture}
  \tikz {
    \begin{scope}[transparency group]
      \begin{scope}[blend mode=screen]
        \fill[red!90!black] ( 90:.6) circle (1);
        \fill[green!80!black] (210:.6) circle (1);
        \fill[blue!90!black] (330:.6) circle (1);
      \end{scope}
    \end{scope}
  }

  \begin{tikzpicture}
    \shade [left color=red,right color=blue] (-2,-1) rectangle (2,1);
    \begin{scope}[transparency group=knockout]
      \fill [white] (-1.9,-.9) rectangle (1.9,.9);
      \node [opacity=0,font=\fontencoding{T1}\fontfamily{ptm}\fontsize{45}{45}\bfseries] {Ti\emph{k}Z};
    \end{scope}
  \end{tikzpicture}
  \begin{tikzpicture}[opacity=0.5]
    \begin{scope}[transparency group]
      \draw [line width=5mm] (0,0) -- (2,2);
      \draw [line width=5mm] (2,0) -- (0,2);
    \end{scope}
  \end{tikzpicture}
%\end{preview}
  
\end{document}

PSTricks example:

enter image description here

\documentclass{standalone}

\usepackage{pstricks-add}

\begin{document}
\psset{fillstyle=solid,linewidth=0.1,opacity=0.4,strokeopacity=0.7}

\begin{pspicture}(-3.48,-3.06)(3.48,3.48)
  \pscircle[fillcolor=green,linecolor=green](2;135){2cm}
  \pscircle[fillcolor=red,linecolor=red](2;45){2cm}
  \pscircle[fillcolor=blue,linecolor=blue](1;-90){2cm}
\end{pspicture}
\end{document}
13
  • Interesting: does that mean transparency in PostScript is 'dead' (at least for secure ones).
    – Joseph Wright
    Oct 4, 2018 at 11:36
  • 1
    @AlexG thanks! I changed on Texstudio and on Texmaker Ps2Pdf command : ps2pdf -dNOSAFER %.ps %.pdf and tikz and pstricks works fine. Although I can't make it work in Kile. Oct 4, 2018 at 12:16
  • 2
    This answer saved my life. I encountered this issue after upgrading GS.
    – WDC
    Nov 9, 2018 at 18:36
  • 1
    This is the answer that keeps on giving. Its been two and a half years, and it just saved me a lot of pain. Thank you Jan 21, 2020 at 16:08
  • 1
    It looks like the gs developers made a breaking change to transparency handling in 9.51 (ghostscript.com/pipermail/gs-devel/2020-May/010295.html). I solved the problem by downgrading gs to 9.27 Jul 9, 2020 at 8:02
2

I'm using Kile. In Kile I use the pdflatex command with the -shell-escape option. For working with opacity I have found this solution. Use the auto-pdf package with this option: \usepackage[pspdf={-dDELAYSAFER}]{auto-pst-pdf}

1

You must log in to answer this question.

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