MPS115/116 Presentation Lecture 5:
Common LaTeX Let-Downs
and Grammatical Grumbles

Dr Simon Willerton

We are looking at more detailed issues with LaTeX and writing. You will be starting your first mini-project next week. You will also be (anonymously) critiquing the write-ups of others.

1 Environments

Markup and environments  

There are three basic ways to ‘mark up’ text in LaTeX.

Environments begin with \begin{..} and end with \end{..}.

I indent environments with four spaces to make my file more readable.

2 Seven common LaTeX let-downs

LaTeX let-downs  

1.

Maths not in maths-mode.

2.

Text in maths-mode.

3.

Using the wrong dash.

4.

Punctuation in the wrong place.

5.

Using too much displayed mathematics.

6.

Using bold text.

7.

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. Using the wrong dash  

In typography there are at least four(!) kinds of dash.

name LaTeX
hyphen - - quick-witted quick-witted
minus sign $-$ 3 4 = 1 $3 - 4 = -1$
en-dash -- 30–40 people 30--40 people
em-dash ---

For numerical ranges you use an en-dash not a hyphen.

The “en” and “em” refer to the width of the letters “N” and “M”.

In British English, for parenthetical asides – like this – the en-dash is used.

However, in American English, typically—in this way—the em-dash is used.

4. 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.

4. 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.

5. Using too much displayed mathematics I  

Beginners to LaTeX 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.

5. 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

5. 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

6. Using bold text  

As we know, 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. The choice of bold or italic for emphasized text should be left to LaTeX. This ensures consistency and stops mixing bold and italics. For emphasized text you should use the \emph{...} command.

7. 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’. An hbox is a horizontal box of text.

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.

3 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…

4 Activity time

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

5 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).

6 The lab this week

About Computer Lab 5  

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