I will provide you with 6 batch files. Each takes a (La)TeX input file name without extension. It will compile a single (La)TeX input file to produce an output in both PDF and EPS. In development phase, you may compile the same (La)TeX input file with each of the 6 batch files, and investigate which one suits you best. Each of the 6 batch files processes a single (La)TeX input file using different steps internally. The description will be clearer later in the next explanation.
In the production phase, you should have decided which one among them will be applied on a bunch of (La)TeX input files you have. Since applying the batch file on a bunch of (La)TeX input files is very tedious job, I provide you with an additional batch file to automate the process. Thus there are 7 batch files in total.
BatchA.bat
rem batchA.bat
rem echo off
latex -interaction=nonstopmode %1
dvips -R -t unknown %1
ps2pdf -dAutoRotatePages#/None -dCompatibilityLevel#1.5 -dPDFSETTINGS#/prepress %1.ps %1-temp.pdf
pdfcrop --restricted --hires %1-temp %1.pdf
pdftops -level3 -eps %1.pdf
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1.ps
del %1-temp.pdf
- It can be used for an input file with any paper size.
- Steps:
TEX -> DVI -> PDF -> cropping -> EPS
.
pdfcrop
takes a significant amount of time to do cropping. If you don't need cropping, don't use this batch file.
BatchB.bat
rem batchB.bat
echo off
latex -interaction=nonstopmode %1
dvips -R -t unknown %1
ps2pdf -dAutoRotatePages#/None -dCompatibilityLevel#1.5 -dPDFSETTINGS#/prepress %1.ps
pdftops -level3 -eps %1.pdf
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1.ps
- It can be used only for an input file with tight paper size.
- Steps:
TEX -> DVI -> PDF -> EPS
.
- It runs faster than
batchA.bat
because no cropping with pdfcrop
. The drawback is you must specify the paper size tightly.
BatchC.bat
rem batchC.bat
echo off
latex %1
dvips -t unknown %1
gswin32c -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%1.pdf %1.ps
pdftops -eps %1.pdf
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1.ps
- It is almost the same as the
batchB.bat
but with fewer switches to speed up the compilation.
- It can be used only for an input file with tight paper size.
- Steps:
TEX -> DVI -> PDF -> EPS
.
- It runs faster than
batchA.bat
because no cropping with pdfcrop
. The drawback is you must specify the paper size tightly.
BatchD.bat
rem batchD.bat
echo off
tex %1
dvips -t unknown %1
gswin32c -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%1.pdf %1.ps
pdftops -eps %1.pdf
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1.ps
- It is almost the same as the
batchC.bat
but using tex.exe
instead of latex.exe
. The input file must be in plain TeX format. I hope it becomes faster than methodC.bat
, but it has not been tested yet as I have many troubles to convert the input file from LaTeX to plain TeX. Benchmarking will be done soon.
- It can be used only for an input file with tight paper size.
- Steps:
TEX -> DVI -> PDF -> EPS
.
- It runs faster than
batchA.bat
because no cropping with pdfcrop
. The drawback is you must specify the paper size tightly.
BatchE.bat
rem batchE.bat
rem echo off
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
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1-temp.eps
- It can be used for an input file with any paper size.
- Steps:
TEX -> DVI -> EPS -> bounding box correction -> PDF
.
- The file size of the resulting EPS is larger than that of one produced by each of the first 4 batch files (a,b,c,d).
BatchF.bat
rem batchF.bat
echo off
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
rem acrord32 %1.pdf
del %1.log
del %1.aux
del %1.dvi
del %1-temp.ps
del %1-temp.eps
- It can be used for an input file with any paper size.
- Steps:
TEX -> DVI -> PS -> EPS -> bounding box correction -> PDF
.
- The file size of the resulting EPS is larger than that of one produced by each of the first four batch files (a,b,c,d).
- I forgot the benchmark result when comparing
batchE.bat
and batchF.bat
.
Automate.bat
rem automate.bat
rem it takes a single character from {a,b,c,d,e,f}.
rem the options are case-insensitive.
rem for example: automate a
rem another example: automate F
echo off
for %%x in (*.tex) do batch%1.bat %%~nx
pause
If you have any problem, drop a comment.
Update in response to your misuse.
Each of {batchA.bat
,batchB.bat
,batchC.bat
,batchD.bat
,batchE.bat
,batchF.bat
} takes one input file name without extension. For example, if you want to use batchE.bat
for helloworld.tex
, then you must type batchE helloworld
and hit enter.
If you want to use batchE.bat
for a bunch of input files that exists in the same directory in which all batch files exist, then you type automate E
and hit enter.
Best Answer
This seems to be because EPS (and PDF) uses PostScript points (=1/72in, called
bp
(big points) in TeX), not the normal TeX points (1pt=1/72.27in). The EPS contains its size (bounding box) as integers, so rounding the size upwards. You can try and add the hi-resolution bounding box header which contains the size as floating point numbers. However, it depends on the used tool which of the two are used.You can get these headers calculated by Ghostscript using:
which prints the required EPS headers:
You can then simply replace the original headers with the updated one. There might be tools which do this for you (e.g.
eps2eps
) but these might actually change the font settings etc. I wrote my own Perl script calledfixbb
once which does nothing else then callinggs
like above and replacing the headers. (But I'm just seeing know that it doesn't add theHiResBoundingBox
header if it wasn't use before.)As workaround you could make sure that your diagrams are drawn using
bp
notpt
, at least the outer rectangle.BTW: I would use
\documentclass[border=0pt]{standalone}
instead. This saves you some steps (e.g. page style is already set to be empty, ...). However, I still get a white border at the right and top.