LaTeX 术语集 Nomenclatures

原  文:Nomenclatures
译  者:Xovee
翻译时间:2021年7月9日

术语集 Nomenclatures

在科研论文中,缩略语和符号的列表被称为 Nomenclatures。这种类型的列表可以由 nomencl包来生成。本文介绍如何创建术语集(Nomenclatures),以及自定义符号的顺序和分组规则。

术语集条目和索引条目非常相似:

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\begin{document}
\mbox{}
\nomenclature{\(c\)}{Speed of light in a vacuum}
\nomenclature{\(h\)}{Planck constant}

\printnomenclature
\end{document}

在这里插入图片描述
在文档的 preamble 中引入该包:\usepackage{nomencl}。它有三个基础的命令:

  • \makenomenclature:该命令通常放置在引入包的命令之后。
  • \nomenclature:定义术语集条目。拥有两个参数,分别为符号和其对应的描述。
  • \printnomenclatures:打印术语集。

基础语法

在引入nomencl包的时候,你可以传递额外的参数。下面的例子介绍了如何将术语集添加到目录之中,以及如何改变术语集的默认语言。

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[intoc, spanish]{nomencl}
\makenomenclature

\begin{document}
\tableofcontents

\section{Primera Sección}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdie...

\nomenclature{\(c\)}{Speed of light in a vacuum}
\nomenclature{\(h\)}{Planck constant}

\printnomenclature
\end{document}

在这里插入图片描述
这里使用的额外的参数包括:

  • intoc:将术语集包含在目录之中
  • spanish:更改语言,将默认的标题Nomenclatures更改为对应语言所适用的标题。支持的语言包括:croatiandanishenglishfrenchgermanitalianpolishportugueserussianspanishukranian

其他有用的特点包括:你可以手动地设置术语表的标题,以及添加额外的注释。

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\renewcommand{\nomname}{List of Symbols}

\renewcommand{\nompreamble}{The next list describes several symbols that will be later used within the body of the document}

\begin{document}
\mbox{}

\nomenclature{\(c\)}{Speed of light in a vacuum}
\nomenclature{\(h\)}{Planck constant}

\printnomenclature
\end{document}

在这里插入图片描述
命令

\renewcommand{\nomname}{List of Symbols}

改变了默认的标题。

命令

\renewcommand{\nompreamble}{The next list...}

添加了位于标题和符号表之间的文字。

分组

我们现在介绍如何为符号们进行分组。我们为每个符号添加一个前缀,然后利用etoolbox包来对前缀进行对比。

\documentclass{article}
\usepackage{amssymb}
\usepackage{nomencl}
\makenomenclature

%% This code creates the groups
% -----------------------------------------
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{P}{Physics constants}{%
  \ifstrequal{#1}{N}{Number sets}{%
  \ifstrequal{#1}{O}{Other symbols}{}}}%
]}
% -----------------------------------------

\begin{document}
\mbox{}

\nomenclature[P]{\(c\)}{Speed of light in a vacuum}
\nomenclature[P]{\(h\)}{Planck constant}
\nomenclature[P]{\(G\)}{Gravitational constant}
\nomenclature[N]{\(\mathbb{R}\)}{Real numbers}
\nomenclature[N]{\(\mathbb{C}\)}{Complex numbers}
\nomenclature[N]{\(\mathbb{H}\)}{Quaternions}
\nomenclature[O]{\(V\)}{Constant volume}
\nomenclature[O]{\(\rho\)}{Friction index}

\printnomenclature
\end{document}

在这里插入图片描述
在这个例子中我们添加了一些分组。代码并不简单,我们使用了命令\ifstrequal{}{}{}{}。前两个参数是用来对比的字符串,如果它们相同,则将它们添加到一个分组中,如果它们不同,则检查下一个嵌套的条件。

需要注意的是,每一个\nomenclature命令都有一个位于方括号之中的额外的参数:前缀。

如果你不能使用etoolbox包,你可以使用ifthen包,后者提供了条件命令\ifthenelse{}{}{}。它的语法更为复杂一点。

\usepackage{ifthen}
  \renewcommand{\nomgroup}[1]{%
  \item[\bfseries
  \ifthenelse{\equal{#1}{P}}{Physics constants}{%
  \ifthenelse{\equal{#1}{O}}{Other symbols}{%
  \ifthenelse{\equal{#1}{N}}{Number sets}{}}}%
  ]}

上面的代码将会生成相同的术语集分组。

对物理常数添加单位

你还可以使用siunitx包来添加单位,将单位向对应条目的右侧进行对齐。你需要首先定义nomunit宏指令,下面介绍一个例子:

\documentclass{article}
\usepackage{amssymb}
\usepackage{nomencl}
\usepackage{siunitx}
\usepackage{hyperref}
\makenomenclature
\hypersetup{
    colorlinks=true,
    urlcolor=blue,
}
%% This will add the subgroups
%----------------------------------------------
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{A}{Physics Constants}{%
  \ifstrequal{#1}{B}{Number Sets}{%
  \ifstrequal{#1}{C}{Other Symbols}{}}}%
]}
%----------------------------------------------

%% This will add the units
%----------------------------------------------
\newcommand{\nomunit}[1]{%
\renewcommand{\nomentryend}{\hspace*{\fill}#1}}
%----------------------------------------------

\title{Nomenclatures Example}
\author{Overleaf Team}
\date{\today}

\begin{document}
\maketitle

\noindent This is an example to show how the \texttt{nomencl} package works, with units typeset via the \texttt{siunitx} package. \href{https://www.nist.gov/pml/fundamental-physical-constants}{NIST} was referenced to provide the values of physical constants, and their corresponding units---links are provided via the \texttt{hyperref} package:

\nomenclature[A, 02]{\(c\)}{\href{https://physics.nist.gov/cgi-bin/cuu/Value?c}
{Speed of light in a vacuum}
\nomunit{\SI{299792458}{\meter\per\second}}}
\nomenclature[A, 03]{\(h\)}{\href{https://physics.nist.gov/cgi-bin/cuu/Value?h}
{Planck constant}
\nomunit{\SI[group-digits=false]{6.62607015e-34}{\joule\per\hertz}}}
\nomenclature[A, 01]{\(G\)}{\href{https://physics.nist.gov/cgi-bin/cuu/Value?bg}
{Gravitational constant} 
\nomunit{\SI[group-digits=false]{6.67430e-11}{\meter\cubed\per\kilogram\per\second\squared}}}
\nomenclature[B, 03]{\(\mathbb{R}\)}{Real numbers}
\nomenclature[B, 02]{\(\mathbb{C}\)}{Complex numbers}
\nomenclature[B, 01]{\(\mathbb{H}\)}{Quaternions}
\nomenclature[C]{\(V\)}{Constant volume}
\nomenclature[C]{\(\rho\)}{Friction index}

\printnomenclature

\end{document}

在这里插入图片描述

对条目进行排序

下面是默认的排序顺序:

\documentclass{article}
\usepackage{nomencl}

\makenomenclature

\begin{document}
\mbox{}

\nomenclature{\(+a\)}{Operator}
\nomenclature{\(2a\)}{Number}
\nomenclature{\(:a\)}{Punctuation symbol}
\nomenclature{\(Aa\)}{Uppercase letter}
\nomenclature{\(aa\)}{Lowercase letter}
\nomenclature{\(\alpha\)}{Greek character}

\printnomenclature

\end{document}

在这里插入图片描述
注意,在上面的例子中,希腊字母在英文字母之前是因为反斜杠\而导致的(例如\alpha)。

类似于分组,你可以添加一个前缀来手动地为术语集条目进行排序:

\documentclass{article}
\usepackage{nomencl}

\makenomenclature

\begin{document}
\mbox{}

\nomenclature[06]{\(+a\)}{Operator}
\nomenclature[03]{\(2a\)}{Number}
\nomenclature[05]{\(:a\)}{Punctuation symbol}
\nomenclature[04]{\(Aa\)}{Uppercase letter}
\nomenclature[01]{\(aa\)}{Lowercase letter}
\nomenclature[02]{\(\alpha\)}{Greek character}

\printnomenclature

\end{document}

在这里插入图片描述
方括号之中的数字代表对应字符的顺序。你也可以同时使用分组和手动排序:

\documentclass{article}
\usepackage{amssymb}
\usepackage{nomencl}
\makenomenclature

\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{A}{Physics Constants}{%
  \ifstrequal{#1}{B}{Number Sets}{%
  \ifstrequal{#1}{C}{Other Symbols}{}}}%
]}

\begin{document}
\mbox{}

\nomenclature[A, 02]{\(c\)}{Speed of light in a vacuum}
\nomenclature[A, 03]{\(h\)}{Planck constant}
\nomenclature[A, 01]{\(G\)}{Gravitational constant}
\nomenclature[B, 03]{\(\mathbb{R}\)}{Real numbers}
\nomenclature[B, 02]{\(\mathbb{C}\)}{Complex numbers}
\nomenclature[B, 01]{\(\mathbb{H}\)}{Octonions}
\nomenclature[C]{\(V\)}{Constant volume}
\nomenclature[C]{\(\rho\)}{Friction index}

\printnomenclature

\end{document}

在这里插入图片描述
注意,在这里,用来分组的大写字母与我们之前的例子有所不同,因为它们被用来对不同的分组进行排序。

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值