Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
LaTeX Beginner's Guide - Second Edition

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

Product type Book
Published in Oct 2021
Publisher Packt
ISBN-13 9781801078658
Pages 354 pages
Edition 2nd Edition
Languages
Author (1):
Stefan Kottwitz Stefan Kottwitz
Profile icon Stefan Kottwitz

Table of Contents (16) Chapters

Preface Chapter 1: Getting Started with LaTeX Chapter 2: Formatting Text and Creating Macros Chapter 3: Designing Pages Chapter 4: Creating Lists Chapter 5: Including Images Chapter 6: Creating Tables Chapter 7: Using Cross-References Chapter 8: Listing Contents and References Chapter 9: Writing Math Formulas Chapter 10: Using Fonts Chapter 11: Developing Large Documents Chapter 12: Enhancing Your Documents Further Chapter 13: Troubleshooting Chapter 14: Using Online Resources Other Books You May Enjoy

Chapter 8: Listing Contents and References

LaTeX makes it very easy to create lists for many purposes. For example, we've seen that just the simple \tableofcontents command creates a nice-looking table of contents. It takes the entries from the headings and the numbers of the pages they fall on and produces a nice list.

A table of contents (TOC) and an index are handy for navigating within a book. Lists of tables and lists of figures are similarly helpful. Usually, an academic paper or a book requires a list of references for citations, a bibliography. Once you finish this chapter, you will know how to create such lists and how to customize them.

In this chapter, we will cover the following topics:

  • Customizing the table of contents
  • Generating an index
  • Creating a bibliography
  • Changing the headings

We will start with the contents.

Technical requirements

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

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

In this chapter, we will use LaTeX standard features and the index package.

Furthermore, we will briefly talk about the following packages: biblatex, cite, hyperref, makeidx, minitoc, multitoc, natbib, titlesec, titletoc, tocbibind, tocloft, and url.

You can find related examples in the LaTeX Cookbook, Chapter 7, Contents, Indexes, and Bibliographies, with code examples available on the book's website: https://latex-cookbook.net/chapter-7.

Customizing the table of contents

Besides just calling \tableofcontents to get a pre-designed list of contents, LaTeX provides basic ways to modify it. Let's use some.

We will create a document that we will use for customizing, and it will also be our working example for the following sections.

We will build the frame of a document containing some headings. We will modify the automatically created table of contents to be more nuanced and to contain additional entries.

In Chapter 3, Designing Pages, we saw the effect of \tableofcontents. LaTeX collected the entries from the headings. We will use headings down to the subsubsection level.

Later, we will extend the TOC further. We will manually add entries for some headings. Let's start with the base document:

  1. Start a new book document:
    \documentclass{book}
  2. Set the table of contents' depth value to 3 to include headings down to the subsubsection level:
    \setcounter{tocdepth}{3}
  3. Begin the document...

Generating an index

Extensive documents often contain an index. An index is a list of words or phrases and page numbers pointing to where we can find related material in the document. In contrast to a full-text search feature, the index provides selective pointers to relevant information.

When it's our turn to identify and mark the words for the index, LaTeX will collect this information and typeset the index.

Suppose our example contains information about an enterprise and its structure as well as its network structure and design. We will mark places in the text where these concepts occur. Finally, we will order LaTeX to typeset the index, as follows:

  1. Go back to our example. In the preamble, load the index package and add the command to create the index:
    \usepackage{index}
    \makeindex
  2. In the caption of our enterprise diagram, index this point with the keyword enterprise:
    \caption{\index{enterprise}Enterprise Organizational 
    Chart}
  3. In the third chapter, which...

Creating a bibliography

Scientific documents in particular commonly contain a list of references or a bibliography. We will work out how to typeset a bibliography and how to refer to its entries.

Using LaTeX's standard features, we will create a small list of references containing a book and an article by Donald E. Knuth, the creator of TeX. In our body text, we will refer to both:

  1. Create a new document as follows:
    \documentclass{article}
    \begin{document}
    \section*{Recommended texts}
    To study \TeX\ in depth, see \cite{DK86}.
    For writing math texts, see \cite{DK89}.
    \begin{thebibliography}{8}
    \bibitem{DK86} D.E. Knuth, \emph{The {\TeX}book}, 1986
    \bibitem{DK89} D.E. Knuth, \emph{Typesetting Concrete
    Mathematics}, 1989
    \end{thebibliography}
    \end{document}
  2. Click on Typeset and examine the output:

Figure 8.6 – A list of references

We used an environment called thebibliography to typeset the list of references, which is similar to a...

Changing the headings

As in our diagram example in Figure 8.2, if you don't like the heading Contents, you could easily change it. LaTeX stores the text of the heading in the \contentsname text macro. So, just redefine it as follows:

\renewcommand{\contentsname}{Table of Contents}

Here's a list of such macros and their default values:

  • \contentsname: Contents
  • \listfigurename: List of figures
  • \listtablename: List of tables
  • \bibname: Bibliography (in the book and report classes)
  • \refname: References (in the article class)
  • \indexname: Index

Furthermore, as promised, here's a list of other macros for names used by LaTeX, with their default values:

  • \figurename: Figure
  • \tablename: Table
  • \partname: Part
  • \chaptername: Chapter
  • \abstractname: Abstract
  • \appendixname: Appendix

This is not really surprising! Using name macros is especially useful when you write in another language. For instance, the babel...

Summary

In this chapter, we dealt with many kinds of lists. Specifically, we learned about generating and customizing the table of contents, lists of figures and tables, producing an index pointing to relevant information for keywords and phrases, and creating bibliographies, both manually and using a bibliography database.

These lists will guide you to the information that you are looking for. They aren't just for listing and summarizing. That's why the headings of the list of figures and the list of tables usually don't appear in the TOC, as they directly follow the TOC. Sometimes, there's even the strange requirement to list the table of contents within itself. If you are not sure about a design or a requirement, have a look at a good book in your particular field to see what exemplary tables of contents, lists, and indexes might look like.

In the next chapter, we will look at scientific writing in depth.

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 2021 Publisher: Packt ISBN-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.
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}