A LTEX for Netsoc

Simon Dardis
dalamar@netsoc.tcd.ie

February 22, 2011

Setup

Login to Spoon or Cube, there will be small amounts of interactivity. You’ll probably want to be running screen or some NX client.

Overview

A LTEX is a typesetting language for reports, documents and presentations.

A LTEX is a macro package for TeX, a type setting language.

Getting started

Open your favourite editor (Nano, Vim, Emacs, ...) \documentclass{article} \begin{document} Hello World! \end{document}

Save as “test.tex” and run “pdflatex test.tex”. pdflatex will spit back a PDF of your document.

A LTEX distros

For your own home machine or laptop: A OS LTEX distro Windows MikTex Linux TeXLive OSX TeXShop (though macports)

A LTEXdocuments

Document classes describe the sort of document that TeX will produce and have different environments associated with them. Standard ones are article, report, book, letter. More unusual ones exist such as beamer for presentations.

We can pass options to the document class in braces ( [. . . ] ) like: \documentclass[11pt]{report} In that example we’re setting the text size to 11pt.

A LTEXdocuments

A LTEX expects each .tex file to start with either a comment (%) or a \documentclass{$CLASS}.

The “\begin{document}” and “\end{document}” delimit the contents of our document. We’ll repeatedly see the use of “\begin{$SOMETHING} . . . \end{$SOMETHING}” for various things. These are called environments.

Text

A For text, LTEX will effectively collapse all tabs and spaces between two words to the standard word spacing for that document class and expects two newlines between paragraphs.

Certain symbols are interpreted as control sequences as we’ve seen—\documentclass—the short list is “\ $ % { } # &”. These need to be escaped with \, except for \ which has to be written as \textbackslash{}.

More text

Changing the text style can be done with a variety of commands such as: \emph{} \textrm{} \textsf{} \texttt{} \textup{} \textit{} \textsc{} \uppercase{} \textbf{} { \em } {\rmfamily } {\sffamily } {\ttfamily } {\upshape } {\itshape } {\scshape } none {\bfseries } emphasis roman font family sans serif font family teletypefont family upright shape italic shape Small Capitals UPPERCASE (all caps) bold

Chapters and Sections

Chapters which can occur in document, book type document classes are started with the chapter command—\chapter{chapter title}. Sections can also occur within chapters.

Articles are made up of sections. The section command “\section{section title}” will give you section with that optional title. Subsections can be created with \subsection{. . . } and sub-subsections with \subsubsection{. . . }.

Finally, \tableofcontents will give you a table of contents where that command occurs.

Titles, abstracts, authors

A LTEX has commands to set the title, author and date of a document—\title, \author and \date respectively. \maketitle will produce a title page with those details.

If we want to attach an abstract to our document, \begin{abstract} . . . \end{abstract} will do that for us. This should be written within the document environment.

Lists

A LTEX gives us several forms of lists out of the box: the list, itemize and the enumerate environments.

In both cases each item in the list should be prefixed with the \item command. For the enumerated environment putting what immediately follows the item command with [ . . . ] will give you a definition style list with an altered layout.

List example

Enumerate example code: \begin{enumerate} \item first \item second \item third \end{enumerate}

Result: 1. first 2. second 3. third

Pictures and graphics

To include graphics in our documents, we need some additional help from the graphicx package. To use this we’ll need to use the \usepackage{$PACKAGE} command before the document environment.

We then have to declare what extensions latex should match with the \DeclareGraphicsExtensions{. . . } command. PNG and JPG are the easiest formats to deal with provided you’re using pdflatex. Otherwise you’ll need to convert your image files to .eps (encapsulated postscript) format.

Pictures and graphics continued

To actually include an image in our document, we’ll need to use “\includegraphics{$FILENAME”} where the file name is missing its’ extension. That’s somewhat plain, and we can do better by wrapping it in the figure environment which allows for a “\caption $CAPTION” to be set as well.

We can give the picture a label with “\label{$LABELNAME}”, allowing us to write “as per figure \ref{$LABELNAME}” which A LTEX will replace $LABELNAME with a number.

Tables

A Tables in LTEX use the tabular environment. For example: “\begin{tabular}{c c c} 1&2&3 4&5&6 \end{tabular}’ give us:

1 4

2 5

3 6

More Tables!

The number of columns and their justification is set in the { . . . } that follows the beginning of a tabular environment. l, c, r align the columns leftwise, center and right as expected.

Use \\ to add a new row. | in the table specification puts a vertical bar between columns, while following \\ with \hline will add a horizontal line.
A LTEX is extremely picky about tables (among other things) and will curse you out unless the tables are filled as they’re declared.

Advanced table example

1 4

2 5

3 6

Made with: \begin{tabular}{ l | c || r} \hline 1 & 2 & 3 \ \ \hline 4 & 5 & 6 \ \ \hline \end{tabular}

We can also in \label in tabular environments, allowing us to \ref{$TABLE} them later.

Biblography

A LTEX has support for citations in various styles of presentation.

The simple way is to include: “\bibliographystyle{plain} \bibliography{$BIBLIOFILE}”. Again, located within the document environment Bibtex files have their own layout which is fairly simple.

Biblography files

This is a simple example of a bibtex entry: @inproceedings{IGA, author = {H. Chef and J Bloggs.}, title = {Tasty Food}, booktitle = {Proceedings of the 12th international conference on Food}, year = {2003}, pages = {185–199}, numpages = {15}, publisher = {World Foods}, } A bibtex file (ending in .bib) is simply a bare list of these.

Biblography files

@inproceedings, @phdthesis, @book, . . . are different entry types. Components of them such as “year” can be compulsory in some and optional in others.
A To cite our “Tasty Food” document, we use \cite{IGA}. LTEX is fairly permissive about what characters can occur in a citation handle, but it’s best to stick to [a-zA-Z0-9:]+.

To get the citations to appear, first run “latex $FILE”, “bibtex $FILE”, “latex $FILE”, then your choice of driver (pdflatex). latex and bibtex have to be run multiple times to fix up the references.

Reference, thanks

A Dr. Edsko de Vries, http://www.edsko.net , held previous LTEX talks whose slides are available the web.

Dr. David Wilkins, http://www.maths.tcd.ie/˜dwilkins/LaTeXPrimer/ , fairly popular A guide to LTEX. Wikibooks, http://en.wikibooks.org/wiki/LaTeX/, incredibly useful gude.
A And yes, this entire presentation was written in LTEX with beamer.

Sign up to vote on this title
UsefulNot useful