Aravind's Tutorials

Home
Projects
Research
Publications
Astrophotography
Photography
Tutorials
Reviews
Links
CV

My Images
Blog

Picture of the picosecond
Picture of the picosecond


Laying out your document for pdflatex


pdflatex is a very useful tool for generating Adobe PDFs from a LaTeX document. In this tutorial I will show some of the most frequently used and useful layout specifications in LaTeX that will allow you to generate nice looking documents.

I have tested this in many versions of pdflatex on a variety of unix and linux platforms in addition to the pdflatex in MikTex.
The most important aspects that determine the layout of your document come at the very begining of the document.

The first thing you should set is the document class
\documentclass[9pt]{report}
There are several options for document classes including, report, article, and book. In addition, many distributions come with lots of document classes. For examplet he siggraph class which creates a paper in siggraph style. There are also document classes for various types of books and theses.

If you want to use pdflatex, and want it autogenerate the links, you should include the pdflatex and hyperlink packages
\usepackage[pdftex,colorlinks]{hyperref}

The next important aspect is setting up margins, shown below
\setlength{\topmargin}{-0.4in}		% distance from top of page to begining of text
\setlength{\topskip}{0.3in}    		% between header and text
\setlength{\textheight}{9.0in} 		% height of main text
\setlength{\textwidth}{7in}    		% width of text
\setlength{\oddsidemargin}{-0.2in} 	% odd page left margin
\setlength{\evensidemargin}{-0.2in} 	% even page left margin
\setlength{\headheight}{15pt}
These margins can be specified in a variety of units and you should set these up depending on the document class you chose.


Double spacing is a common thing people who write reports for theses want to do. The line below will double space
\renewcommand{\baselinestretch}{2}
Note that if can change the amount of baseline stretch to values other than 2 (and to even real values like 1.5) to give precise control over the line spacing.


There is a useful package called fancyhdr which can be used to generate pleasing headers on the top of your document. This is useful for large reports and theses. Shown below is how to use this package
\usepackage{fancyhdr}
	.
	.
	.
% after title, TOC and list of figures
\pagestyle{fancy}



Graphics are important in many documents. There are three packages you need for graphics 'graphics' for the actual import of graphics and 'floatflt' and 'graphicx' which are used for laying out the graphics. Shown below is a sample of including graphics
\usepackage{graphics}
\usepackage{floatflt,graphicx}

	.
	.
	.

\begin{figure}[!ht]
\centerline{\includegraphics[scale=0.6]{picture.pdf}}
\caption{\emph{Caption for the graphic}}
\label{fig:label_name}
\end{figure}

Non-PDF formats are also supported, for example PNG is supported. The scale parameter scales the image before placement. the '!ht' directive tells pdflatex to try very hard to place the graphic at this location of your document. There are other directives that can tell pdflatex where to place the graphic, including a directive to put graphics on their own page. The label allows you to refer to this graphic with automatic numbering from anywhere in your document.


Tables are also very useful in documents, and LaTeX has support for tables. The code below shows how to setup a table
\begin{tabular}{lll}
 & Requirement & Status\\
 1	& Req A & Achieved \\
 2	& Req B & Achieved \\
 3	& Req C & Achieved \\
\end{tabular}



Ofcouse what is a LaTeX document without equations? There are two ways to use equations. One is to embed it with your text. This is done by putting '$' around the equations.
It must sum to one and it must be 0 whenever $p_i(X_{i,j}) 0.
The other is to place the equation in its own line and give it its own label. This is shown below.
\begin{equation}
\label{eqn:propagated}
L_p(x,\psi,\lambda) = \int_{in. \psi} p(x,\psi, \psi^\prime, \lambda) L_{in}(x,\psi^\prime,\lambda)\cos\theta_id\omega_i
\end{equation}
Personally, I like to describe what each of the elements in my equation mean in a table below the equation. Shown below is an example of this with an equation.
\begin{equation}
\label{eqn:rendering}
L_{out}(x,\psi,\lambda) = L_e(x,\psi,\lambda) + L_p(x,\psi,\lambda)
\end{equation}

\begin{tabular}{lll}
Where: & &\\
$L_r(x,\psi,\lambda)$		& $\rightarrow$ & The radiance leaving the point $x$ in direction $\psi$ at wavelength $\lambda$ \\
$L_e(x,\psi,\lambda)$		& $\rightarrow$ & The radiance emmitted by point $x$ in direction $\psi$ at wavelength $\lambda$ \\
$L_p(x,\psi,\lambda)$		& $\rightarrow$ & The radiance propagated by point $x$ in direction $\psi$ at wavelength $\lambda$
\end{tabular}



Below is a sample begining of a report including chapter and sections
\documentclass[9pt]{report}
\usepackage{graphics}				% for pictures
\usepackage{fancyhdr}				% for fancy headers on the top of pages
\usepackage[pdftex,colorlinks]{hyperref}
\usepackage{floatflt,graphicx}
\usepackage{code}

\thispagestyle{empty}
\setlength{\topmargin}{-0.4in}
\setlength{\topskip}{0.3in}    			% between header and text
\setlength{\textheight}{9.0in} 			% height of main text
\setlength{\textwidth}{7in}    			% width of text
\setlength{\oddsidemargin}{-0.2in} 		% odd page left margin
\setlength{\evensidemargin}{-0.2in} 		% even page left margin
\setlength{\headheight}{15pt}

%\renewcommand{\baselinestretch}{2}

\title{My Fancy Report}
\author{Aravind Krishnaswamy \\ University of Waterloo}

\begin{document}

\maketitle
\pagestyle{empty}
\tableofcontents
\listoffigures

\pagestyle{fancy}

\chapter{Overview}
This is an overview of my document

\chapter{First Chapter}
\label{chapter:intro}
Welcome to my first chapter.  There are some sections

\section{First section}
\label{sec:ch1:first}
Now I talk about stuff

\vspace{0.35cm}
Now I start another paragraph

\subsection{First subsection}
\label{sec:ch1:first:sub}

\chapter{Second Chapter}
\label{chapter:more}

\bibliographystyle{acm}
\bibliography{report}
\end{document}


Return to tutorial index


Hosted by theorem.ca

All text and images (c) 2000-2010 Aravind Krishnaswamy. All rights reserved.