next up previous
Next: Arrays of Figures Up: No Title Previous: No Title

Basics

The following figure was made in S and included in a LaTeX document using the \includegraphics facility in the new version of LaTeX, which is denoted LaTeX2e. The figure was made using the S postscript() function but could have been made with any application that produces an Encapsulated PostScript (EPS) file. In fact any PostScript file that includes a line beginning %%BoundingBox: may work.

  figure22
Figure: Scatterplot with regression line.

The LaTeX to include the figure was the following:

\begin{figure}[h]
  \centerfig{4.75 in}{new.ps}
  \caption[]{Scatterplot with regression line.}
\end{figure}

The argument ``4.75 in'' to \centerfig says that the figure is to be reduced or enlarged from its original size (whatever it was) to 4.75 inches in width. Any other length could be substituted. For example, specifying \textwidth would make the figure exactly the width of the text. The argument ``new.ps'' to \centerfig is the name of the file containing the PostScript for the plot.

The following macro definitions are needed at the top of the LaTeX file:

\newcommand{\centerfig}[2]{\centerline{\dofig{#1}{#2}}}
\newcommand{\dofig}[2]{\resizebox{#1}{!}{\includegraphics{#2}}}
As always, it is wise to use a macro so that all the figures can be changed by redefining the macro, in case you sometime have to use a system that hasn't been upgraded to LaTeX2e. The command \usepackage{graphics} must also appear in the preamble, between the \documentclass and \begin{document} commands.



Charles Geyer
Mon Mar 17 13:46:17 CST 1997