At 01:33 PM 3/11/2002 -0500, John Culleton wrote:
>Context in its present form cannot handle Pstricks because
>Pstricks generate Postscript code that is a bit scary when
>inserted in a pdf file. (I have heard of Postscript embedded
>in PDF but I would not want to count on it.) However
>Metapost code is handled by an on-the-fly call to the
>mpost program. I wonder if the same principle could be
>used for incorporating Pstricks figures and special
>effects into Context?
>
>Pstricks is more directly concerned with e.g. graphs,
>tree diagrams, etc. and has many useful commands. Before
>being lured by pdftex and Context it was a standard part
>of my vocabulary.
So you want to pipe the graphic to an external app?
\starttext
\startbuffer[pst]
\startTEXpage
\usemodule[pstrick]
\pspicture(0,0)(10,10)
\dorecurse{10}{\psline(0,0)(10,\recurselevel)}
\dorecurse{10}{\psline(\recurselevel,0)(100,100)}
\endpspicture
\stopTEXpage
\stopbuffer
\immediate\write18{texexec \bufferprefix pst.tmp --once --batch}
\immediate\write18{dvips \bufferprefix pst}
\immediate\write18{ps2pdf \bufferprefix pst.ps \bufferprefix pst.pdf}
\externalfigure[\bufferprefix pst.pdf]
\stoptext
say that this is file test.tex, then "texexec --pdf test" should work
(given that write 18 is enabled);
Now, the problem is to get the right boundingbox; collecting the picts in a
file is also not that hard, so if you don't care about real trickery, this
is as way.
Now, let's wrap that in a decent macro:
% interface=en output=pdftex
\starttext
\unprotected \long\def\startPSTRICKS#1\stopPSTRICKS
{\bgroup
\setbuffer[pstrick]%
\usemodule[pstrick]%
\setbox\scratchbox=\hbox{#1}%
\immediate\openout\scratchwrite=\bufferprefix dim.tmp
\immediate\write\scratchwrite{\dimen0=\the\ht\scratchbox}%
\immediate\write\scratchwrite{\dimen2=\the\wd\scratchbox}%
\immediate\closeout\scratchwrite
\startTEXpage
\box\scratchbox
\stopTEXpage
\endbuffer
\immediate\write18{texexec \bufferprefix pstrick.tmp --once --batch}%
\immediate\write18{dvips \bufferprefix pstrick}%
\immediate\write18{ps2pdf \bufferprefix pstrick.ps \bufferprefix
pstrick.pdf}%
\readlocfile{\bufferprefix pstrick-dim.tmp}{}{}%
\setbox\scratchbox=\hbox
{\externalfigure[\bufferprefix pstrick.pdf][\c!object=\v!nee]}%
\setbox\scratchbox=\hbox
{\lower\ht\scratchbox\hbox{\raise\dimen2\box\scratchbox}}%
\wd\scratchbox\dimen0
\ht\scratchbox\dimen2
\dp\scratchbox\zeropoint
\box\scratchbox
\egroup}
\ruledhbox{\startPSTRICKS
\pspicture(0,0)(10,10)
\dorecurse{10}{\psline(0,0)(\recurselevel,10)}
\dorecurse{10}{\psline(0,0)(10,\recurselevel)}
\endpspicture
\stopPSTRICKS}
\stoptext
I will add the startPSTRICKS (actually a sligthly better version that is
less sensitive for input and that adapts itself to dvi/pdf) macro to
m-pstrick and send you the file,
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | [EMAIL PROTECTED]
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
fall-back web server:
www.pragma-ade.nl
-------------------------------------------------------------------------