我正在尝试在文档的前言中添加一个主要的缩写列表和两个包含具有不同标题的其他缩写子列表的小节,使用包中的“首字母缩略词” glossaries
,并将标题显示在目录中作为“缩写列表”(主标题)、“时间”(小节)、“城市”(小节)。
有没有办法将主缩略词和子集中的首字母缩略词分别拆分为一个标题?我可以看到这是可能的,例如,\newglossary
如果它是一个词汇表,则使用命令,然后在为词汇表定义新术语时指定“类型”,但是首字母缩略词是否有类似的功能?我还试图通过例如添加来稍微改变两个列表首字母缩略词的样式\texttt
。
非常感谢您的帮助,非常感谢!
\documentclass{article}
% Abbreviations
\usepackage[acronym,nonumberlist,toc]{glossaries}
%Remove the dot at the end of glossary descriptions
\renewcommand*{\glspostdescription}{}
\renewcommand*{\acronymname}{List of Abbreviations}
\renewcommand*\acronymname{Time}
\newacronym{utc}{UTC}{Coordinated Universal Time}
\newacronym{adt}{ADT}{Atlantic Daylight Time}
\renewcommand*\acronymname{Cities}
\newacronym{la}{LA}{Los Angeles}
\newacronym{ny}{NY}{New York}
\makeglossaries
\begin{document}
\frontmatter
\listoffigures % print list of figures
\listoftables % print list of tables
\printglossaries
\mainmatter
\chapter{Introduction}
% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.
\end{document}
有些东西我已经正常工作了,但我仍然无法让它正确地打印主要缩略词并将其他缩略词作为子列表:
\documentclass{article}
\usepackage{hyperref}
\usepackage[style=long, nonumberlist, nogroupskip]{glossaries}
\makenoidxglossaries
% The main title "List of Abbreviations with some acronyms should be printed first, followed by the subsections "Time" and "Cities"
%\setglossarysection{section}
\newglossary[alg1,nonumberlist, type=\acronymtype, section=subsection]{time}{acn1}{acr1}{Time}
\newglossary[alg2,nonumberlist,type=\acronymtype, section=subsection]{cities}{acn2}{acr2}{Cities}
% This entry is part of the main glossary
\newglossaryentry{orange}{name=orange, description={an orange coloured fruit},first={Orange}}
\newglossaryentry{utc}{type=time, name=\textsf{UTC}, description={Coordinated Universal Time},first={Coordinated Universal Time (UTC)}}
\newglossaryentry{la}{type=cities, name=\textrm{LA}, description={Los Angeles},first={Los Angeles (LA)}}
%: ----------------------- list of figures/tables/acronyms ------------------------
\begin{document}
\frontmatter
% TABLE OF CONTENTS
\listoffigures % print list of figures
\listoftables % print list of tables
\glsaddall
\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{List of Abbreviations}
\printglossary[title=List of Abbreviations, toctitle=List of Abbreviations]
\printnoidxglossary[type=time]
\printnoidxglossary[type=cities]
\mainmatter
\chapter{Introduction}
% Use the acronyms
\gls{orange} is a main acronym, while \gls{utc} is part of a sub-list of acronyms called Time and \gls{la} is part of another sub-list of acronyms called Cities.
\end{document}
答案1
\newacronym
内部使用\newglossaryentry
并具有一个可选参数,可用于添加条目所需的任何额外键。有两种可能的方法。第一种是使用子条目:
\documentclass{book}
% Abbreviations
\usepackage[acronym,nonumberlist,
nopostdot,% Remove the dot at the end of glossary descriptions
style=tree,% use hierarchical style
toc]{glossaries}
\makeglossaries
\renewcommand*{\acronymname}{List of Abbreviations}
\newglossaryentry{time}{name=Time,description={}}
\newacronym[parent=time]{utc}{UTC}{Coordinated Universal Time}
\newacronym[parent=time]{adt}{ADT}{Atlantic Daylight Time}
\newglossaryentry{cities}{name=Cities,description={}}
\newacronym[parent=cities]{la}{LA}{Los Angeles}
\newacronym[parent=cities]{ny}{NY}{New York}
\begin{document}
\frontmatter
\printglossaries
\mainmatter
\chapter{Introduction}
% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.
\end{document}
得出的结果为:
在这种情况下,词汇表样式必须支持分层条目,因此我选择了tree
MWE 的样式。请参阅预定义词汇表样式表在用户手册中查看其他选项(最高级别需要为 1 或更多,但不应是同形异义词样式之一)。
第二种方法是定义不同的词汇表并使用type
键。例如:
\documentclass{book}
\usepackage[nonumberlist,
nopostdot,% Remove the dot at the end of glossary descriptions
style=tree,% change as appropriate
toc]{glossaries}
\newglossary{time}{gls2}{glo2}{Time}
\newglossary{cities}{gls3}{glo3}{Cities}
\makeglossaries
\newglossaryentry{sample}{name=sample,description={an example}}
\newacronym[type=time]{utc}{UTC}{Coordinated Universal Time}
\newacronym[type=time]{adt}{ADT}{Atlantic Daylight Time}
\newacronym[type=cities]{la}{LA}{Los Angeles}
\newacronym[type=cities]{ny}{NY}{New York}
\begin{document}
\frontmatter
\printglossary
\chapter{List of Abbreviations}
\setglossarysection{section}
\printglossary[type=time]
\printglossary[type=cities]
\mainmatter
\chapter{Introduction}
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.
\gls{sample} entry.
\end{document}
这会将main
词汇表放在一章中(假设您想要这样做),但两个缩写词汇表放在几节中。结果如下所示:
该样式不再需要支持子条目,因此您可以将其更改为任何合适的样式。