# Unwanted white space when compiling to pdf from eps

A journal requires submission of figures in .eps format, so I need to be able to compile using an eps image "on the fly". Here is a MWE which uses an eps graphics file:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[t]
\centering
\caption{too much white space!}
\includegraphics[scale=0.4]{fdr80}
\end{figure}
\end{document}


The eps image has minimal margins (by fixing its BoundingBox), but the converted pdf image has too much white space on top (I think latex does the conversion automatically, I don't call epstopdf but I can see it being used in the log). How do I get rid of the white space? I've already tried the answer at Using pdfcrop within epstopdf? and it doesn't work: I get an error saying that it can't find the pdf file. (so epstopdf called by pdflatex is probably failing there).

EDIT: Some more information is in order. I produced the eps figure using R. More importantly, I used the R package "extrafont" to embed a Computer Modern font into the eps. I believe this embedding is causing the problem. I just tried to use a simple eps (no embedding of fonts) and tex converts it to a pdf with the correct borders, no additional white space on top.

• impossible to say much given this amount of information, but if you put \frame{\includegraphics....} is the extra space inside or outside the box drawn be \frame ? – David Carlisle Oct 4 '16 at 6:56

Upon inspecting the eps file (in a text editor), I saw that there were two lines starting with %%HiResBoundingBox. Deleting the wrong one fixed the problem.

I had a similar issue with a .eps file exported from Matlab, which ended up with unwanted margins on the top and right of the image when converted to .pdf. I thought that I would add an answer here since I came to this question through a web search.

In my case, the .eps file had PageBoundingBox and BoundingBox lines set as follows:

%%Page: 1 1
%%PageBoundingBox: 0 0 641 29
...
%%Trailer
%%BoundingBox: 0 0 653 35
%%Pages: 1
%%EOF


In this case, the two were different, and copying the values from PageBoundingBox to BoundingBox removed the unwanted margins.