Error including image in Latex [closed]
Asked Answered
R

7

40

I am getting the following error while compiling my Latex File :

! LaTeX Error: Cannot determine size of graphic in tree.jpg (no BoundingBox).

Why do I get this error ? What has this to do with an .eps file ?

In fact, I could compile it fine with MacTex on my machine. But when I submit it online to a scientific journal for publication, it compiles it on the server and sends me the resultant PDF which has all these errors that prevent it from compiling.

I am using the following syntax for including the images :

\begin{figure}[!h]
    \begin{center}
        \scalebox{0.45}{
            \includegraphics{tree.jpg}}
    \end{center}
            \caption{\small A sample}
            \label{tree}
\end{figure}

What should I do ? Could it be that their server is using an old compiler ?

UPDATE : It finally worked. I converted the first image to PDF and the compilation happened perfectly. I guess it used the bounding box value from that PDF and applied it to all images.

Remonstrant answered 8/4, 2009 at 21:29 Comment(8)
Are you using pdflatex? Cause latex only supports vector graphics (read: eps)Maiga
I don't know the engine they are using on the server. My machine has MacTex and it is able to compile it.Remonstrant
Ah, yes. s/you/they/. Perhaps you should contact the journal and ask them about the specifics of their latex implementation.Maiga
For what it's worth, JPG is quite possibly the worst image format to use when you're going to print something (because of the quality degradation). In Latex EPS is best, PDF is a close second.Overstudy
@David: EPS and PDF are essentially equivalent when it comes to image quality. It just depends whether you're using LaTeX or pdfLaTeX as to which you'd choose.Phonoscope
Should we migrate this (and other tex questions) to tex.stackexchange.com?Disciplinant
@euphoria83: I flagged the post for moderator attention. Perhaps you can do that too? If we don't hear anything I'll post something on meta about migrating the questions from this tag.Disciplinant
Duplicate of: tex.stackexchange.com/questions/98679/…Dionysius
T
22

I've had the same problems including jpegs in LaTeX. The engine isn't really built to gather all the necessary size and scale information from JPGs. It is often better to take the JPEG and convert it into a PDF (on a mac) or EPS (on a PC). GraphicsConvertor on a mac will do that for you easily. Whereas a PDF includes DPI and size, a JPEG has only a size in terms of pixels.

( I know this is not the answer you wanted, but it's probably better to give them EPS/PDF that they can use than to worry about what happens when they try to scale your JPG).

Tomboy answered 8/4, 2009 at 21:31 Comment(11)
Thanks. Great help. But then why is it working on my machine ? How is it getting the bounding box values ?Remonstrant
MacTex seems to be more robust than other Tex distributions that I've seen. After working with too many academic publishers I've realized that I can never find something as old and incompatible as whatever they're using, so I just create EPS or PDFs.Tomboy
By the way, if you draw diagrams take a look at OmniGraffle. One of the best reasons to use a MacTomboy
Yeah, its surprising how the interface for CS journals are so out-dated. How do I convert to PDF format ? Is GraphicsConvertor a software provided with the OS ? I could not find it here and on the internet.Remonstrant
@euphoria: Which journal are you publishing to? A lot of the ACM journals and conferences actually take word files, which is even worse.Tomboy
Even this journal takes word. I guess that why they don't care much about having an up-to-date latex engine on the server. But still, what's GraphicsConvertor? Is that a software ?Remonstrant
Yea, it's a really good conversion software for the mac. Costs a lot, but you could use the demo for a while. lemkesoft.com I use it for all my screenshot and conversion needs.Tomboy
Enjoy. Congratulations on the paper ! I've only done conferences so far.Tomboy
you work on really cool stuff. API documentation is always a big pain. I applied to CMU too. But Luis Von Ahn couldn't help me get in. I had worked on CAPTCHA before.Remonstrant
@euphoria83: I think Luis has got his hands full with so many students and people working for him. And this year CMU's been feeling the crunch so the number of students it can support has been lower.Tomboy
IT was a fun topic (took me a while to get to it), it's a pity I'll never follow up on it ever again as I'm going to the industry. I hope I can at least get people to use my eMoose tool.Tomboy
C
28

To include png and jpg, you need to specify the Bounding Box explicitly.

\includegraphics[bb=0 0 1280 960]{images/some_image.png}

Where 1280 and 960 are respectively width and height.

Clothbound answered 23/8, 2011 at 3:34 Comment(2)
that would make the document terribly fragile to included image size changes, wouldn't it ?Sideward
@sylvainulg : you are rightClothbound
T
22

I've had the same problems including jpegs in LaTeX. The engine isn't really built to gather all the necessary size and scale information from JPGs. It is often better to take the JPEG and convert it into a PDF (on a mac) or EPS (on a PC). GraphicsConvertor on a mac will do that for you easily. Whereas a PDF includes DPI and size, a JPEG has only a size in terms of pixels.

( I know this is not the answer you wanted, but it's probably better to give them EPS/PDF that they can use than to worry about what happens when they try to scale your JPG).

Tomboy answered 8/4, 2009 at 21:31 Comment(11)
Thanks. Great help. But then why is it working on my machine ? How is it getting the bounding box values ?Remonstrant
MacTex seems to be more robust than other Tex distributions that I've seen. After working with too many academic publishers I've realized that I can never find something as old and incompatible as whatever they're using, so I just create EPS or PDFs.Tomboy
By the way, if you draw diagrams take a look at OmniGraffle. One of the best reasons to use a MacTomboy
Yeah, its surprising how the interface for CS journals are so out-dated. How do I convert to PDF format ? Is GraphicsConvertor a software provided with the OS ? I could not find it here and on the internet.Remonstrant
@euphoria: Which journal are you publishing to? A lot of the ACM journals and conferences actually take word files, which is even worse.Tomboy
Even this journal takes word. I guess that why they don't care much about having an up-to-date latex engine on the server. But still, what's GraphicsConvertor? Is that a software ?Remonstrant
Yea, it's a really good conversion software for the mac. Costs a lot, but you could use the demo for a while. lemkesoft.com I use it for all my screenshot and conversion needs.Tomboy
Enjoy. Congratulations on the paper ! I've only done conferences so far.Tomboy
you work on really cool stuff. API documentation is always a big pain. I applied to CMU too. But Luis Von Ahn couldn't help me get in. I had worked on CAPTCHA before.Remonstrant
@euphoria83: I think Luis has got his hands full with so many students and people working for him. And this year CMU's been feeling the crunch so the number of students it can support has been lower.Tomboy
IT was a fun topic (took me a while to get to it), it's a pity I'll never follow up on it ever again as I'm going to the industry. I hope I can at least get people to use my eMoose tool.Tomboy
M
12

Using .jpg files do not forget about compiling directly to .pdf (pdflatex) and use: graphicx package with pdftex option (\usepackage[pdftex]{graphicx}).

Methane answered 1/7, 2011 at 11:21 Comment(2)
N.B.: But it's not always the best solution. Working with DVI is often faster and compatible with more packages. So sometimes, it is worth converting an image into a PDF.Valuate
and when one comes from a regular latex compile and want to switch to pdflatex, that [pdftex] is likely to be missing in the {graphicx} line.Sideward
B
7

If you have Gimp, I saw that exporting the image in .eps format would do the job.

Bipetalous answered 25/4, 2010 at 0:9 Comment(0)
D
4

I use MacTex, and my editor is TexShop. It probably has to do with what compiler you are using. When I use pdftex, the command:

\includegraphics[height=60mm, width=100mm]{number2.png}

works fine, but when I use "Tex and Ghostscript", I get the same error as you, about not being able to get the size information. Use pdftex.

Incidentally, you can change this in TexShop from the "Typeset" menu.

Hope this helps.

Disciplinant answered 8/4, 2009 at 21:45 Comment(2)
yeah. but i can't change the engine on the server. ;-)Remonstrant
Yea, I had the same problem when I tried using this. I eventually just decided to let the file contain everything.Tomboy
M
3

On a Mac (pdftex) I managed to include a png file simply with

\includegraphics[width=1.2\textwidth]{filename.png}

. But in order for that to work I had to comment out the following 2 packages:

%\usepackage[dvips]{epsfig}

%\usepackage[dvips]{graphicx}

...and simply use package graphicx:

\usepackage{graphicx}

It seems [dvips] is problematic when used with pdftex.

Munson answered 15/6, 2013 at 17:22 Comment(1)
removing this [dvips] is working for me, i hate this [dvips] spend my whole daysIncumbent
L
0

I had the same problem, caused by a clash between the graphicx package and an inclusion of the epsfig package that survived the ages...

Please check that there is no inclusion of epsfig, it is deprecated.

Legible answered 20/3, 2013 at 13:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.