LaTeX Lessons
Lesson Eleven: Inserting EPS Figures
To import EPS (encapsulated postscript) figures into your document, the epsfig
package is required. Insert command \usepackage{epsfig}
after
the \documentclass
definition:
\documentclass[12pt]{article}
\usepackage{epsfig}
Download: latsam11.tex and myfigure.eps
Inserting the EPS file
The basic code to insert an EPS format image into the document is as follows:
\begin{figure}
\epsfig{file=myfigure.eps}
\end{figure}
Note: the above code has been indented. This is ignored by the latex compiler, but it useful to help people understand the code.
Images can be placed anywhere in the main document i.e. between the \begin{document}
and \end{document}
tags. The latex compiler will place the image as close as possible to where the image is declared in the document, taking into
account other objects and page breaks.
Adding a caption the image
\begin{figure}
\epsfig{file=myfigure.eps}
\caption{This is a caption}
\end{figure}
Resizing the image
In the next example, the resizebox
command has been used to set the size of the image:
\begin{figure}
\resizebox{8cm}{!}{
\epsfig{file=myfigure.eps}
}
\end{figure}
Centering the image
The image can also be centered by inserting \begin{center}
and \end{center}
tags:
\begin{figure}
\begin{center}
\epsfig{file=myfigure.eps}
\end{center}
\end{figure}
Putting it all together
\begin{figure}
\begin{center}
\resizebox{8cm}{!}{
\epsfig{file=myfigure.eps}
}
\caption{This is a caption}
\end{center}
\end{figure}
This concludes lesson 11.