MAS116/117 Presentation Lecture 5:
Common LaTeX Let-Downs
and Grammatical Grumbles

Dr Simon Willerton

1 Six common LaTeX let-downs

LaTeX let-downs  

1.

Maths not in maths-mode.

2.

Text in maths-mode.

3.

Punctuation in the wrong place.

4.

Using too much displayed mathematics.

5.

Using bold text.

6.

Overful hboxes.

1. Maths not in math-mode  

When using inline maths, it is easy to forget the single dollars.

Look out for maths symbols not displayed in italics.

Examples. This x is correct, whereas this x is not. This f(x) is wrong as well, as is this set A, which is should be A.

2. Text in math-mode  

The reverse situation is using text in math-mode.

This is easy to spot, as the text becomes italic and spacing isn’t correct.

Examples.

Thistextisinmath mode Thislineisalsoinmath modewith usedforspaces

The first case here may have happened by accident.

The second is someone fiddling to make things look okay, but looks bad.

2. Text in math-mode II  

Text is occassionally needed within math-mode.

If it is necessary, use the \text{...} command (from amsmath).

The \text command allows us to write

x = u + vandy = u v.

Notice the spacing between the maths and text. This has been done using the \quad command, which creates a large space:

    \[
        x = u + v
        \quad\text{and}\quad
        y = u - v.
    \]

3. Punctuation in the wrong place  

Punctuation needs to be outside of inline mathematics.

Correct

Therefore $x=2$.  The result is proved.

Wrong

Therefore $x=2.$  The result is proved.

These display as follows.

Correct

Therefore x = 2. The result is proved.

Wrong

Therefore x = 2. The result is proved.

There are two things wrong here.

These subtle differences will make your document look worse.

3. Punctuation in the wrong place II  

Conversely, punctuation needs to be inside of displayed mathematics!

Otherwise it can fall to the next line.

    Thus,
    \[
        \sin^2 x + \cos^2 x = 1
    \],
    and the result follows.

gives rise to

Thus,

sin 2x + cos 2x = 1

, and the result follows.

This clearly looks poor.

4. Using too much displayed mathematics I  

Beginners to LATE X often overuse displayed mathematics. Displayed mathematics should be used for important steps that you would like to stand out, or for formulas and equations too big to display well in-line. Too much displayed maths slows the reader down.

Here’s an example of something broken up too much by display-math.

4. Using too much displayed mathematics II  

Example. Suppose not, and 2 is rational. Then, by Lemma 1.2,

2 = a b,

where a and b share no common factors. Thus, squaring, we get

2b2 = a2.

It follows that a2 is even, and hence so is a. Write

a = 2m

for some m

4. Using too much displayed mathematics III  

Example (Re-write). Suppose not, and 2 is rational. Then, by Lemma 1.2, 2 = a b, where a and b share no common factors. Thus, squaring, we get 2b2 = a2. It follows that a2 is even, and hence so is a. Write a = 2m for some m

5. Using bold text  

As explained in an earlier lecture, LaTeX is a mark-up language. The best approach is to use LaTeX to tell the computer what kind of thing your text is, rather than specifically how to display it. Bold text is almost never used in sentences, where the \emph{...} command (meaning ‘emphasised text’) is used instead.

6. Overfull hboxes  

LaTeX creates documents with fully-justified text (i.e., text stretched from the left margin to the right). Usually LaTeX does this well, and doesn’t like to stretch the space between the words too much. Sometimes it chooses to spill over the right margin slightly. If this happens, you will get a warning about an ‘overfull hbox’ in the log-file.

Example. Overfull hboxes can happen with looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong words.

To fix this, slightly reword the sentence; usually LaTeX finds a better way to split the lines. If the overfull hbox is very slight, you might choose to ignore it.

2 Two grammatical grumbles

Grammatical grumbles  

1.

Using too many paragraphs.

2.

Not writing in full sentences.

1. Using too many paragraphs  

Some have a habit of starting each new sentence as a new paragraph. Each new paragraph should represent a change of idea or step forward.

Example (Bad). Let y = ex cos x.

Differentiating, we find dy dx = ex(cos x sin x).

Thus, dy dx = 0 if and only if ex(cos x sin x) = 0.

Since ex > 0 for all x, it follows that…

Example (Better). Let y = ex cos x. Differentiating, we find dy dx = ex(cos x sin x). Thus, dy dx = 0 if and only if ex(cos x sin x) = 0. Since ex > 0 for all x, it follows that…

2. Not writing in full sentences  

Mathematicians often try to save time when writing by hand, adding little notes, and these might not be written in full sentences.

When typing mathematics you should write everything in full sentences.

Example (Bad). If y = sin (x)cos (x) then y = cos 2(x) sin 2(x) (product rule). Sub in x = 𝜃2. Then…

Example (Better). If y = sin (x)cos (x) then use the product rule to obtain y = cos 2(x) sin 2(x). Substitute in x = 𝜃2. Then…

3 Activity time

Activity (More proof-reading). The document on the course website in the Presentation Materials has a number of problems with it. Find as many ways of improving the document as you can.

4 Next week

First mini-project to launch next week  

Make sure you attend the Week 6 lectures next week, as the first mini-project will be launched then (to be submitted in Week 8).

5 Examples of LaTeX errors

Most often, errors are just due to bad LATE X code. Error message alerts show up at the bottom of the left-hand pane in TeXworks and just above the output pane in Overleaf. Unfortunately, LaTeX’s error messages aren’t always the clearest (though Overleaf, in particular, does a good job of trying to help).

1! Missing $ inserted. 
2<inserted text> 
3               $ 
4l.55 \item Let f(x) = a_ 
5                       0+a_1x+a_2x^2+a_3x^3 and $g(x) = b_0+b_1x+b_2x^2$. F... 
6Ive inserted a begin-math/end-math symbol since I think you left one out.

This is maths symbols used not in math-mode (in this case, the _ symbol).

1! LaTeX Error: \begin{enumerate} on input line 74 ended by \end{document}. 
2 
3See the LaTeX manual or LaTeX Companion for explanation. 
4Type  H <return>  for immediate help. 
5 ...

This is a forgotten \end{enumerate}.

1Runaway argument? 
2{Maclaurin and Taylor series, drawing attention to the $x-a$ in the d\ETC. 
3! File ended while scanning use of \emph . 
4<inserted text> 
5               \par 
6<*> ...10*Maclaurin*series/10_maclaurin_series.tex 
7 
8I suspect you have forgotten a ‘}’, causing me to read past where you wanted me to stop.

This is a forgotten }.

1! LaTeX Error: Environment enumreate undefined. 
2 
3See the LaTeX manual or LaTeX Companion for explanation. 
4Type  H <return>  for immediate help. 
5 ... 
6 
7l.54 \begin{enumreate} 
8 
9Your command was ignored.

This is a misspelling of ‘enumerate’.

PIC

This is a missing \end{document}.

Many LATE X errors will be a variation on one of the above examples.

About Computer Lab 5  

In Computer Lab 5 we’ll look at referencing and tables and a few other things.