I am drawing some setup using Pstricks and pst-optexp.

I want to know what the following example means. Also I can't find a detailed description of how to use \pstVerb and tx@addDict.

\i\space 650 400 sub 59 div mul 400 add
tx@addDict begin wavelengthToRGB end }%
\drawbeam[beamangle=\i\space 0.1 mul 3 sub]{2-}%
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Adam Liter Oct 26 '14 at 23:09

\pstVerb{...} - The argument is included as verbatim PostScript, not grouped by (g)save and (g)restore. The currentpoint should be TeX's currentpoint.

\i\space - is needed to get the looping variable and a following space

tx@addDict begin ... end - is needed to use the special PostScript dictionary, in this case the one from pstricks-add

You'll find some more examples in the package documentations


Admittedly, that is not the best example from a didactical point of view. Here is an alternative version, with some additional explanations. What you are missing in your snippet is the color definition, which is the reason for all that \pstVerb stuff:

\documentclass[pstricks, margin=5pt]{standalone}
  \optprism[prismalign=center, prismangle=59](A)(B)(C)
    tx@addDict begin tx@OptexpDict begin
      Wavelength wavelengthToRGB 
      Red Green Blue 
    end end }%
  \addtopsstyle{Beam}{linecolor=bl, linewidth=0.4\pslinewidth, beamalign=abs}
    \pstVerb{/Wavelength \iLambda\space def }%
    \drawbeam[n=Wavelength Sellmaier]{-}%

The syntax \definecolor[ps]... allows you to use some values computed at Postscript level for the actual color definition (see the xcolor documentation). In your example, the values Red, Green, and Blue are recalculated in every iteration and their values are used to draw the following beam.

In my changed version it may (or may not) become a bit more apparent: in every iteration I define a new Wavelength which is then both used to calculate a new refractive index and a new color triple for the next beam.

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.