[pstricks] psPrintValue

Herbert Voss LaTeX at ZEDAT.FU-Berlin.DE
Thu Mar 6 09:51:28 CET 2008

Poul Riis schrieb:
> I'd better correct some stupid errors in the example....

there are now the optional arguments valUnit= and valUnitSep=...


\define at key[psset]{pst-func}{valUnit}{\def\psk at valunit{#1}}
\define at key[psset]{pst-func}{valUnitSep}{\pst at getlength{#1}\pst at valUnitSep }
	valUnit={},valUnitSep=2pt}% unit and sep between value and unit
\def\psPrintValue{\pst at object{psPrintValue}}
\def\psPrintValue at i#1{%
  \begin at SpecialObj
  \addto at pscode{
     gsave \psk at PSfont findfont \psk at fontscale scalefont setfont
     #1 \psk at valuewidth string cvs 0 0 moveto show
	\pst at valUnitSep\space 0 rmoveto(\psk at valunit) show grestore
  \end at SpecialObj%

\psaxes[ticksize=-3pt 0,Dx=0.2,Dy=0.1]{->}(0,0)(-1.85,0)(1.85,1.05)
\pstVerb{/pi 3.14159265 def /aa 0.0025 def /lambda 0.00006328 def /kk pi
	aa mul lambda div def /LL 50 def}%%%% Everything in cm
	x dup mul LL dup mul add
	sqrt x exch div kk mul /alpha exch def alpha RadtoDeg sin alpha div
	dup mul x LL div dup mul 1 add div}
	\psPrintValue[valUnit=nm]{lambda 10000 mul 1000 mul}}
\uput{0pt}[0](1.0,0.90){$a=$\psPrintValue[valUnit=mm]{aa 10 mul}}
\uput{7pt}[90](1.7,0){$x$ /cm}
\uput{9mm}[180]{90}(0,0.85){Intensity (arbitrary units)}


More information about the PSTricks mailing list