7

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}
\usepackage{pstricks-add} 

\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. –  Apr 22 '14 at 06:55
  • @ChristianHupfer how can I make an eps file? – Erel Segal-Halevi Apr 22 '14 at 06:58
  • 1
    Just add ps2pdf opacity.ps to the sequence of commands. This makes transparency visible in a PDF viewer. – AlexG Apr 22 '14 at 07:01
  • @ErelSegalHalevi: See my 'answer' below. –  Apr 22 '14 at 07:05

2 Answers2

4

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}

enter image description here

3

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{pstricks-add} 
\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. –  Sep 06 '14 at 07:11
  • @Herbert: Is there a new version/new pstricks package for this feature? –  Sep 06 '14 at 08:17
  • no, there is no replacement. One can use xelatex or auto-pst-pdf or pst2pdf. No need for creating such single eps files. –  Sep 06 '14 at 08:31