# PSTricks transparency failed on MacTEX

I started with PGF/Tikz at the beginning and was always happy with the result. It fits my workflow for LaTeX perfectly, as I normally use pdfLatex and all my figures included in LaTeX are .pdf format. However, the pst-optexp package based on PSTricks is rather an attractive option to draw optics diagrams for me. So I tried to learn a bit of PSTricks as well, but soon I found the transparency (opacity) is not working on my Mac OS X. The TeX distribution I use is MacTeX-2015.

The code I am trying is as follows:

\documentclass{standalone}

% Do not forget load pstricks with option 'distiller'
% if you want to get transparency in generated PDF files.
\usepackage[distiller]{pstricks}

\begin{document}

\begin{pspicture}(5,5)
\psset{fillstyle=solid}
\psframe[fillcolor=red](0,1)(3,4)
\psframe[fillcolor=blue,opacity=0.7](2,2)(5,5)
\psframe[fillcolor=green,opacity=0.7](1,0)(4,3)
\pscircle[fillcolor=cyan,opacity=0.5](1.5,3.5){1.25}
\rput(2.5,2.5){\psframebox[fillcolor=magenta,opacity=0.1]{%
% PSTricks do not make transparent text. We use pdfmark ...
\special{ps:gsave [ /ca 0.3 /CA 0.3 /SetTransparency pdfmark}%
\bf\Huge\green Great Box}%
\special{ps:grestore}%
}
\end{pspicture}

\end{document}


According to the link: http://www.bakoma-tex.com/menu/trans.php I should get some transparency effect, but here is how my .pdf or .ps files look like:

To compile the .tex file I use latex-drips-ps2pdf or pstopdf, I also tried with xelatex but got same failure. Actually I did not see any transparency even I used DocView checking the .dvi file directly. I searched some threads on some mailing list or here but none of them seems to work for me. Could anyone here, knowing the reason or having similar problems, give me some suggestions? Many thanks in advance.

EDIT:

Hmm... I got weired problem with pst-optexp though. For the PSTricks example, I got consistent result when I check the generated .dvi or .pdf file in DocView in Emacs as well as with Mac's Preview app or Adobe Reader. However for an optics example from this stackusing pst-optexp, I can get the same results as the author when I check the .dvi and .pdf within DocView. But when the file is opened in Preview, the colour is changed. If it's opened in Adobe Reader, the startup colour is correct but starts to change when I zoom in or zoom out. Any idea about this weird thing?

Following is the different images, the top one is the pdf file opened in DocView, while the bottom one is from Preview.

And the code is

\documentclass{standalone}
% \usepackage{pstricks}
\usepackage{pst-optexp}
\begin{document}
\begin{pspicture}(-0.2,0)(12.3,8.8)
\newpsobject{laser}{optbox}{position=start, innerlabel}
\psset[optexp]{lens=2, phwidth=0.07, outerheight=0.6}
\pnode(1,7){L}\pnode([offset=-6]L){PSLM}
\pnode([Xnodesep=2,offset=1]L){ASLM}\pnode([offset=-0.5,Xnodesep=9]L){MRef}
\pnode([offset=-7]ASLM){ML}\pnode([Xnodesep=8.5]ML){Cam}
\begin{optexp}
\laser[optboxsize=1.6 0.6](L)(PSLM){Nd:YAG}
\beamsplitter[bssize=0.4, labelangle=-90](L)(L|MRef)(MRef){BS}
\lens[abspos=1.2, lens=0.5 0.5 0.4, n=2.5, labelangle=-10](L)(PSLM){MO}
\pinhole[abspos=1.4, labelangle=10](L)(PSLM){PH}
\lens[abspos=2.3](L)(PSLM){L}
\opttripole[label=0.5](L)(PSLM)(ASLM){\psframe[dimen=outer](-0.5,0)(0.5,0.1)}{PSLM}
\lens[label=0.6 -40](PSLM)(ASLM){L}
\opttripole[label=0.5](PSLM)(ASLM)(ML){\psframe[dimen=outer](-0.5,0)(0.5,0.1)}{ASLM}
\lens[position=0.45, labelangle=180](ASLM)(ML){L}
\optretplate[labelangle=180, position=0.55](ASLM)(ML){$\lambda/2$}
\optplate[labelangle=180, position=0.62](ASLM)(ML){P}
\mirror[labeloffset=0.4](ASLM)(ML)(Cam){M}
\newpsstyle{Beam}{fillcolor=green!80!black, opacity=0.5, fillstyle=solid, linestyle=none, beaminside=false}
\drawwidebeam[beamwidth=0.1, stopinside]{1-5}
\drawwidebeam[stopinside, savebeampoints=2]{5-7}
\drawwidebeam[beamdiv=-8.5, beamangle=-4.5]{8-9}
\drawwidebeam[beamdiv=-8.5, beamangle=4.5]{8-9}
\lens[abspos=2](ML)(Cam){L}
\lens[abspos=4](ML)(Cam){L}
\crystal[abspos=6, voltage, crystalsize=1 0.6, fillcolor=yellow!90!black, fillstyle=solid](ML)(Cam){SBN}
\beamsplitter[bssize=0.6](MRef)(MRef|Cam)(Cam){BS}
\lens[n=2.4](MRef|Cam)(Cam){L}
\optbox[optboxsize=0.8 0.6, position=end](ML)(Cam){Cam}
\drawwidebeam[savebeampoints=2, stopinside]{9-13}
\drawwidebeam[beamangle=-5]{14-18}
\drawwidebeam[beamangle=5]{14-18}
\lens[lens=0.5 0.5 0.4, n=2](L|MRef)(MRef){MO}
\pinhole[position=0.53, labelangle=180](L|MRef)(MRef){PH}
\lens[position=0.65](L|MRef)(MRef){L}
\optplate[position=0.7](L|MRef)(MRef){S}
\mirror[labeloffset=0.4](L|MRef)(MRef)(MRef|Cam){M}
\drawwidebeam{21-23}{16-18}
\end{optexp}
\end{pspicture}
\end{document}

• run the pst-optexp example only with latex->dvips->ps2pdf. pst-optexp makes heavy use of nodes and xelatex has some problems with it. – user2478 Apr 14 '16 at 13:50
• Actually the results were generated from this workflow: latex-drips-ps2pdf. – Fanpeng Apr 14 '16 at 14:44
• then it is a problem with the viewer if you get different results – user2478 Apr 14 '16 at 17:26

\usepackage[distiller]{pstricks}

\usepackage{pstricks}

My output with xelatex: