This is intended to be quick guide to LaTeX, with only the most important features you may want to use for your lab reports. There are some much longer and better guides out there, for example, there is a very good Latex Wikibook

If you are familiar with html you will probably find the logic behind latex to be very similar and intuitive. If you've never written a webpage and your computing experience in mostly with Microsoft Office then at first it may seem strange, but trust me, once you get used to it, its a much better way of doing things!

Choose a compiler

There are many online compilers for LaTeX.

One which is very basic is

Two which have more features are or

They all seem to work pretty well, which one you choose will depend on whether you want to save your work online (then choose one of the latter two) or whether you want to prepare and save your work in a text editor and paste it in to the compiler to generate your pdf.

First things

When you begin writing a document in LaTeX there are a few things you need to set up at the start of your document.

The first is to define the document class. We will use the article document class which is suitable for writing a scientific article.

The first line of our file should thus be.


Actually this is also the place where need to define a couple of characteristics of the document. For example as we are in the US we will probably want our document to be on letter sized paper, and we may also want to choose the font size used for the body of the document, for example, if we want 12 pt text and letter sized paper we write


We may also need to use some LaTeX packages which add some additional capabilities to the basic ones that come with LaTeX. One you will almost certainly need is the graphicx package, if you don't load this package then you won't be able to include any figures. One I also often use, because the default LaTeX margins are quite big, is fullpage, which will give you smaller margins. So I usually follow the documentclass command by


If you want even smaller margins you can replace




Beginning and Ending

Once you have everything you need in your preamble you are ready to begin the document. You do this by writing


In LaTeX, whenever you begin an environment, in this case the document, you need to end it. So the last line of your file should be


It's usually a good idea to put that in right at the beginning so you don't forget!

Top Matter

Your report should have your name and a title for the report.

These go in to what is called the top matter and are followed by the command \maketitle in the following way

\title{My lab Report}
\author{Your Name}


Your article needs an abstract.

After the \maketitle command you should put an abstract by writing

Your abstract text summarizing your report.


Now you are in the document proper LaTeX is very good at organizing your document, using sections, subsections, subsubsections etc.

For example

Some Text
\subsection{A sub-section to the introduction}
Some Text
\subsection{A 2nd sub-section to the introduction}
Some Text
\Section{Apparatus and Procedure}


Any figure you wish to include should be in either .pdf, .png or .jpg format. Other file formats will not work! You'll need to upload the figure and put text into your document to include the figure.

To place a figure you need to begin and end a figure environment. Within this you need to use an includegraphics command to load the figure. You should also include a caption and a label to allow you to refer to the figure

\caption{Your caption text here}

To refer to the figure in the text you should write “Figure \ref{myfigure}.” and LaTeX automatically organizes the numbering correctly. (You usually have to run it twice for it to get it right.)

You will probably want to define some options. For example, if you want the figure to appear close to where you put the command then you start with \begin{figure}[h], if you want it to be close to the top of the page then you start with \begin{figure}[t] and near the bottom \begin{figure}[b]. However, the philosophy of LaTeX is to let the software decide where the figure should be don't be surprised if it doesn't end up exactly where you expect.

You have more control over the size of your figure. You define this as an option for the \includegraphics command for example if I want my figure to be 10cm wide I say \includegraphics[width=10cm]{picture.png}

If I want my figure to be centered in the page I should add a center environment around the figure, which I would do like this,

\caption{Your caption text here}


There are two ways to include math in LatTeX. Inline math should be enclosed by 2 $ signs.

If you want to make a numbered equation you should type

\begin{equation}\\ The LaTeX for your equation\\ \end{equation}

Probably the best way to learn the syntax for writing LaTeX math is to take a look at the equations on this website, they are all generated from LaTeX syntax. If you double click on any equation on this page you will see the LaTeX code used to generate it. (Feel free to copy!)


Tables are often a great way to present data. The latex environment for tables is called tabular, so to start a table I write \begin{tabular}. I need to tell latex at this time how many columns I want, how I want the text to be aligned in each column and whether I want vertical lines or not.

\begin{tabular}{ l c r } begins a 3 column table with the three columns having left, center and right justified text. If I want vertical lines I would write \begin{tabular}{| l | c | r |}

Horizontal lines need to be added using a \hline command wherever I want a horizontal line.

Oh, and of course we need some data.

Each row of data should have the data to go each in each cell separated by & and ending with a new line command \\

and as usual you need to end the table with \end{tabular}

See the wikibook for more details on tables and some examples!


One of the best things about LaTeX is the way it deals with references.

To add references in your document you need to add a bibliography right before the end of the document. To start the bibliography you say


Your references go as items in the place of .. using the \bibitem command. With the bibitem command you give a label to your reference

for example


Giancoli, Physics for Scientists and Engineers, 4th Edition

Stony Brook PHY141 course webpage,


then when you want to cite the textbook in your report you would just write \cite{textbook} or for the coursepage you would write \cite{webpage}. LaTeX takes care of all the numbering!

Putting it all together

Download this template illustrating the above. Feel free to use it as a starting point and adapt as necessary! You will also need to download the included figure and upload it to your compiler for it to appear in your generated .pdf file

phy141/labs/latex.txt · Last modified: 2011/10/07 09:54 by mdawber
CC Attribution-Noncommercial-Share Alike 3.0 Unported
Driven by DokuWiki