Your support for our advertisers helps cover the cost of hosting, research, and maintenance of this document

Formatting Information — An introduction to typesetting with LATEX

Chapter 1: Writing documents

In this chapter…

  1. Markup
  2. Choosing your LATEX processor
  3. Picking an Editor
  4. Quick start for the impatient
  5. LATEX commands
  6. White-space in LATEX
  7. Special characters
  8. Quotation marks
  9. Accents
  10. Dimensions, hyphenation, justification, and breaking
  11. Mathematics

LATEX documents are all plaintext files. This means printable characters only (in whatever writing system is native to your language and culture), no hidden internal binary gubbins like fonts or formatting (except for spaces and linebreaks). If you haven’t seen a plaintext file before, it looks like this:

This means printable characters only (in whatever 
writing system is native to your language and culture), 
no hidden internal binary gubbins like fonts or 
formatting (except for spaces and linebreaks).

By comparison, wordprocessor files saying the same thing actually look something like this inside:

@A@[@O@B@@@@@@@h@@PñÿB@h@@@M@D@e@f@a@u@l@t@ @S@t@y@l
@@I@T@e@x@t@ @B@o@d@kj@mHIXs@X@OJF@aJX@_H9D@@@@

The big advantage of plaintext is not just that it’s readable; it’s that the files can be copied, downloaded, or uploaded to any computer system running LATEX and they will typeset exactly the same. Because they are plain text they cannot corrupt your system, and they cannot be used for hiding virus infections in the way that binary (coded non-plaintext) files can be. Everything you can see is in the file and everything in the file is there for you to see: there is nothing hidden or secret and there are no manufacturers’ proprietary ‘gotchas’ like suddenly going out of date with a new version or imposing selective Digital Restrictions Management (DRM), leaving you unable to open your files.

Exercise 1.1 — Plaintext and wordprocessor files

  1. Open your favourite wordprocessor (eg Libre Office, Microsoft Word, Apple Pages, Google Docs, etc)

  2. Create a new, completely empty document (no template)

  3. Type the single word LaTeX

  4. Save the file (call it LaTeX-test or something obvious) in an obvious folder that you will remember (eg Home, Documents, Desktop, My Documents, ~/, or similar)

  5. Close and quit the wordprocessor completely

  6. Open your text editor (eg Emacs, Linux vi, Microsoft Notepad, Apple TextEdit,VS Code, Sublime, etc)

  7. Open the document you just saved

  8. See if you can find the word LaTeX that you typed in it

  9. If it’s not visible, that’s because the wordprocessor you used doesn’t use plaintext

So, you may ask, if LATEX files are all plaintext, how does LATEX know how to format them? The answer is that it uses markup: a system of labels which identifies what’s what in your document. LATEX and its packages recognise the labels and know how to format them, so you don’t usually need to add formatting by hand unless you want to do something very special or invent something out of the ordinary.

Wordprocessors use markup too (Libre Office and Microsoft Word actually use XML internally nowadays) but it’s extraordinarily complex, and encoded to prevent casual inspection. It’s then packaged up (often into a zip file) with all the stylesheets, images, and other bits and pieces. LATEX prefers to keep everything out in the open, making it very obvious how you are constructing your documents, so you can come back to them in the future and not have to worry about what you did.

  1. Some which are straightforward are shown in Figure 1.1 below. 

  2. The £ sign is now nearly obsolete except in the United Kingdom (UK) and some of its former colonial dependencies; in Egypt, Sudan, and Syria; and some other countries for historical purposes. It should not be confused with ₤, used in countries using the Lira. 

  3. Remember not everyone is lucky enough to be able to install new software: many users on business and academic networks still use old versions of TEX because they or their system managers don’t know how to update them. Local user groups may be able to provide help and support here. 

  4. Bear in mind that the degree symbol is a non-ASCII character, so you must specify what input encoding you are using if you want to type it: see the example of the inputenc package in § 1.9 above. If you don’t want to use non-ASCII characters (or if you are using a system which cannot generate them), you can use the command \textdegree to get the degree sign. 

  5. You will also see dollar signs used for math mode. This is quite common but deprecated: it’s what plain TEX used in the days before LATEX, and the habit got ingrained in many mathematicians. It still works as a convenient shorthand like $x=y$, as do double-dollars for display-mode math like $$E=mc^2$$, but they are only mentioned here to warn readers seeing them in other authors’ work that \(...\) and \[...\] are the proper LATEX commands.