0% found this document useful (0 votes)
12 views10 pages

latex-handout

Latex Handout

Uploaded by

cnokaf28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

latex-handout

Latex Handout

Uploaded by

cnokaf28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

A brisk introduction to LATEX

Clive Newstead

Being able to type up your mathematical writing is a beneficial skill to have. Unfortunately, most
Office-style WYSIWYG (‘what you see is what you get’) text editors are not designed for this
task—they just can’t cope with all the notation. A typical mathematical paper will contain so
many mathematical symbols that using graphical methods is unrealistic.

LATEX1 is a markup language that allows you to input both text and mathematical notation.
Formatting and mathematical notation are input by typing code, and LATEX process the code to
produce beautifully typeset documents.

It is the (unofficial) industry standard amongst mathematicians for writing journal articles, lecture
notes, books, posters and presentations. It is not just used by mathematicians: it is one of the
most-used methods of typesetting in academia, and being able to use LATEX is a desirable skill
for many jobs in industry.

Aside from this, typesetting mathematical work instills good practice: communicating a proof
requires you to select the information you want to convey to the reader, and what information to
leave out. Moving from pen(cil)-and-paper to typed up work breaks the habit of ‘showing your
work’, in favour of ‘communicating an argument’.

What follows is a brisk introduction to LATEX that should suffice for the purposes of this course.

1 Finding the software

There are several good LATEX editors that you can install on your computer—I recommend Tex-
maker (http://www.xm1math.net/texmaker/) if you’re new to it, because it’s cross-platform and
fairly intuitive.

There are also online editors that you can use if you want to avoid installing new software; I
highly recommend ShareLaTeX (http://www.sharelatex.com), which is free to use and stores
your .tex files on the cloud.

There is some faffing around to be done with document headers and so on. So that you can
avoid this, I’ve uploaded template .tex files to Blackboard that you can use in your homework
write-ups.
1
The word LATEX is pronounced like ‘lay-tek’ or ‘lah-tek’; some people pronounce the ‘k’ like the German ‘ch’ sound,
meant to resemble the Greek letter chi (χ). It doesn’t really matter, but if you pronounce it like ‘lay-teks’ then
people will think you’re talking about something somewhat different.

1
2 Text mode and math mode

Before we get into the nitty-gritty, I should mention the difference between ‘text mode’ and ‘math
mode’.

• Text mode is the default mode: the stuff you type will appear as text, and this is the
mode you should use when writing anything that isn’t mathematical notation.

• You should use math mode when you’re typing anything which is mathematical notation,
including variables, numbers, fractions, square roots, powers, sums, products, binomial
coefficients, and so on.

To enter math mode, enclose whatever mathematical notation you are writing with dollar signs
($). For example, if I type $E=mc^2$ then LATEX shows E = mc2 . Sometimes it is convient to
put longer expressions on their own line, in which case you can enclose it with double-dollar signs
($$); for example, if I type $$a^2+b^2+c^2=ab+bc+ca$$ then LATEX displays

a2 + b2 + c2 = ab + bc + ca

on a line all of its own.

If you need to type text inside math mode (enclosed by $ signs), you can do that using \text{...},
for example the code

$$\sum {i=1}^n i = \frac{n(n+1)}{2} \text{ for all } n \in \mathbb{N}$$

gives
n
X n(n + 1)
i= for all n ∈ N
2
i=1
Note the spaces before and after ‘for all’; had I left those out of the code, they would not appear
because LATEX ignores spacing in math mode. You can force a space by putting a backslash before
a space, for example $a b$ gives ab but $a\ b$ gives a b.

All mathematical notation should be in math mode, including single variables. Notice the differ-
ence between the following two lines:

If a and b are both even then so is a+b.

If a and b are both even then so is a + b.


While the first is written entirely in text mode, the second is written using math mode for the
variables and + sign.

2
3 Mathematical symbols

The following table lists—I hope—all of the mathematical symbols you will need in this course.
If you come across other symbols, please let me know.

Logic
conjunction, disjunction ∧, ∨ \wedge, \vee
negation ¬ \neg
implication, biconditional ⇒, ⇔ \Rightarrow, \Leftrightarrow
exclusive disjunction ⊕ \oplus
true, false (in truth table) X, × \checkmark, \times
quantifiers (universal, existential) ∀, ∃ \forall, \exists
Set theory
element, subset ∈, ⊆ \in, \subseteq
not equal, proper subset 6=T,$ \ne, \subsetneqq
intersection, (indexed) ∩, Sni=1 \cap, \bigcap {i=1}^{n}
union, (indexed) ∪, ni=1 \cup, \bigcup {i=1}^{n}
relative complement, complement X \Q Y, X c \setminus, X^c
product, (indexed) ×, ni=1 \times, \prod {i=1}^{n}
implied lists {1, . . . , n} \{ 1, \dots, n \}
indexed sets {xi | i ∈ I} \{ x i \mid i \in I \}
set-builder notation {x | p(x)} \{ x \mid p(x) \}
empty, universal set ∅, U \varnothing, \mathcal{U}
number sets N, Z, Q, R \mathbb{N}, \mathbb{Z}, etc.
Numbers and combinatorics
multiplication m × n, m · n \times, \cdot
m n
fractions, exponents n , m \frac{m}{n}, m^{n}
order relations ≤, ≥ \le, \ge
divisibility, (non-) m | n, m - n \mid, \nmid
n
binomial coefficient Pn kQ \binom{n}{k}
n
indexed sum, product i=1 a i , i=1 a i \sum {i=1}^{n} a i, \prod {i=1}^{n} a i
modular arithmetic a ≡ b mod n, 6≡ a \equiv b \bmod{n}, \not\equiv
Functions and relations
f
functions f :X →Y, X − → Y \to, X \xrightarrow{f} Y
composition g◦f \circ
isomorphism ∼
= \cong
equivalence relations ∼, ≈ \sim, \approx
Structured sets
order relation , ≺ \preceq, \prec
group operations ·, ?, ◦ \cdot, \star, \circ

3
4 Organisation and formatting

When typing up solutions to problem, organisation can be the difference between a masterpiece
and an unreadable heap of notation. Here are some tips to help you organise your work:

Sections and paragraphs

You can split your work up into sections, subsections, subsubsections, and even subsubsubsections.
To do this, use \section{Section title} or \section*{Section title}; the former includes
a section number, and the latter omits it. To start a new paragraph, simply make two new lines
in the code.

Bulleted and enumerated lists

Sometimes it is useful to use bullet points or give an enumerated list. For example, in these notes,
I separate the base case from the induction step in proofs by induction by using bullet points.

For a bulleted list you can use the itemize environment:

\begin{itemize}
\item Something here\dots • Something here. . .
\item You can do lists within lists:
• You can do lists within lists:
\begin{itemize}
\item Like this. – Like this.
\item Isn’t it crazy!
– Isn’t it crazy!
\end{itemize}
\item Well, not that crazy. • Well, not that crazy.
\end{itemize}

For an enumerated list, you can use the enumerate environment. You can play around with
different methods of enumeration, which you specify in square brackets [...]; personally I like
(1), (i) and (a) the best:

\begin{enumerate}[(a)]
\item Here’s the first thing; (a) Here’s the first thing;
\item Here’s the second thing; (b) Here’s the second thing;
\item And here’s the third thing.
\end{enumerate} (c) And here’s the third thing.

4
Definitions, results and proofs

If you use the provided templates, you can make definitions, and state and prove results, using
the following environments:

definition, example, proposition, theorem, lemma, corollary, proof

They are given a number m.n, where m is the section number and n is the position within the
section.

Here’s an example of a theorem appearing in the third section of a document, in which five
definitions, results or examples come before it:

\begin{theorem}
If $n \in \mathbb{N}$ then $n \ge 0$.
\end{theorem}
Theorem 3.6. If n ∈ N then n ≥ 0.
Proof. This is really obvious.
\begin{proof}
This is really obvious.
\end{proof}

Note that the box () designating the end of the proof is inserted automatically when you close
the proof environment.

Labels

As you change the contents of a document, the numbering of the definitions, examples and results
might change. To refer to a specific result, instead of typing the number and having to change it
each time the number changes, you can use the \label and \ref commands.

An example of this in action is as follows:

\begin{definition}
\label{defDivides}
Say $a$ \textbf{divides} $b$ if there Definition 2.11. Say a divides b if
exists $k \in \mathbb{Z}$ such that there exists k ∈ Z such that ka = b.
$ka=b$.
\end{definition} We will use Definition 2.11 for abso-
lutely nothing.
We will use Definition \ref{defDivides}
for absolutely nothing.

5
Formatting

In text mode. To put the icing on the cake, you might want to make some words bold
or italicised. This is simple: for bold text type \textbf{text here} and for italic text type
\textit{text here}. In Texmaker and ShareLaTeX you can press Ctrl+B and Ctrl+I to avoid
having to type all this out. Other useful fonts include monospace (\texttt{text here}), sans-
serif (\textsf{text here}) and underlined (\underline{text here}).

In math mode. There are also various fonts or font styles that you can use inside math mode,
including:

• Roman (i.e. not italic): AaBbCc, \mathrm{AaBbCc};

• Bold: AaBbCc, \mathbf{AaBbCc};

• Sans-serif: AaBbCc, \mathsf{AaBbCc};

• Blackboard bold: ABCDE, \mathbb{ABCDE} — only capital letters;

• Fraktur: AaBbCc, \mathfrak{AaBbCc};

• Calligraphic: ABCDE, \mathcal{ABCDE} — only capital letters;

Tables

Tables can be created using the tabular environment. You can specify how columns are aligned
and separated as an argument to the command \begin{tabular}: write l, c or r to specify that
a column should be aligned left, centre or right, respectively. If you want columns to be separated
by a single or double line, enter a single or double bar (| or ||), respectively.

Columns are then separated by ampersands (&) and you can move to a new row by entering a
double-backslash (\\). To insert a horizontal line between two rows, simply enter \hline.

Here’s an example:

\begin{tabular}{c||ccc}
$\times$ & 1 & 2 & 3 \\ \hline \hline × 1 2 3
1 & 1 & 2 & 3 \\ 1 1 2 3
2 & 2 & 4 & 6 \\ 2 2 4 6
3 & 3 & 6 & 9 \\ 3 3 6 9
\end{tabular}

6
Aligned equations

Occasionally a proof may require you to demonstrate that two terms are equal by proving a
sequence of intermediate equations. This can be done using the align* environment, which
behaves much like the tabular environment.

New lines are introduced by inserting a double-backslash (\\), and the two columns are separated
by an ampersand (&). The left column is aligned right, and the right column is aligned left. Here’s
an example:

\begin{align*}
(n+1)! - n! & = (n+1)n! - n! \\ (n + 1)! − n! = (n + 1)n! − n!
& = n \cdot n! + n! - n! \\ = n · n! + n! − n!
& = n \cdot n! = n · n!
\end{align*}

Note that the align* environment automatically enters into math mode, so to enter text you
should use the \text command.

Entering more ampersands will create more columns, whose alignment alternates (right, left, right,
left, and so on). For example, to add annotations to each line, you can enter a double-ampersand
(&&). For example, the following code. . .

\begin{align*}
(n+1)! - n! & = (n+1)n! - n! && \text{by recursive def of factorials} \\
& = n \cdot n! + n! - n! && \text{by distributivity} \\
& = n \cdot n! && \text{by cancellation}
\end{align*}

. . . yields the following output:

(n + 1)! − n! = (n + 1)n! − n! by recursive def of factorials


= n · n! + n! − n! by distributivity
= n · n! by cancellation

Note again that, because the align* environment automatically enters math mode, any annota-
tions must be made within the \text command.

7
Graphics

To insert graphics into your documents, you need to make sure that the code \usepackage{graphicx}
is somewhere in the document header, i.e. above the line that says \begin{document}.

Images can then be inserted using the \includegraphics command. The format is

\includegraphics[parameters]{filename}

where, in the above, parameters denotes information telling LATEX how large you want the image
to be, and filename is the name of the image file, which. . .

• . . . excludes the extension, for example ‘donkey’ instead of ‘donkey.png’;

• . . . includes the path relative to the main .tex file, for example if donkey.png is stored in a
directory called images, you would enter ‘images/donkey’ instead of ‘donkey’.

The simplest way to control the size of the image is to enter [width=k\textwidth], where k is a
scaling factor between 0 and 1.

For example, the following code:

\begin{center}
\includegraphics[width=0.3\textwidth]{donkey}
\end{center}

yields the following output:

8
5 Practice page

Use the provided LATEX template template.tex to re-create the following page:

Squarefree integers
Carl Friedrich Gauss, Wednesday 14th September 1831

Introduction

When you’ve written this page, you will be unstoppable, at least as far as typesetting mathematics
is concerned. You will need to implement:

• Text mode stuff: sections, paragraphs, text formatting, labels and references, lists;
• Math mode stuff: definitions and results, aligned equations, etc.

So let’s get on with it!

1 Squarefree integers

1.1 Definition and an elementary result

Definition 1.1. An integer a is squarefree if it is divisible by no perfect square other than 1.


That is, if n2 divides a then n2 = 1.
Proposition 1.2. A non-zero non-unit a is squarefree if and only if
a = p1 × p2 × · · · × pn
for distinct primes p1 , p2 , . . . , pn .

Proof. We leave the proof as an exercise to the reader.

1.2 Some examples

Example 1.3. Some concrete examples include:

(i) 5610 is squarefree by Proposition 1.2, since


5610 = 10 × 561
= (2 × 5) × (11 × 17)

(ii) 12 is not squarefree since 4 | 12 and 4 = 22 .

9
6 More advanced techniques

I should take a moment to emphasise that what matters in this course is your ability to com-
municate mathematical arguments clearly and correctly. The LATEX tools discussed so far in this
section are more than sufficient for the purposes of this course.

However, if you are interested in pushing your LATEX skills further or there is a feature you’re
unsure about how to implement, then I recommend browsing or searching one of the following
websites:

• http://tex.stackexchange.com — Q&A website about LATEX

• https://en.wikibooks.org/wiki/LaTeX — online LATEX manual

10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy