Little LaTeX Lessons

I know most of the world uses Word and Microsoft Office products so this post is for the chosen few – the small minority do use LaTeX. LaTeX produces beautiful documents, with equations if needed which is big selling point for many. LaTeX has been around since the 1980′s and is based on TeX produced by iconic computer scientist Donald Knuth in 1978. Unlike most things in the ethereal world of information technology, its seems LaTeX is not going to die even in the age of tablets (see The revolution will be typeset, D.Steele, Physics World, Jan 2013, p35).
However LaTeX is not simple to use.  There is lots of help, many free guides which a search for LaTeX guide will turn up, or one of my favourites, Tobi Oetiker’s The not so short guide to LaTeX2e.
What is missing are some of the little things.  At least, these useful snippets may be out there but they are buried under the important things. So I thought I would post my top tiny tips, the little bits it took me ages to discover, the things I see again and again in the reports from my students.
  1. Never leave an empty line after the end of an equation or eqnarray unless you really mean to start a new paragraph after the equation.
    An empty line in regular text always indicates the start of a new paragraph and the next line of text will be indented. Usually equations are meant to be read as being in the middle of a paragraph.
  2. Quotes in LaTeX are built from the two different types of single quotes, do not use the double quote symbol.
    The right way to get quotes is to put one or two single backwards quote characters ` (grave accent, ASCII 96, on a funny key to the left of the number 1 on my UK keyboard) at the start of a phrase, and match with the same number of normal single quotes  (apostrophe, ASCII code 39, with the @ symbol on my UK keyboard). Never use the single symbol for a double quote  (ASCII 34, on the key with the number 2 on my UK keyboard). LaTeX will interpret matched pairs of single quotes as a double quote and will produce a nice result.
  3. For labels as subscripts, use the \mathrm{text} to get the text in roman not italic style usually used for maths.
    Thus x_{\mathrm{max}} looks better than plain x_{max}. If you use this a few times, why not define a new command
    e.g. \newcommand{\xmax}{x_{\mathrm{max}}} which is usually placed before the \begin{document}.
  4. Likewise all the standard functions of mathmatics have their cown commands.  The function is then typeset in standard roman so that it stands out from the italic style usually used for maths.  That is use \ln not ln as the latter sometimes looks like it might be two variables l and n multiplied together.
  5. For “much less than” and “much more than” symbols do not use double less than or double greater than signs.
    There are special commands \ll and \gg which look much better than doing << and >>.
  6. To see all the labels used in equations figures, sections etc. while you are writing a document, put a

    command near the top of the LaTeX file, just after the documentclass command.

  7. Dashes and hyphens:-
    • one for a hyphenated-word,
    • two for a number range 1–2,
    • three for a punctation dash — like this (note spaces either side of the three dashes).
  8. To get the name of the file used to start LaTeX use something like

    To get the names of all the constituent LaTeX files is harder.

  9. I may want to create my own simple symbol by placing two on top of each other. LaTeX has some standard symbols for spaces and it is useful to know some of them for minor tweaks.
    • \; a thick space
    • \: a medium space
    • \, a thin space
    • \! a negative thin space
    • \qquad a large space

    So for example I might write

             A &=& B \, , \qquad B=C
             I &=& \int_{0}^{1} dx \; x \cos(2 \pi x)


Leave a Reply