Basic LaTeX: Difference between revisions

From Advanced Labs Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[2013 | Back to 2013 Main Page]]
[[2013 | Back to 2013 Main Page]]
[[2012 | Back to 2012 Main Page]]
[[2012 | Back to 2012 Main Page]]



Revision as of 03:36, 28 January 2013

Back to 2013 Main Page

Back to 2012 Main Page

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.

Example "report.tex"

You'll need to have this figure in the same directory as the text below. media:Apparatus.pdf

%
% 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

%For figures.
\usepackage{graphicx}

%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}

Describe the phenomenon being measured and any historical info. This should not contain much information 
about what you did in the experiment-- just roundly what you aim to do. The intro is mainly useful background.

In order to make another paragraph, leave a space between this and the previous paragraph. If you refer to a 
previous work on the subject, you'll want to cite it like this \cite{Erdos01}. Note the citation goes inside the 
sentence. See the end of the documentary for the bibliography specification along with the tag ``Erdos01".

\section{Experiment}

Describe the experiment setup and procedure, including apparatus etc.

\subsection{Apparatus}

The apparatus is was incredibly complicated and impossible to describe in just words. See Figure \ref{apparatus}. 
See the label mark-up in the apparatus figure specification. ALWAYS use the ref/label pairs instead of putting
in an absolute reference like ``Figure 1". This way if you move figures, then the numbering through out the text
automatically adjusts.

%A figure (need graphicx package -- see preamble). See also ``wrapfigure" -- a useful package for saving space.
\begin{figure}[t] % the [t] says to put it at the top of the page (if possible)
\begin{center} % center the figure
\includegraphics[width=9cm]{apparatus}
\caption{\small Apparatus.}
\label{apparatus} %this is so you can refer to the figure with a '\ref' markup.
\end{center}
\end{figure}

\subsection{Procedure}

We came up with a particularly clever way to carry out the experiment. It consisted in 

\begin{itemize}
\item doing this,
\item doing that,
\item and finally doing that other thing.
\end{itemize}

\section{Analysis}

Describe the model that you used to fit the data. Discuss the goodness of the fit and, if the fit was good, 
the derived model parameters and errors. Here is the model for this experiment
\begin{equation}
m(x; a,b) = ax + b
\label{model}
\end{equation}
This is obviously a simple model. The slope in Equation \ref{model} represents an important physical
quantity.

If you refer to a particular analysis technique that you don't describe fully, then it's important to give a 
reference \cite{ConcreteMath}.

\section{Discussion}

Interpret your results and discuss what may have gone wrong if, e.g., the fit in the Data Analysis section was not good.
You probably don't need any subsections in this section

\begin{table}[h]
\begin{center}
\begin{tabular}{| r | c | c | c | c | c |}
\hline 
Material & Category & n & $\tan\delta$ & $\kappa$ & Applications\\ 
         &          &   & ($\times 10^{4}$) & $W /(cm K)$ &  \\ \hline \hline
Polypropylene & Polymer & 1.5 & 5-7 & 0.001-0.002 & MM Filter, ND Filter \\ \hline
Mylar & Polymer & 1.8 & 100 & 0.001 & MM Filter \\ \hline
PTFE & Polymer & 1.40-1.45 & 3-6 & 0.002-0.003 & Anti-reflection, ND Filter\\ \hline
\hline
\end{tabular}
\caption{\small Index of refraction, n; loss tangent, $\tan\delta$; and thermal conductivity, $\kappa$, for selected materials.}
\label{materials}
\end{center}
\end{table}


\section{Conclusion}

A short section where you summarize the paper.

\begin{thebibliography}{9}

\bibitem{Erdos01} P. Erd\H os, \emph{A selection of problems and
results in combinatorics}, Recent trends in combinatorics (Matrahaza,
1995), Cambridge Univ. Press, Cambridge, 2001, pp. 1--6.

\bibitem{ConcreteMath}
R.L. Graham, D.E. Knuth, and O. Patashnik, \emph{Concrete
mathematics}, Addison-Wesley, Reading, MA, 1989.

\end{thebibliography}

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