Index Creation

This is an excerpt of the book “Better Books with LaTeX.” The book comes with a LaTeX template you can use to easily create your own books.

As opposed to their electronic counterparts, printed books do not have a search functionality to find specific words in the text. Instead, they have an index at the end as a service for the reader to quickly find certain parts of the book that he or she wants to read. If you are planning to only write an e-book version of your book, you can skip this section—e-books do not have indexes because they do not have fixed page numbers: they are formatted differently on different devices.

Did you know?

While an index for e-books is not needed, it can help tremendously with finding keywords for advertisement purposes. -→ Read more in Writing Better Books, the Agile Way

Unfortunately, there is no easy way of generating an index automatically—at least not in the quality a human can. Why is that?

Beyond simply listing all the concepts in a book, a good index is like an intelligent filter. The person creating the index has to think about what a reader might search for and list that word, even though it might never literally appear in the book. Likewise, if a concept consists of multiple words, it might be good to include both variations, for example “language → mathematics” and “mathematics → language” to refer to the language of mathematics and mathematics as a language.

But how can LaTeX help in this regard? In traditional book-making, creating the index of a book is a separate process after the actual book is finished. You can imagine it basically as having the printed book in front of you, then going through page by page, noting which concepts appear on a particular page. This approach gets problematic if you want to make changes to the book that affect the page numbers: you would have to redo the entire index each time.

 Indexing in Word

Figure 5.1:Marking an entry to add it to the index in Microsoft Word.

Word and LaTeX address each this issue in its own way. In Word, you can select the word or words you would like to use as an index entry, and click on Mark Entry (on the References tab, in the Index group). A dialog shows up (see Figure 5.1) where you can configure the index entry (search for “Create and update an index” to find Microsoft Office help on this topic). Once done, Word switches into the hidden symbol mode that shows things like line breaks or index entries which are usually hidden. In that regard, Word switches into a kind of hybrid mode, and you no longer “see what you get.” If you want to edit an index entry, you have to edit the code, for example “Mathematics{*XE*”language:mathematics”*}.”

  Indexing in LaTeX

In LaTeX, you insert the command in a straightforward way by adding the \index{…} directly into the text. For example, if you have the sentence “Mathematics is a language” you could add two indexes: “Mathematics\index{mathematics} is a language\index{language}.”

The big question is: which words should you index? Before we address that, let us look at an overall indexing strategy. Myself, I am using this one:

First, index all the terms that need to be indexed no matter what. Those are:

  • People names. Whenever you mention (or quote) a person, add the index command behind his or her name. The format for indexing people names is “\index{last name, first name middle name},” for example, “\index{Darwin, Charles Robert}.”
  • Media titles. Likewise, whenever mentioning a work of art (book, movie, software, etc.), it needs to be added at this position. If you mention the title directly, use “\index{title of the work@{title of the work}}”. Preferably, use the previously discussed “\citetitle{bibid}”: “\{@\citetitle{bookid}}”. The “bibid” stands for the id you have given in the bibliography file. The “@”-character is necessary for the indexing engine to recognize the italic font formatting. The exception to this rule would be titles that start with an article (a, the) which is usually put at the end (e.g., Last Unicorn, The instead of The Last Unicorn).
  • Concept definitions. When introducing a concept and providing its definition (especially in glossary items), this is a place a reader might want to look first. For indexing, you can mark those indexes in bold by adding “—textbf”: “\index{word—textbf}”. For example:
    Science\index{science|textbf} is the formalized process of gaining new knowledge.
  • Captions. Do not index entries in captions of figures. This will cause problems during compilation. Instead, index the place where the figure is referenced in the text.

Once those basics are implemented, you move into the second phase. Now go from paragraph to paragraph and ask yourself each time what concepts this paragraph discusses.

It is not enough that a word is mentioned, the paragraph should explain something about the word or concept in question. Imagine the reader looking up the word in the index, going to the page, and then wanting to read what the word in question is about. For example, take the sentence “A republic is different than a democracy as it sets the constitution as its highest arbiter.” Of course you would index “republic” in this sentence. But if you also indexed “democracy,” a reader will gain no value from it. From the sentence, the reader does not get any explanation of what democracy is about. If the sentence was “A republic is different than a democracy as it puts the constitution, not the people, as its highest arbiter,” the situation would be different. It is not a definition of democracy, so you would not mark it as bold in the index, but the sentence describes what democracy is. Alternatively, you can also always use more general concepts in an index. Here, you could use “systems of government” instead of either republic or democracy, especially when you are just comparing different systems of government in that paragraph. Even if you never use the expression “system of government” in your book, a reader will be satisfied reading the paragraph as—at least in its content—it compares systems of government. As the following phases will only remove or combine indexes, it is safe to “overindex” in this second phase. You can even add multiple index entries for individual words. Using the example from above, you could add both “republic” and “systems of government.”

Once you are done with indexing individual words, in phase three, you can take a break and have your editor (or a friend) take the role of a reviewer. Alternatively, take a longer break and revisit your book one month later with a fresh mind. For the review, go one by one through the index, go to the page specified, and ask yourself if the paragraph really explains the concept. If not, remove it.

Phase four then deals with cleaning up this “overindexed” index. Look at the index and see if you can find entries that can be combined. For example, you might find you have the following entries in your index: “Greek alphabet”, “Latin alphabet”, and “Phoenician alphabet.” Here you have to ask yourself if your readers search for “alphabet” or already have a specific language in mind. In my book “Philosophy for Heroes: Knowledge ,” I decided for the former and combined the index into “alphabet, Greek”, “alphabet, Latin”, “alphabet, Phoenician.” This categorization can be done in LaTeX with the following construct:

\index{main category!sub category}. In our case: “\index{alphabet!Greek}”, “\index{alphabet!Latin}”, and “\index{alphabet!Phoenician}” respectively. You can also go one level deeper, although that should be the exception. For example, you could categorize “natural numbers in mathematics” as \index{mathematics!number!natural}. In both cases, LaTeX will automatically combine those three entries and arrange them together.

With this in mind, I recommend reading a few indexes of the books in your library to learn how the authors combined their concepts. In addition, if you want to know more about the theory of knowledge and categorization of language and in philosophy, check out Philosophy for Heroes: Knowledge which explains it in detail.

Next, you might want to explain to the reader that two different words in the index actually refer to the same concept. Maybe there is a popular expression for something and (in your field of work) the correct expression for something. In the index, you can point one expression to the other.

For example, one application is when citing a person who has different names, maybe a real name and an artist name. Readers might look for either version of the name. For example, the mathematicianLeonardo Bonacci is also known as Fibonacci. You might list both names and tell the reader that he is referring to the same person. If you used “Leonardo Bonacci” in your text, you can add an index with the following format: \index{one version of the word—see{other version of the word}}. In our case this would be “Leonardo Bonacci was a famous mathematician.\index{Bonacci, Leonardo}\index{Fibonacci—see{Bonacci, Leonardo}}”. Another example and a bit of an inside joke would be recursion: “If a statement relates to itself, it is called recursive.\index{recursion}\index{recursion—see{recursion}}”

Finally, read through the entire index again and check for spelling mistakes. These are common if your main tool of proofreading is the PDF or a printout because the index commands are hidden. The most common mistakes are having some index entries in singular form and some in plural, mixing British and American English, or having some expressions with and some without hyphens.

That is it!

Here again are the steps of the index creation as a list:

Index all the basic terms (titles, people names, definitions).
Go through the entire text and index all the terms that are explained in a particular paragraph.
Check all indexes by going backwards from the index to the text.
Combine indexes into groups.
Check books with similar topics and get ideas based on how the authors did their indexing.
Add references from one index to another (e.g., for people with several names).
Check for spelling errors.

Bibliography and Citations

This is an excerpt of the book “Better Books with LaTeX.” The book comes with a LaTeX template you can use to easily create your own books.

Science is a collaborative enterprise spanning the generations. When it allows us to see the far side of some new horizon, we remember those who prepared the way […]

—Carl Sagan, Cosmos: Blues for a Red Planet

Books build upon other books, just like scientific experiments build on other scientific experiments. Be it out of scientific accuracy, as a service to the interested reader, or out of gratitude, you should include references to your sources.

Myself, I love to know the source of an author’s ideas. This is basically the story of my book series Philosophy for Heroes, which is a summary of a number of philosophers and scientists I admire for their work.

Zotero   Zotero is a plugin for Word (see which integrates into Word and your browser so you can fetch bibliographical information from the web and import it via a menu in Word.

In Word, there is no built-in way of managing a bibliography (other than manually writing each entry and referencing it in the text). You can check out plugins like Zotero ( which integrate into Word and your browser so you can fetch bibliographical information from the web and import it via a menu in Word.

In LaTeX, the support for a bibliography is inbuilt. All entries are saved in the file bibliography/main.bib in the root directory. The file is structured as a list of entries of the format TYPE{id, title={ title }, author={ author }, year={year of release}, …}. While LaTeX allows special characters like colons to be used in the id field, I recommend using only lowercase characters and numbers. Besides the title and release year, an entry can have a number of different parameters depending on its type. The main types are:

  • @BOOK All books have this type. Additional entries are isbn, and publisher.
  • @ARTICLE Articles published in scientific journals have this type. Additional entries are journalpages, and publisher.
  • @MISC Any other source fall under this category, for example websites or movies. Additional entries are url, and note. If you are referencing a website, add a note that contains something like “note = { [online; last accessed March 3rd, 2018] }” as the website’s contents might change. Ideally, keep a local copy of the website for yourself in case it vanishes. Please note that for the url field, include “http://” or “https://” at the front to make it a valid field.

Please note that it is not possible to use the url field to set it to an Amazon affiliate link. This is prohibited by Amazon (see

  Getting Bibliographical Information

The simplest approach is to go to Amazon, search for the book or movie title, and copy the information (author, publisher, ISBN, etc.) manually into a new entry. If you are citing scientific articles, look for a button on a website that says something about BibTeX. This way, you can download an already filled-out bibliographical entry and copy and paste it into your bibliography/main.bib library. Finally, you want to know how to actually use the bibliography. The template is already set up to load the entries of bibliography/main.bib. With the following commands, you have access to the full library:

  • \citetitle{id} This command prints out the title specified in the corresponding entry in the bibliography. For example, “\citetitle{PFH1E}” cites my book Philosophy for Heroes: Knowledge in italics.
  • \cite{id} This command prints out the reference to the media and sets a link to the bibliography in the back matter.
  • \citep{id} This command is the same as above, but puts parentheses around the reference.
  • \footcite{id} This command is the same as above, but puts the citation into a footnote.

Concerning the citation itself, there are many different formats that show a combination of year, title and / or author. If you want to use a different format, check out the documentation at