MAS116/MAS117 Presentation Lecture 2:
LaTeX

Dr Simon Willerton

1 The general philosophy of LaTeX

LaTeX is a ‘mark-up’ language.  

You ‘mark-up’ your content to tell LaTeX how it should be treated.

You do not decide how these things are actually displayed. Bold? Italic? Small caps? Large?

Such formatting, or style, decisions are kept in a document class file. Style and content are kept separate.

LaTeX process schematic 1  

IOnuDptouPpctDuuFtmLLeaanTTPteeDXXFclafifisllsee:::
   cffliiallsees...tpcedlxfs

Why keep style and content separate?  

This is different to Word or Google Docs and might take getting used to!

We will see in Week 8 that webpages are written in the same way. You have HTML files for content and CSS files for style.

Altering the style: using class options  

Using a document class does not mean that everything is unchangeable. Two ways of changing things are with class options and with packages.

Class options appear in the \documentclass command. For example,

  \documentclass[11pt, a4paper]{amsart}

Note that a4paper in amsart gives seemingly wide margins on the page. Documents are most readable when there is 60–75 characters per line. Professional document class designers (typographers) know this. Untrained folk would opt for much longer, less readable lines of text.

Altering the style: using packages  

Packages are extra programs that add extra features or alter things. You load in packages in the preamble, that is the part of the LaTeX file between \documentclass and \begin{document}.

Eg, there are two standard ways to mark the begining of a paragraph.

1.

Either put in some blank, vertical space, or,

2.

indent the first line.

In amsart the default is the second of those. To switch the first you put the following in your preamble.

    \usepackage{parskip}

Tweaking the layout should be kept to a minimum. It is easy to make the document look worse.

Aside: Paragraphs  

Documents are made up of sentences inside paragraphs inside sections. In LaTeX,

So, two paragraphs will look like this in a LaTeX document.

    Paragraph 1 starts here... blah blah blah blah
    blah blah blah blah blah blah blah blah blah

    Paragraph 2 starts here... blah blah blah blah
    blah blah blah blah blah blah blah blah blah

LaTeX will then display the two chunks of text as separate paragraphs.

LaTeX process schematic 2  

IOnuDptouPpctDuuPFtmaLLecaankTTPtaeeDgXXFecsla:fifisllsee:::

  pcafflciiakllsaeesg...etpc1edl.xfssty
  package2.sty

2 Activity time

Activity time  

Activity. Look at the two circulated documents which have the same LaTeX code, but differ in their preamble. In pairs or threes, find at least five differences in how the document displays and discuss which one you prefer. Also count an average line-length for each document. Do you have strong opinions about margins?

3 Text versus mathematics

Typography  

Typography is the art and technique of arranging type to make written language legible, readable and appealing when displayed.

The arrangement of type involves selecting typefaces, point sizes, line lengths, line spacing, letter spacing, and spaces between pairs of letters. [Wikipedia]

The actual process of positioning letters and punctuation according to typographical rules is called typesetting.

Both general typographical rules and information in the document class will determine how LaTeX does its typesetting. There can be many subtle things happening, such as ligatures. These are where letters are combined to a single symbol, as in Sheffield.

Text versus mathematics  

The typography of English text is one thing. The typography of mathematics is a completely different thing! Mathematical typography has its own rules and conventions. These might be subtle but are important for clarity.

Here are some very basic rules (but there are many more)

Lots of rules go in to typesetting complicated mathematics.

te t dt = lim x0n!sin (x) x + x2

Using maths mode  

In order to know whether to use the rules for English or maths, LaTeX needs to know whether your content is English or maths.

You put content in maths mode by using $..$ or \[..\] or using ‘environments’ like \begin{align*}.

The Fundamental Law of LaTeX. All mathematics in LaTeX must be in maths mode.

If you don’t put maths in maths mode then you document will not be typeset properly and this can be unhelpful for the reader.

LaTeX Output
Right The variable $x$ The variable x
Wrong! The variable x The variable x
Right We have $\sin(x)=1$. We have sin (x) = 1.
Wrong! We have sin(x)=1. We have sin(x)=1.

4 Obtaining LaTeX

Installing LaTeX  

In order to use LaTeX on a computer, you need various things:

1.

software to edit LaTeX files and display PDF files, eg. TeXworks;

2.

the PDFLaTeX program;

3.

all of the document class files and package files.

The are usually collected together into a single bundle to download.

The analogue of TeXworks in MacTeX is called TeXshop.

Alternatively, you can just use a browser.

5 This afternoon…

Computer Lab 2  

In Computer Lab 2, we will develop more of the LaTeX commands that you’ll be needing to write documents. For example, we’ll look at

and how to typeset things like

Γ(x) lim x0 v=0n1n!nx1 x + v .

Don’t forget that you need to hand-in a printout of your homework at the start of the lab.