Cookies

We use cookies to ensure that we give you the best experience on our website. You can change your cookie settings at any time. Otherwise, we'll assume you're OK to continue.

Department of Mathematical Sciences

LaTeX sample

The file below is a simple example explaining how many of the basic LaTeX things work. If you want to play with it on your own computer, you can download it as a LaTeX source file latex_sample.tex (also download the lion.png image). If all is installed correctly, you should be able to produce the latex_sample.pdf file from it.

\documentclass[11pt]{report}


% To set margin width, text height, space for footnotes and all sorts
% of other settings related to the geometry of the pages in your
% report, use the 'geometry' package.
%
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=geometry

\usepackage[margin=2cm]{geometry}


% For inclusion of figures, use the 'graphicx' package. This allows
% you to later include a figure using '\includegraphics{filename}' and
% it will also for simple sizing of the figure in your text.
%
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=graphicx

\usepackage{graphicx}


% You may want to add hyperlinks to your document, which can be tricky
% to typeset because they often have weird symbols in them which LaTeX
% interprets in its own way. Use 'hyperref' for this. It also has many
% options to add e.g. a list of thumbnails to your pdf file.
%
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=hyperref

\usepackage[colorlinks=true]{hyperref}



% Finally, for various useful tools for mathematics typesetting, use
% the 'amsmath' package with a few assorted companion packages which
% provide extra symbols.
%
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=amsmath
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=amssymb

\usepackage{amsmath}
\usepackage{amssymb}

% For figure/table caption settings.

%\usepackage{varwidth}
%\usepackage[noonelinecaption=true]{caption}



\begin{document}

% The 'article' document class provides a simple way to make a title
% page:

\title{A report}
\author{Someone}
\maketitle

% A table of contents can be generated automatically as well:

\tableofcontents


% Now comes the true content.

\chapter{A chapter on something}
\label{c:intro}
\section{A section}
\subsection{A sub-section}

Some text here. You can \emph{emphasise it} or {\bfseries make it
  bold-face} or {\large larger} or \emph{\bfseries\large combine those
  settings}. A random equation:
\begin{equation}
\label{e:Einstein1}
E=mc^2 \,.
\end{equation}
If you want to align equations, use either {\tt align} or {\tt
  aligned}. See the examples below. The difference is the way in which
the equation numbers are added. Here is the option with the two
equations receiving only one number:
\begin{equation}
\label{e:Einstein2}
\begin{aligned}
E &= mc^2  \\
i\hbar \frac{\partial}{\partial t} |\psi, t\rangle
  &= \hat{H} |\psi,t\rangle\,,
\end{aligned}
\end{equation}
and here is the one where every equation gets its own number:
\begin{align}
\label{e:Einstein3}
E &= mc^2  \\
\label{e:Schroedinger}
i\hbar \frac{\partial}{\partial t} |\psi, t\rangle
  &= \hat{H} |\psi,t\rangle\,,
\end{align}

\chapter{Another chapter}
\section{Again a section}

You can cite any paper or book which is in your bibliography list
(see below). Papers everyone should read are~\cite{Einstein:1935rr}
and \cite{Feynman:1948ur}.

You can refer to equations, such as~\eqref{e:Einstein3}, or to
chapters, such as~\ref{c:intro}, or figures, such as figure~\ref{f:lion}.

\begin{figure}[h]
\begin{center}
\includegraphics[width=.3\textwidth]{lion.png}
\end{center}
\caption{This is the lion which is the \TeX{} mascotte.\label{f:lion}}
\end{figure}


And here is a link to a web page: \url{http://www.google.com}.




% Finally the bibliography. You can cut and paste these entries
% straight from e.g. the inSpire database at http://inspirehep.net 
% (select one of the 'LaTeX' output options) or many other maths
% databases. % % A better but more complicated way to do references is to use BiBTeX. \begin{thebibliography}{50} \bibitem{Einstein:1935rr} A.~Einstein, B.~Podolsky and N.~Rosen, ``Can quantum mechanical description of physical reality be considered complete?,'' Phys.\ Rev.\ {\bf 47} (1935) 777. %%CITATION = PHRVA,47,777;%% %\cite{Feynman:1948ur} \bibitem{Feynman:1948ur} R.~P.~Feynman, ``Space-time approach to nonrelativistic quantum mechanics,'' Rev.\ Mod.\ Phys.\ {\bf 20} (1948) 367. %%CITATION = RMPHA,20,367;%% \end{thebibliography} \end{document}