22

I want to include an eps file in LaTeX. I typed the following in Texmaker

\begin{document}
\begin{figure}[!ht]
\centering
\includegraphics[scale=1]{figure}
\end{figure}

\end{document}

The error I get is

! LaTeX Error: Cannot determine size of graphic in figure.eps (no BoundingBox). 

Please help!

8
  • Welcome to TeX.SE! What is the filename extension of your graphics file? Is it .eps, or something else? Please advise.
    – Mico
    Commented Sep 17, 2013 at 19:20
  • 2
    does you figure have a bounding box (a line like %%BoundingBox: 1 2 3 4) It should have if it is a valid EPS file. Commented Sep 17, 2013 at 19:24
  • 1
    @DavidCarlisle -- we've had problems here in production with the bounding box at the end; maybe it's dvips that can't find it properly, but in any case, we always have to make repairs. so i made an assumption ... Commented Sep 17, 2013 at 21:14
  • 1
    What do you get with \includegraphics[bb=0 0 100 100]{figure} ?
    – user2478
    Commented Jan 29, 2014 at 8:38
  • 1
    Also, I encountered the same problem. In my case, I had dots in the filename. e.g. abc.def.png Commented Sep 24, 2019 at 10:57

3 Answers 3

16

Although the question has been answered by @DavidCarlisle in the comment, I'll try to complete the answer here.

This is not supposed to happen for valid eps files, as they should contain a BoundingBox comment and the graphicx package should be able to read it. The error message is typical when including bitmap graphics, e.g. jpg, as explained here.

In case you have a peculiar eps file which contains a BoundingBox comment but, for some reason, graphicx cannot read it, you can try searching your file. Do this either by opening the file in a text editor or by using something like the grep command:

grep BoundingBox figure.eps

You should normally see a line like:

%%BoundingBox: 0 0 30 30

Then, update your \includegraphics by supplying that:

\includegraphics[scale=1,bb=0 0 30 30]{figure}

In case you cannot find a bounding box (and your eps file is still usable, of course, which may not be the case), I'd suggest that you try guessing it. Start, e.g. with bb=0 0 100 100 and see what you get, then try increasing or decreasing the numbers. They are, in turn: lower-left-x (llx), lower-left-y (lly), upper-right-x (urx), and upper-right-y (ury). The width of the picture is urx-llx and the height is ury-lly.

0

I've had the same error occur too. In my case it turned out that I had a file named figure.eps.pdf, and so the \includegraphics command (which apparently tries to guess the file ending) tried to load that instead of figure.eps. Deleting the file figure.eps.pdf solved my problem.

2
  • 2
    This does not seem to be an answer, because it does not explain what you did to resolve the problem.
    – TeXnician
    Commented Jan 1, 2018 at 16:33
  • It does now.... Commented Jun 10, 2018 at 13:36
0
\documentclass[12pt]{article}
\usepackage[pdftex]{graphicx}

That solved my problem in any format .png, pdf, ps, eps...

1
  • 1
    Why the downvote? this worked for me.
    – A.D
    Commented May 26, 2021 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .