2

I have troubles with optexp environment. There is a code

\documentclass[pstricks,margin=12pt]{standalone} 
\usepackage{pst-optexp}

\begin{document}
\begin{pspicture}(3.2,5)
\pnodes(0,3){A}(1,3){BS}(3,3){M1}(1,5){M2}(1,1){PD}
\psset{mirrortype=extended, mirrordepth=0.2}

\begin{optexp}
\beamsplitter[bsstyle=plate, compname=BS](A)(BS)(PD)
\mirror[compname=M1](BS)(M1)(BS)
\mirror[compname=M2, variable](BS)(M2)(BS)
\lens[compname=L](BS)(PD)
\optdetector[compname=Det, dettype=diode](BS)(PD)
\addtopsstyle{Beam}{beamwidth=0.2, fillstyle=solid,fillcolor=green!20!white}
\drawwidebeam(A){BS}{M1}{BS}{M2}{BS}{L}{Det}
\end{optexp}
\end{pspicture}

\end{document}

and the result is this

enter image description here

and I get "MiKTeX GPL Ghostscript 9.19: Unrecoverable error, exit code 1" error. When I remove optexp environment, so

\documentclass[pstricks,margin=12pt]{standalone} 
\usepackage{pst-optexp}

\begin{document}
\begin{pspicture}(3.2,5)
\pnodes(0,3){A}(1,3){BS}(3,3){M1}(1,5){M2}(1,1){PD}
\psset{mirrortype=extended, mirrordepth=0.2}


\beamsplitter[bsstyle=plate, compname=BS](A)(BS)(PD)
\mirror[compname=M1](BS)(M1)(BS)
\mirror[compname=M2, variable](BS)(M2)(BS)
\lens[compname=L](BS)(PD)
\optdetector[compname=Det, dettype=diode](BS)(PD)
\addtopsstyle{Beam}{beamwidth=0.2, fillstyle=solid,fillcolor=green!20!white}
\drawwidebeam(A){BS}{M1}{BS}{M2}{BS}{L}{Det}

\end{pspicture}

\end{document}

the result is

enter image description here

which is correct but optical components are behind beam. I use XeLatex. What am I doing wrong? Which packages are missing? Thank you (example is from manual "Drawing optical experimental setups" where the code works correctly).

  • pst-optexp doesn't work with XeLaTeX – Christoph Jul 8 '18 at 7:24
  • Without XeLatex the code doesn't work at all. What I have to run? – Ron LaHire Jul 8 '18 at 7:44
  • 2
    latex file.tex && dvips file.dvi && ps2pdf file.ps – Christoph Jul 8 '18 at 8:37
3

The pst-optexp package doesn't work with XeLaTeX. You must use the toolchain

latex file.tex && dvips file.dvi && ps2pdf file.ps
1

If you need a new TeX engine you can use lualatex, which does nearly the same as xelatex. Run the following example with lualatex --shell-escape file.tex

\documentclass{article} 
\usepackage{auto-pst-pdf-lua}
\usepackage{pst-optexp}
\usepackage{libertinus-otf}
\begin{document}
Some text before \ldots

\bigskip
\begin{pspicture}(3.2,5)
    \pnodes(0,3){A}(1,3){BS}(3,3){M1}(1,5){M2}(1,1){PD}
    \psset{mirrortype=extended, mirrordepth=0.2}

    \begin{optexp}
    \beamsplitter[bsstyle=plate, compname=BS](A)(BS)(PD)
    \mirror[compname=M1](BS)(M1)(BS)
    \mirror[compname=M2, variable](BS)(M2)(BS)
    \lens[compname=L](BS)(PD)
    \optdetector[compname=Det, dettype=diode](BS)(PD)
    \addtopsstyle{Beam}{beamwidth=0.2, fillstyle=solid,fillcolor=green!20!white}
    \drawwidebeam(A){BS}{M1}{BS}{M2}{BS}{L}{Det}
    \end{optexp}
\end{pspicture}

\noindent
and some text after \ldots
\end{document}

Then you'll get the output:

enter image description here

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.