AW: [pstricks] PostScript code within PSTricks
Ulrich Dirr
ud at art-satz.de
Wed Jun 13 08:07:30 CEST 2001
Hi.
I've tested your solution, but always get an postscript error!?
Unrecoverable error: undefined in SDict
Operand stack:
--nostringval-- --nostringval-- 0 0 0 0 9.06744e+006
1.25712e+007 0 0 0 0 9.06744e+006 4.06323e+006 0 0 0 0
9.06744e+006 4.06323e+006 0 0 0 0 9.06744e+006 4.06323e+006 0
0 0 0 9.06744e+006 4.06323e+006 0 0 0 0 3.95182e+007 0.0 0
0 0 0 4.14843e+007 0.0 0 0 0 0
I'm using PSTricks v97 patch 14 <1999/12/23> (tvz) with YandYTeX.
(when I commented out the \rput-line in the definition of \myline then
everything works ...)
Regards,
Ulrich Dirr
--
Art & Satz
Ulrich Dirr
Arnimstraße 9
81369 München
Germany/Deutschland
--
fon (+49 89) 743 30 60
fax (+49 89) 743 30 61
email ud at art-satz.de
--
-=*:-)
> -----Ursprüngliche Nachricht-----
> Von: pstricks-admin at tug.org
> [mailto:pstricks-admin at tug.org]Im Auftrag
> von Denis Girou
> Gesendet: Dienstag, 12. Juni 2001 22:13
> An: PSTricks mailing list
> Betreff: Re: [pstricks] PostScript code within PSTricks
>
>
> >>>>> "Vinay.Kanetkar" == Vinay Kanetkar
> <vkanetka at uoguelph.ca> writes:
>
> Vinay.Kanetkar> This may be trivial question for those
> familiar with Postscript
> Vinay.Kanetkar> but in following code I am trying to
> add 0.1 to argument.
> Vinay.Kanetkar> I am not having much success in do it.
>
> Vinay.Kanetkar> In particular, following line:
> Vinay.Kanetkar> \rput(#1,! #2\space\a add}){\tiny 23.8\%}
>
> Vinay.Kanetkar> \documentclass{article}
> Vinay.Kanetkar> \usepackage[dvips]{graphics} % From
> LaTeX distribution
> Vinay.Kanetkar> \usepackage{pst-all} % From PSTricks
>
> Vinay.Kanetkar>
> \newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=10,grid
> labels=6pt}
> Vinay.Kanetkar> \textheight=23cm
> Vinay.Kanetkar> \topmargin=-2cm
> Vinay.Kanetkar> \textwidth=16cm
> Vinay.Kanetkar> \oddsidemargin=0cm
> Vinay.Kanetkar> \evensidemargin=0cm
> Vinay.Kanetkar> \def\mydata1{.25}
> Vinay.Kanetkar> \def\myang{35 45}
> Vinay.Kanetkar> \def\a{.1}
>
> Vinay.Kanetkar> \newcommand{\myline}[3]{%
> Vinay.Kanetkar> \SpecialCoor
> Vinay.Kanetkar>
> \psframe[linewidth=1pt,fillstyle=solid,fillcolor=#3](! #1
> \mydata1\space
> Vinay.Kanetkar> add 0)(! #1 \mydata1\space sub #2)
> Vinay.Kanetkar> \pscustom{ \SpecialCoor
> Vinay.Kanetkar> %\rput(#1 ! #2\space\a
> add}){\tiny 23.8\%} %%%%%% This line
> Vinay.Kanetkar> does not work.
> Vinay.Kanetkar> }
> Vinay.Kanetkar> }
>
> Vinay.Kanetkar> \begin{document}
>
> Vinay.Kanetkar> \begin{figure}[!htbp]
> Vinay.Kanetkar> \centering
> Vinay.Kanetkar> \begin{pspicture}(0,0)(3,3)\showgrid
> Vinay.Kanetkar> \myline{1}{1.376}{gray}
>
> Vinay.Kanetkar> \psline{->>}(3; ! \myang\space add)
>
> Vinay.Kanetkar> \end{pspicture}
> Vinay.Kanetkar> \end{figure}
> Vinay.Kanetkar> \end{document}
>
> Ulrich Dirr already give you some insights about your
> code, but there are
> several remarks to formulate (using PostScript expressions
> for coordinates
> is rather easy, but nevertheless not "trivial" at
> beginning). And some remarks
> are general and doesn't concern specially your test case.
>
> - Never use digits inside macro names (\mydata1): this is
> a definitive
> source of pitfalls with (La)TeX
>
> - Take care to side effects when defining you own
> variables. In LaTeX,
> \newcommand has a protection mechanism to avoid to erase
> existing macros
> by inadvertence. For instance, \a is an existing macro that
> you erase
> (using \show\a before the redefinition will show you the existing
> definition).
>
> - Don't put commands like \SpecialCoor inside a macro,
> but outside,
> to avoid to execute it each time. \SpecialCoor just switch
> the mechanism
> to analyse coordinates, allowing various ways to define
> them. By default,
> you can't use them because this analysis step slow down the
> compilation
> process a little bit (nevertheless, you will not notice a
> difference with
> a not too old CPU and in any case only if your code handle
> thousands of
> coordinates...)
>
> - The usage of \pscustom is not required in your case.
> The \rput macro
> can directly handle it coordinates as PostScript expressions.
>
> - (#1 ! #2\space\a add}) is an incorrect syntax, as
> Ulrich said already:
>
> * correct syntax is (! ... ...)
> * \space is not useful after #2 but require after \a
> (and any other
> (La)TeX macros)
> * } is of course to suppress
>
> - \psline{->>}(3; ! \myang\space add)
>
> * You can't use both polar and PostScript notations for the same
> coordinate
> * In your case you must compute both coordinates in
> PostScript (there is
> such an example page 72). So, I suppose:
> \psline{->>}(! 3 \myang\space add cos mul 3 \myang\space
> add sin mul)
>
>
> To summary:
>
> \documentclass{article}
>
> \usepackage{pstricks}
>
> \newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=10,grid
> labels=6pt}
>
> \def\mydata{.25}
> \def\myang{35 45}
> \def\mya{.1}
>
> \newcommand{\myline}[3]{%
> \psframe[linewidth=1pt,fillstyle=solid,fillcolor=#3]
> (! #1 \mydata\space add 0)(! #1 \mydata\space sub #2)
> \rput(! #1 #2 \mya\space add){\tiny 23.8\%}}
>
> \SpecialCoor
>
> \pagestyle{empty}
>
> \begin{document}
>
> \begin{figure}[!htbp]
> \centering
> \begin{pspicture})(3,3)\showgrid
> \myline{1}{1.376}{gray}
> %
> \psline{->>}(! 3 \myang\space add cos mul 3
> \myang\space add sin mul)
> \end{pspicture}
> \end{figure}
>
> \end{document}
>
>
> D.G.
> _______________________________________________
> pstricks mailing list
> pstricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
>
More information about the PSTricks
mailing list