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:


% Do not forget load pstricks with option 'distiller'
% if you want to get transparency in generated PDF files.


      % 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}%


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:

enter image description here

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.


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. pdf file opened in DocView and Preview

And the code is

% \usepackage{pstricks}
\newpsobject{laser}{optbox}{position=start, innerlabel}
\psset[optexp]{lens=2, phwidth=0.07, outerheight=0.6}
  \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[label=0.6 -40](PSLM)(ASLM){L}
  \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}
  \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[loadbeampoints=2, beamdiv=-8.5]{7-8}
  \drawwidebeam[loadbeampoints=2, beamdiv=-8.5, beamangle=-4]{7-8}
  \drawwidebeam[beamdiv=-8.5, beamangle=-4.5]{8-9}
  \drawwidebeam[loadbeampoints=2, beamdiv=-8.5, beamangle=4]{7-8}
  \drawwidebeam[beamdiv=-8.5, beamangle=4.5]{8-9}
  \crystal[abspos=6, voltage, crystalsize=1 0.6, fillcolor=yellow!90!black, fillstyle=solid](ML)(Cam){SBN}
  \optbox[optboxsize=0.8 0.6, position=end](ML)(Cam){Cam}
  \drawwidebeam[savebeampoints=2, stopinside]{9-13}
  \drawwidebeam[loadbeampoints=2, beamdiv=-16, beamangle=5, stopinside]{13-14}
  \drawwidebeam[loadbeampoints=2, beamdiv=-16, beamangle=-5, stopinside]{13-14}
  \lens[lens=0.5 0.5 0.4, n=2](L|MRef)(MRef){MO}
  \pinhole[position=0.53, labelangle=180](L|MRef)(MRef){PH}
  \drawwidebeam[loadbeampoints=false, beamwidth=0.1, savebeampoints]{2}{19-21}
  • 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

makes only sense when using the distiller from Acrobat Pro at the backend. Simply use


My output with xelatex:

enter image description here

  • Thanks you so much, Herbert! I got the transparency too, and now I can use the pst-optexp for my optics diagram:) – Fanpeng Apr 14 '16 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.