Reader small image

You're reading from  LaTeX Beginner's Guide - Second Edition

Product typeBook
Published inOct 2021
PublisherPackt
ISBN-139781801078658
Edition2nd Edition
Tools
Right arrow
Author (1)
Stefan Kottwitz
Stefan Kottwitz
author image
Stefan Kottwitz

Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation. For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX and goLaTeX and the Q&A sites TeXwelt and TeXnique. He runs the TeX graphics gallery sites TeXample, TikZ, and PGFplots, the TeXlive online compiler, the TeXdoc service, and the CTAN software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet. He publishes ideas and news from the TeX world on his blogs LaTeX and TeX. Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.
Read more about Stefan Kottwitz

Right arrow

Chapter 11: Developing Large Documents

The first chapter of this book claimed that LaTeX handles large documents easily. When you create extensive documents, you will notice that LaTeX keeps on doing its job reliably. For the computer, it doesn't matter how the source code is formatted. But for you, as the developer, it's essential to keep your source document manageable. After all, it may consist of hundreds of pages with thousands of lines.

By the end of this chapter, we will be able to handle a big document project with several files, a title page, and separately numbered front matter and back matter parts.

In this chapter, we will learn about the following:

  • Splitting the input
  • Creating front and back matter
  • Designing a title page
  • Working with templates

That's a big step forward on the way to writing a thesis, a book, or an extensive report.

Let's begin by building a document based on several files.

Technical requirements

You can use a local LaTeX installation, or you can compile the example code online at https://latexguide.org/chapter-11.

The code is available on GitHub at https://github.com/PacktPublishing/LaTeX-Beginner-s-Guide-2nd-Edition-/tree/main/Chapter_11_-_Developing_Large_Documents.

In this chapter, we will use the following packages: amsmath, amsthm, babel, blindtext, fontenc, geometry, lmodern, microtype, natbib, and tocbibind.

We will also briefly look at the pdfpages and titling packages.

Splitting the input

Divide and conquer—this could be our motto now. We will figure out how to break down a document into several sub-documents. Thus, while we are writing, we will be able to manage a huge project consisting of many chapters in separate files.

Firstly, we will separate settings and body text by swapping out the preamble. Secondly, we will write chapters in separate files and include them afterward.

We will begin to write a detailed document regarding equations and equation systems. The result should be in the style of a thesis or a book. We can use the last example of Chapter 9, Writing Math Formulas, where we dealt with theorems concerning equations.

We will create several files, step by step:

  1. Create a new document. Inside this, load all the packages and specify the options, like we did in our preambles in the previous chapters. Use all the beneficial packages that we have already learned about:
    \usepackage[english]{babel} 
    \usepackage[T1]{fontenc...

Creating front and back matter

In contrast to reports, books often begin with introductory material such as copyright information, a foreword, acknowledgments, or a dedication. This part, including the title page and the table of contents, is called the front matter.

At the end, a book might include an afterword and supporting material such as a bibliography and an index. This part is called the back matter.

The book class and some other classes, such as scrbook and memoir, support this kind of sectioning directly. Often, desired consequences of this sectioning are differences in the numbering of pages and chapters. Let's see how it works.

Our book will begin with a dedication. The front matter will consist of the table of contents, lists of tables and figures, and a dedication. All the pages of the front matter will be numbered with Roman numerals. Finally, we add an appendix providing supplementary proofs, which we like to present outside the main chapters:

    ...

Designing a title page

We can quickly create a good-looking title page using \maketitle, as we did in Chapter 2, Formatting Text and Creating Macros. Document classes usually offer this command to generate a suitable pre-formatted title page. Alternatively, you could use a titlepage environment to design its layout freely. So, let's design a nice title page for our book of equations.

In Chapter 2, Formatting Text and Creating Macros, we have already used some formatting commands, such as \centering, and font size and shape commands, such as \Huge and \bfseries, to format a title. We will do it similarly within a titlepage environment:

  1. Create a file, title.tex, with the following content:
    \begin{titlepage}
    \raggedleft
    {\Large The Author\\[1in]}
    {\large The Big Book of\\}
    {\Huge\scshape Equations\\[.2in]}
    {\large Packed with hundreds of examples and solutions\\}
    \vfill
    {\itshape 2011, Publishing company}
    \end{titlepage}
  2. Add this line right after \frontmatter:
    \include...

Working with templates

When we develop a document, we specify the document class, choose meaningful packages and options, and create a frame for the content. To repeat these steps for each document would be too laborious.

If we plan to write several documents of the same type, we may create a template. This could be a .tex file containing the following:

  • A declaration of a suitable document class together with a set of meaningful options
  • Routinely used packages and packages that are most eligible for our document type
  • A predefined layout for the header, footer, and body of the text
  • Self-made macros to facilitate our work
  • A framework of sectioning commands, where we fill in the headings and the body text
  • Or a framework containing \include or \input commands, for which we create the body text chunks later on

As we improve our LaTeX knowledge, such templates might grow and become better and more sophisticated. Many users publish their elaborate templates...

Summary

The techniques we learned in this chapter will help us to develop and maintain bigger projects. Though enthusiastic users prefer LaTeX to write small documents, many people learn LaTeX because they plan to write longer texts such as a thesis. However, splitting documents and the use of templates are useful for small pieces of writing as well, such as for letters—just think of the header, footer, and address fields.

In this chapter, we created and managed large documents consisting of several files, including front and back matter and a separate title page.

Now that we can develop and handle large documents, we will see how to improve them further in the next chapter.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
LaTeX Beginner's Guide - Second Edition
Published in: Oct 2021Publisher: PacktISBN-13: 9781801078658
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Stefan Kottwitz

Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation. For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX and goLaTeX and the Q&A sites TeXwelt and TeXnique. He runs the TeX graphics gallery sites TeXample, TikZ, and PGFplots, the TeXlive online compiler, the TeXdoc service, and the CTAN software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet. He publishes ideas and news from the TeX world on his blogs LaTeX and TeX. Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.
Read more about Stefan Kottwitz