PHYS408W : LATEX Guide

next up previous
Next: 8 Bibliographic Citations/References Up: PHYS408W : LATEX Guide Previous: 6 Typesetting Mathematics

Subsections


7 Including Graphics

7.1 The graphics Package

In order to include graphics in a document, you need the graphics package. In the preamble of your .tex file (after the \documentclass statement and before the \begin{document} statement), include the following line.

\usepackage{graphics}

Note: the graphics package will only work with TeXnicCenter as described here if you have selected LaTeX => DVI under Build -> Select Output Profile ...

The graphics package enables you to import graphics files in the Encapsulated Postscript (eps) format with the \includegraphics command. LATEX replaces the \includegraphics statement with the graphics file specified in its argument. For example, to place the contents of the file file.eps in the document, the syntax is

\includegraphics{file.eps}
Note : the file must be located in the same directory as your .tex file.

You can scale the size of the graphics file with the \scalebox command. To scale the file by 75%, the syntax is

\scalebox{0.75}{
\includegraphics{file.eps}
}

7.2 The figure Environment

It is often useful in a document to place graphics in a figure with a descriptive caption and a number to reference in the text. These tasks are handled with the LATEX figure environment.

\begin{figure}
\centering

\includegraphics{file.eps}

\caption{A brief description of the figure goes here.}
\label{myfigure}

\end{figure}
TeXnicCenter provides a figure shortcut button ( \scalebox{0.7}{\includegraphics{figure.eps}}) that gives you an Insert Figure window which saves you the trouble of typing the commands. It gives you a file browser so that you don't have to type in the full path to the graphics file.

Once you have defined a figure and given it a label, you can refer to it using its label with the \ref command.

For example, here is some text in which I refer to Figure \ref{myfigure}.
LATEX will automatically number the figures in your document and replace the \ref{myfigure} statement with the appropriate figure number in the typeset document.

7.3 Graphics Exercises

  1. Use Inkscape to create a diagram. Save it in Encapsulated Postscript (.eps) format. Note: Encapsulated Postscript is not a vector graphics format, so Inkscape cannot edit .eps files! If you want to be able to open your diagram in Inkscape for later modification, also save it in .svg format! Put your diagram into a figure with a caption and a label. Refer to your figure with a \ref command in some text. Experiment with the \scalebox command.

  2. Use Excel to graph some data. Select the chart by clicking on the border, and copy it. Paste it into Microsoft Paint. Reduce the size of the canvas (the white rectangle in the background) to fit the chart using the handle on the lower right corner. Save it as a png file. Then, open it in Inkscape and save it as an eps file. (Sorry. Inkscape doesn't support pasting from the clipboard, and Paint doesn't support the eps format.) Make a figure out of it.

next up previous
Next: 8 Bibliographic Citations/References Up: PHYS408W : LATEX Guide Previous: 6 Typesetting Mathematics

Copyright © 2006-2009, Lewis A. Riley Updated Wed Jan 14 22:58:50 2009