5

In my drawing using pst-optexp, I found weird whitespace occured when using \drawbeam, \pstVerb and tx@addDict together. Here are the minimum reproduction codes for my claim:

\documentclass{standalone}
\usepackage{pst-optexp}

\begin{document}

\begin{pspicture}(1.8,-0.1)(5,2.3)
\pnodes(2,1){A}(3,1){B}
\lens[n=2, lensradius=4 4, lensheight=2](A)(B){}
\definecolor[ps]{bl}{rgb}{%
tx@addDict begin Red Green Blue end}%
\addtopsstyle{Beam}{linecolor=bl, beaminside=false}
\multido{\r=-0.8+0.005}{321}
    {
    \pstVerb{\r\space 550 400 sub mul 550 add tx@addDict begin wavelengthToRGB end}
    \drawbeam[beampos=\r](A){}(B)
    }
\end{pspicture}

\end{document} 

The generated PDF looks like this, please note the unwanted whitespace on the right: enter image description here

However, if I don't use \pstVerb and tx@addDict with \drawbeam, the whitespace doesn't appear. Here is another code, it is slightly changed against the previous one:

\documentclass{standalone}
\usepackage{pst-optexp}

\begin{document}

\begin{pspicture}(1.8,-0.1)(5,2.3)
\pnodes(2,1){A}(3,1){B}
\lens[n=2, lensradius=4 4, lensheight=2](A)(B){}

\addtopsstyle{Beam}{linecolor=green, beaminside=false}
\multido{\r=-0.8+0.005}{321}
    {
    \drawbeam[beampos=\r](A){}(B)
    }
\end{pspicture}

\end{document} 

It turned out to be like this, which is quite reasonable: enter image description here

So I draw the conclusion that the usage of varying color for drawing rays lead to the extra unwanted whitespace.

My questions are: How does it happen? And can I use varying colors to draw different rays and without suffering from the unwanted whitespace?

I appreciate your attention and thanks in advance.

1 Answer 1

4

You must add a comment character % at the opening bracket of \multido:

\documentclass{standalone}
\usepackage{pst-optexp}

\begin{document}

\begin{pspicture}(1.8,-0.1)(5,2.3)
\pnodes(2,1){A}(3,1){B}
\lens[n=2, lensradius=4 4, lensheight=2](A)(B){}
\definecolor[ps]{bl}{rgb}{%
tx@addDict begin Red Green Blue end}%
\addtopsstyle{Beam}{linecolor=bl, beaminside=false}
\multido{\r=-0.8+0.005}{321}
    {% <--
    \pstVerb{\r\space 550 400 sub mul 550 add tx@addDict begin wavelengthToRGB end}%
    \drawbeam[beampos=\r](A){}(B)}
\end{pspicture}
\end{document}

Many PSTricks macros, and also \drawbeam suppress trailing white space, but \pstVerb does not.

enter image description here

I would suggest you to wrap the whole pst-optexp commands with an optexp environment. This moves the component outlines on top of the beams:

\documentclass{standalone}
\usepackage{pst-optexp}

\begin{document}

\begin{pspicture}(1.8,-0.1)(5,2.3)
\pnodes(2,1){A}(3,1){B}
\definecolor[ps]{bl}{rgb}{%
tx@addDict begin Red Green Blue end}%
\addtopsstyle{Beam}{linecolor=bl, beaminside=false}
\begin{optexp}
  \lens[n=2, lensradius=4 4, lensheight=2](A)(B){}
  \multido{\r=-0.8+0.005}{321}
      {% <--
      \pstVerb{\r\space 550 400 sub mul 550 add tx@addDict begin wavelengthToRGB end}%
      \drawbeam[beampos=\r](A){}(B)}
  \end{optexp}
\end{pspicture}
\end{document}

enter image description here

1
  • Thank you for the answer. And optexp is a very helpful package.
    – WDC
    Commented Jul 23, 2015 at 10:14

You must log in to answer this question.

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