我的文档前言中有三组首字母缩略词(一组主要的称为“缩写列表”,另外两组有自己的标题,“时间”和“城市”),我按照这个例子使用了词汇表包中的“首字母缩略词” 自定义词汇表组标题。
\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym,acronymlists={general}, nomain,makeindex]{glossaries}
% new glossary style
\newglossarystyle{onecol}{%
%
\renewenvironment{theglossary}%
{\begin{description}}{\end{description}}%
%
%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupheading}[1]{%
\item[{\glsgetgrouptitle{##1}}]}
%
\renewcommand*{\glsgroupskip}{ \\}%
\renewcommand*{\glossaryentryfield}[5]{%
\item[\glstarget{##1}{##2}] ##3%
}%
}
%% glossary
\newglossary{general}{general.sys}{general.syo}{List of Abbreviations}
\newcommand*{\Agroupname}{}
\newcommand*{\Ggroupname}{Cities}
\newcommand*{\Sgroupname}{Time}
% This entry is part of the main glossary
\newglossaryentry{orange}{name=orange, description={an orange coloured fruit},first={Orange}, type={general}, sort=a}
% Entries for first group
\newglossaryentry{utc}{name=UTC, description={Coordinated Universal Time},first={Coordinated Universal Time (UTC)}, type={general}, sort=g}
\newglossaryentry{adt}{name=ADT, description={Atlantic Daylight Time},first={Atlantic Daylight Time (ADT)}, type={general}, sort=g}
% Entries for second group
\newglossaryentry{la}{name=LA, description={Los Angeles},first={Los Angeles (LA)}, type={general}, sort=s}
\newglossaryentry{ny}{name=NY, description={New York},first={New York (NY)}, type={general}, sort=s}
\makeglossaries
\begin{document}
\listoffigures % print list of figures
\listoftables % print list of tables
\glsaddall
\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{List of Abbreviations}
\printglossary[type={general},style={onecol}]
\chapter{Introduction}
% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.
\end{document}
我正在尝试为属于不同组的项目设置略有不同的字体,例如,属于一个组的项目在简短版本中显示为 \texttt{acronym}。现在我通过直接格式化每个项目的名称来实现这一点,如下所示:
\newglossaryentry{utc}{name=\textsf{UTC}, description={Coordinated Universal Time},first={Coordinated Universal Time (UTC)}, type={general}, sort=a}
我查看了词汇表包手册中的分组功能,但当我尝试在 \newglossarystyle 定义中执行 \renewcommand*{\acronymfont}[1]{\textsf{#1}} 时,所有格式都发生了改变。我如何才能为每个组单独更改字体和大小?非常感谢您的建议!
答案1
我认为对于这种事情使用分层机制比尝试强制条目组更简单。此外,它还可以简化定义语义命令的过程。例如:
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[hidelinks]{hyperref}
\usepackage[acronym,acronymlists={general},nomain,makeindex,toc]{glossaries}
% new glossary style
\newglossarystyle{onecol}{%
%
\renewenvironment{theglossary}%
{\begin{description}}{\end{description}}%
%
%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupheading}[1]{}
%
\renewcommand*{\glossentry}[2]{%
\item[\glstarget{##1}{\glossentryname{##1}}] \glossentrydesc{##1} ##2%
}%
\renewcommand*{\subglossentry}[3]{%
\item[\glstarget{##2}{\glossentryname{##2}}] \glossentrydesc{##2} ##3%
}%
}
\renewcommand*{\glsnamefont}[1]{\textmd{#1}}
%% glossary
\newglossary{general}{general.sys}{general.syo}{List of Abbreviations}
\newglossaryentry{main}{name={\null},description={\nopostdesc},
type={general},nonumberlist}
\newglossaryentry{cities}{name={Cities},description={\nopostdesc},
type={general},nonumberlist}
\newglossaryentry{time}{name={Time},description={\nopostdesc},
type={general},nonumberlist}
% This entry is part of the main glossary
\newglossaryentry{orange}{name=orange, description={an orange
coloured fruit},first={Orange}, type={general}, parent=main}
% Entries for first group
\newcommand*{\timefont}[1]{\textit{#1}}
\newcommand*{\newtime}[3]{%
\newglossaryentry{#1}{name={\timefont{#2}},sort={#2},description={#3},
first={#3 (\timefont{#2})},type={general},parent=time}%
}
\newtime{utc}{UTC}{Coordinated Universal Time}
\newtime{adt}{ADT}{Atlantic Daylight Time}
% Entries for second group
\newcommand*{\cityfont}[1]{\textsf{#1}}
\newcommand*{\newcity}[3]{%
\newglossaryentry{#1}{name={\cityfont{#2}},sort={#2},description={#3},
first={#3 (\cityfont{#2})},type={general},parent=cities}%
}
\newcity{la}{LA}{Los Angeles}
\newcity{ny}{NY}{New York}
\makeglossaries
\begin{document}
\glsaddall
\printglossary[type={general},style={onecol}]
\chapter{Introduction}
% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.
\end{document}
这将重新定义\glsnamefont
以抵消 引入的粗体\item
,并定义两个命令\timefont
和\cityfont
,用于时间和城市条目的不同格式。您可以根据需要修改它们。您可能还想对 条目执行类似操作orange
。
这将产生词汇表:
以及文件正文: