You want a list of abbreviations and terms — or a table of symbols — at the back of your document, with only the terms that actually appear in the text, sorted automatically. Build such a table by hand and a single new term sends you back to re-sorting and re-numbering. LaTeX has two dedicated tools for this. The **glossaries package (and its modern successor glossaries-extra) builds a glossary of terms and abbreviations; the nomencl package is purpose-built for a nomenclature — a list of mathematical symbols. Like the index and cross-references, both work by marking entries in the body, sorting them with an external program, and pulling them in on an extra compilation pass.**
Glossaries — the basics
glossaries lets you define each term, notation, or abbreviation once in the preamble and then call it with a short command in the body. First load the package, then write **\makeglossaries. That line declares the glossary files to be opened — omit it and no glossary is produced at all.** One caveat: if you use hyperref, load **glossaries *after* hyperref** (an exception to the usual “load hyperref last” advice).
You define a term with **\newglossaryentry{key}{name=..., description=...}**. The first argument key is the reference label (an arbitrary string); the second is a list of key=value settings, chiefly name (the display name) and description (the definition). To use the term in the body, write **\gls{key}**: it inserts the name and, at the same time, records that the term should appear in the glossary.
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{set}{%
name={set},
description={a collection of distinct objects}%
}
\newglossaryentry{matrix}{%
name={matrix},
plural={matrices},% 不規則な複数形を明示 / irregular plural
description={a rectangular array of numbers}%
}
\begin{document}
本文で \gls{set} と \glspl{matrix} に言及する。
\printglossary
\end{document}\gls has capitalising and plural variants — you switch between them just by changing the leading letters. The plural built automatically from name is merely name plus “s”, so an irregular form like matrices must be given explicitly with the **plural key. When the reference form should differ from the display name, use text; an associated symbol goes in the symbol** key.
| Command | Output | Use |
|---|---|---|
\gls{set} | set | Ordinary (lowercase) reference |
\Gls{set} | Set | Capitalise the first letter (sentence start) |
\glspl{matrix} | matrices | Plural form |
\Glspl{matrix} | Matrices | Plural with leading capital |
\glsdesc{set} | a collection of distinct objects | Insert the description field |
Acronyms — expand on first use
Abbreviations get a dedicated command, **\newacronym{key}{short}{long}**: short is the abbreviation (e.g. SVM), long the full form (e.g. support vector machine). Call it with \gls{key} and it switches automatically — the first use shows “long form (short form)”, and every use after that shows only the short form — so the machine enforces the convention that an abbreviation is spelled out the first time it appears. To collect acronyms in a separate list, load the package as \usepackage[acronym]{glossaries}.
\usepackage[acronym]{glossaries}
\makeglossaries
\newacronym{svm}{SVM}{support vector machine}
\begin{document}
\gls{svm} は強力だ。% 初出: support vector machine (SVM)
その後も \gls{svm} を使う。% 2回目以降: SVM
\end{document}The first-use flag is tracked entry by entry across the document. To force a term to be spelled out in full again from some point on, use \glsreset{key}; to reset every entry at once, \glsresetall. And when a description is long enough to span paragraphs, use **\longnewglossaryentry** instead of \newglossaryentry.
The build — you need makeglossaries
As with the index, a glossary does not appear from a single compilation. LaTeX only writes the recorded terms to auxiliary files — it neither sorts nor formats them. For that you run the external program **makeglossaries, a Perl script that inspects the document’s settings and invokes makeindex or xindy** appropriately under the hood, producing a sorted glossary. The procedure has three steps.
pdflatex mydoc # 用語をファイルへ書き出す / write the recorded terms
makeglossaries mydoc # 整列・整形(拡張子なし)/ sort & format (no extension)
pdflatex mydoc # 用語集を本文へ流し込む / pull the glossary into the documentWhere Perl is not available (e.g. on Windows), the Lua-based **makeglossaries-lite** does the same job. Skip the makeglossaries call and just rerun pdflatex, and the glossary stays blank — exactly the same trap as forgetting makeindex for an index. On Overleaf the necessary steps run automatically behind the scenes, so you rarely have to think about this sequence.
The modern way — glossaries-extra and bib2gls
By the same author (Nicola Talbot), **glossaries-extra** is a higher-level package that extends glossaries and is the currently recommended setup. The modern build method to pair with it is **bib2gls**. The idea resembles biber for bibliographies: you collect your terms in a **.bib file**, and bib2gls selects only the terms actually used in the body, sorts them, and pulls them in. A single program takes over the roles of makeindex/xindy — both selection and sorting.
To use it, load the package with the **record option: \usepackage[record]{glossaries-extra}** (this is the key to bib2gls integration — it disables makeindex/xindy indexing and instead writes records to the .aux file). Each entry in the .bib file uses a type such as **@entry (a term), @abbreviation (an abbreviation), or @symbol** (a symbol).
@entry{set,
name = {set},
description = {a collection of distinct objects}
}
@abbreviation{svm,
short = {SVM},
long = {support vector machine}
}In the document, instead of \input you load the .bib with **\GlsXtrLoadResources[src={terms}]** (src is the filename without extension). You still use a term with \gls{set}, but because the entries are already sorted you print with **\printunsrtglossary** (unsrt = unsorted, meaning: bib2gls has already ordered them, so emit them as-is).
\usepackage[record]{glossaries-extra}
\GlsXtrLoadResources[src={terms}]% terms.bib を読む / load terms.bib
\begin{document}
\gls{set} と \gls{svm} を本文で使う。
\printunsrtglossary
\end{document}For the build you call bib2gls in place of makeglossaries. The --group switch makes it divide entries into letter-group headings; you may replace pdflatex with xelatex or lualatex.
pdflatex mydoc
bib2gls --group mydoc # .aux を読み .glstex を書き出す / read .aux, write .glstex
pdflatex mydocNomenclature — the nomencl package
When you want a list of symbols at the front of a paper, you can do it with glossaries, but for symbols alone the lightweight **nomencl package is convenient. Put \usepackage{nomencl} and \makenomenclature in the preamble, mark each symbol where it first appears with \nomenclature{symbol}{description}, and write \printnomenclature** wherever you want the list. Symbols are math, so wrap them in $...$.
\documentclass{article}
\usepackage{nomencl}
\makenomenclature
\begin{document}
重力加速度を $g$ とする。%
\nomenclature{$g$}{gravitational acceleration}%
質量 $m$ の物体には $F = mg$ が働く。%
\nomenclature{$m$}{mass of the object}%
\nomenclature{$F$}{force}%
\printnomenclature
\end{document}It is conventional to end the line just before \nomenclature with a **% so that no stray space or newline creeps in (a space around the symbol throws off the sorting). To control the order precisely, you can supply a sort key as an optional argument — in \nomenclature[<prefix>]{symbol}{description}** the <prefix> is what gets sorted on. For instance, a Greek letter \sigma would otherwise sort first because of its leading backslash, so you tune its position with a prefix: \nomenclature[g-sigma]{$\sigma$}{...}.
Building and tuning nomencl
nomencl uses makeindex under the hood. With \makenomenclature in place, LaTeX writes the symbol information to a **.nlo** file. The next command sorts it using nomencl’s bundled style **nomencl.ist and produces the output .nls**. Compile once more and .nls is read in, so the nomenclature appears.
pdflatex mydoc
makeindex mydoc.nlo -s nomencl.ist -o mydoc.nls
pdflatex mydocThe heading defaults to the English “Nomenclature.” You can change it — e.g. \renewcommand{\nomname}{List of Symbols}. To list it in the table of contents, load the package as \usepackage[intoc]{nomencl}. There are also options that annotate each entry automatically: **refpage appends “, page n”, and refeq appends “, see equation (n)”. To split symbols into groups (physical constants, variables, and so on), you can use the sort prefix together with a redefined \nomgroup** to produce sub-groups with their own headings.
- **For a glossary of terms and abbreviations, use
glossaries/glossaries-extra.** First-use expansion, plurals, and capitalisation are all automatic. - **Starting fresh? Use
glossaries-extra+bib2gls.** Write entries in a.bib, and\printunsrtglossaryemits only the used terms, already sorted. - **For a list of mathematical symbols alone, use
nomencl.** It is lightweight: mark with\nomenclatureand runmakeindexonce. - All of them need an extra compilation. Insert the external program (
makeglossaries/bib2gls/makeindex), then run LaTeX again.