> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/wen-dang-jie-gou/05-glossaries.md).

# 术语表

## 引言

在编写一份包含某些特定领域概念的文档时，添加术语表可能会很方便。术语表是某一知识领域中的术语及其定义列表。本文将介绍如何创建它。

**重要提示**：你的项目的 [主文件](/latex/zh-cn/zhi-shi-ku/127-set-main-document.md) 应始终位于根目录中（任何文件夹之外），以确保所有编译步骤都将在正确的目录中运行，并确保所需的辅助文件可用，例如在创建术语表或添加索引时。

让我们从一个简单的例子开始。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
    name=latex,
    description={是一种特别适合
    用于科学文档的标记语言}
}

\newglossaryentry{maths}
{
    name=数学,
    description={数学就是数学家所做的事情}
}

\title{如何创建术语表}
\author{ }
\date{ }

\begin{document}
\maketitle

\Gls{latex} 排版标记语言特别适合
包含 \gls{maths} 的文档。

\clearpage

\printglossaries

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Glossaries+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+%0A++++for+scientific+documents%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Ctitle%7BHow+to+create+a+glossary%7D%0A%5Cauthor%7B+%7D%0A%5Cdate%7B+%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%0A%0A%5Cclearpage%0A%0A%5Cprintglossaries%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的术语表：

![Glossary1OLV2.png](/files/e1be63fa343157cd91bfde7e683e8573666dff68)

要创建术语表，必须导入 `glossaries` 宏包。这可以通过下面这一行来实现

```latex
\usepackage{glossaries}
```

在导言区中。命令 `\makeglossaries` 必须写在第一个术语表条目之前。

每个术语表条目都由命令 `\newglossaryentry` 创建，它接受两个参数，然后每个条目都可以在文档后文通过命令 `\gls`引用。有关更完整的说明，请参见关于 [术语](#terms) 的小节。

命令 `\printglossaries` 它将实际渲染每个条目中输入的词语和定义列表，标题为“术语表”。在本例中它显示在文档末尾，但 `\printglossaries` 也可以用于其他任何位置。

## 术语和缩略词

通常术语表中有两类条目：术语及其定义，或缩略词及其含义。这两类可以在你的 LaTeX 文档中分别打印。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym]{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
        name=latex,
        description={是一种特别适合用于
科学文档的标记语言}
}

\newglossaryentry{maths}
{
        name=数学,
        description={数学就是数学家所做的事情}
}

\newglossaryentry{formula}
{
        name=公式,
        description={一个数学表达式}
}

\newacronym{gcd}{GCD}{最大公约数}

\newacronym{lcm}{LCM}{最小公倍数}

\begin{document}

\Gls{latex} 排版标记语言特别适合
用于包含 \gls{maths} 的文档。\Glspl{formula} 会
在习惯这些命令后，就能轻松且正确地渲染出来。

给定一组数字，有一些基本方法可以计算
其 \acrlong{gcd}，其缩写为 \acrshort{gcd}。这个
过程与用于 \acrfull{lcm} 的过程类似。

\clearpage

\printglossary[type=\acronymtype]

\printglossary

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Glossaries+Terms+and+Acronyms+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%5Cusepackage%5Bacronym%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++++++name%3Dlatex%2C%0A++++++++description%3D%7BIs+a+mark+up+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++++++name%3Dmathematics%2C%0A++++++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++++++name%3Dformula%2C%0A++++++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cnewacronym%7Bgcd%7D%7BGCD%7D%7BGreatest+Common+Divisor%7D%0A%0A%5Cnewacronym%7Blcm%7D%7BLCM%7D%7BLeast+Common+Multiple%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+%0Arendered+properly+an+easily+once+one+gets+used+to+the+commands.%0A%0AGiven+a+set+of+numbers%2C+there+are+elementary+methods+to+compute+%0Aits+%5Cacrlong%7Bgcd%7D%2C+which+is+abbreviated+%5Cacrshort%7Bgcd%7D.+This+%0Aprocess+is+similar+to+that+used+for+the+%5Cacrfull%7Blcm%7D.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btype%3D%5Cacronymtype%5D%0A%0A%5Cprintglossary%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的部分输出：

![Glossary2OLV2.png](/files/69b0945cc7b25581bb3a0b37c0559e2c0fcf9317)

以下小节将说明如何创建每种列表类型。

### 术语

如在 [引言](#introduction)中所见，术语是通过命令 `\newglossaryentry`

```latex
\documentclass{article}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=数学,
    description={数学就是数学家所做的事情}
}

\newglossaryentry{latex}
{
    name=latex,
    description={是一种特别适合
科学文档的标记语言}
}

\newglossaryentry{formula}
{
    name=公式,
    description={一个数学表达式}
}

\begin{document}

\Gls{latex} 排版标记语言特别适合
用于包含 \gls{maths} 的文档。\Glspl{formula} 会被
在习惯这些命令后，正确且轻松地渲染出来。

\clearpage

\printglossary

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例创建的术语表：

![Glossary3OLV2.png](/files/6db11440421143139e372a6fb4d41f4832afa99c)

让我们更详细地看看传给命令 `\newglossaryentry`的每个参数的语法。示例中定义的第一个术语是“数学”。

* `maths`。第一个参数是该术语的标签，用于在文档中通过 `\gls`
* `name=数学`来引用它。包含要定义的词，在本例中是“数学”。建议用小写字母和单数形式书写。
* `description={数学就是数学家所做的事情}`。大括号内是当前术语的定义。

定义完术语后，在编写 LaTeX 文件时若要使用它们，请使用下面描述的命令之一：

**\gls{ }**

输出该术语的小写形式。例如，\gls{maths} 在使用时会输出 数学。

**\Gls{ }**

与 \gls 相同，但首字母将以大写形式打印。示例：\Gls{maths} 会输出 数学

**\glspl{ }**

与 \gls 相同，但该术语会以复数形式输出。例如，\glspl{formula} 会在最终文档中输出 公式。

**\Glspl{ }**

与 \Gls 相同，但该术语会以复数形式输出。例如，\Glspl{formula} 显示为 公式。

最后，要打印术语表，请使用命令

```latex
\printglossary
```

### 缩略词

首字母缩略词是由短语中各个单词的首字母组成的词。下面是 LaTeX 中缩略词的一个示例

```latex
\documentclass{article}
\usepackage[acronym]{glossaries}

\makeglossaries

\newacronym{gcd}{GCD}{最大公约数}

\newacronym{lcm}{LCM}{最小公倍数}

\begin{document}
给定一组数字，有一些基本方法可以计算
其 \acrlong{gcd}，其缩写为 \acrshort{gcd}。这个过程
与用于 \acrfull{lcm} 的过程类似。

\clearpage

\printglossary[type=\acronymtype]

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bacronym%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewacronym%7Bgcd%7D%7BGCD%7D%7BGreatest+Common+Divisor%7D%0A%0A%5Cnewacronym%7Blcm%7D%7BLCM%7D%7BLeast+Common+Multiple%7D%0A%0A%5Cbegin%7Bdocument%7D%0AGiven+a+set+of+numbers%2C+there+are+elementary+methods+to+compute+%0Aits+%5Cacrlong%7Bgcd%7D%2C+which+is+abbreviated+%5Cacrshort%7Bgcd%7D.+This+process+%0Ais+similar+to+that+used+for+the+%5Cacrfull%7Blcm%7D.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btype%3D%5Cacronymtype%5D%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的部分输出：

![Glossary4OLV2.png](/files/cbdffdfb47324bb08fa8a953fdeeff17d8e5b6b0)

要使用缩略词，在导入该宏包时必须使用一个额外参数。要添加到导言区的行是 **glossaries** 宏包。需要添加到导言区的行是

```latex
\usepackage[acronym]{glossaries}
```

一旦添加了这一行，命令 `\newacronym` 将声明一个新的缩略词。为了举例，下面是该命令的说明 `\newacronym{gcd}{GCD}{最大公约数}`

* `gcd` 是标签，用于在文档后文引用这个缩略词。
* `GCD` 即缩略词本身。通常缩略词以大写字母书写。
* `最大公约数` 是该缩略词所对应的短语。

在导言区中包含这些缩略词后，可以通过下面这些命令来使用它们：

**\acrlong{ }**

显示该缩略词所代表的短语。将缩略词的标签放在花括号中。在示例中，\acrlong{gcd} 输出 最大公约数。

**\acrshort{ }**

输出作为参数传入其标签的缩略词。例如，\acrshort{gcd} 显示为 GCD。

**\acrfull{ }**

同时输出缩略词及其定义。在示例中，\acrfull{lcm} 的输出是 最小公倍数 (LCM)。

要打印缩略词列表，请使用命令

```latex
\printglossary[type=\acronymtype]
```

缩略词列表需要由 `\printglossary` 生成的临时文件才能工作，因此你必须在行 `\printglossary[type=\acronymtype]` 之前添加上述命令，并编译你的文档；一旦首次编译完成，就可以删除该行 `\printglossary`.

## 更改术语表标题

如果你想把术语表的默认标题改成别的内容，这很简单：在打印术语表时必须添加两个参数。下面是一个示例。

```latex
\documentclass{article}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=数学,
    description={数学就是数学家所做的事情}
}

\newglossaryentry{latex}
{
    name=latex,
    description={是一种特别适合
科学文档的标记语言}
}

\newglossaryentry{formula}
{
    name=公式,
    description={一个数学表达式}
}

\begin{document}

\Gls{latex} 排版标记语言特别适合
用于包含 \gls{maths} 的文档。\Glspl{formula} 会被
在习惯这些命令后，正确且轻松地渲染出来。

\clearpage

\printglossary[title=特殊术语, toctitle=术语列表]

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btitle%3DSpecial+Terms%2C+toctitle%3DList+of+terms%5D%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的部分输出：

![Glossary5OLV2.png](/files/cabe39162764559ad61cb58f5d83eedcacdcfb44)

请注意命令 `\printglossary` 有两个以逗号分隔的参数：

* `title=特殊术语` 是显示在术语表顶部的标题。
* `toctitle=术语列表` 这是要显示在目录中的条目。请参见 [下一节](#show-the-glossary-in-the-table-of-contents).

## 在目录中显示术语表

要让术语表显示在目录中，请在

```latex
\usepackage[toc]{glossaries}
```

添加到文档的导言区中

```latex
\documentclass{article}
\usepackage[toc]{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=数学,
    description={数学就是数学家所做的事情}
}

\newglossaryentry{latex}
{
    name=latex,
    description={是一种特别适合
科学文档的标记语言}
}

\newglossaryentry{formula}
{
    name=公式,
    description={一个数学表达式}
}

\begin{document}

\tableofcontents

\section{第一节}
\Gls{latex} 排版标记语言特别适合
用于包含 \gls{maths} 的文档。\Glspl{formula} 会被
在习惯这些命令后，正确且轻松地渲染出来。

\clearpage

\printglossary[title=特殊术语, toctitle=术语列表]

\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Btoc%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Ctableofcontents%0A%0A%5Csection%7BFirst+Section%7D+%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btitle%3DSpecial+Terms%2C+toctitle%3DList+of+terms%5D%0A%0A%5Cend%7Bdocument%7D)

下图显示了上面示例生成的两页内容。请注意命令

```latex
\printglossary[title=特殊术语, toctitle=术语列表]
```

会为目录（“术语列表”）和正文中使用的对应标题（“特殊术语”）生成不同的标题：

![Glossary6OLV2.png](/files/fb8da7ac09f3362902355a5f05107056949dd2c5)

## 编译术语表

要编译一个包含术语表的文档，在 [Overleaf](http://overleaf.com) 中你不需要做任何特殊操作，但如果在编译后向术语表中添加了新术语，请务必点击 *清除缓存文件* （先在日志选项下）。

如果你正在编译文档，例如一个名为 `glossaries.tex`，使用 pdflatex **在你的本地机器上**，你必须使用以下命令：

`pdflatex glossaries.tex`

`makeglossaries glossaries`

`pdflatex glossaries.tex`

## 参考指南

**术语表可用样式**

命令 `\setglossarystyle{style}` 必须插入在 `\printglossaries`之前。以下是可用样式列表：

* list。将所定义的术语以粗体字体写出
* altlist。术语后插入换行，并缩进说明。
* listgroup。根据首字母对术语分组。
* listhypergroup。在索引顶部添加超链接。

## 进一步阅读

更多信息请参见：

* [索引](/latex/zh-cn/wen-dang-jie-gou/04-indices.md)
* [表格与图形列表](/latex/zh-cn/tu-biao-he-biao-ge/03-lists-of-tables-and-figures.md)
* [目录](/latex/zh-cn/wen-dang-jie-gou/02-table-of-contents.md)
* [章节和小节](/latex/zh-cn/wen-dang-jie-gou/01-sections-and-chapters.md)
* [超链接](/latex/zh-cn/wen-dang-jie-gou/09-hyperlinks.md)
* [国际语言支持](/latex/zh-cn/yu-yan/03-international-language-support.md)
* [章节和公式的交叉引用](/latex/zh-cn/wen-dang-jie-gou/03-cross-referencing-sections-equations-and-floats.md)
* [大型项目中的管理](/latex/zh-cn/wen-dang-jie-gou/07-management-in-a-large-project.md)
* [多文件 LaTeX 项目](/latex/zh-cn/wen-dang-jie-gou/08-multi-file-latex-projects.md)
* [WikiBooks 上的术语表文章](http://en.wikibooks.org/wiki/LaTeX/Glossary)
* [glossaries 宏包：初学者指南](http://theoval.cmp.uea.ac.uk/~nlct/latex/packages/glossaries/glossariesbegin.html)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/wen-dang-jie-gou/05-glossaries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
