1

When I wrote my LaTeX file in windows, I have just given the name of the image without extension to add it anywhere like the following.

\begin{figure}[h]
    \centering
    \includegraphics[scale=0.6]{./img/varsityLogo}
\end{figure}

For the above lines in action, I put the image varsityLogo.png under the img sub-folder of the folder containing this file.

But when I went to compile it in ubuntu 16.04 LTS, it gives the following error.

! LaTeX Error: File `./img/varsityLogo' not found.

How to solve it? Should I edit all the paths of images and add corresponding extension like the code below? If yes, then is not there any way to make it platform independent?

\begin{figure}[h]
    \centering
    \includegraphics[scale=0.6]{./img/varsityLogo.png}
\end{figure}

But it produces a new error:

! LaTeX Error: Cannot determine size of graphic in ./img/varsityLogo.png (no Bo
undingBox).

What is the simplest way to resolve these issues while changing the platform?

Note that, my .tex file runs and produces pdf file without any error in windows.

  • 2
    the image formats supported do not depend on the operating system You are using pdflatex on windows and latex on linux. You would see the same error if you used latex on windows and it would work without error if you used pdflatex on linux – David Carlisle Sep 23 '16 at 13:25
  • 2
    unrelated but you should not use [h] (normally it gives a warning and is turned into [ht] but [htp] makes it far less likely that the image goes to the end of the document.) – David Carlisle Sep 23 '16 at 13:26
  • @DavidCarlisle Thanks for your suggestion in second comment. Wow! Does there exist another package called pdflatex? How to install and use that? Could you please help me? Thanks in advance. – Enamul Hassan Sep 23 '16 at 13:28
  • @DavidCarlisle Thanks, I got it. In the terminal instead of latex <file_name>, I had to use pdflatex <file_name>. However, Thanks once again. :) – Enamul Hassan Sep 23 '16 at 13:32
  • @DavidCarlisle: Should I delete this question? – Enamul Hassan Sep 23 '16 at 13:33
  • @MarcvanDongen Could you please explain? Thanks. – Enamul Hassan Sep 23 '16 at 13:56

2 Answers2

1

The image formats supported do not depend on the operating system.

You are using pdflatex on windows and latex on linux. You would see the same error if you used latex on windows and it would work without error if you used pdflatex on linux.

If you need to use latex on either platform, use an image editor (or a tool such as imagemagic convert) to make a varsityLogo.eps file and then latex/dvips will use the eps version and pdflatex (or lualatex or xelatex) would use the png.

David Carlisle
  • 757,742
0

In Ubuntu, considering the img subfolder you have already created, you need to address your file as: 'img/varsityLogo.png'.

Also you should use pdflatex instead of latex, since latex does not support reading the size of PNG, JPG or PDF images.

Maybe easiest way (Not best) to get rid of these errors while transferring your code among your operating systems, is to put the images right beside your tex file. In this case, you need to just write the filenames in address.