1. Introduction

In this tutorial, we’ll show how to embed images of various formats in a LaTex document: the Encapsulated Postscript (.eps) filesPostscript images (.ps), PDFs, JPEGs, PNG images, and others.

2. TeX Engines

There are many TeX engines such as PDFLaTeX, LaTeX, XeLaTeX, and LuaLaTeX. Each has slightly different capabilities when it comes to including images. We’ll be using PDFLaTeX in our examples but will also describe how to circumvent the limitations of other engines.

3. The \includegraphics COMMAND

The \includegraphics command is part of the graphicx package. We use it to insert figures into our LaTeX documents. This command is typically used as follows:


The options control features such as width. Most of the time, we can omit the filename extension since the graphicx package can take care of it automatically in most modern LaTeX engines.

3.1. Including .pdf FILES

If we had a file rectangles.pdf we wished to include, our code would be as follows:

Here is a pdf file, rectangles.pdf.

We would find the output to be:

Show the result of including a pdf image file into a LaTeX document using includegraphics.

3.2. Including .eps FILES

We can include a .eps file directly when using PDFLaTeX. The system will take care of the conversion from .eps to .pdf.

Here is an .eps file, polygons.eps.

The output is:

Shows the result of inserting an eps file in a latex document using includegraphics

If we are running a LaTeX engine that cannot do automatic conversion of .eps to .pdf, we can do so explicitly using the package epstopdf. All we need to do is include epstopdf after graphicx.


However, if we run into a situation where that doesn’t work, we should manually convert an EPS image into a PDF. On Linux systems, we can use convert to switch between image formats:

convert polygons.eps polygons.pdf

We would then specify polygons.pdf in our \includegraphics command.

If we’re running Windows or macOS, we’ll need to install ImageMagick and follow the instructions for conversion. It offers Windows and macOS users the same functionalities as convert.

3.4. Including Postscript Files

If we need to include a .ps (postscript) file, we can use the following command on Linux systems:

ps2eps polygon.ps

which will create polygon.eps. Then, we can include it as any other .eps file. Windows and macOS can use ImageMagick for conversion.

3.5. Other Filetypes

Package graphicx can handle many file types that are frequently used nowadays, such as .png and .jpeg. However, it can’t handle all the types, e.g., .tiff. In that case, we have no option but to manually convert the format. For instance:

convert polygon.tiff polygon.pdf

We can then include polygon.pdf in our LaTeX document.

4. Conclusion

In this article, we showed how to include image files in a LaTeX document using \includegraphics. We found this to be relatively easy in a Linux environment running a modern LaTeX system, such as PDFLaTeX.

Handling different formats is automated most of the time, but if that doesn’t work, we can convert our files manually.

Comments are closed on this article!