# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8894172310829163, "perplexity": 10531.7664736585}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-32/segments/1438042989301.17/warc/CC-MAIN-20150728002309-00045-ip-10-236-191-2.ec2.internal.warc.gz"}