![如何使用 nomencl 包创建缩写列表和命名法列表?](https://linux22.com/image/259882/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20nomencl%20%E5%8C%85%E5%88%9B%E5%BB%BA%E7%BC%A9%E5%86%99%E5%88%97%E8%A1%A8%E5%92%8C%E5%91%BD%E5%90%8D%E6%B3%95%E5%88%97%E8%A1%A8%EF%BC%9F.png)
我在网上搜索了一整天,但所有的线程都表明只能通过使用nomencl
包来实现其中一个列表。我想创建两个缩写列表和使用包命名列表nomencl
。如何区分两者,\printnomenclature
以便 LaTeX 可以清楚地将它们分开?
答案1
我不知道如何使用 来实现这一点nomencl
。不过,还有其他包可以使用。我将给出两个示例,一个是我的包acro
一个glossaries
。
acro
该acro
包允许将首字母缩写词分配给一个类别并打印每个类别的列表(也适用于组合类别...)。此事实可用于该任务。条目使用以下语法定义:
\DeclareAcronym{<ID>}{
short = <short> ,
long = <long> ,
class = <class>
}
以下是完整示例:
\documentclass{article}
\usepackage{acro}
% probably a good idea for the nomenclature entries:
\acsetup{first-style=short}
% class `abbrev': abbreviations:
\DeclareAcronym{ny}{
short = NY ,
long = New York ,
class = abbrev
}
\DeclareAcronym{la}{
short = LA ,
long = Los Angeles ,
class = abbrev
}
\DeclareAcronym{un}{
short = UN ,
long = United Nations ,
class = abbrev
}
% class `nomencl': nomenclature
\DeclareAcronym{angelsperarea}{
short = \ensuremath{a} ,
long = The number of angels per unit area ,
sort = a ,
class = nomencl
}
\DeclareAcronym{numofangels}{
short = \ensuremath{N} ,
long = The number of angels per needle point ,
sort = N ,
class = nomencl
}
\DeclareAcronym{areaofneedle}{
short = \ensuremath{A} ,
long = The area of the needle point ,
sort = A ,
class = nomencl
}
\begin{document}
\ac{ny}, \ac{la} and \ac{un} are abbreviations whereas
\ac{angelsperarea}, \ac{numofangels} and \ac{areaofneedle} are part of the
nomenclature
\printacronyms[include=abbrev,name=Abbreviations]
\printacronyms[include=nomencl,name=Nomenclature]
\end{document}
glossaries
该glossaries
软件包功能更强大。您可以根据需要定义任意数量的词汇表。在这里,我们可以利用已经定义首字母缩略词词汇表的事实。类似地,nomencl
它要求您运行脚本来对条目进行排序。如果您的文件被调用,file.tex
这通常是通过调用
makeglossaries file
从命令行。详细信息可在用户手册(第 26 页,第 1.3.3 节)。
完整示例:
\documentclass{article}
\usepackage{longtable}
\usepackage[acronym]{glossaries}
% abbreviations:
\newacronym{ny}{NY}{New York}
\newacronym{la}{LA}{Los Angeles}
\newacronym{un}{UN}{United Nations}
% nomenclature:
\newglossaryentry{angelsperarea}{
name = $a$ ,
description = The number of angels per unit area,
}
\newglossaryentry{numofangels}{
name = $N$ ,
description = The number of angels per needle point
}
\newglossaryentry{areaofneedle}{
name = $A$ ,
description = The area of the needle point
}
\makeglossaries
\begin{document}
\gls{ny}, \gls{la} and \gls{un} are abbreviations whereas
\gls{angelsperarea}, \gls{numofangels} and \gls{areaofneedle} are part of the
nomenclature
\printglossary[type=\acronymtype,title=Abbreviations]
\printglossary[title=Nomenclature]
\end{document}
答案2
它是确实可以使用两个单独的列表nomencl
。
您可以将它们定义为群组并附有相应的标题。
当这样做时,您需要通过将主标题放在\renewcommand{\nomname}{}
序言中来删除它。
以下是包含两个组的示例:
\documentclass{article}
\usepackage{nomencl}
\makenomenclature
%% This removes the main title:
\renewcommand{\nomname}{}
%% this modifies item separation:
\setlength{\nomitemsep}{8pt}
%% this part defines the groups:
%----------------------------------------------
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\Large\bfseries
\ifstrequal{#1}{N}{Nomenclature}{%
\ifstrequal{#1}{A}{List of Abbreviations}{}}%
]\vspace{10pt}} % this is to add vertical space between the groups.
%----------------------------------------------
\begin{document}
\nomenclature[A]{\textbf{IMO}}{in my opinion}
\nomenclature[A]{\textbf{OP}}{original poster}
\nomenclature[N]{$c$}{speed of light in vacuum}
\nomenclature[N]{$h$}{Plank constant}
\printnomenclature[2cm]
\end{document}
给予:
答案3
这也有效(我无法让上面的脚本适用于带有单位和词汇表的符号列表......)。这里的行顺序很重要!
基本文件.tex:
%Load the package
\usepackage[
nonumberlist, %do not show page numbers
acronym, %generate acronym listing -> Not used in this example (see line with %%% )
toc, %show listings as entries in table of contents
section] %use section level for toc entries
{glossaries}
%Generate a list of symbols
\newglossary[slg]{symbols}{syi}{syg}{List of symbols}
%Remove the dot at the end of glossary descriptions
\renewcommand*{\glspostdescription}{}
%Activate glossary commands
\makeglossaries
%Load nomenclature and glossary files
\loadglsentries{nomenclature}
\loadglsentries{glossary}
%These commands sort the lists
%%%makeindex -s filename.ist -t filename.alg -o filename.acr filename.acn
%makeindex -s filename.ist -t filename.glg -o filename.gls filename.glo
%makeindex -s filename.ist -t filename.slg -o filename.syi filename.syg
\begin{document}
%Print the glossary
\printglossary[style=altlist,title=Glossary]
%%%%Print list of acronyms
%%%\printglossary[type=\acronymtype,style=long]
%Print list of symbols
\printglossary[type=symbols,style=long4col]
\clearpage
bla-bla \gls{h} \gls{nslats} \gls{illuminance}
\end{document}
命名法.tex:
%Some entries for the list of symbols
\newglossaryentry{nslats}{
name=$nslats$,
description={The number of slats},
sort=S, type=symbols, symbol=[$-$]}
\newglossaryentry{h}{
name=$h$,
description={Height},
sort=h, type=symbols, symbol=[$m$]}
词汇表
%Some glossary terms
\newglossaryentry{illuminance}{
name=Illuminance,
description={Light flux striking a surface, measured in Lux (lx).}
}
%%% In case you also want a list acronyms
%%%\newacronym{MS}{MS}{Microsoft}
%%%\newacronym{CD}{CD}{Compact Disc}
我不使用 Perl,因此在任何文件发生变化后,我直接在命令提示符中输入这些行(注意:如果您没有更改任何有关词汇表或符号列表的内容,则只需输入一次 pdflatex 就可以了!):
pdflatex BasicFile.tex
pdflatex BasicFile.tex
makeindex -s BasicFile.ist -t BasicFile.slg -o BasicFile.syi BasicFile.syg
makeindex -s BasicFile.ist -t BasicFile.glg -o BasicFile.gls Report_Base_v6.glo
pdflatex BasicFile.tex
BasicFile.pdf