1
Introduction

1.1 Introduction

It would be a great disservice to say LaTeX is just a system for typesetting mathematics. Its applications span writing business and personal letters, newsletters, articles, and books covering the whole range of the sciences and humanities, right up to full-scale volumes and encyclopaedias and reference works on all topics [2].

Nowadays, distributions of LaTeX exist for practically every type of computer and Operating System (OS) . This chapter hopes to provide a strong justification of its use along with a wealth of information about its many present-day uses. First, however, let’s look at some background information.

1.2 A Historical Overview

1.2.1 Inception

In May 1977, Donald Knuth 1 1 An American computer scientist, mathematician, and professor emeritus at Stanford University. He is the 1974 recipient of the ACM Turing Award. Knuth has been called the “ father of the analysis of algorithms ”. of Stanford University [3] started work on the text-processing system that is now known as TeXand METAFONT [ 4 , 5 ]. In the framework of the TeXbook [6], He writes:

TeX a new typesetting system intended for the creation of beautiful books–and especially for books that contain a lot of mathematics. By preparing a manuscript in TeX format, you will be telling a computer exactly how the manuscript is to be transformed into pages whose typographic: quality is comparable to that of the world’s finest printers”

In 1979, Gordon Bell wrote in a foreword to an earlier book, TeX and METAFONT , 2 2 A description language used to define raster fonts. New Directions in Typesetting [7]: Knuth on designing and implementing TeX

Donald Knuth’s Tau Epsilon Chi (TeX) is potentially the most significant invention in typesetting in this century. It introduces a standard language in computer cryptography and in terms of importance could rather be introduction of the Gutenberg press”

In the early 1990s, Donald Knuth officially announced TeX would NOT undergo any further development [8] in the interest of stability. 3 3 The current version can be seen in CTAN . The 1990s saw a flowering of experimental projects which extended TeX in various directions which many of these are coming to fruition in the early 21 st century, making it an exciting time to be involved in automated typography [2].

The development of TeX from its birth as one of Donald Knuth’s “personal productivity tools” 4 4 created simply to ensure the rapid completion and typographic quality of his then-current work on The Art of Computer Programming was largely influenced and improved by the American Mathematical Society (AMS) on behalf of US research mathematicians.

Information : The Art of Computer Programming

Donald Knuth is known for working on the Art of Computer Programming rather than LaTeX and therefore it is worth taking a slight detour here and look at it.

It is a comprehensive, multi-volume monograph presenting programming algorithms and their analysis. As of 2025 it consists of published volumes 1, 2, 3, 4A, and 4B, with more expected to be released in the future. The Volumes 1-5 are intended to represent the central core of computer programming for sequential machines with the subjects of Volumes 6 and 7 are important but more specialised. The books are known to be hard to read but contain a detailed and scientific look at the performance of algorithms.

1.2.2 Adding Macros: LaTeX

While Knuth was developing TeX, in the early 1980s, Leslie Lamport 5 PIC 5 An American computer scientist and mathematician, known for his seminal work in distributed systems, and as the initial developer of the document preparation system LaTeX and the author of its first manual. started work on the document preparation system now called LaTeX, which used TeX’s typesetting engine and macro system to implement a declarative document description language based on that of a system called Scribe by Brian Reid [9]. The appeal of such a system is that a few high-level LaTeX declarations, or commands, allow the user to easily compose a large range of documents without having to worry much about their typographical appearance .

The details of the layout can be left for the document designer to specify elsewhere.

The 2 nd edition of LaTeX: A Document Preparation System [10] begins with:

LaTeX is a system for typesetting documents. Its first widely available version, mysteriously numbered 2.09, appeared in 1985.”

This release of a stable and well-documented LaTeX led directly to the rapid spread of LaTeX-based document processing beyond the mathematical community.

LaTeX was the first widely used language for describing the logical structure of a large range of documents and hence introducing the philosophy of logical design.

The essence of “logical design” is that the author should be concerned only with the logical content of his or her work and not its visual appearance.

Back then, LaTeX was described variously as TeX for the common men. Its use spread very rapidly during the next decade. By 1994 Leslie could write,

LaTeX is now extremely popular in the scientific and academic communities, and it is used extensively in industry [2]

The worldwide availability of LaTeX allowed fast adoption in TeX and in its use for typesetting a range of languages. LaTeX 2.09 came with documentation worth translating because of its clear structure and straightforward style. There were two (2) pivotal conferences 6 6 Exeter UK, 1988, and Karlsruhe Germany, 1989 which established clearly the widespread adoption of LaTeX in Europe and led directly to internationalisation with the work led by Johannes Raman [11] on more general support for languages and switching between them.

In context of typography, the word language does NOT refer exclusively to the variety of natural languages and dialects across the universe as it also has a wider meaning.

For typography, “language” covers a lot more than just the choice of “characters that make up words”, as many important distinctions derive from other cultural differences that affect traditions of written communication. Therefore, important typographic differences are NOT necessarily in line with national groupings but rather arise from different types of documents and distinct publishing communities.

1.2.3 Reworking Fonts and the LaTeX Project

Another important contribution to the reach of LaTeX was the pioneering work of Frank Mittelbach. 7 PIC 7 A Senior IT professional, working with computer typesetting and TeX since the mid 80’s, leading the LaTeX development since the beginning of the 90’s [12]. and Rainer Schopf on a complete replacement for LaTeX’s interface to font resources, the New Front Selection Scheme (NFS). They were also heavily involved in the production of the AMS-LaTeX system that is added advanced mathematical typesetting capabilities to LaTeX.

As a reward for all their efforts, which included a steady stream of bug reports, and fixes for Lamport, by 1991 Mittelbach and Schopf had been allowed to take over the technical support and maintenance of LaTeX with on of their first acts was to consolidate International LaTeX as part of the kernel of the system, based on the typographical standards of Europe [2].

Very soon Version 2.09 was formally frozen and, although the change-log entries continue for a few months into 1992, plans for its demise as a supported system were already far advanced as something new was badly needed. The worldwide success of LaTeX by the early 1990s led in a sense to too much development activity to improve and add functionality by numerous developer. This finally culminated with the announcement in 1994 of the new standard LaTeX, christened LaTeX2e. However this was not enough and another unification effort went underway to unify the branching dialects of LaTeX under one branch.

The development of this “New Standard LaTeX” and its maintenance system was started in 1993 by the LaTeX3 Project Team [13]. Although the major changes to the basic LaTeX kernel and the standard document classes (systems in 2.09) were completed by 1994, substantial extra support for coloured topography, generic graphics, and fine positioning control were added later, largely by David Carlisle. 8 8 Principal Technical Consulant and Group Leader of the XML Technologies group along with a core member of the LaTeX group. He is currently active in the TeX stack exchange, answering anyone’s questions, the author of this book included. Additional work by Mark Purtill on extensions of New Font Selection Scheme (NFSS) to better support variable font encodings and scalable fonts [ 2 , 14 ].

Although the original goal for this new version was consolidation of the wide range of models carrying the LaTeX nature, what emerged was a substantially more powerful system with both a robust mechanism (via LaTeX packages) for extension and, importantly, a solid technical support and maintenance system. This provides robustness via standardisation and maintainability of both the code base and the support systems.

This system remains the current standard LaTeX system.

PIC

Figure 1.2: The LaTeX Project logo, found on its official website [15].

1.3 Current State

Before diving into how to program and type wonderful documents, let’s have an overview of the vast array of files used by a typical LaTeX system with its many components. This overview will also involve some descriptions of how the various components interact with each other and of course with the LaTeX compiler. Most users 9 9 For anyone who wants to learn on how to make good documents, it is worth understanding the internal cogs and gears of the software. will never need to know anything of this software environment which supports their work, but this section will be a useful general reference and an aid to understanding some of the more technical parts of the lecture book [2].

The following description assumes familiarity with a standard computer file system in which a file extension is used to denote the the file type. 10 10 i.e., a .doc extension would tell it is a Word file, or .txt file would imply it is a text file.

When processing a document, LaTeX reads and writes several files , some of which are further processed by other smaller applications. 11 11 For example, if you were to have a glossary of acronyms in your document, an additional .glo would be generated during its compilation. These files, in a non-exhaustive list, are listed in Table 1.1 .

The most obviously important files in any LaTeX documentation project are the input source files. Typically, there will be a master file that uses other subsidiary files. These files most often have the extension .tex, which are known as plain text files as they can be edited with a basic text editor.

Often, several graphical images are included in the typeset document utilizing the graphicx which we will talk later.

For LaTeX to operate, it also needs several files containing structure and layout definitions:

Many of these aforementioned files are provided by the basic system set-up, but others may be supplied by individual users as customisation. LaTeX is distributed with five (5) standard document classes out-of-the-box:

article, report, book, slides, and letter.

These document classes can further be customised by the contents of other files specified either by class options (.cls) or by loading additional packages (.sty). In addition, many LaTeX documents will implicitly input language definition files of the babel system with the extension .ldf and encoding definition files of the inputenc/fontent packages with the extension .def.

The information LaTeX needs about the glyphs 12 12 a glyph is “ the specific shape, design, or representation of a character ”. is found in TeX font metric files (.tfm).

This does NOT include information about the shapes of glyphs, only about their dimensions.

Information about which font files are needed by LaTeX is stored in font definition files (.fd). 13 13 Both types are loaded automatically when necessary.

The output from LaTeX itself is a collection of internal files mentioned previously, plus one (1) very important file that contains all the information produced by TeX about the typeset form of the document.

1.3.1 Files During Compilation

TeX’s own particular representation of the formatted document is that of a device-independent file (.dvi). TeX positions glyphs and rules with a precision far better than 0.01 μ m . 14 14 This is one of the reasons why the document generated by TeX is considered device independent as no device can accurately produce a document better that what TeX describes internally.

Some variants of the TeX program, such as pdfTeX, can produce device-independent file formats including the Portable Document Format (PDF) (.pdf), which is the native file format of Adobe Acrobat.

.dvi specifies ONLY the names/locations of fonts and their glyphs. It does NOT contain any rendering information for those glyphs whereas .pdf file format can contain such rendering information.

File Type Common File Extension(s)
Document Input text .tex .dtx .ltx
Bibliography .bbl
Index/Glossary .ind .glo
Graphics Internal .tex
External .ps .eps .tif .png .jpg .gif .pdf
Other Input Layout and Structure .cls .sty
Internal Auxiliary .aux
Tables of Content .toc
List of figures/tables .lof .lot
Output Results .pdf .dvi
Transcript .log
Bibliography Input and Ouput .aux .bib
Database, Style, Transcript .bib .bst .blg
Table 1.1: An overview of all important files being generated during a LaTeX compilation process (Adapted from [2]).

Some of the internal files contain code needed to pass information from one LaTeX run to the next, such as for cross-references. 15 15 the auxiliary file extension. and for typesetting particular elements of the document such as the table of contents (.toc), the lists of figures (.lof), and of tables (.lot).

There can be others which can be specific to particular packages or to other parts of the system.

Finally, LaTeX generates a transcript file of its activities with the extension .log. This file contains a lot of information, such as:

and other pertinent data that is especially useful when debugging errors. 16 16 It is an infamous joke among programmers, that the error messages of LaTeX can be cryptic. I personally disagree. While the errors may NOT give exact information, it does give you enough information.

Information about citations in document is written by LaTeX to a .aux file. This information is used first to extract the information from a database (i.e., .bib ) and then sort it which is then written to a bibliography file (.bbl) [2].

Because of the limitations of TeX, especially its failure to handle graphics, it is often necessary to complete the formatting of some elements of the typeset document after TeX has positioned everything and written this information to the .dvi file. This is normally done by TeX’s \special primitive which simply puts this information at the correct place in the .dvi file.

This information may be simply the name of a graphs file to be input; or it may be instructions in a graphics language.

Once the document has been successfully processed by TeX, we will probably want to take a look at the format. This is commonly done on screen, but detailed inspection of printed output should always be performed via printing on paper at the highest available resolution. A current favorite approach is to use a .pdf file, especially when electronic distribution of the formatted document is required [2].

Occasionally you will find that some applications will produce much better quality screen output than others; this is due to limitations of the different technologies and the availability of suitable font resources.

1.3.2 A Hello, World!

LaTeX is a programming language . It is a full fledged language, technically 17 17 When I say technically, I mean given enough time and perseverance it is possible to do any kind of computation like other languages. However, this doesn’t mean it is easy. with similar capabilities to C, C++, Python. To start it is always good to write the simplest programme possible and that is generally a Hello, World! programme.

Below you can see the LaTeX version of it.

latex
\documentclass[a4paper,12pt]{article} \begin{document} If one merely wishes to type in ordinary text, without complicated mathematical formulae or special effects such as font changes, then one merely has to type it in as it is, leaving a completely blank line between successive paragraphs. You do not have to worry about paragraph indentation: all paragraphs will be indented with the exception of the first paragraph of a new section. One must take care to distinguish between the `left quote' and the `right quote' on the computer terminal. Also, one should use two `single quote' characters in succession if one requires ``double quotes''. One should never use the (undirected) `double quote' character on the computer terminal, since the computer is unable to tell whether it is a `left quote' or a `right quote'. One also has to take care with dashes: a single dash is used for hyphenation, whereas three dashes in succession are required to produce a dash of the sort used for punctuation---such as the one used in this sentence. \end{document}

For anyone curious, this is a passage from a semi-famous document about LaTeX [17]. While the language may look unwieldy, please don’t worry as by the end of this course you will learn how to craft well typed and designed documents.

1.4 Installation

As with most software which is free and open-source, there are many ways in which we can install LaTeX on our computers [18].

The core of LaTeX is a back end software package that complies the LaTeX code (.tex file) and creates the final document (PDF).

There are a various programs available to compile your document depending on your OS .

The LaTeX Project provides information about how to install LaTeX on Windows, macOS, and Linux, as well as online (Overleaf) services.

We will look at the instruction on how to install the most common LaTeX programs for Windows and macOS in the next section.

Aside from the back end software required to run LaTeX It is highly recommend to use a text editor. 18 18 It would NOT be the best practice to use notepad or textedit to do the majority of your academic writing on.

A text editor, to put it simply, is a front-end software which can be used to create .tex file used by the compiler and provides numerous benefits such as:

Text editor programs such as TeXwork , TexStudio , TexMaker , and TexShop provide a friendly interface for users and are usable out of the box with minimal configuration.

Often these front end programs include help menus, wizards for creating LaTeX objects, drop down menus for inserting symbols or altering text, and many other features that will support both new and experienced LaTeX users. You will find more information about these frontend programs in the "LaTeX Interfaces" box below.

Information : Advanced Editors

Of course, these are NOT the only editors capable of working with LaTeX. As it is written in plain text , any editor can technically work with it. For anyone who has a pre-defined work-flow or have an affinity to working with a specific editor they are welcome to use their own editors.

For this course, we will look at TeXStudio , a well-crafted and supported editor.

1.4.1 Windows

For a Windows computer it is strongly recommend to use the common MiKTeX distribution. The MiKTeX/about page contains several links including how to install, deploy, and update MiKTeX. 19 PIC 19 The logo for miktex A basic set of installation instruction can be found below, but if you are having trouble be sure to check the MiKTeX page (click the previous install hyperlink):

We should have a working LaTeX distribution on our computer. Next we need to install a nice editor and as mentioned we shall install TexStudio .

The installation should be very straightforward. Once the installation is finished. Please click on the icon to start the application which you will be greeted with the following window

PIC

Figure 1.4: Startup of TeXStudio on Windows 11.

On the left we have the side panel which is currently showing an empty structure view. On the lower right you see the messages panel which can be switched to the log panel, the preview panel, or the search results panel. The toolbar allows easy access to some often needed functions, three of them are marked as we will use them soon. The central toolbar offers access to some common latex commands as we will see [19].

1.4.2 Creating a Document

To start easy, lets use their “Quick start” option. Inside the TeXStudio, please click on the menu File/New From Template. You will be greeted with the following menu in Fig. 1.4a :

Here we choose the article class. Once chosen, we can see some boilerplate code being entered into our editor.

PIC

(a) Default installed LaTeX templates.

PIC

(b) Template entered to the editor, ready to be compiled.

As a final part of this chapter, to see if everything is working, please click on the green triangle button to run the LaTeX compiler and then click on the document with the magnifier to see your output.