Resources‎ > ‎LaTeX‎ > ‎

## Including an image using pdflatex

If you are processing your .tex file(s) with pdflatex in order to generate a PDF file, you can include the following types of images:

• PNG
• PDF
• EPS
• JPG
You can include image files of the above image formats as:

\documentclass{article}
\usepackage{graphics}

\begin{document}

\includegraphics[width=0.5\textwidth, clip]{apple.png}
\includegraphics[width=0.5\textwidth, clip]{apple.pdf}
\includegraphics[width=0.5\textwidth, clip]{apple.eps}

\end{document}

## Including an image using latex

Sometimes, you are required to produce latex document in the form of .dvi format.  To produce a .dvi file, you have to use latex command and not pdflatex command.

Usually, once a .dvi file is produced, you would generate an output file using a output driver software such as dvips(k) and dvipdfm(x).

Even when you use latex command, you can still include images with different formants like .eps, .pdf, .jpg and .png .

### Including an image for dvips(k)

If you're going to use dvips to convert .dvi file into .ps file, you can only include .eps (.ps) files.  Before you include an image you need to specify the type of output driver as dvips in \usepackage.  The following is an example of including .eps file using latex for dvips:

\documentclass{article}
\usepackage[dvips]{graphics}
\begin{document}

\includegraphics[width=0.5\textwidth, clip]{apple.eps}

\end{document}

### Including an image for dvipdfm(x)

If you're going to use dvipdfm(x) to convert .dvi file into .pdf file, you can include .eps (.ps), .pdf, .jpg, .png files.  Before you include an image you need to specify the type of output driver as dvipdfm in \usepackage.

#### including .pdf and .eps images

The following is an example of including .eps and .pdf files using latex for dvipdfm:

\documentclass{article}
\usepackage[dvipdfm]{graphicx}
\begin{document}

\includegraphics[width=0.5\textwidth, clip]{apple.pdf}
\includegraphics[width=0.5\textwidth, clip]{apple.eps}

\end{document}

#### including .jpg and .png images

While you can easily include .pdf and .eps files as above because they have a BoundingBox information in the file.  However, since .jpg and .png files do not contain such information, you first need to produce the BoundingBox information for .jpg and .png files.  You can use a command called ebb to generate .bb file, which contains the BoundingBox information of an image:

\$ ebb apple.jpg (or ebb apple.png)

will produce apple.bb:
%%Title: ./apple.png
%%Creator: extractbb 20110311
%%BoundingBox: 0 0 307 357
%%CreationDate: Tue Sep 6 22:45:01 2011

Keep .bb file in the same place as .jpg and .png file and you can include .jpg and .png files using latex for dvipdfm:

\documentclass{article}
\usepackage[dvipdfm]{graphicx}
\begin{document}

\includegraphics[width=0.5\textwidth, clip]{apple.png}
\includegraphics[width=0.5\textwidth, clip]{apple.jpg}

\end{document}

ċ
Masahiro Takatsuka,
6 Sept 2011, 06:01
ą
apple.jpg
(24k)
Masahiro Takatsuka,
6 Sept 2011, 06:01
Ċ
Masahiro Takatsuka,
6 Sept 2011, 06:01
ą
apple.png
(21k)
Masahiro Takatsuka,
6 Sept 2011, 06:02