Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question is made to accompany the existing question: How can I create a pdf document exactly as big as my tikz picture?.

Constraints:

  1. It is not allowed to use pdfcrop by any means whatsoever. It is because pdfcrop takes a significant amount of time as explained in Searching for a better workflow to get a cropped PDF and EPS graphics - Stage 2.
  2. Manually calculating a tight paper dimension and other related dimensions is not allowed. For example, the solution for the first case in this link is not allowed because the margin is manually setup to avoid the top and bottom parts get cropped accidently.
  3. Neither BatchA.bat nor BatchB.bat is allowed because they produce big PDF and EPS files. Any variants of them might not be allowed as well. But they might be allowed if there is a way to reduce the file size, at least the same as the file size produced by latex->dvips->ps2pdf->pdfcrop.

    BatchA.bat:

    latex -interaction=nonstopmode %1
    dvips  -R -t unknown -E %1 -o %1-temp.eps
    epstool --copy --bbox %1-temp.eps %1.eps
    epstopdf --hires %1.eps
    

    BatchB.bat:

    latex -interaction=nonstopmode %1
    dvips -R -t unknown %1 -o %1-temp.ps
    ps2eps %1-temp.ps
    epstool --copy --bbox %1-temp.eps %1.eps
    epstopdf --hires %1.eps
    

How can I create PDF and EPS exactly as big as my PSTricks picture without breaking the constraints above?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You can't. Not if you meanby the size of graphic you mean the rectangle around all the print. The postscript graphics are calculated by the postscript interpreter (e.g. dvips) after the (La)TeX run. So LaTeX has absolutly no chance to know where all the black or colored ink points will be.

You can try dvips -E but as the documentation says to the -E option:

Generate an EPSF file with a tight bounding box. This only looks at marks made by characters and rules, not by any included graphics. In addition, it gets the glyph metrics from the TFM file, so characters that print outside their enclosing TFM box may confuse it. In addition, the bounding box might be a bit too loose if the character glyph has significant left or right side bearings. Nonetheless, this option works well enough for creating small EPSF files for equations or tables or the like.

share|improve this answer
add comment

Would the preview package help?

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
....
\begin{pspicture*}
....
\end{pspicture*}

Running latex gives a .dvi file with each page consisting of one pspicture tightly bound. You can then use dvipdfm and/or ghostscript to then automatically extract each pspicture to its own .pdf and .eps.

share|improve this answer
    
@xport I thought first running dvipdf then gs on the resulting PDF to get 1 pspicture per PDF/EPS (worked for me). It's true that I didn't look specifically at the time required and file size produced though. –  LianTze Lim Jul 14 '11 at 3:38
    
@xport Oops, didn't know that, sorry. How about: latex file; dvipdf file; gs -opics%02d.eps -sDEVICE=epswrite file.pdf; gs -opics%2d.pdf -sDEVICE=pdfwrite file.pdf ? Sorry I don't have a Win box now to compare the benchmark. –  LianTze Lim Jul 14 '11 at 6:41
add comment

Your Answer

 
discard

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.