# How to insert figures into LaTeX articles

A LaTeX version of this paper is available here . You might find it more useful, as it is a working file that can be compiled, and then edited to see what changing various bits and pieces does. The postscript that this file produces is here (1.2Mb).

## Inserting single figures into LaTeX articles

First off, you have to have some text in your file before you can include any diagrams without LaTeX complaining.

Then you can insert a picture with something like:

\begin{figure}[htp]
\centering
\includegraphics{erptsqfit}
\caption{Transverse momentum distributions}\label{fig:erptsqfit}
\end{figure}
• Fig.[fig:erptsqfit] is your basic picture. The [htp] command works like usual to tell LaTeX how to position the graphic in the text.
• The placement specifier p lets the figure take up a full page without waiting until the end of the chapter
• centering tells LaTeX to centre everything within the graphics environment.
• includegraphics is your basic command to include a graphics object. (The bits in [...]  shown below are various options that can be omitted. In the curly brackets is the name of the file you want included.) As you can see the extension of the graphics filename is omitted - LaTeX looks for this file with various possible extensions - .eps, .ps, ... (Note: LaTeX will look for filename.ps before filename.eps.)
• the most important option in [...] is the size. There are a few choices that are useful ...
[width=xxx cm], ... [height=xxx cm], etc.
A slightly more complicated version looks like the below example. This is used to select only a portion of your picture, and the part of the caption in square brackets is taken as the caption in a list of figures. This means that you can format the caption that appears with your figure differently to the way it will appear in the list of figures. Also, the figure caption will typically be longer, and more detailed than that which appears in the list of figures.
\begin{figure}[htp]
\centering
\includegraphics[totalheight=0.8\textheight,viewport=50 260 400 1000,clip]{erptsqfit}
\caption[Transverse momentum distributions - E-R model.]
{Transverse momentum distributions - E-R model fit (intercept 1.2).}\label{fig:erptsqfit}
\end{figure}

The most useful option to use, I find, is to set the width or height you want your picture scaled to to be some fraction of the textwidth or height, as is done in the above, where we have [totalheight=0.8\textheight], that is, the total height of the figure is set to 80\,\% of the height of the text on a normal page of typing.

The viewport command needs some fiddling with to get right - if you choose to use it at all (you need it for mathematica files as they are saved very very poorly as PS files). Basically it's the number of points to take off the top, left, bottom, right, in that order, I think. You just have to play around and see. The idea is, it takes this much space off all around the document, leaving only the inside bit that is what you want to see in your document. You need the clip'' command to force LaTeX to ignore the stuff outside the limits you specify by viewport''.

• The stuff in [...] in the caption command tells LaTeX what to put in the table of contents. Otherwise is just uses the stuff in the curly brackets if you omit [...]. The stuff in curly brackets is what appears as your figure caption.

## Multiple figures

Multiple figures can be inserted in this manner (where here I have just used the same figure several times). The \hfill command gives you a nice spacing between the figures.
\begin{figure}[htp]
\centering
\includegraphics[width=0.4\textwidth,viewport=50 260 400
1000,clip]{erptsqfit}
\hfill
\includegraphics[width=0.4\textwidth,viewport=50 260 400 1000,clip]{erptsqfit}\\
\includegraphics[width=0.4\textwidth,viewport=50 260 400
1000,clip]{erptsqfit}
\hfill
\includegraphics[width=0.4\textwidth,viewport=50 260 400 1000,clip]{erptsqfit}\\
\caption[Transverse momentum distributions - E-R model.]{Transverse momentum distributions - E-R model fit
(intercept 1.2).}\label{fig:erptsqfit}
\end{figure}

## Subfigures

However, sub-figures using the subfigure package in LaTeX is really the way to do this!! This package come with the standard distribution of LaTeX, is called using
\usepackage{subfigure}
in the document preamble (i.e. before the \begin{document} command).

A nice example of the use of this package to create a 2x2 figure is as follows

\begin{figure}%[htp]
\centering
\subfigure[Donnachie-Landshoff form factor model in Feynman gauge
(solid line) and in non-covariant gauge (dashed line). Here
$\Lambda=0.2\gev^2$ and $\intercept=1.08$.]{
\label{fig:dl2858}
\psfrag{ylabel}{$\frac{1}{\sigma}\frac{\rmd\sigma}{\rmd\ptsq}\gev^2$}
\psfrag{xlabel}{\small{$\ptsq\gev^2$}}
\includegraphics[width=.45\textwidth]{dlddlanalysis99fit2858loglin.eps}}
\hspace{.3in}
\subfigure[Ellis-Ross form factor model in Feynman gauge (solid
line) and in non-covariant gauge (dashed line). Here
$\Lambda=0.2\gev^2$ and $\intercept=1.08$.]{
\label{fig:er2858}
\psfrag{ylabel}{$\frac{1}{\sigma}\frac{\rmd\sigma}{\rmd\ptsq}\gev^2$}
\psfrag{xlabel}{\small{$\ptsq\gev^2$}}
\includegraphics[width=.45\textwidth]{erderanalysis99fit2858loglin.eps}}\\
\vspace{.3in}
%     \hspace{.1in}
\subfigure[Single-gluon exchange model (solid line) and Scalar
Pomeron exchange model (dashed line).]{
\label{fig:cminusscalar2858}
\psfrag{ylabel}{$\frac{1}{\sigma}\frac{\rmd\sigma}{\rmd\ptsq}\gev^2$}
\psfrag{xlabel}{\small{$\ptsq\gev^2$}}
\includegraphics[width=.45\textwidth]
{cminusscalaranalysis99fit2858loglin.eps}}
\subfigure[Two-gluon exchange model.]{
\label{fig:2glue2858}
\psfrag{ylabel}{$\frac{1}{\sigma}\frac{\rmd\sigma}{\rmd\ptsq}\gev^2$}
\psfrag{xlabel}{\small{$\ptsq\gev^2$}}
\includegraphics[width=.45\textwidth]{2glueanalysis99fit2858loglin.eps}}
\caption{Fit of pomeron models to Thrust Jet
after the turn-over of the curves. Curves correspond to
model fits, while solid points are H1 data. These plots
show the fits for several models for diffractive masses in
the region of $M_X=28.58\gev$. The statistical and
\end{figure}