1

So, I'm having some trouble with pst-optexp lately. There seems to be some compilation problems with my sketch, since it doesn't show the elements properly. My current code is

\documentclass{standalone}
    \usepackage{pstricks-add}
    \usepackage{pst-optexp}
        \let\clipbox\relax

\begin{document}
    \begin{pspicture}[showgrid](0,-0.3)(9,2.3)
        \pnode(1.8,1){A}\pnode(4.5,1){B}\pnode(7,1){C}\pnode(8,1){D}
        \begin{optexp}
            \optbox[position=start, labeloffset=0](A)(B){Fonte}
            \lens[n=1.3, lensradius=-1 -1, lensheight=1](A)(B)
            \lens[n=2, lensradius=2 2, lensheight=2](B)(C)
            \pinhole[position=end, innerheight=0, outerheight=1.5](B)(D)
            \drawwidebeam[beamwidth=0.3,fillstyle=solid, fillcolor=green!40](A){2-3}(D)
        \end{optexp}
    \end{pspicture}
\end{document}

This code yields the following result (when compiled with XeLaTeX on Overleaf v2): enter image description here

If I remove the optexp environment, i.e., use the following code:

\documentclass{standalone}
    \usepackage{pstricks-add}
    \usepackage{pst-optexp}
        \let\clipbox\relax

\begin{document}
    \begin{pspicture}[showgrid](0,-0.3)(9,2.3)
        \pnode(1.8,1){A}\pnode(4.5,1){B}\pnode(7,1){C}\pnode(8,1){D}
            \optbox[position=start, labeloffset=0](A)(B){Fonte}
            \lens[n=1.3, lensradius=-1 -1, lensheight=1](A)(B)
            \lens[n=2, lensradius=2 2, lensheight=2](B)(C)
            \pinhole[position=end, innerheight=0, outerheight=1.5](B)(D)
            \drawwidebeam[beamwidth=0.3,fillstyle=solid, fillcolor=green!40](A){2-3}(D)
    \end{pspicture}
\end{document}

Then I'll get this result: enter image description here

I have dealed with similar issues on other PSTricks diagrams, which seemed to compiled when put in certain pages of the document, but were breaking in other places. How can I solve this?

I'm sorry if this is a known issue or something alike, I've been searching the web for quite sometime now and I just couldn't find a solution. Also, please let me know if there are bad style issues in this post, I have asked few questions over here so far.

1
  • Compiling with LaTeX (+dvipdf) seems to work better.
    – imnothere
    Sep 6, 2018 at 2:00

1 Answer 1

1

pst-optexp didn't work with xelatex. Use latex->dvips->ps2pdf or package auto-pst-pdf and pdflatex --shell-escape <file>:

\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{pst-optexp}

\begin{document}
\begin{pspicture}[showgrid](0,-0.3)(9,2.3)
    \pnodes(1.8,1){A}(4.5,1){B}(7,1){C}(8,1){D}
    \begin{optexp}
    \optbox[position=start, labeloffset=0](A)(B){Fonte}
    \lens[n=1.3, lensradius=-1 -1, lensheight=1](A)(B)
    \lens[n=2, lensradius=2 2, lensheight=2](B)(C)
    \pinhole[position=end, innerheight=0, outerheight=1.5](B)(D)
    \drawwidebeam[beamwidth=0.3,fillstyle=solid, fillcolor=green!40](A){2-3}(D)
    \end{optexp}
\end{pspicture}
\end{document}

enter image description here

2
  • Perhaps due to Overleaf's configuration it didn't work out... Actually, all of the pst's broke when I changed it Sep 7, 2018 at 10:12
  • I have no idea how overleaf works, but I cannot believe that nothing will do
    – user2478
    Sep 7, 2018 at 10:19

Not the answer you're looking for? Browse other questions tagged .