也许有一个内置的解决方案,但我在glossaries(-extra)
文档中没有找到任何解决方案。
我想写:
The \gls{un} is an intergovernmental organization.
The \gls{un} was established in 1945.
并得到
联合国(UN)是一个政府间组织。联合国成立于1945年。
词汇表
联合国(UN)一个组织。
这就是我想到的:
\newglossaryentry{un}{
name={United Nations}, % long name to display in the glossary section
text={UN}, % acronym (short name) I'd like to use in text
first={United Nations (UN)}, % I'd like automatically substitute the acronym here
description={An organization} % just the description
}
显然,这个解决方案缺少一些东西。
- 我如何在类似的字段中重复使用该
text
字段?first
first={United Nations (\usefirstfieldhere)}
- 如何在词汇表部分显示长名称和简称?
- 如何使用类似显示全名
acrfull
?
梅威瑟:
\documentclass[]{article}
\usepackage{glossaries}
\usepackage{glossaries-extra}
\newglossaryentry{un}{
name={United Nations}, % long name to display in the glossary section
text={UN}, % acronym (short name) I'd like to use in text
first={United Nations (UN)}, % I'd like automatically substitute the acronym here
description={An organization} % just the description
}
\makeglossaries
\begin{document}
he \gls{un} is an intergovernmental organization.
The \gls{un} was established in 1945.
\printglossaries
\end{document}
答案1
这是内置的glossaries-extra
,请参阅第 4 节缩写的文件。
\documentclass{article}
\usepackage[
abbreviations,
shortcuts=abbr,
]{glossaries-extra}
\makeglossaries
\newabbreviation{un}{UN}{United Nations}
\begin{document}
The \ab{un} is an intergovernmental organization.
The \ab{un} was established in 1945.
\as{un}
\al{un}
\printglossaries
\end{document}
(\gls
也有效,但我发现简写更清楚。)
如果您还想要额外的描述,则必须定义自己的词汇表样式。(不过,您可能无论如何都想这样做,所以这不是什么大问题。)例如:
\documentclass{article}
\usepackage[
abbreviations,
shortcuts=abbr,
stylemods=longbooktabs,
]{glossaries-extra}
\makeglossaries
\glsaddkey{extradesc}
{}
\glsentryextradesc
\Glsentryextradesc
\glsextradesc
\Glsextradesc
\GLSextradesc
\newglossarystyle{custom-long-booktabs}{%
\setglossarystyle{long-booktabs}%
\renewcommand\glossentry[2]{%
\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &%
\glossentrydesc{##1}%
\setbox0=\hbox{\glsentryextradesc{##1}\unskip}%
\ifdim\wd0=0pt\else
\ \small(\glsentryextradesc{##1})%
\fi
\glspostdescription\space ##2\tabularnewline
}%
}
\newabbreviation[
extradesc={An organization},
]{un}{UN}{United Nations}
\begin{document}
The \ab{un} is an intergovernmental organization.
The \ab{un} was established in 1945.
\printglossary[type=abbreviations, nonumberlist, style=custom-long-booktabs]
\end{document}
答案2
事实证明,在我的问题中,我距离适合我的解决方案只有一步之遥,尽管它需要一些样板:
- 如果我声明一个,
\newabbreviation
我不需要(重新)使用text
:出现的排版first
将由定义\setabbreviationstyle
。 - 以下是 中的样板
name
。如果我只提供description
而不提供name
,那么词汇表中的长版本就会丢失。 - 我可以将
\acf
as 与任何首字母缩略词或缩写一起使用。
\documentclass{article}
\usepackage[style = list]{glossaries-extra}
\setabbreviationstyle[abbreviation]{long-short}
\makeglossaries
\newabbreviation[%
name={\glsxtrfull{un}},
description={An intergovernmental organization.}
]{un}{UN}{United Nations}
\begin{document}
The \gls{un} is an intergovernmental organization.
The \gls{un} was established in 1945.
\printglossaries
\end{document}