# Opacity and transparency

I found some discussions about the opacity parameter in pstricks, but I still can't make it work. Here is my tex file:

\documentclass{article}
\usepackage{pstricks}

\begin{document}

\begin{pspicture}(-2,-2)(2,2)
\psset{fillstyle=solid}
\psline[linecolor=blue,linewidth=12pt](-2,-2)(2,2)
\psframe[fillcolor=red,opacity=0.5](-1,-1)(1,1)
\end{pspicture}

\end{document}


I compile it on Ubuntu using:

latex opacity.tex
dvips opacity.dvi


but in the PS file, there is no transparency.

What should I do to see the picture with the transparency effect?

-
As far as I know, PostScript does not know of transparency. Try to make a standalone .eps file from your picture/diagram and convert it .pdf then with epstopdf or something similar. – Christian Hupfer Apr 22 '14 at 6:55
@ChristianHupfer how can I make an eps file? – Erel Segal-Halevi Apr 22 '14 at 6:58
Just add ps2pdf opacity.ps to the sequence of commands. This makes transparency visible in a PDF viewer. – AlexG Apr 22 '14 at 7:01
@ErelSegalHalevi: See my 'answer' below. – Christian Hupfer Apr 22 '14 at 7:05
@AlexG thanks, this worked. – Erel Segal-Halevi Apr 22 '14 at 7:05

Run the document with xelatex or latex->dvips->ps2pdf. PostScript itself cannot show transparency effects. You have to use a PDF output:

\documentclass{article}
\usepackage{pstricks}
\begin{document}

\begin{pspicture}(-2,-2)(2,2)
\psline[linecolor=blue,linewidth=12pt](-2,-2)(2,2)
\psframe[fillstyle=solid,fillcolor=red,opacity=0.5](-1,-1)(1,1)
\end{pspicture}

\end{document}


-

This is rather the workflow than a true answer, but only for desired output as .pdf or as standalone .eps file.

\documentclass{article}

\usepackage{pstricks}
\usepackage{pst-eps}

\begin{document}

\begin{TeXtoEPS}

\begin{pspicture}(-2,-2)(2,2)
\psset{fillstyle=solid}
\psline[linecolor=blue,linewidth=12pt](-2,-2)(2,2)
\psframe[fillcolor=red,opacity=0.5](-1,-1)(1,1)
\end{pspicture}

\end{TeXtoEPS}

\end{document}


Run

latex foo.tex

dvips -E -o foo.eps foo.dvi

epstopdf foo.eps

-
Using pst-eps is obsolet. – Herbert Sep 6 '14 at 7:11
@Herbert: Is there a new version/new pstricks package for this feature? – Christian Hupfer Sep 6 '14 at 8:17
no, there is no replacement. One can use xelatex or auto-pst-pdf or pst2pdf. No need for creating such single eps files. – Herbert Sep 6 '14 at 8:31