Front/back matter

Table of contents, list of figures, list of tables
Synopsis, one of:

\tableofcontents
\listoffigures
\listoftables

Produce a table of contents, or list of figures, or list of tables. Put the command in the input file where you want the table or list to go. You do not type the entries; for example, typically the table of contents entries are automatically generated from the sectioning commands \chapter, etc.
This example illustrates the first command, \tableofcontents. LaTeX will produce a table of contents on the book’s first page.

\documentclass{book}
% \setcounter{tocdepth}{1}
\begin{document}
\tableofcontents\newpage
  ...
\chapter{...}
  ...
\section{...}
  ...
\subsection{...}
  ...
\end{document}

Uncommenting the second line would cause that table to contain chapter and section listings but not subsection listings, because the \section command has level 1. See Sectioning, for level numbers of the sectioning units. For more on the tocdepth see Sectioning/tocdepth.
Another example of the use of \tableofcontents is in Larger book template.
If you want a page break after the table of contents, write a \newpage command after the \tableofcontents command, as above.
To make the table of contents, LaTeX stores the information in an auxiliary file named root-file.toc (see Splitting the input). For example, this LaTeX file test.tex

\documentclass{article}
\begin{document}
\tableofcontents\newpage
\section{First section}
\subsection{First subsection}
  ...

writes these lines to test.toc.

\contentsline {section}{\numberline {1}First section}{2}
\contentsline {subsection}{\numberline {1.1}First subsection}{2}

Each line contains a single command, \contentsline (see \contentsline). The first argument, the section or subsection, is the sectioning unit. The second argument has two components. The hook \numberline determines how the sectioning number, 1 or 1.1, appears in the table of contents (see \numberline). The remainder of the second argument of \contentsline, ‘First section’ or ‘First subsection’, is the sectioning title text. Finally, the third argument, ‘2’, is the page number on which this sectioning unit starts.
To typeset these lines, the document class provides \l@section-unit commands such as \l@section{text}{pagenumber} and \l@subsection{text}{pagenumber}. These commands often use the \@dottedtocline command (see \@dottedtocline).
A consequence of LaTeX’s strategy of using auxiliary files is that to get the correct information in the document you must run LaTeX twice, once to store the information and the second time to retrieve it. In the ordinary course of writing a document authors run LaTeX a number of times, but you may notice that the first time that you compile a new document, the table of contents page will be empty except for its ‘Contents’ header. Just run LaTeX again.
The commands \listoffigures and \listoftables produce a list of figures and a list of tables. Their information is stored in files with extension .lof and .lot. They work the same way as \tableofcontents but the latter is more common, so we use it for most examples.
You can manually add material to the table of contents, the list of figures, and the list of tables. For instance, add a line about a section to the table of contents with \addcontentsline{toc}{section}{text}. (see \addcontentsline). Add arbitrary material, that is, non-line material, with \addtocontents, as with the command \addtocontents{lof}{\protect\vspace{2ex}}, which adds vertical space to the list of figures (see \addtocontents).
Lines in the table of contents, the list of figures, and the list of tables, have four parts. First is an indent. Next is a box into which sectioning numbers are placed, and then the third box holds the title text, such as ‘First section’. Finally there is a box up against the right margin, inside of which LaTeX puts the page number box. For the indent and the width of the number box, see \@dottedtocline. The right margin box has width \@tocrmarg and the page number is flush right in that space, inside a box of width \@pnumwidth. By default \@tocrmarg is 2.55em and \@pnumwidth is 1.55em. Change these as with \renewcommand{\@tocrmarg}{3.5em}.
CTAN has many packages for the table of contents and lists of figures and tables (see CTAN). The package tocloft is convenient for adjusting some aspects of the default such as spacing. And, tocbibbind will automatically add the bibliography, index, etc. to the table of contents.
To change the header for the table of contents page, do something like these commands before you call \tableofcontents, etc.

\renewcommand{\contentsname}{Table of Contents}
\renewcommand{\listfigurename}{Plots}
\renewcommand{\listtablename}{Specifications}

Internationalization packages such as babel or polyglossia will change these headers depending on the chosen base language.

\@dottedtocline
Synopsis:

\@dottedtocline{section-level-num}{indent}{numwidth}{text}{pagenumber}

Used internally by LaTeX to format an entry line in the table of contents, list of figures, or list of tables. Authors do not directly enter \@dottedtocline commands.
This command is typically used by \l@section, \l@subsection, etc., to format the content lines. For example, the article.cls file contains these definitions:

\newcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
\newcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
\newcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}

In this example, \@dottedcline appears to have been given only three arguments. But tracing the internal code shows that it picks up the final text and pagenumber arguments in the synopsis from a call to \contentsline (see \contentsline).
Between the box for the title text of a section and the right margin box, these \@dottedtocline commands insert leaders, that is, evenly-spaced dots. The dot-to-dot space is given by the command \@dotsep. By default it is 4.5 (it is in math units, aka. mu, which are 1/18 em. Change it using \renewcommand, as in \renewcommand{\@dotsep}{3.5}.
In the standard book class, LaTeX does not use dotted leaders for the Part and Chapter table entries, and in the standard article class it does not use dotted leaders for Section entries.

\addcontentsline
Synopsis:

\addcontentsline{ext}{unit}{text}

Add an entry to the auxiliary file with extension ext.
The following will result in an ‘Appendices’ line in the table of contents.

\addcontentsline{toc}{section}{\protect\textbf{Appendices}}

It will appear at the same indentation level as the sections, will be in boldface, and will be assigned the page number associated with the point where the command appears in the input file.
The \addcontentsline command writes information to the file root-name.ext, where root-name is the file name of the root file (see Splitting the input). It writes that information as the text of the command \contentsline{unit}{text}{num}, where num is the current value of counter unit (see \contentsline). The most common case is the table of contents and there num is the page number of the first page of unit.
This command is invoked by the sectioning commands \chapter, etc. (see Sectioning), and also by \caption inside a float environment (see Floats). But it is also directly used by authors. For example, an author writing a book whose style is to have an unnumbered preface may use the starred \chapter*. But that command leaves out table of contents information, which can be entered manually, as here.

\chapter*{Preface}
\addcontentsline{toc}{chapter}{\protect\numberline{}Preface}

In the root-name.toc file LaTeX will put the line \contentsline {chapter}{\numberline {}Preface}{3}; note that the page number ‘3’ is automatically generated by the system, not entered manually.
All of the arguments for \addcontentsline are required.
ext 	Typically one of the strings toc for the table of contents, lof for the list of figures, or lot for the list of tables. The filename extension of the information file.
unit 	A string that depends on the value of the ext argument, typically one of:
toc 	For the table of contents, this is the name of a sectional unit: part, chapter, section, subsection, etc.
lof 	For the list of figures: figure.
lot 	For the list of tables: table.
text 	The text of the entry. You must \protect any fragile commands (see \protect) used in it.
The \addcontentsline command has an interaction with \include (see \include & \includeonly). If you use them at the same level, as with \addcontentsline{...}{...}{...}\include{...} then lines in the table of contents can come out in the wrong order. The solution is to move \addcontentsline into the file being included.
If you use a unit that LaTeX does not recognize, as with the typo here

\addcontentsline{toc}{setcion}{\protect\textbf{Appendices}}

then you don’t get an error but the formatting in the table of contents will not make sense.

\addtocontents
Synopsis:

\addtocontents{ext}{text}

Add text, which may be text or formatting commands, directly to the auxiliary file with extension ext. This is most commonly used for the table of contents so that is the discussion here, but it also applies to the list of figures and list of tables.
This will put some vertical space in the table of contents after the ‘Contents’ header.

\tableofcontents\newpage
\addtocontents{toc}{\protect\vspace*{3ex}}

This puts the word ‘Page’, in boldface, above the column of page numbers and after the header.

\tableofcontents
\addtocontents{toc}{~\hfill\textbf{Page}\par}
\chapter{...}

This adds a line announcing work by a new author.

\addtocontents{toc}{%
  \protect\vspace{2ex}
  \textbf{Chapters by N. Other Author}\par}

The difference between \addtocontents and \addcontentsline is that the latter is strictly for lines, such as with a line giving the page number for the start of a new subset of the chapters. As the above examples show, \addtocontents is for material such as spacing.
The \addtocontents command has two arguments. Both are required.
ext 	Typically one of: toc for the table of contents, lof for the list of figures, or lot for the list of tables. The extension of the file holding the information.
text 	The text, and possibly commands, to be written.
The sectioning commands such as \chapter use the \addcontentsline command to store information. This command creates lines in the .toc auxiliary file containing the \contentsline command (see \addcontentsline). In contrast, the command \addtocontents puts material directly in that file.
The \addtocontents command has an interaction with \include (see \include & \includeonly). If you use them at the same level, as with \addtocontents{...}{...}\include{...} then lines in the table of contents can come out in the wrong order. The solution is to move \addtocontents into the file being included.

\contentsline
Synopsis:

\contentsline{unit}{text}{pagenumber}

Used internally by LaTeX to typeset an entry of the table of contents, list of figures, or list of tables (see Table of contents etc.). Authors do not directly enter \contentsline commands.
Usually adding material to these lists is done automatically by the commands \chapter, \section, etc. for the table of contents, or by the \caption command inside of a \figure or \table environment (see figure and see table). Thus, where the root file is thesis.tex, and contains the declaration \tableofcontents, the command \chapter{Chapter One} produces something like this in the file thesis.toc.

\contentsline {chapter}{\numberline {1}Chapter One}{3}

If the file contains the declaration \listoffigures then a figure environment involving \caption{Test} will produce something like this in thesis.lof.

\contentsline {figure}{\numberline {1.1}{\ignorespaces Test}}{6}

To manually add material, use \addcontentsline{filetype}{unit}{text}, where filetype is toc, lof, or lot (see \addcontentsline).
For manipulating how the \contentline material is typeset, see the tocloft package.
Note that the hyperref package changes the definition of \contentsline (and \addcontentsline) to add more arguments, to make hyperlinks. This is the source of the error Argument of \contentsline has an extra } when one adds/remove the use of package hyperref and a compilation was already run. Fix this error by deleting the .toc or .lof or .lot file, and running LaTeX again.

\nofiles
Synopsis:

\nofiles

Prevent LaTeX from writing any auxiliary files. The only output will be the .log and .pdf (or .dvi) files. This command must go in the preamble.
Because of the \nofiles command this example will not produce a .toc file.

\documentclass{book}
\nofiles
\begin{document}
\tableofcontents\newpage
\chapter{...}
  ...

LaTeX will not erase any existing auxiliary files, so if you insert the \nofiles command after you have run the file and gotten a .toc then the table of contents page will continue to show the old information.

\numberline
Synopsis:

\numberline{number}

Typeset its argument flush left in a box. This is used in a \contentsline command to typeset the section number (see \contentsline).
For example, this line in a .toc file causes the 1.1 to be typeset flush left.

\contentsline {subsection}{\numberline {1.1}Motivation}{2}

By default, LaTeX typesets the section numbers in a box of length \@tempdima. That length is set by the commands \l@section, \l@subsection, etc. Put section numbers inside a natural-width box with \renewcommand{\numberline}[1]{#1~} before \tableofcontents.
This command is fragile so you may need to precede it with \protect (see \protect). An example is the use of \protect in this command,

\addcontentsline{toc}{section}{\protect\numberline{}Summary}

to get the \numberline into the \contentsline command in the .toc file: \contentsline {section}{\numberline {}Summary}{6} (the page number ‘6’ is automatically added by LaTeX; see \addcontentsline).

Indexes
If you tell LaTeX what terms you want to appear in an index then it can produce that index, alphabetized and with the page numbers automatically maintained. This illustrates the basics.

\documentclass{article}
\usepackage{makeidx}  % Provide indexing commands
  \makeindex
% \usepackage{showidx}  % Show marginal notes of index entries
  ...
\begin{document}
  ...
Wilson's Theorem\index{Wilson's Theorem}
says that a number $n>1$ is prime if and only if the factorial
of $n-1$ is congruent to $-1$
modulo~$n$.\index{congruence!and Wilson's Theorem}
  ...
\printindex
\end{document}

As that shows, declare index entries with the \index command (see \index). When you run LaTeX, the \index writes its information, such as ‘Wilson's Theorem’ and the page number, to an auxiliary file whose name ends in .idx. Next, to alphabetize and do other manipulations, run an external command, typically makeindex (see makeindex), which writes a file whose name ends in .ind. Finally, \printindex brings this manipulated information into the output (see \printindex).
Thus, if the above example is in the file numth.tex then running ‘pdflatex numth’ will save index entry and page number information to numth.idx. Then running ‘makeindex numth’ will alphabetize and save the results to numth.ind. Finally, again running ‘pdflatex numth’ will show the desired index, at the place where the \printindex command is in the source file.
There are many options for the output. An example is that the exclamation point in \index{congruence!and Wilson's Theorem} produces a main entry of ‘congruence’ with a subentry of ‘and Wilson's Theorem’. For more, see makeindex.
The \makeindex and \printindex commands are independent. Leaving out the \makeindex will stop LaTeX from saving the index entries to the auxiliary file. Leaving out the \printindex will cause LaTeX to not show the index in the document output.
There are many packages in the area of indexing. The showidx package causes each index entries to be shown in the margin on the page where the \index appears. This can help in preparing the index. The multind package, among others, supports multiple indexes. See also the TeX FAQ entry on this topic, https://www.texfaq.org/FAQ-multind, and the CTAN topic, https://ctan.org/topic/index-multi.

Produce the index manually
Documents that are small and static can have a manually produced index. This will make a separate page labeled ‘Index’, in twocolumn format.

\begin{theindex}
\item acorn squash, 1
\subitem maple baked, 2
\indexspace
\item bacon, 3
\subitem maple baked, 4
\end{theindex}

Note that the author must enter the page numbers, which is tedious and which will result in wrong numbers if the document changes. This is why in most cases automated methods such as makeindex are best. See Indexes.
However we cover the commands for completeness, and because the automated methods are based on these commands. There are three levels of entries. As the example shows, a main entry uses \item, subentries use \subitem, and the lowest level uses \subsubitem. Blank lines between entries have no effect. The example above includes \indexspace to produce vertical space in the output that some index styles use before the first entry starting with a new letter.

\index
Synopsis:

\index{index-entry-string}

Declare an entry in the index. This command is fragile (see \protect).
For example, as described in Indexes, one way to get an index from what’s below is to compile the document with pdflatex test, then process the index entries with makeindex test, and then compile again with pdflatex test.

% file test.tex
  ...
W~Ackermann (1896--1962).\index{Ackermann}
  ...
Ackermann function\index{Ackermann!function}
  ...
rate of growth\index{Ackermann!function!growth rate}

All three index entries will get a page number, such as ‘Ackermann, 22’. LaTeX will format the second as a subitem of the first, on the line below it and indented, and the third as a subitem of the second. Three levels deep is as far as you can nest subentries. (If you add \index{Ackermann!function!growth rate!comparison} then makeindex says ‘Scanning input file test.idx....done (4 entries accepted, 1 rejected)’ and the fourth level is silently missing from the index.)
If you enter a second \index with the same index-entry-string then you will get a single index entry with two page numbers (unless they happen to fall on the same page). Thus, adding as for Ackermann.\index{Ackermann} later in the same document as above will give an index entry like ‘Ackermann, 22, 151’. Also, you can enter the index entries in any order, so for instance \index{Ackermann!function} could come before \index{Ackermann}.
Get a page range in the output, like ‘Hilbert, 23--27’, as here.

W~Ackermann (1896--1962).\index{Ackermann}
  ...
D~Hilbert (1862--1943)\index{Ackermann!Hilbert|(}
  ...
disapproved of his marriage.\index{Ackermann!Hilbert|)}

If the beginning and ending of the page range are equal then the system just gives a single page number, not a range.
If you index subentries but not a main entry, as with \index{Jones!program} and \index{Jones!results}, then the output is the item ‘Jones’ with no comma or page number, followed by two subitems, like ‘program, 50’ and ‘results, 51’.
Generate a index entry that says ‘see’ by using a vertical bar character: \index{Ackermann!function|see{P\'eter's function}}. You can instead get ‘see also’ with seealso. (The text ‘see’ is defined by \seename, and ‘see also’ by \alsoname. You can redefine these either by using an internationalization package such as babel or polyglossia, or directly as with \renewcommand{\alsoname}{Also see}.)
The ‘see’ feature is part of a more general functionality. After the vertical bar you can put the name of a one-input command, as in \index{group|textit} (note the missing backslash on the \textit command) and the system will apply that command to the page number, here giving something like \textit{7}. You can define your own one-input commands, such as \newcommand{\definedpage}[1]{{\color{blue}#1}} and then \index{Ackermann!function|definedpage} will give a blue page number (see Color). Another, less practical, example is this,

\newcommand\indexownpage[1]{#1, \thepage}
  ... Epimenides.\index{self-reference|indexownpage}

which creates an entry citing the page number of its own index listing.
The two functions just described combine, as here

\index{Ackermann!function|(definedpage}
  ...
\index{Ackermann!function|)}

which outputs an index entry like ‘function, 23--27’ where the page number range is in blue.
Consider an index entry such as ‘α-ring’. Entering it as $\alpha$-ring will cause it to be alphabetized according to the dollar sign. You can instead enter it using an at-sign, as \index{alpha-ring@$\alpha$-ring}. If you specify an entry with an at-sign separating two strings, pos@text, then pos gives the alphabetical position of the entry while text produces the text of the entry. Another example is that \index{Saint Michael's College@SMC} produces an index entry ‘SMC’ alphabetized into a different location than its spelling would naturally give it.
To put a !, or @, or |, or " character in an index entry, escape it by preceding it with a double quote, ". (The double quote gets deleted before alphabetization.)
A number of packages on CTAN have additional functionality beyond that provided by makeidx. One is index, which allows for multiple indices and contains a command \index*{index-entry-string} that prints the index-entry-string as well as indexing it.
The \index command writes the indexing information to the file root-name.idx file. Specifically, it writes text of the command \indexentry{index-entry-string}{page-num}, where page-num is the value of the \thepage counter. On occasion, when the \printindex command is confused, you have to delete this file to start with a fresh slate.
If you omit the closing brace of an \index command then you get a message like this.

Runaway argument?  {Ackermann!function
!  Paragraph ended before \@wrindex was complete.

makeindex
Synopsis, one of:

makeindex filename
makeindex -s style-file filename
makeindex options filename0 ...

Sort, and otherwise process, the index information in the auxiliary file filename. This is a command line program. It takes one or more raw index files, filename.idx files, and produces the actual index file, the filename.ind file that is input by \printindex (see \printindex).
The first form of the command suffices for many uses. The second allows you to format the index by using an index style file, a .isty file. The third form is the most general; see the full documentation on CTAN.
This is a simple .isty file.

% book.isty 
%   $ makeindex -s book.isty -p odd book.idx
% creates the index as book.ind, starting on an odd page. 
preamble
"\\pagestyle{empty}
\\small
\\begin{theindex}
\\thispagestyle{empty}"

postamble
"\n
\\end{theindex}"

The description here covers only some of the index formatting possibilities in style-file. For a full list see the documentation on CTAN.
A style file consists of a list of pairs: specifier and attribute. These can appear in the file in any order. All of the attributes are strings, except where noted. Strings are surrounded with double quotes, ", and the maximum length of a string is 144 characters. The \n is for a newline and \t is for a tab. Backslashes are escaped with another backslash, \\. If a line begins with a percent sign, %, then it is a comment.
preamble 	Preamble of the output index file. Defines the context in which the index is formatted. Default: "\\begin{theindex}\n".
postamble 	Postamble of the output index file. Default: "\n\n\\end{theindex}\n".
group_skip 	 Traditionally index items are broken into groups, typically a group for entries starting with letter ‘a’, etc. This specifier gives what is inserted when a new group begins. Default: "\n\n \\indexspace\n" (\indexspace is a command inserting a rubber length, by default 10pt plus5pt minus3pt).
lethead_flag 	An integer. It governs what is inserted for a new group or letter. If it is 0 (which is the default) then other than group_skip nothing will be inserted before the group. If it is positive then at a new letter the lethead_prefix and lethead_suffix will be inserted, with that letter in uppercase between them. If it is negative then what will be inserted is the letter in lowercase. The default is 0.
lethead_prefix 	If a new group begins with a different letter then this is the prefix inserted before the new letter header. Default: ""
lethead_suffix 	If a group begins with a different letter then this is the suffix inserted after the new letter header. Default: "".
item_0 	What is put between two level 0 items. Default: "\n \\item ".
item_1 	Put between two level 1 items. Default: "\n \\subitem ".
item_2 	put between two level 2 items. Default: "\n \\subsubitem ".
item_01 	What is put between a level 0 item and a level 1 item. Default: "\n \\subitem ".
item_x1 	What is put between a level 0 item and a level 1 item in the case that the level 0 item doesn’t have any page numbers (as in \index{aaa|see{bbb}}). Default: "\n \\subitem ".
item_12 	What is put between a level 1 item and a level 2 item. Default: "\n \\subsubitem ".
item_x2 	What is put between a level 1 item and a level 2 item, if the level 1 item doesn’t have page numbers. Default: "\n \\subsubitem ".
delim_0 	Delimiter put between a level 0 key and its first page number. Default: a comma followed by a blank, ", ".
delim_1 	Delimiter put between a level 1 key and its first page number. Default: a comma followed by a blank, ", ".
delim_2 	Delimiter between a level 2 key and its first page number. Default: a comma followed by a blank, ", ".
delim_n 	Delimiter between two page numbers for the same key (at any level). Default: a comma followed by a blank, ", ".
delim_r 	What is put between the starting and ending page numbers of a range. Default: "--".
line_max 	An integer. Maximum length of an index entry’s line in the output, beyond which the line wraps. Default: 72.
indent_space 	What is inserted at the start of a wrapped line. Default: "\t\t".
indent_length 	A number. The length of the wrapped line indentation. The default indent_space is two tabs and each tab is eight spaces so the default here is 16.
page_precedence 	A document may have pages numbered in different ways. For example, a book may have front matter pages numbered in lowercase roman while main matter pages are in arabic. This string specifies the order in which they will appear in the index. The makeindex command supports five different types of numerals: lowercase roman r, and numeric or arabic n, and lowercase alphabetic a, and uppercase roman R, and uppercase alphabetic A. Default: "rnaRA".
There are a number of other programs that do the job makeindex does. One is xindy (https://ctan.org/pkg/xindy), which does internationalization and can process indexes for documents marked up using LaTeX and a number of other languages. It is written in Lisp, highly configurable, both in markup terms and in terms of the collating order of the text, as described in its documentation.
A more recent indexing program supporting Unicode is xindex, written in Lua (https://ctan.org/pkg/xindex).

\printindex
Synopsis:

\printindex

Place the index into the output.
To get an index you must first include \usepackage{makeidx}\makeindex in the document preamble and compile the document, then run the system command makeindex, and then compile the document again. See Indexes, for further discussion and an example of the use of \printindex.

Glossaries
Synopsis:

\usepackage{glossaries} \makeglossaries
  ...
\newglossaryentry{label}{settings}  
  ...
\gls{label}.  
  ...
\printglossaries

The glossaries package allows you to make glossaries, including multiple glossaries, as well as lists of acronyms.
To get the output from this example, compile the document (for instance with pdflatex filename), then run the command line command makeglossaries filename, and then compile the document again.

\documentclass{...}  
\usepackage{glossaries} \makeglossaries
\newglossaryentry{tm}{%
  name={Turing machine},
  description={A model of a machine that computes.  The model is simple
               but can compute anything any existing device can compute.
               It is the standard model used in Computer Science.},
  }  
\begin{document}  
Everything begins with the definition of a \gls{tm}.  
  ...
\printglossaries
\end{document}

That gives two things. In the main text it outputs ‘... definition of a Turing machine’. In addition, in a separate sectional unit headed ‘Glossary’ there appears a description list. In boldface it says ‘Turing machine’ and the rest of the item says in normal type ‘A model of a machine … Computer Science’.
The command \makeglossary opens the file that will contain the entry information, root-file.glo. Put the \printglossaries command where you want the glossaries to appear in your document.
The glossaries package is very powerful. For instance, besides the commands \newglossaryentry and \gls, there are similar commands for a list of acronyms. See the package documentations on CTAN.

\newglossaryentry
Synopsis, one of:

\newglossaryentry{label} 
{ 
  name={name}, 
  description={description}, 
  other options, ... 
}

or

\longnewglossaryentry{label} 
{ 
  name={name}, 
  other options ..., 
} 
{description}

Declare a new entry for a glossary. The label must be unique for the document. The settings associated with the label are pairs: key=value.
This puts the blackboard bold symbol for the real numbers ℝ, in the glossary.

\newglossaryentry{R}  
{  
  name={\ensuremath{\mathbb{R}}},  
  description={the real numbers},  
}

Use the second command form if the description spans more than one paragraph.
For a full list of keys see the package documentation on CTAN but here are a few.
name 	(Required.) The word, phrase, or symbol that you are defining.
description 	(Required.) The description that will appear in the glossary. If this has more than one paragraph then you must use the second command form given in the synopsis.
plural 	The plural form of name. Refer to the plural form using \glspl or \Glspl (see \gls).
sort 	How to place this entry in the list of entries that the glossary holds.
symbol 	A symbol, such as a mathematical symbol, besides the name.

\gls
Synopsis, one of:

\gls{label}
\glspl{label}
\Gls{label}
\Glspl{label}

Refer to a glossary entry. The entries are declared with \newglossaryentry (see \newglossaryentry).
This

\newglossaryentry{N}{%
  name={the natural numbers},
  description={The numbers $0$, $1$, $2$, $\ldots$\@},
  symbol={\ensuremath{\mathbb{N}}},
  }  
  ...
Consider \gls{N}.

gives the output ‘Consider the natural numbers’.
The second command form \glspl{label} produces the plural of name (by default it tries adding an ‘s’). The third form capitalizes the first letter of name, as does the fourth form, which also takes the plural.