Basic LaTeX

From Advanced Labs Wiki
Jump to navigation Jump to search

This tutorial is a "getting started" document. The TAs will give a more in depth tutorial with realtime feedback etc in the third week, before the first reports are due.

LaTeX is a documentation system in which you specify content and, for the most part, you let the LaTeX system deal with the formatting. It's a bit like a mark-up language (e.g., Hyper Text, which is used to create web pages). The general procedure for creating a document with LaTeX is to create a file (call it report.tex) with the content and special markers indicating things like sections, tables, figures, mathematical symbols, etc, and then you process this with a LaTeX formatter. (Many times you have to run the formatter twice in order to resolve cross-references in the document). LaTeX formatting programs are available freely for Linux/Unix, Mac, and Windows operating systems.

Linux. Open a terminal and, in the directory with your report, execute "pdftex report.tex". This is usually enough to generate a report.pdf under Linux.

Mac. For OSX, I like TeXShop. It has a graphic interface. Under the "Typeset" menu, select "Pdflatex". You enter your "report.tex" in their editor window and press "typeset" in order to generate a pdf.

Windows. Several editors exists. We used WinEdt last year and this worked well.

Here is an annotated "report.tex" file that you can use as a template

% % LaTeX Example 1 for Advanced Lab % (Note the % sign denotes that the following text is a comment and will be ignored by the editor %

% Document class -- specify font size (11pt) and document type (article). This should work for all reports. \documentclass[11pt]{article}

% Packages augment basic latex. Here I use the geometry package to change the margins. \usepackage{geometry}  % give some flexibility to format \geometry{verbose,tmargin=1.00in,bmargin=1.00in,lmargin=1.0in,rmargin=1.0in} % needs the package geometry to work

%This marks the start \begin{document}

\title{Experiment X} \author{Tobias Marriage} \date{Febuary 1, 2011} \maketitle

\begin{abstract} In order to investigate Y about physical system Z, we carried out experiment X. A T apparatus was used to carry out the experiments. We measured some parameter to be 6 $\pm$ 5 J (J is units -- always remember units!). \end{abstract}

%This marker indicates a section heading \section{Introduction}

\section{Experiment} \subsection{Apparatus} \subsection{Procedure}

\section{Analysis}

\section{Discussion}

\section{Conclusion}

%Don't forget to end the document -- rookie mistake. \end{document}