Brendan's LaTeX Notes Page

This is where I keep a list of some common and less common LaTeX tricks that I can copy/paste from rather than trying to remember how I did it last time.

Insert an image

\includegraphics[width=2in]{6point3_contour_x1_s}

Wrap an image inside a LaTeX figure for referencing in the text

\begin{figure}[htb!]
\begin{center}
\includegraphics[width=2in]{6point3_contour_x1_s}
\end{center}
\caption{My contour plot for variable $x_1$}
\label{fig:contour_x1}
\end{figure}

Refer to an image (or anything else you label such as sections, chapters, tables, etc.) in the text

See Figure~\ref{fig:contour_x1}

Insert an array of images

$\begin{array}{c@{\hspace{.1in}}c@{\hspace{.1in}}c}
\includegraphics[width=2in]{6point3_contour_x3_s}  &  
\includegraphics[width=2in]{6point3_contour_x2_s} &
\includegraphics[width=2in]{6point3_contour_x1_s}   \\
\end{array}$

Show computer code in protected format (verbatim)

\begin{verbatim}
> eigen(B)$values
[1] -0.8184859 -2.3399197 -3.2829737
\end{verbatim}

Converting images offline to the necessary eps and pdf formats

I use the Unix ImageMagick utility from the command line to do this, but there are similar programs available for other platforms.

convert noiseE145.jpg noiseE145.eps
convert noiseE145.jpg noiseE145.pdf

Clipping an image to fit where you want it

I find I need to do this when I'm generating PDF files since the PDF images I use in the documents often have a lot of whitespace padding in them, depending on how they were generated (e.g. straight from a Matlab figure, using the convert utility above, etc). So I use Ghostview to measure the X and Y pixel coordinates of the lower left and upper right corners and set that to be the bounding box of the graphic in LaTeX. There are multiple ways to do this but I use the following format
viewport=lowerLeftX lowerLeftY upperRightX upperRightY
For example
\includegraphics[viewport=154 352 452 434, width=3in, clip]{6point3_contour_x3_s} 

Insert a blank number line

This gives a basic number line from -10 to 10.

\begin{center}
\begin{picture}(21,2)(-10,0)
\numbline[1]{-10}{11}
\end{picture} 
\end{center}

Shade an interval within the number line

The inequality symbols (<, >) specify that the interval goes to the end of the numberline. The curved brackets () specify open end points, where closed brackets [] indicate closed endpoints.
\interval<-10,-2)
\interval(2,10>

Maintained by Brendan Hogan, comments or questions: bph4r@virginia.edu
Last Modified: Thursday, 10-Apr-2008 00:07:47 EDT