If you want to crop an esp file, see Method D
- Method A (R users) Before you make your graph in R, use par(mar=c(bottom, left, top, right))to specify the margin you want to keep. The default value is c(5, 4, 4, 2) + 0.1. Try this example to see the differences.
par(mar=c(5,4,4,2)+0.1) # The defualt margin
splot(rnorm(100))
dev.copy2eps() # Save as eps
par(mar=c(4,4,0,0)+0.1) # Figure with very tight margins
plot(rnorm(100))
dev.copy2eps()
- Method B (use epstool) Very handy tool that can handle the optimal bounding box
epstool --copy --bbox file.eps file_new.eps
- Method C (use ps2epsi)It automatically calculates the bounding box required for all encapsulated PostScript files, so most of the time it does a pretty good job
ps2epsi <input.eps> <output.eps>
- Method D (DIY for any eps )Use a text editor open your eps file and you will find a line like this
%%BoundingBox: 0 0 503 503
in the front lines of the file. Adjust these vales to proper integers. Save it and test if the margins are better. When you want to crop an eps file and include it into LaTeX with \includegraphics command, you should use \includegraphics* instead. Because If * is present, then the graphic is ‘clipped’ to the size specified. If * is omitted, then any part of the graphic that is outside the specified ‘bounding box’ will over-print the surrounding text. By the way, the options trim, bb, viewport options in \includegraphics can do the same job in a different manner without editing the eps file, see the help document for details.
Leave a Reply