# Sample of Frequently Used LaTeX Items

#### Introduction

I use LaTeX to write any documents that require the display of mathematics. In fact, since I will be writing my thesis in LaTeX, I am creating experiment summaries and analysis notes with it. Since I use some options very often it was worthwhile to create a simple template document. The template is the starting point for anything I write and is now available as a sample LaTeX document for download. The included pdf has examples of the following and links to original sources:

• Defining Shortcut Commands for Frequently Used Symbols or Environments
• Placing Clickable Web Links in PDF Output (hyperref package)
• Creating Tables that Span Multiple Pages (longtable package)
• Images Placed in Horizontal Alignment

The available download is a zip file with the .tex source and the resultant .pdf from my processing. To keep the zip file as small as possible, it does not include the images that are present in the pdf. That means you will receive errors if you try to compile the source immediately after download. Simply comment out the figure placement commands or rename them to images already on your computer in order to compile.

The image below displays the side-by-side images and longtable usage.

Partial screenshot of the LaTex sample document.

The LaTeX source code may be browsed online at the final page of this item (see article index). A comment form is available at the end of that page, and I welcome any input.

#### LaTeX Source Display

Below is the source of the LaTeX file that is included in the download. If you are curious about these commands, then you can simply copy-paste them into a document of your own. The pdf is only available in the download, so if you want to see the final output then downloading is necessary.

%using 11pt for font size may significantly reduce number of pages
\documentclass[12pt]{article}

%set line spacing of document
\usepackage{setspace} \onehalfspacing %\doublespacing

%various margin changes to optimize page usage
\setlength{\textheight}{9.truein}
\setlength{\textwidth}{7.0truein}
\setlength{\oddsidemargin}{-20pt}
\setlength{\topmargin}{-60pt}

\usepackage{graphicx, color}
\usepackage{amssymb, amsmath}
\usepackage{epstopdf,ulem}
\usepackage{subfigure}
\usepackage{palatino,longtable}
\usepackage{enumitem,cancel}

%set directory from which images will be taken (example of relative and absolute directory) \graphicspath{{images/},{/Users/example/path/absolute/}}

%set shortcut commands for commonly used items
\newcommand{\curl}{\vec{\nabla}\times} %curl, nabla times something
\newcommand{\dive}{\vec{\nabla}\cdot} %divergence, nabla dot something
\newcommand{\Jb}{\vec{J}_{b}}
\newcommand{\Kb}{\vec{K}_{b}}
\newcommand{\bea}{\begin{eqnarray}} % begin eqnarray
\newcommand{\eea}{\end{eqnarray}}
\newcommand{\lp}{\left(} % resized parentheses
\newcommand{\rp}{\right)}
\newcommand{\een}{\end{enumerate}}
\newcommand{\nn}{\nonumber} %skip numbering on line space in equation array
\newcommand{\alf}{Alfv$\acute{\text{e}}$n} %plasma people use Alfven a lot

%set appearance of enumerated lists
\def\theenumi{\alph{enumi}} \def\labelenumi{\bf \theenumi .}
%\def\theenumii{\alph{enumii}} %for lower level nested lists
%\def\labelenumii{\bf (\theenumii)}

%document information, printing is controlled after document environment is begun
\title{Sample \LaTeX ~Document} % use ~ to force a space
\author{David Pace} \date{\today} %use \date{} to suppress date printing

\begin{document}
\maketitle
\abstract{This document is intended to provide a sample of the \LaTeX ~options that I use most frequently. If you already have \LaTeX ~working on your computer, then this sample document may prove useful.}

\section{Introduction}
This document has been compiled with TeXShop (2.10 beta 9) on Mac OS X. While I wrote this sample, I used examples from the following websites to eventually find the layout I wanted. Some of the web pages no longer exist, so here are the ones still available as of today.

\ben
\item TeXShop: \url{http://www.uoregon.edu/~koch/texshop/index.html}
\item Example of the longtable package: \url{http://users.sdsc.edu/~ssmallen/latex/longtable.html}
\item hyperref, placing clickable weblinks in PDF output (and much more): \url{http://www.tug.org/applications/hyperref/manual.html}
\item Very helpful coverage of indexes and Bibtex usage (even though I’m not covering that here): \url{http://web.image.ufl.edu/help/latex/}
\item My website, the source of this document: \url{http://www.davidpace.com}
\een

\section{Text} Not so much text examples, as these are math shortcut examples. All of my equation sets are placed in the equation array environment and the following equation set uses some of the shorthand notation defined in the document’s preamble.

\bea
\dive \vec{B} \e 0 \label{eq:dive} \\ \nn \\
\left| \vec{P}(x) \right| \e \left\{ \begin{array}{lr} 0 & \text{for} \; x \leq 9 \\ \\
27 & \text{for} x > 9 \end{array}\right. \label{eq:multi} \\ \label{eq:empty} \\
a &\approx& b \label{eq:approx}
\eea

where these are all simple expressions because there are a lot of resources available for learning how to typeset math.   The equation array example illustrates the following,
\ben
\item Use of shorthand notation in the divergence line in \eqref{eq:dive}.
\item Large bracket with multiple lines in \eqref{eq:multi}.
\item Numbering of empty line in \eqref{eq:empty}.
\item Use of an alignment character other than the predefined equal sign in \eqref{eq:approx}.
\een
and the above list demonstrated the enumerate environment with the defined lower case alphabet listing.

\section{Images}
\subsection{Single Image}
Getting things started with an introductory paragraph.   The second paragraph is indented.   At this point a reference is made to figure \ref{fig:single}, to point out that it is a single image with resizing performed in the document processing.
\begin{figure}[!h] % !h forces image to be placed “here”
\centering
\includegraphics[width=4.8in]{farge06noiseCompare} %figure name does not need extension if unique \caption{\small Noisy Signal} \label{fig:single}
\end{figure}

\subsection{Side-by-Side Images}
Figure \ref{fig:sides} displays two images next to each other in a horizontal alignment. It is possible to adjust the sizes as necessary, though if you set the sizes too large, then the images will be displayed vertically.   It is also possible to reference figures \ref{fig:sides:a} and \ref{fig:sides:b} separately.

%figures side-by-side, adjust each image size and the \hspace between them to optimize appearance. %images of about 3.1in with hspace of zero is just about the largest possible while keeping them
%in a side-by-side display
\begin{figure}[!h]
\centering
\subfigure[Small Logo] % caption for subfigure a
{ \label{fig:sides:a} \includegraphics[width=1.25in]{pace144} }
\hspace{1.9in}
\subfigure[Large Plasma Device] % caption for subfigure b { \label{fig:sides:b} \includegraphics[width=3.1in]{thesisRun10} }
\caption{\small It is also possible to place a caption here and leave the individual captions blank. The (a) and (b) markers will still be printed and you can still reference them individually. }
% caption for the whole figure
\label{fig:sides}
\end{figure}

\section{Tables}
Table \ref{tab:long} will stretch across multiple pages if necessary.

\begin{longtable}[c]{p{1.2in}p{5.5in}} % p{} treats the input as paragraph text
\textbf{Name} & \textbf{Parameters and Notes} \\
\hline
Item 1 & The description is input just like writing a paragraph of normal text.   New paragraphs are not indented, however, so it is not exactly like writing body text.   After this entry is complete, double vertical spacing is forced in the table (see $\backslash\backslash ~\backslash\backslash$) \\ \\