Free Online Introduction To Latex Part 2
Free Online Introduction To Latex Part 2
Free Online Introduction To Latex Part 2
Dr John D. Lees-Miller
December 2, 2017
Outline
\title{The Title}
\author{A. Author}
The Title
\date{\today} A. Author
December 2, 2017
\begin{document} Abstract
\begin{abstract}
Abstract goes here...
\end{abstract}
\end{document}
Sections
I Just use \section and \subsection.
I Can you guess what \section* and \subsection* do?
\documentclass{article}
\begin{document}
\section{Introduction} 1 Introduction
The problem of . . .
The problem of \ldots
2 Method
\section{Method}
We investigate . . .
\section{Results}
\section{Conclusion}
\end{document}
Labels and Cross-References
I Use \label and \ref for automatic numbering.
I The amsmath package provides \eqref for referencing equations.
\documentclass{article}
\usepackage{amsmath} % for \eqref
\begin{document}
\section{Introduction}
\label{sec:intro}
1 Introduction
In Section 2, we . . .
In Section \ref{sec:method}, we \ldots
2 Method
eiπ + 1 = 0 (1)
\label{sec:method}
\begin{equation}
\label{eq:euler}
e^{i\pi} + 1 = 0
\end{equation}
\end{document}
Structured Documents Exercise
1
Typeset this short paper in LATEX:
Make your paper look like this one. Use \ref and \eqref to avoid
explicitly writing section and equation numbers into the text.
1
From http://pdos.csail.mit.edu/scigen/, a random paper generator.
Outline
\includegraphics[
width=0.5\textwidth]{gerbil}
\includegraphics[
width=0.3\textwidth,
angle=270]{gerbil}
makes the text bigger (12pt) and puts it into two columns.
I Where do you find out about these? See the slides at the end
of this presentation for links to more information.
Floats
I Allow LATEX to decide where the figure will go (it can “float”).
I You can also give the figure a caption, which can be
referenced with \ref.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering Figure 1: Aww. . . .
\includegraphics[%
Figure 1 shows . . .
width=0.5\textwidth]{gerbil}
\caption{\label{fig:gerbil}Aww\ldots.}
\end{figure}
\end{document}
@InProceedings{Brooks1997Methodology,
author = {Fredrick P. Brooks and John Kubiatowicz and
Christos Papadimitriou},
title = {A Methodology for the Study of the
Location-Identity Split},
booktitle = {Proceedings of OOPSLA},
Month = jun,
Year = 1997}
I Each entry in the .bib file has a key that you can use to
reference it in the document. For example,
Jacobson1999Towards is the key for this article:
@Article{Jacobson1999Towards,
author = {Van Jacobson},
...
}
I It’s a good idea to use a key based on the name, year and title.
I LATEX can automatically format your in-text citations and
generate a list of references; it knows most standard styles,
and you can design your own.
bibTEX 3
I Use the natbib package2 with \citet and \citep.
I Reference \bibliography at the end, and specify a
\bibliographystyle.
\documentclass{article}
\usepackage{natbib}
\begin{document}
Brooks et al. [1997] show that . . . . Clearly, all odd numbers are prime
[Jacobson, 1999].
\citet{Brooks1997Methodology}
References
show that \ldots. Clearly, Fredrick P. Brooks, John Kubiatowicz, and Christos Papadimitriou. A method-
ology for the study of the location-identity split. In Proceedings of OOPSLA,
all odd numbers are prime June 1997.
Van Jacobson. Towards the analysis of massive multiplayer online role-playing
\citep{Jacobson1999Towards}. games. Journal of Ubiquitous Information, 6:75–83, June 1999.
\bibliography{bib-example}
% if `bib-example' is the name of
% your bib file
\bibliographystyle{plainnat}
% try changing to abbrvnat
\end{document}
2
There is a new package with more features named biblatex but most of
the articles templates still use natbib.
Exercise: Putting it All Together