[pst-eps] Exporting EPS files (from ctt)

Denis Girou Denis.Girou at idris.fr
Thu May 7 20:27:20 CEST 1998


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

  I often forget to forward a copy of some messages about PSTricks from the
comp.text.tex (also known as ctt) Usenet newsgroup. But as only some of you
have access to the newsgroup or follow ctt discussions, it can interest some
people to have a copy of some messages of general interest.

D.G.

------- Start of forwarded message -------
From: Denis Girou <Denis.Girou at idris.fr>
Newsgroups: comp.text.tex
Subject: Re: PSTricks - exporting EPS files: An example that works?
Date: 06 May 1998 21:05:31 +0200

>>>>> "Michael.Friendly" == Michael Friendly <friendly at hotspur.psych.yorku.ca> writes:

    Michael.Friendly> I have been trying to export some simple PSTricks figures as EPS
    Michael.Friendly> files, which I can then use in a document w/o PSTricks.  I've read
    Michael.Friendly> the documentation, but my attempts fail  -- I get a nearly empty
    Michael.Friendly> eps file, and using dvips -E doesn't help either.

    Michael.Friendly> Does anyone have an example that works that I could modify?

    Michael.Friendly> Here's what I've tried:

    Michael.Friendly> \documentclass{article}
    Michael.Friendly> \usepackage{pstricks,pst-node,pstcol,pst2eps,graphicx}
    Michael.Friendly> \usepackage{array}
    Michael.Friendly> \begin{document}
    Michael.Friendly> \newcommand{\pssave}[2]{%
    Michael.Friendly>   \PSTtoEPS[bbllx=0,bblly=0,bburx=100,bbury=100]{#1.eps}{#2}
    Michael.Friendly> }
    Michael.Friendly> \newcommand{\newtridot}[1]{%
    Michael.Friendly> 	\begin{pspicture}(-.01, -.01)(1.0,1.0)
    Michael.Friendly> 	\psset{xunit=.85cm,yunit=.85cm}
    Michael.Friendly> 	\color{black}
    Michael.Friendly> 	\rput(0,0){\circlenode{A}{\textsf{A}}}
    Michael.Friendly> 	\rput(1.0,0){\circlenode{B}{\textsf{B}}}
    Michael.Friendly> 	\rput(.5,.866){\circlenode{C}{\textsf{C}}}
    Michael.Friendly> 	#1
    Michael.Friendly> 	\end{pspicture}%
    Michael.Friendly> 	\rule{0in}{1.1cm}
    Michael.Friendly> %	}
    Michael.Friendly> }

    Michael.Friendly> \TeXtoEPS
    Michael.Friendly> \pssave{tridot1}{\newtridot{}}\includegraphics{tridot1.eps}
    Michael.Friendly> \endTeXtoEPS
    Michael.Friendly> \end{document}

  Hum, several intricated problems here...

    1/ Don't use:

\usepackage{pstricks,pst-node,pstcol,pst2eps,graphicx}

but:
\usepackage{pstcol,pst-node,pst2eps,graphicx}

  If you want to use the standard `color' package (as it is a good idea),
load it first - and it will load pstricks by itself.

  Of course, this is not related to the original problem...

    2/ PSTricks offer two solutions to export graphics as EPS files. But you
can't use both at the same time! So, you must choose between the \PSTtoEPS
macro and the TeXtoEPS environment.

    3/ The \PSTtoEPS macro has the great advantage to work "on the fly", so to
allow to include later the resulting EPS file in the same compiled (La)TeX
file. Nevertheless, as explained page 80 of the documentation, this is
restricted to "pure graphics objects" (those described in Chapter II of the
documentation), which is not your case. So you can't use it here.

    4/ But you can use the general solution with the TeXtoEPS environment.
Nevertheless, you must have one pass, or one (La)TeX file, to generate the EPS 
file and one other (changing the code), or one other (La)TeX file, to include
it, as the two steps must be separated.

       And with this solution the classic pitfall is to omit to add a
\pagestyle{empty} command, which will avoid to integrate the bottom page
number in the EPS file.

  So, with the \PSTtoEPS macro:

\documentclass{article}

\usepackage{pstcol,pst-node,pst2eps,graphicx}

\newcommand{\pssave}[2]{\PSTtoEPS[bburx=3,bbury=3]{#1.eps}{#2}}

\begin{document}

\pssave{tridot1}
       {\begin{pspicture}(3,3)
          \psframe[linewidth=1mm](3,3)
        \end{pspicture}}

\includegraphics{tridot1}

\end{document}

  And with the TeXtoEPS environment:

\documentclass{article}

\usepackage{pstcol,pst-node,pst2eps,graphicx}

\newcommand{\newtridot}[1]{%
	\begin{pspicture}(-.01, -.01)(1.0,1.0)
	\psset{xunit=.85,yunit=.85}
	\color{black}
	\rput(0,0){\circlenode{A}{\textsf{A}}}
	\rput(1.0,0){\circlenode{B}{\textsf{B}}}
	\rput(.5,.866){\circlenode{C}{\textsf{C}}}
	#1%
	\end{pspicture}
	\rule{0in}{1.1cm}
}

\pagestyle{empty}

\begin{document}

\begin{TeXtoEPS}
  \newtridot{}
\end{TeXtoEPS}

%\includegraphics{tridot2}       % Available only in a second step

\end{document}

with in this case:
latex xx ; dvips -E -o tridot2.eps xx.dvi

------- End of forwarded message -------

  Nevertheless, it appear today that one point was unclear for this user,
who was surprise to get a PostScript error when he try to visualize it.
So, it can be useful to precise this point (excerpt from my answer):

---------------------------------------------------------------------------
  I understand now that it was the EPS file itself that you try to
directly visualize. But you can't like this, because it is not a
self-sufficient file: the headers are missing. It is devoted to later
inclusion in a (La)TeX document, which will load PSTricks (so which will
require headers loading).

  But if you really need a self-sufficient file, for instance to use it
with other software, you just need to ask the headers to be included when you
generate the EPS file.

  So, for instance in your case:

latex tridot2
dvips -E -h ~/tex/pst97/dvips/pstricks.pro \ 
         -h ~/tex/pst97/dvips/pst-node.pro -o tridot2.eps tridot2.dvi

  Just take care to two points:

    - do this only if necessary (and not in the (La)TeX case), because of
course the size of the resulting file will be bigger (42 Ko comparing to 17 Ko 
in your case),

    - you must load the headers you need for the kind of graphics you have
(so also pst-grad.pro if you use PST gradients, etc.).
---------------------------------------------------------------------------

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list