Modifying Attributes of a Figure in LaTeX

Figures in Latex are inserted using the figure environment. That is, a figure can be added using the following code, as explained in the article on how to insert figures in LaTeX.

\begin{figure}
\includegraphics{myimage}
\end{figure}

However, it is frequently necessary to modify the attributes of an image once it is inserted in a document. Examples of such changes are modifying the height of an image, or stretching the image to be contained exactly on a specific area of the page. Other common modifications to an image in a LaTeX document include cropping and rotating it.

The Include Graphics Command

All these operations can be performed just by using the includegraphics command. With includegraphics, one can add parameters that will determine how to perform operations such as rotate, stretch, or crop.

To give an example, let us try to change the height of a figure. First, one needs to have the proper command to include the unmodified picture:

\includegraphics{myimage}

It is not really necessary to add the extension of the figure (eps, jpg, or gif), since the TeX command will try to locate the figure with one of these extensions and display it correctly.

The next step is to add a parameter to determine the right of the resulting figure. In this case, suppose we want the hight to be 3 inches:

\includegraphics[height=3in]{myimage}

In Latex, optional parameters are added within square brackets. In this case, the parameter is just defining the height of the resulting image. We can also combine parameters as in the following example:

includegraphics[height=3in,width=5in]{myimage}

In this way, we can define several properties of the resulting image in the same line.

Here is a list of the most used parameters that can be passed to includegraphics.

Article created on 2009-01-03 22:13:05

Post a comment