TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a mathematics book that makes use of a huge number of PSTricks pictures. For the sake of re-usability and maintaining separation of concern, I always put the self-contained PSTricks code in a separate .tex file. The following code shows an example of self-contained PSTricks input file:

% gridon.tex


Then I compile the gridon.tex using the following batch file to produce gridon.eps.

latex %1.tex
dvips -R %1.dvi
ps2pdf -dCompatibilityLevel#1.5 -dPDFSETTINGS#/prepress %1.ps %1-temp.pdf
pdfcrop --restricted --hires %1-temp.pdf %1.pdf
pdftops -eps %1.pdf %1.eps

From my main .tex file, I will then import the gridon.eps as follows

% main.tex


I am \rnode[tl]{A}{xport} not \rnode[tr]{B}{xpert}.


Note that in the main.tex file I also have inline PSTricks codes in between the text so I cannot put them in separate files. The main input file is then compiled using latex->dvips->ps2pdf.

How to manage a document with a huge number of PSTricks figures?

share|improve this question
hmmm. I think that your question is not focused enough...I'd suggest splitting your "approach" into it's bare parts and ask a separate question about each one (-1) – Yossi Farjoun Dec 30 '10 at 9:37
Well, your own "answer" seems to imply that there's an issue with the BBox...so that's a separate issue. compile time seems to be another issue. Automation, a third issue...am I mistaken? – Yossi Farjoun Dec 30 '10 at 11:53
Inline PSTricks code can also be put into a separe file! You only have to choose the same page setting and fonts. – Herbert Jul 9 '11 at 20:39
And I do not unserstand the advantage of having external files when you already run the latex->dvips->ps2pdf sequence. I have more than 1000 PSTricks images in a book which I write out as external documents, run it vis a makefile and insert them all as a pdf. – Herbert Jul 9 '11 at 20:45

I wrote the standalone package to allow the compilation of pictures (tikz or pstricks) and other material as part OR separately from the main document. While mainly thought for fast recompilation during picture creation, it can also be used to create eps or pdf images from your pictures which are then inserted in your main document. So instead recompiling every picture every time the main document is compiled, you can compile it once and then only use the image. Should not degrade the quality if done right.


% Self-contained, compilable PSTricks picture
% e.g. "pic001.tex"


% Main document

% Replace .eps with .pdf if main file uses pdflatex


Then you compile the picture file first and convert it to a .eps (dvi->ps, simply rename .ps to .eps) or .pdf.

The above code is not full tested, because I don't have pstricks installed on my machine. I'm a PGF/TikZ fan and minded the disk space required by pstricks. I'm planning a build-in feature like that for the next release of 'standalone'.

share|improve this answer
Are you sure we can get EPS from PS produced by dvips by renaming the extension as you said above, i.e., changing from .ps to .eps? – xport Jul 9 '11 at 15:37
@xport: AFAIK the basic difference between EPS and PS is that EPS can't contain multiple pages and requires specific headers (for bounding box etc.) which are not mandatory of PS. However, often PS files have these headers as well and if they only hold one page then renaming the file ending works usually. I did that for a while, but it depends on the tools which produce the file and which use it later again. It's of course not a 100% safe thing. However, using dvips -E instead should do it anyway. I didn't though about that when I wrote the post. I will edit my post. – Martin Scharrer Jul 9 '11 at 15:49
@xport: I tested it now and have some issues getting the correct bounding box in all stages. It should work actually after the manual of the preview package which is used internally by standalone. I might delete my answer. – Martin Scharrer Jul 9 '11 at 16:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.