我在使用 optexp 环境时遇到了问题。有一个代码
\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}
结果如下
我得到了“MiKTeX GPL Ghostscript 9.19:不可恢复的错误,退出代码 1”错误。当我删除 optexp 环境时,
\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}
结果是
这是正确的,但光学元件在光束后面。我使用 XeLatex。我做错了什么?缺少哪些包?谢谢(示例来自手册“绘制光学实验设置”,其中代码正常工作)。
答案1
该pst-optexp
软件包不适用于 XeLaTeX。您必须使用工具链
latex file.tex && dvips file.dvi && ps2pdf file.ps
答案2
如果你需要一个新的 TeX 引擎,你可以使用lualatex
,它的功能与 几乎相同xelatex
。使用 运行以下示例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}
然后你会得到输出: