# Weird whitespace occurs using \drawbeam in pst-optexp

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}
\definecolor[ps]{bl}{rgb}{%
tx@addDict begin Red Green Blue end}%
\multido{\r=-0.8+0.005}{321}
{
\drawbeam[beampos=\r](A){}(B)
}
\end{pspicture}

\end{document}


The generated PDF looks like this, please note the unwanted whitespace on the right:

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}

\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:

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?

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}
\definecolor[ps]{bl}{rgb}{%
tx@addDict begin Red Green Blue end}%
\multido{\r=-0.8+0.005}{321}
{% <--
\drawbeam[beampos=\r](A){}(B)}
\end{pspicture}
\end{document}


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

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