You are on page 1of 7

L

A
T
E
X SHORT COURSE
UNIVERSITY OF EDINBURGH
1. Overview
By the end of this short course you should be reasonably comfortable
with the L
A
T
E
X typesetting system, using WinEdt as a front-end and editor.
You should be making good use of the standard features of L
A
T
E
X, including
the sectioning commands, lists and tables, type-setting mathematics, and
theorem-like environments. Where appropriate, you should also be able
to make use of the cross-referencing facilities provided by L
A
T
E
X, including
references to numbered equations and sections, and inclusion of a numbered
list of references. You should also be happy about including graphical output
in your documents.
1.1. Resources. Most people learn how to use L
A
T
E
X by typing documents,
looking at a manual as needed. I hope you will be happy to pick up L
A
T
E
X
in this kind of way. The manual I recommend (at least initially) is the Not
So Short Introduction to L
A
T
E
X2e [4].
The le linalgnotes.tex is a sample L
A
T
E
X le, with many comments,
which you can use as a crib for looking up how to do things if you cant nd
what youre looking for in [4].
In order to develop your L
A
T
E
X skills, you are strongly encouraged to type
a 23-page document during the lab session. The task is purely secretarial
in nature: you are presented with a PDF le, and must try to write a L
A
T
E
X
le that will reproduce it.
2. Getting started
To get started, download the les:
linalgnotes.tex,
preamble.tex,
slide example.tex,
nss new.pdf,
amsldoc.pdf,
equivreln.pdf.
Now open WinEdt.
2.1. WinEdt. You will be using the editor WinEdt to generate your L
A
T
E
X
documents. The following is a very brief outline of WinEdt. Please exper-
iment with opening the les youve just downloaded and/or creating some
new ones of your own as you read over this subsection.
The basic features of WinEdt will probably be familiar from other editors
you have used. First of all, to start a new document, click on File and New
Date: Updated: December 2, 2010.
1
2 UNIVERSITY OF EDINBURGH
(or use the keyboard short-cut Ctrl+N). To modify an existing document
select Open from the same menu (or use the short-cut Ctrl+O). Dont forget
regularly to save your work (Ctrl+S, or Save from the File menu). If youve
created a new document, youll have to use Save as... to give it a suitable
name.
One useful feature of WinEdt is the following. Say youre working on le
A.tex, and you want to check something in le B.tex. Without quitting
A.tex, you can open B.tex, and will appear in a second tab. This allows
you to work on two les at once; in particular you can cut and paste text
from A.tex to B.tex an vice versa. These tabs can be closed individually
from the File menu (or use Ctrl+F4).
Under the Edit and Search menus you will nd standard and reasonably
self-explanatory tools for editing and searching your document.
The Insert menu contains some tools that help you to typeset with
L
A
T
E
X; you can explore these for yourself as the course progresses.
We shall not have much use for the Document or Project menus. The
Tools menu allows you to access some spell-checking programs: it is worth
using these on nished documents, as long as you remember that this spell-
checker thinks that American spellings are correct.
The button below Tools sets up a GUI (graphical user interface) for
commonly used L
A
T
E
X symbols; so, for example, when you want to get L
A
T
E
X
to generate an you can just select this symbol from the Greek menu which
appears between the standard tool-bar and the document. I personally
am used to typing everything (e.g., \alpha) but I can see that this GUI
system has its advantages, especially at the beginning. Similarly, below
Accessories there are buttons that give you the L
A
T
E
X commands for bold,
italic and teletype fonts.
The other buttons we shall be using are the one marked PDFL
A
T
E
X (on the
top row of buttons on the tool bar, towards the right-hand end) and the
button with the Adobe Acrobat logo (a curly triangle) on it, just below the
PDFL
A
T
E
X button. The rst of these runs the L
A
T
E
X processor on the source-le
and attempts to produce a PDF le. The second allows you to view (and
hence print) the PDF le.
I suggest that you open a document (either one of the L
A
T
E
X les you have
just downloaded, or a new one) and play around with some of these features
until you feel condent that you are able to use WinEdt. Notice that if you
open one of the L
A
T
E
X les, then WinEdt automatically colours some of the
characters and symbols that appear. The rationale for this will make much
more sense when you know a bit more about L
A
T
E
X; then you will see that
this colouring is very helpful in checking for possible programming errors.
As set up in the labs, you may get an error message when you quit
WinEdt. Just click Ignore when this happens.
2.2. Basic structure of L
A
T
E
X. I suggest that you now read through
1.11.4 of the Not so short guide [4] (either new or old version). This will
give you an overview of how typesetting with L
A
T
E
X works. The L
A
T
E
X les
you have downloaded should help to illustrate some of the points made here.
In particular, I have put lots of comments in linalgnotes.tex, including
page references to the relevant pages or sections of [3].
L
A
T
E
X SHORT COURSE 3
2.3. Texing a document. Open linalgnotes.tex and convert it into a
beautiful PDF document as follows:
Click on the PDFL
A
T
E
X icon. This directs the processor to convert the
source-le to PDF. You will see a window open and some text appear
in this windowthis is the processors log. If there are no errors
in the source-le, this window will disappear again. The processor
will grind to a halt with an error message in the log window if there
is anything wrong with the source le.
Assuming that your document is OK, the Acrobat button immedi-
ately below will appear in colour (red); click this button to re up
the Acrobat Reader, which will automatically select the output of
the le youve just processed.
This two-step procedure will be the same for all the documents that you
will be producing with L
A
T
E
X and WinEdt. Note that if your document
contains cross-references and/or a bibliography, you will have to run L
A
T
E
X
at least twice for them to come out right.
This procedure is dierent from that outlined in 1.5 of [3] and
[4], which is more adapted to Unix platforms.
2.4. Errors. The colour-coding that WinEdt does automatically makes it
relatively easy to spot the more common coding errors even as you are
typing. If you process a le with an error in it, the processing will stop,
there will be no PDF le, and the log window will show the line of the
source-le that it didnt like. A nice feature of WinEdt is that if you now
type e followed by Enter, you will nd yourself back in the source-le, with
the bad line highlighted. In general, the error messages are not too helpful,
but you will soon become familiar with the more common ones.
Lets go into this process of error-correcting in a little more detail. Youve
typed up a L
A
T
E
X source-le and have started to tex it. The log window
comes up with an error. You return to your source and correct the error.
What next? You have a couple of options. It is often worth returning to the
log window and hitting Enter; this will tell the processor to carry on as best
it can, ignoring the error. Chances are, it will come up with another error,
later on, that you will also be able to correct, and so on until it reaches the
end of your source-le. Then, texing again, you should have a le free of
errors which youll be able to view.
Sometimes, however, an error will have such far-reaching (bad) conse-
quences that the above is not a sensible way to proceed. Then you can quit
the processing by typing x followed by Enter in the log window.
2.5. Warning: conicts between Acrobat and L
A
T
E
X. Sometimes,
while working on a documentand I confess, I am not sure exactly when
this happensyou will get an error message to the eect that L
A
T
E
X cannot
write to the PDF le, or the Acrobat Reader is unable to open it. If this
happens, check if there is an open log le somewhere (i.e. the processor
thinks its still working on the le) and hit Enter. If this doesnt work, then
quit the Acrobat Reader, or at least close the le: click the lower of the two
crosses in the top right-hand corner. If this still doesnt clear the problem,
save your work, quit WinEdt and start again.
4 UNIVERSITY OF EDINBURGH
I have only encountered these diculties when the document has already
been texed at least once and the acrobat reader has already been red up.
3. Practice
This short assignment is intended to get you used to the idea of typesetting
using L
A
T
E
X. You will type a L
A
T
E
X source-le which generates PDF output
similar to that of a given le.
3.1. How to get started. Download equivreln.pdf from the web. The
goal today is to type a L
A
T
E
X document whose output closely resembles this
document. To get started, copy preamble.tex into a new le and give it
a suitable name. Now you can start typing this document, referring to [4,
Chapters 23] and/or linalgnotes.tex as needed. Dont be discouraged if
it seems to go very slowly to begin with...
3.2. Tips. The main tip is: let L
A
T
E
X do all the hard work! The whole
point of this typesetting system is that it has many features that make
typesetting mathematical documents easyof course, it may take some
practice before you appreciate just how easy L
A
T
E
X can be...
The more you use the features that L
A
T
E
X oers, the better your docu-
ments will look, and the less trouble you will have in producing them. Here
are some of the features of L
A
T
E
X which you will nd yourself using all the
timemost of them are available from the Insert menu on the WinEdt
toolbar.
Lists and so on: use the list-making environments provided by L
A
T
E
X
[4, 2.11.1].
Mathematics in text: enclose with dollar signs: $...$.
Displayed equations: use \begin{equation*}...\end{equation*}
Numbered equations: use \begin{equation}...\end{equation}.
Paragraphs: just leave a blank line.
Sections and subsections: use \section{...}, \subsection{...}.
Theorem-like structures: use the environments provided by the stan-
dard preamble.
Cross-referencing: this is one of the coolest features oered by L
A
T
E
X
see linalgnotes.tex for examples or [3, 4, 2.8].
4. Including Graphics
The pdflatex package allows the inclusion of filename.jpg by the se-
quence of commands
begin{figure}\label{}
\begin{center}
\includegraphics[width=0.5\textwidth]{filename}
\end{center}
\caption{}
\end{figure}
L
A
T
E
X SHORT COURSE 5
Here \label gives you the chance to label your gure (for cross-referencing)
and \caption will generate a caption for it. Both are optional but highly rec-
ommended. It is essential to have the line \usepackage[pdftex]{graphicx}
in your preamble for the above to work.
See Chapter 4 of [4] for more details on these commands. Note, however,
that that Chapter concentrates on the inclusion of encapsulated postscript
graphics, rather than jpg les.
5. Further topics
It will be apparent from [4] that a lot more can be done with L
A
T
E
X than
we have described here. For example, one can produce documents with
active cross-referencing, using the hyperref package [4, 4.7]. The not-so-
short guide has been written this way, with clickable links to other parts of
the document as well as to places on the web. One can also use colour, using
the color package, and one can produce power-point like presentations in a
number of ways (see, for example [4, 4.8] and slide example.tex).
A useful quick reference is the NASA website Hypertext Help with
L
A
T
E
X located at http://www.giss.nasa.gov/tools/latex/ltx-2.html.
For more detailed information on L
A
T
E
X packages and manuals go to the
CTAN Archive: http://www.ctan.org/.
6. Notes on scientific writing
There are many good books which oer advice and guidance about good
use of English in documents where precision and conciseness are the main
aims. Two aimed specically at writing mathematics are [1] and [2]. A re-
markably entertaining book on punctuation, which I think everybody should
read, is [5].
Here are some very brief tips:
6.1. Grammar, punctuation and spelling. Make sure that your report
is written in complete sentences, and that it does not contain elementary
grammatical errors. In particular, every sentence should contain a verb, and
this verb should agree with its subject.
Punctuation: some aspects of punctuation are very subtle, others are not
[5]. Please check in particular that you use its and its correctly, as in
the following:
Its a beautiful day today.
but
She put the apostrophe in its proper place.
Correct punctuation is very important in making sentences readable: use
commas etc. to clarify the structure of longer sentences.
Clarity of your writing is the most important objective. Keep sentence
structure simple and short. Make sure you do not repeat yourself needlessly.
Read out loud what you have written. If you can not easily and naturally
say it, then it probably will not make sense to anyone else.
Use a spell-checker.
6 UNIVERSITY OF EDINBURGH
6.2. How not to. . . Here are twenty examples of bad writing:
Verbs has to agree with their subjects.
Prepositions are not words to end sentences with.
And dont start a sentence with a conjunction.
It is wrong to ever split an innitive.
Avoid cliches like the plague.
Also, always avoid annoying alliteration.
Be more or less specic.
Parenthetical remarks (however relevant) are (usually) unnecessary.
No sentence fragments.
Contractions arent necessary and shouldnt be used.
One should never generalize.
Dont use no double negatives.
Eschew ampersands & abbreviations, etc.
Eliminate commas, that are, not necessary.
Never use a big word when a diminutive one would suce.
Kill all exclamation marks!!!
Use words correctly, irregardless of how others use them.
Use the apostrophe in its proper place and omit it when its not
needed.
Puns are for children not groan readers.
Proofread carefully to see if you any words out.
6.3. Conventions of scientic writing. Scientic reports (and other re-
ports, where precision is important) are usually written in a sober, im-
personal style. Avoid quirkiness, personal language, colloquialisms and
jokinessit may amuse some readers but it is likely to annoy others and
may lead to what you write not being taken seriously.
It is tiresome to read reports written entirely in the rst or second persons.
You should not write
Im now going to tell you how to integrate this function. First
Im going to divide top and bottom by x, then Im going t
make the substitution y = x
2
...
or
To see why this is true, you just have to substitute in the
denitions. Then when youve simplied, you nd that...
It is conventional to use we or one, or to use the passive. Again, it is
tiresome if we is used throughout an entire document, but it is dicult
to read documents where one keeps chopping and changing. The following
might be more acceptable renderings of the above spoof mathematics:
In order to integrate this function, rst divide top and bot-
tom by x. Making the substitution y = x
2
, we obtain...
In order to see why this is true, it is enough to substitute in
the denitions. On simplication, one nds that...
Do not begin sentences with formulae or mathematical symbols and re-
member to enclose even single letters such as x in dollar signs, so as to get
L
A
T
E
X SHORT COURSE 7
x rather than x. Remember punctuation at the end of displayed equations
and formulae.
6.4. Organization of material. In any writing in which precise informa-
tion is to be conveyed concisely to the reader, it is highly desirable to spend
some time deciding how to organize the material: what is really essential,
what is less important; and in what order should the dierent topics be
presented. L
A
T
E
X makes it very easy to organize your report into sections,
subsections, subsubsections and paragraphs, and you should make full use
of this, deciding how best to divide your material.
This document is by no means perfect, but I have tried to use the sec-
tioning commands in a consistent way: each of the three assignments has
a section to itself, preceded by the introductory sections Overview and
Getting Started.
In the context of writing mathematics, you should also make use of num-
bered denitions, theorems, propositions, etc. It takes some practice to get
the right balance between a formal style in which everything is a denition,
lemma, theorem, or proof, and an informal style, with no denitions and
theorems: the former is very dry to read, but has the advantage that you
can see clearly what is being donethe latter may be more enjoyable to
read, but you cannot see the main points at a glance.
References
[1] Nicholas J. Higham, Handbook of writing for the mathematical sciences, Society for
Industrial and Applied Mathematics, Philadelphia, 1993.
[2] Steven G. Krantz, A primer of mathematical writing: being a disquisition on having
your ideas recorded, typeset, published, read, and appreciated, American Mathematical
Society, Providence, R.I. c1997.
[3] T Oetiker, H Partl, I Hyna, E Schlegl, The Not So Short Introduction to Latex2e
Version 3.20, 9 August 2001.
[4] T Oetiker, H Partl, I Hyna, E Schlegl, The Not So Short Introduction to Latex2e,
Version 4.17, September 27, 2005.
[5] Lynne Truss, Eats, Shoots and Leaves, Prole Books, 2003.

You might also like