1

I'm attempting to include image files in my LaTeX document whose code is:

\documentclass[a4paper, 11pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{cleveref}
\usepackage[parfill]{parskip}
\usepackage[none]{hyphenat}
\usepackage{amsbsy}
\usepackage{bm}
\usepackage{float}

\begin{document}

    \begin{figure}[h]
    \includegraphics[width=0.5\textwidth]{fig1}
    \end{figure}

\end{document}

where 'fig1.jpg' is in the same folder as this LaTeX file but still on compiling I'm getting the error 'fig1 not found'.Is there any way this error be rectified and what might be the reason behind this error?

  • 1
    Are you compiling with latex or pdflatex? – Ulrike Fischer Apr 17 '15 at 22:15
  • @UlrikeFischer I'm compiling with LaTeX using 'latex f1.tex'.Anyway should that make any difference? – Akshay Bansal Apr 17 '15 at 22:18
  • 2
    Yes, it makes a difference, latex can't handle jpg but pdflatex can. – Ulrike Fischer Apr 17 '15 at 22:22
  • @UlrikeFischer thanks it worked like a charm.Just out of curiosity, any idea why it wasn't working while compiling with latex in the first place? – Akshay Bansal Apr 17 '15 at 22:28
  • @UlrikeFischer This is a duplicate to http://tex.stackexchange.com/q/239201/10898 – azetina Apr 17 '15 at 22:33
  • Glad to hear its working. Since your two questions are related, I recommend you to edit one so that it reflects your problem. As it is, the two questions are considered duplicates of each other and one of them will be closed. Since an answer is already provided by @UlrikeFischer, I recommend him to post the respective solution. Welcome to TeX.SX. – azetina Apr 17 '15 at 22:35
  • @azetina: I'm a woman. And I'm quite confident that some duplicate of this question exists already and that one could delete this one. – Ulrike Fischer Apr 17 '15 at 22:38
  • @UlrikeFischer Oh am sorry. My apologies madam. Je suis désolé :) – azetina Apr 17 '15 at 22:42

1 Answers1

0

Actually, Ulrike Fischer has given a brief answer (I up-voted her comment, accordingly), I will just detail it a bit. The only format you can include while compiling with latex is Encapsulated PostScript (EPS). Because an EPS file declares the size of the image, it makes it easy for systems like LaTeX to arrange the text and the graphics in the best way.

If you are compiling with pdflatex to produce a PDF, you have a wider choice. You can insert:

  • JPG
  • PNG
  • PDF
  • EPS

Choosing one of these formats will heavily depend on the graphic itself. I you are including a photo, for example, then JPG will be your best choice. If you are including a non-vector diagram, a screenshot ...etc, then you may choose a PNG format. PDF on the other hand, can handle bit-map images as well as vector graphics. Therefore, it is the preferred choice for vector graphics. But for bit-map images, JPG and PNG are better because they occupy less disk space. EPS is also a high-quality vector graphics format, but it needs some configuration. The epstopdf package should be installed in your system (It actually is in current systems). If this is still not sufficient, then you need to load this package after graphicx, besides, you also need to give your compiler the permission to convert EPS file to PDF. This is done by adding the option, for example pdflatex -shell-escape file.tex, to your compiler command.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127