LaTeX is a ‘mark-up’ language.
You ‘mark-up’ your content to tell LaTeX how it should be treated.
\emph{emphasised text}
.
\section{...}
.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.
amsart
.
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}
11pt
specifies the font size
a4paper
specifies that the page is A4-sizedNote 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.
Either put in some blank, vertical space, or,
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.
Documents are made up of sentences inside paragraphs inside sections. In LaTeX,
\section{..}
.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.
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?
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.
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.
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 |
Wrong! | The variable x | The variable x |
Right | We have $\sin(x)=1$. | We have . |
Wrong! | We have sin(x)=1. | We have sin(x)=1. |
In order to use LaTeX on a computer, you need various things:
software to edit LaTeX files and display PDF files, eg. TeXworks;
the PDFLaTeX program;
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.
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
Don’t forget that you need to hand-in a printout of your homework at the start of the lab.