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

Introduction

This book originally accompanied a two-day course on using the LATEX typesetting system. It was extensively revised and updated for publication, so that it could be used for self-study as well as in the classroom. For those with sufficient prior knowledge of computing and authoring, it has also successfully been used as the basis for a 1-day intensive introductory course. It is aimed at users of Unix & GNU/Linux, including Apple Macintosh OS X, and Microsoft Windows systems, but it can be used with LATEX on any platform, including other Unix workstations, mainframes, Android and Apple smartphones, and even some older Personal Digital Assistant (PDA)s.

Who needs this book?

The course was originally designed for computer-literate but non-IT professionals in business, academic, and nonprofit organisations. You may be in a similar position, but you may also come from another background entirely; you may be a hobbyist, a school or college student, a home computer user or a volunteer worker, or you might just be interested in high-quality automated typesetting. However, it’s likely that you have one or more of the following or similar objectives:

  • producing consistent, typeset-quality formatting;

  • formatting long or complex or highly-structured or repetitive or automatically-generated documents;

  • saving time and effort by automating common tasks;

  • gaining independence from expensive and restrictive proprietary hardware, software, or file formats;

  • creating robust, durable documents which will survive changes in technology.

Skills needed

LATEX is a very easy system to learn, and requires no specialist knowledge to get started, although it’s useful if you understand something about writing, formatting, and readability. However, you do need to be completely familiar with using your computer, which means knowing the following topics thoroughly. Note that none of these is in any way specialist; they’re all basic, fundamental, standard computer skills that everyone should know:

  • Using the mouse: how to point and click with your mouse to select text and pick from a menu (or to use keyboard shortcuts to do the same) [1.1.4–1.1.6, 1.3.1, 1.4.1–1.4.2,]

  • Handling files: how to create, open, save, close, rename, copy, move, and delete files and folders (directories) [2.3];

  • Handling characters: where to find all 95 of the printable ASCII characters on your keyboard and what they mean, and how to type accents and symbols, if you need them [3.2.1.2];

  • Using an editor: how to use a good plaintext editor [2.1.3];

  • Downloading files: how to use your Web browser and/or file transfer program to download and save files from the Internet [7.1.6 [7.3.1.6]]

  • Unzip files: how to uncompress and unwrap (unzip or detar) compressed files [2.3.8];

  • Install software: how to install software, both manually and using automated installers [2.6];

  • RTFM: how to read and follow instructions [1.7] and how (and where) to ask for help.

If you don’t know how to do these things yet, it’s important to go and learn them first. Trying to become familiar with basic computer skills at the same time as learning LATEX is not going to be as effective as doing them in the right order.

It is important to understand that these are not specialist skills — they are standard for anyone who uses a computer, and they form a fundamental part of the basic knowledge of computers. With the exception of software installation, they were included in the European Computer Driving Licence (ECDL) course: the relevant module and section numbers of the ECDL syllabus are noted in parentheses or in the margin above (Kelly and O’Connor, 2005).

Objectives of this book

By the end of this book, you should be able to undertake the following tasks:

  1. use your editor to create and maintain your documents;

  2. use LATEX markup to identify your document structure and formatting requirements;

  3. typeset LATEX documents, correct simple formatting errors, and display or print the results;

  4. identify and use additional LATEX packages (using the Internet for downloading where necessary and installing them)

  5. recognise the limitations of procedural markup systems and choose appropriate generic markup methods where appropriate.

Synopsis

The original course covered the following topics as separate sessions. Earlier versions of this document kept to this structure in the book as chapters, but the current version has moved Installation (originally chapter 1) to Appendix A and merged it with the details of configuration; and Typesetting, viewing, and printing (originally chapter 4) to a new Appendix; as the procedure in both cases has been so much simplified that the previous level of detail is no longer needed in most cases.

  1. How to create LATEX documents (with a Quick-Start Guide for the impatient);

  2. Basic document structures (the Document Class Declaration and its layout options; the document environment with sections and paragraphs);

  3. Using packages and CTAN to adapt formatting to your needs;

  4. Other document structures (lists, tables, figures, images, and verbatim text);

  5. Textual tools (footnotes, marginal notes, cross-references, indexes and glossaries, and bibliographic citations);

  6. Typographic considerations (white-space and typefaces; inline markup and font changes; extra font installation and automation);

  7. Programmability and automation (macros and modifying LATEX’s behaviour);

  8. Conversion and compatibility with other systems (XML, Word, etc).

  1. Where to get and how to install LATEX (using the TEX Users Group’s TEX Collection DVD);

  2. How to install new fonts;

  3. Typesetting, viewing, and printing (largely obsolete now that editors are better integrated with viewers and printers);

  4. User groups and the benefits of membership;

  5. The ASCII character set;

  6. The GNU Free Documentation License.

I have made a few other changes in the transition to printed and online form, but the basic structure is the same, and the document functions as a workbook for the course as well as a standalone self-teaching guide.

Where’s the math?

Please understand that this document does not cover mathematical typesetting, complex tabular material, the design of large-scale macros and document classes, or the finer points of typography or typographic design, although it does refer to these topics in passing on a few occasions.

There are several other guides, introductions, and ‘get-started’ documents on the Web and on CTAN which cover these topics and more in great detail. Among the more popular are:

This list was taken from the CTAN search page. There are also lots of books published about TEX and LATEX: the most important of these for users of this document are listed at the end of the the preface ‘Foreword’.

Availability of LATEX systems

The standard implementations of TEX and related systems are in the TEX Collection, published annually on DVD by the TUG. These are all derived from Knuth’s master versions, and adapted for all major platforms (Unix & GNU/Linux, including Apple Mac OS X; and Microsoft Windows). The DVD is sent free to all TUG members and can be obtained from your local user group. You can also download the ISO image file from CTAN to burn your own copy.

Commercial implementations are listed in § 5.

Systems included on the TEX Collection DVD

ProTEXt (Windows)

This is the popular MiKTEX implementation plus the TEXStudio editor.

MacTEX (OS X)

This is TEX Live plus the TEXshop editor (the Mac’s built-in Preview is used for the WYSIWYG display).

TEX Live (Unix & GNU/Linux, including Apple Macintosh OS X, and Windows)

Generic TEX Live for systems without a built-in package distribution.

Users of Red Hat/CentOS, Debian/Ubuntu, and derivative systems should normally use their system-supplied package manager (eg yum, rpm, or apt-get; or Synaptic or Software Installer etc) to install the RPM or DEB packaged versions provided in their supplier’s repositories, as these provide tighter integration with other software such as editors and viewers; but the generic TEX Live can be used where the absolute latest bleeding-edge features are required (in which case any system-installed version SHOULD be removed first to avoid conflicts and unresolved dependencies — see the notes in the appendix ‘Installation’).

Because the TEX program (the internal ‘engine’ which does the actual typesetting) is independent of any other software, it doesn’t have its own editor like a wordprocessor does. Instead, you get to choose whichever editor you prefer: there are lots available, and you can switch between them to find one you like: see § 2 and § A.3 for details.

Graphical interfaces (editors)

Most users run LATEX with a graphical plaintext editor which has a toolbar and menus like other windowing applications. These usually include all the common formatting features of LATEX plus writing tools like spellchecking, thesaurus, indexing, and bibliographic citation, and generally all work in a very similar way. Text-only interfaces are available for use on servers and automated production systems (see § 3).

The Windows and Mac systems described in § 6 come with a recommended editor (TEXStudio and TEXshop respectively), but you can install any other suitable editor you prefer (see § A.3). The Unix & GNU/Linux distribution does not install any editor because these systems usually have their own software repositories with suitable editors already available for installation, such as Emacs, vi, TEXStudio, or Kile.

Fully synchronous typographic interfaces (editors) are available as commercial products: see list item ‘Synchronous typographic displays’.

Command-line interfaces

While you would use a graphical interface to set up an automated system like a web server or e-commerce environment, it is useless where systems have to run in the background, unattended, with no human to click on buttons. In fact, the TEX typesetting engine is a Command-Line Interface (CLI) program, which can be used from any script or console or ‘Command’ window. You can type the command xelatex followed by the name of your document file (see Figure C.2 for an example).

Commands like these let you run LATEX in an automated or scripted environment like a Common Gateway Interface (CGI) script on a web server or a batch file on a document publishing system. All the popular distributions for all systems, both free and commercial, include this CLI interface as standard.

WYSIWYG displays

LATEX usually displays your typeset results in a separate window such as a PDF viewer, updated automatically every time the document is retypeset, because the typesetting is kept separate from the editing. This is called an ‘asynchronous’ display. Some systems, however, can format the typesetting while you type each character, like a wordprocessor, although at the expense of some flexibility. These are called ‘synchronous’ displays.

Asynchronous typographic displays

The WYSIWYG display is updated when the document is reprocessed, rather than while you are still typing, as it would with a wordprocessor. To update the display, just click on the button which reformats the document. You are probably already familiar with this idea if you have used HTML, where you reload the page in a browser to see it, or if you have used a spreadsheet, where the ReCalc button (F9) does something similar.

TEX systems typeset the whole document at one go, including all indexing, cross-references, tables of contents, bibliographic citations, and the placement of figures and tables. TEX also formats whole paragraphs at a time, rather than line-by-line as wordprocessors do, in order to get the quality of spacing, hyphenation, and justification right. This approach makes it much faster than a wordprocessor in dealing with typical complex documents, as it can be done without holding the whole document in memory.

Synchronous typographic displays

The WYSIWYG display is the editing window, and it updates while you type, like a wordprocessor. Some popular examples are LYX (all platforms), Textures (Mac), BaKoMa TEX (Windows), and Scientific Word (Windows) (see Table 1).

With a synchronous display you get Instant Textual Gratification™, but like a wordprocessor, your level of control is restricted to that of the system you use, which cannot provide access to everything that LATEX can do. For complete control of complex material you may still need to use separate editing and display windows as for asynchronous implementations.

Near-synchronous displays

There are a few systems for very-close-to-synchro­nous WYSIWYG display. These include Jonathan Fine’s Instant Preview with the TEX daemon, and David Kastrup’s preview-latex package for embedding typographic fragments from the typeset display back into the editor window.

What You See Is What You Get (WYSIWYG) refers to the accuracy of the typographical display. Most modern ones are pretty good, given the fact that your screen is probably only a fraction of the accuracy of your printer — between 96 dots per inch (DPI) on an old desktop screen and around 300 DPI on some handhelds; as opposed to 600 DPI on your printer, or 1200 DPI or more in photo-quality, and 3,600 DPI or more on laser-driven phototypesetters.

Commercial implementations

Although the TEX Collection is available free of charge, there are several excellent commercial implementations of TEX and LATEX listed in Table 1, with enhanced support and additional features. These companies, founders, and staff have been good friends of the TEX and LATEX communities for many years: if these versions are of benefit to you, I urge you to support them and buy their products.

Symbols and conventions

There are several typographic conventions about how you represent computer-related material in print which are shown in Table 2. Typed commands, keywords, examples of input, and related text are in a fixed-width (monospace) font, like a typewriter, because that’s how program code is usually displayed and edited (this also helps avoid ambiguities, as explained in § 4.7.1.1). Special values, like numeric quantities represented by a name or symbol, are in italics, as in mathematics. Terms or references to products, programs, packages, and other components of LATEX have their own typographic form. Finally there are some symbols like keyboard keys and menus, which are shown graphically.

Table 2: Typographic notations used in this document

NotationMeaning
MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONALThese keywords have a specific and possibly mandatory meaning when shown in THIS STYLE (usually small capitals), according to the specification in RFC 2119 (Bradner, 1997).
\commandLATEX commands (control sequences) that you type which perform an action like \clearpage, or identify your text like \footnote{...}
\lengthControl sequences which store a dimension (a measurement in units), like \textwidth
counterValues used for counting (whole numbers only), like section
termThe defining instance of a new techical term
environmentA LATEX formatting or identification environment, like quotation
classA LATEX document class (available from CTAN), like memoir
packageA LATEX add-on package (available from CTAN), like footmisc
productA program or product name
typewriter typeLiteral examples
valueMnemonic examples of things you must type, where you have to supply real-life values of your own, like \author{your name} means you must replace your name with your own real name.
xA specific key on your keyboard
Ctrl--xTwo keys pressed together, not separately
Escq Two keys pressed one after another
SubmitAn on-screen button to click
MenuSubmenuItemA drop-down menu with items to select
A normal space, just so it’s visible

Production note

This document is written and maintained in XML, using a customized version of the DocBook 5 DTD. Conversions are made to HTML and LATEX using XSLT2 scripts and Michael Kay’s Saxon processor.

The complete source, with all ancillary files, is available online at http://www.ctan.org/tex-archive/info/beginlatex/src/. If you want to try processing it yourself you will need Java and Saxon in addition to a full installation of LATEX.

This document is published under the terms and conditions of the GNU Free Documentation License. Details are in the last appendix ‘License’.

  1. Not a wordprocessor like OpenOffice, Lotus Notes, Corel WordPerfect, or Microsoft Word, and not a ‘dumb’ editor like Apple TextEdit or Microsoft Notepad

  2. Y&Y, Inc, who produced a TEX distribution for many years, have ceased trading. Some of their add-on fonts are now being distributed by the TEX Users Group (see the appendix ‘User Groups’), or have been replaced by Open Source implementations, and there is a mailing list at the TUG web site for the support of former Y&Y users.