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. Quick start for the impatient
  4. LATEX commands
  5. White-space in LATEX
  6. Special characters
  7. Quotation marks
  8. Accents
  9. Dimensions, hyphenation, justification, and breaking
  10. 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 

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

@A@[@O@B@@@@@@@h@@PñÿB@h@@@M@D@e@f@a@u@l@t@ @S@t@y@
BA.@@@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

  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 wordprocessors don’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. 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. 

  3. 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.8 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. 

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