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.

I am using TeX Live 2010. I don't use MikTeX anymore because of many troubles I found in the past.

Input files:

gridon.tex:

% gridon.tex
\documentclass{minimal}
\usepackage{pstricks}

\pagestyle{empty}
\begin{document}

\begin{pspicture}[showgrid=true](3,3)
\pscircle(1.5,1.5){1}
\rput[tr](3,3){3}
\end{pspicture}

\end{document}

gridoff.tex:

% gridoff.tex
\documentclass{minimal}
\usepackage{pstricks}

\pagestyle{empty}
\begin{document}

\begin{pspicture}[showgrid=false](3,3)
\pscircle(1.5,1.5){1}
\rput[tr](3,3){3}
\end{pspicture}

\end{document}

main.tex:

% main.tex
\documentclass{minimal}
\usepackage[hiresbb]{graphicx}
\begin{document}

\includegraphics[scale=2]{gridon}
\vspace{5mm}

\includegraphics[scale=2]{gridoff}
\end{document}

Methods:

MethodA.bat:

echo off
latex %1
dvips %1
ps2pdf %1.ps
pdfcrop --hires %1
pdftops -eps %1-crop.pdf

MethodB.bat:

echo off
latex %1
dvips %1 -E -o %1.eps
epstool --copy --bbox %1.eps %1-crop.eps
epstopdf --hires %1-crop.eps

Results:

enter image description here

share|improve this question
1  
You need to use <pre> .. </pre> HTML tags for non-TeX code, otherwise the % will be taken as comment. –  Martin Scharrer Jul 2 '11 at 11:34
1  
@Martin: Or even better use one of the language tags (though there doesn't seem to be highlighting for .bat files) –  Caramdir Jul 3 '11 at 12:52
1  
If I may give you some tips about this question: You might want to add a short introduction (as always) and also state that you (mainly?) looking for a MS Windows solution. Also, all the del lines in your batch files are not required to see the cropping process but make the code blocks hard to read. I would recommend to remove them. –  Martin Scharrer Jul 6 '11 at 15:15
    
Did you tried the preview package or the standalone class already? Would you like an answer based on them? They produce the DVI or PDF already cropped. However an EPS from DVI will most likely not have the correct HiResBoundingBox. –  Martin Scharrer Jul 6 '11 at 15:20
    
Another idea: measure the size of the content in TeX and print it converted to bp in an external file. These values can then be used to build a HiResBoundingBox header for the (E)PS produced by dvips. This would save you a few conversion steps. –  Martin Scharrer Jul 6 '11 at 15:33

1 Answer 1

up vote 5 down vote accepted
+50

I would recommend method A, because the EPS files will in general be much smaller.

You noticed "bad" cropping with method A. The reason for this is subtle: your use of pstricks produces a PDF where the font used for labelling the grid (eg, the figure "3") is Helvetica and it is not embedded in the PDF. Therefore ghostscript and adobe reader have to use a subsitute font. Most viewers (including the many viewers based on ghostscript, also xpdf) will use a version of Helvetica. Adobe's viewer will substitute ArialMT (on windows at least), which is a slightly different shape and therefore gets cut off. You can check this with Adobe reader on the "fonts" tab of the "document properties" dialog. You can solve this problem by producing a file with the fonts embedded. One way to do this is to change your method A to use ps2pdf -dPDFSETTINGS#/prepress %1.ps %1.pdf.

Why does method B seem to be superior? Actually I was quite confused for a while because on Ubuntu the two methods do produce the same bounding box. Which is to be expected, since pdfcrop and epstool both use gs -sDEVICE=bbox to generate it. So why do you see a difference? Well, I found that the miktex version of epstopdf has a bug in it: it rounds the bounding box to an integer number of points. In this particular case this had the effect of cancelling the clipping, but in general it could make the clipping worse. I'll file a bug against miktex tomorrow, but in the meantime this is another reason to prefer method A if you are using miktex. (The miktex version of epstopdf is a reimplementation in C of the bugless original perl script).

share|improve this answer
    
That comment from Alann Munn is in relation to fonts that are explicitly included by tex. Here, the use of the font is "hidden" from tex by the pstricks specials. –  Lev Bishop Jul 7 '11 at 6:48
    
@xport: you can add a font with dvips -h hv______.pfb <file>.dvi for Helvetica. The fonts are available with the AdobeReader. However, it makes no real sense to emded the standard PostScript fonts because they are already present on any PostScript printer. If you want to embed all PS fonts then create a driver file config.myps and add lines like h hv______.pfb for the fonts and then use dvips -P config.myps ... –  Herbert Jul 7 '11 at 7:14
    
the -dPDFSETTINGS is a ghostscript switch and has nothing to do with the dvips run. –  Herbert Jul 7 '11 at 7:43
    
Yes, it's usually a good idea to use prepress settings. You can read what that does here. –  Lev Bishop Jul 7 '11 at 7:49
    
@xport: the underscores are part of the file name, that's all. You have to use your file name of the helvetica font. –  Herbert Jul 7 '11 at 9:11

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.