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?

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

2 Answers 2

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

1
  • Needs ps2pdf -dNOSAFER <file>.ps
    – user187802
    Commented Jun 13, 2019 at 8:38
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

3
  • Using pst-eps is obsolet.
    – user2478
    Commented Sep 6, 2014 at 7:11
  • @Herbert: Is there a new version/new pstricks package for this feature?
    – user31729
    Commented Sep 6, 2014 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.
    – user2478
    Commented Sep 6, 2014 at 8:31

You must log in to answer this question.

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