IT Services

An Introduction to LaTeX

LaTeX is a way of writing documents that is more like writing a program
than using Word. You write the "source code" using a text editor
(Notepad or Word will do) then you "compile" it. You can get "front-ends"
of various complexity to help you, but I'll concentrate on the basics
here without depending on particular operating systems or extra programs.

So why use LaTeX What are the pros and cons?

Free! On Macs, PCs, Linux, etc.

Source files are small and easily transferable. You can see how effects are
achieved. Tricks can be passed on.

LaTeX was designed with technical reports very much in mind. It encourages (almost insists on) structured writing and the separation of style from content. This is not the way that many people (especially non-programmers) are used to working.

Not good at graphics, layouts

Without a WYSIWYG front end, it's not always easy to find out how to do things.

Nowadays I usually use pdflatex rather than latex to
process files to produce PDF directly.

As you write bigger files you'll need more commands. If you're writing
an essay you might not need to know many more: \textit{...} does italics, \includegraphics{filename.jpg} includes graphics (you need \usepackage{graphicx} to make it work), \tableofcontents adds a table of contents. I suggest you look up features as you go along using the resources mentioned below.

kile is installed on our linux terminals. You still need to type LaTeX code, but Kile has many facilities (templates, wizards, etc) to make it easier - see a screen dump. proTeXt (for Windows) and Scientific Workplace (for Windows - it isn't free) work the same way

lyx is a WYSIWYG front-end for LaTeX that's getting better all the time. It's installed on our linux servers - see a screen dump

Overleaf lets you write LaTeX docs and work collaboratively without needing to install anything.

LaTeX is good at maths, automated numbering, and enforcing stylistic uniformity. The following
example shows how various types of cross-referencing can be easily maintained.

\documentclass{article}
% It's fairly common to use a sans-serif font for headings
% The following line, if uncommented, does this using a package
% \usepackage{sfheaders}
% If you don't have the package on your machine, download it
% from http://www.ctan.org/tex-archive/macros/latex/contrib/sfheaders/
% If you want table numbers to be reset in each section, use the next 2 lines
\usepackage{chngcntr}
\counterwithin{table}{section}
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
% The first time you process this document you'll need to process it
% twice to make the references work.
\usepackage{times}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\section{One}
This document has no tables or figures, but it has the captions for them.
Later you might be interested in table \ref{TABLEB} or in a footnote\footnote{some small print}
\begin{table}[htbp]
\caption{\label{TABLEA}A table}
\end{table}
\section{Two}
Now for some maths
\begin{equation}
x=y\sum_{i=0}^\infty\sin(i)\label{SIN}
\end{equation}
\subsection{Detail}
We'd better go into detail now
\begin{figure}[htbp]
\caption{\label{FIGA}A figure}
\end{figure}
\subsubsection{More detail}
\begin{table}[htbp]
\caption{\label{TABLEB}Another table}
\end{table}
Earlier in equation \ref{SIN} we set x to a value.
\end{document}

Running pdflatex on this twice will produce this PDF file. Then if you have latex2html installed you can type "latex2htmlfilename" to produce a tree of WWW pages.