MPS115/MPS116 PRESENTATION LAB 1
In this lab we will use LaTeX (pronounced ‘lay-tek’) within a software bundle called MiKTeX (pronounced ‘mik-tek’) to create basic mathematical documents.
Log on to a university Windows machine, then check to see if MiKTeX is
installed on the computer by typing texworks into the search box at the bottom
of the screen. If it’s not there, you need to install it from the Software Center on
the desktop.
The Software Center may take a minute or two to work properly. If it’s not responding, wait, then press F5.
Once MiKTeX is installed, start TeXWorks.
Delete any text that appears in the left-hand source pane and carefully type the text below.
\documentclass[11pt, a4paper]{amsart}
\begin{document}
Hello! This is my first document written in LaTeX.
Documents are generally made up of words, sentences
and paragraphs. This will be the first paragraph.
You tell LaTeX that you are starting a new paragraph
by putting in one or more blank lines between the
paragraphs. This will be the second paragraph.
\end{document}
If you find the text hard to read on the screen then use the
Format | Font... menu item to increase the font size, to, say,
11.
Click on the big green triangle, but make sure it says pdfLaTeX and not pdfTeX
by the side. If you’re asked to save your file, make a folder in Documents on your
U: drive called mps115_latex (or mas116_latex) and use the filename
lab_1.tex.
A PDF document should appear; note that the first run might take several seconds.
If the green triangle has turned into a red cross and no PDF has appeared after a little wait, click on the red cross, check your typing carefully and try again. If you still have problems, ask for help.
You can use ctrl-T as a keyboard shortcut for clicking the green triangle.
Compare your source code (the text you typed) with the output. You should see that where you left a blank line, LaTeX has started a new paragraph and has indented the text. That is the standard way for LaTeX to indicate new paragraphs. Note that a new paragraph does not just mean starting a new line. Usually new paragraphs indicate moving onto a new idea.
You will discover that when we start looking a typesetting mathematics in
LaTeX that you can start a newline by using \\ or \newline, however, these
must not be used in text. To create a new paragraph in LaTeX you put a
blank line in your source.
Let’s have a look at what we have typed. Every LaTeX file starts with a
\documentclass command. We are using the American Mathematical Society
(AMS) ‘article’ class, hence amsart. The a4paper part tell LaTeX to use
standard A4 paper size for the document. We will come back to 11pt later. The
main content of the document is put between \begin{document} and
\end{document} commands.
When processing the document, LaTeX will ignore extra spaces and new lines in your source file. Change the first paragraph so it starts as follows.
Hello! This is my first document written in LaTeX.
Process the file and you should see that the output has not changed.
We will now give the document some structure. Let’s begin with a title.
\begin{document} type \title{A First Document},
then process the file. Any change? See below if not.
\maketitle on a line after \begin{document}. Now process
the file. This time it should work.
\author{(your name)} under \title{A First Document},
and process the file again.
\date{September 1684} just after the
\author{...} command. Look at the whole page. What about using
\date{\today} instead?It is starting to look like a proper document. We can add some sections. Before
the first paragraph put the line \section{Introduction}. After the second
paragraph add the following.
\section{Another Section}
This is a very short section.
Process the document and your output should now have sections. Add the
line \tableofcontents after the \maketitle line and you should see a
table of contents appear. Short documents don’t always need a table of
contents.
Now we have the basic structure of a document in LaTeX, let’s look at the important idea of introducing mathematics. There are two ways in which mathematics appears in a document. You can have it inline like which means having it embedded in a paragraph, or you can have it displayed on a line of its own like
For inline mathematics you use dollar signs $..$, for displayed mathematics you
use \[..\]. Add the following to your document.
\section{Some Maths}
Here is some inline mathematics: $f(x) = \frac{e^x}{1 - x}$.
Here it is as displayed mathematics:
\[
f(x) = \frac{e^x}{1 - x}.
\]
Can you see the difference?
$-signs in the source code? Does it work
without them? What happens if you type f(x) without $-signs?
\[ and
\]? (Try turning them into $-signs or vice-versa.)
\frac command done?
Let’s add a second paragraph to this section. What do you think you will get if you type the following line? Think carefully. Try it and see.
Here is an integral: \[ \int \cos(x) dx = \sin(x) + c. \]
Note that by typing \sin and not sin you are telling LaTeX to treat
it as a trigonometric function and not the product of three variables:
.
Let’s do some more experimenting.
\int command into \int_0^\pi?
Finish off the calculation of the definite integral in your document
(including something like “”).
“Let . Then
completing the line by calculating the derivative of by hand and typing it in. Show the steps in your workings by including them as part of the line beginning “”.
“Because the derivative of is , it follows that
where the last line is finished as in question 8.
$-signs and backslashes with the
and
in the previous question, as in $\cos(x)$?This document is nearly finished. Add a new section called ‘Formulas’ and try to write a couple of paragraphs which give the main three differentiation rules (product, quotient and chain) along with the formula for integration by parts. Look them up if you’ve forgotten them! Don’t forget to write in sentences.
In response to a homework question, a student handed in the following.
(chain rule)
Your job is to try and work out what question was asked, then write a much better solution using LaTeX, correcting errors and improving the solution above as much as possible. Be sure to read through the first lecture again before doing this.
Your document should have two sections, ‘Question’ (where you state your guess at the question) and ‘Solution’. Your solution doesn’t need to be long, but should include significantly more words than the badly written one above.
$\sin$ and $\cos$ in your
solution.
.tex LaTeX file.
You must hand then in at the begining of next week’s computer lab.This homework counts towards the homework component of your module mark, as do all the weekly presentation homeworks. As such this must be all your own work: you must not plagiarise or collaborate with other students, and you must not use AI tools.
If you have problems then feel free to use the Discussion Board on Blackboard or Simon Willerton’s office hour.