
LATEX Fergus Toolan Intelligent Information Retrieval Group University College Dublin
What is Latex? • Latex appeared in 1982 as an extension to TeX. • TeX was created in 1978 by Donald Knuth (The Art of Computer Programming) • It is a typesetting language. • Especially good for Mathematical documents.
Components • Latex file: This is where you write your Latex commands and the document text. Use a .tex extension. • DVI file: The file generated when the .tex file is compiled. (DeVice independent) • EPS: Encapsulated Postscript used for graphics. • PDF: Portable Document Format.
Latex Commands • \command_name{parameter list} • Some include • \textbf{Hello World} • \emph{Hello World} • \cite{toolan2003} • \\ • \title{Latex Guide}
Beginning a document \documentclass[times,10pt,twocolumn]{article} • This gives us a document using Times new Roman in 10pt font. • The document contains two columns • It is of class article – others include book, report (used for a thesis – or final year report)
Packages • Like programming languages Latex imports alot of extra functionality. • To do this: \usepackage{package_name} • The only one you are likely to need is graphicx • \usepackage{graphicx}
Beginning the document • Now we are ready to begin the document properly. • \begin{document} • Like blocks of code in programming a begin directive must be followed by an end directive. • At the end so put \end{document}
The Title \title{Essay Title} \author{Fergus Toolan \\ Student No: 12345678 \\ Login ID: s00bfxxx \\ Email: fergus.toolan@ucd.ie } \maketitle
Comments in Latex • Like all programming languages sometimes comments are essential. • The % is the comment character • Anything appearing after % is ignored by Latex. • %----------------------- often used to divide sections for human readers.
% in Latex • % is the comment character but what happens if we wish to print a % sign. • It must be escaped. • To escape a character in latex use \ (like Java) • So to print a % the latex command is \%
The Abstract • the abstract is standard in all scientific papers and reports. It is a brief (< 100 words) synopsis of the paper. • To write an abstract: \begin{abstract} text goes here \end{abstract}
Sections • Sections provide some form of organisation for a report. • \section{Introduction} • Subsections • \subsection{Name of Subsection}
Formatting • Paragraphs. • Hitting the return key twice will begin a new paragraph EG: This is paragraph 1. This is paragraph 2.
Formatting • Newlines • \\ gives a new line. However this must occur on a line with some text on it. Correct: We need a new line \\ Incorrect: We need a new line \\
Formatting • Fonts: • \emph{text} emphasis i.e. italics • \textbf{text} Bold Face. • It is considered very bad practice to use underlines in Latex documents. • This is a throwback to old manually typesetting.
Figures • When a figure – image, equation, algorithm etc appears it has a caption and a number. • \begin{figure} %Equation algorithm image etc.... \caption{\label{eg_fig}This is the eg figure} \end{figure}
Figures The previous example will appear as... Picture or equation appears here. Figure 1: This is the eg figure.
Figures • To refer to a figure in text use: As can be seen in Figure \ref{eg_fig} the values.... Hence Latex worries about the number not the person writing the document.
Graphics • \includegraphics{filename.eps} • Normally inside a figure. • Encapsulated Postscript format • convert orig_file new_file • Or can be created in PSP or Fireworks.
References • All scientific documents must contain references. \begin{thebibliography}[99] \bibitem{toolan2004} Toolan, F. ``A guide to Latex’’, 2004. \end{thebibliography}
References • To then refer to the reference we use the following. In the guide to latex \cite{toolan2004} Toolan stated that.... It is essential to reference correctly.
Compiling • To generate a PDF file use the following commands • latex file.tex • latex file.tex (must do this twice) • xdvi file.dvi (will view the dvi file.) • dvipdf file.dvi (will create the PDF file) • xpdf file.pdf (to view the PDF file)