当我写作时,我通常使用全称,然后再使用缩写形式来保持写作简洁,就像这样
2075 年,StackOverflow 行星联盟推翻了美国,建立了一个单一的世界国家。从此以后,联盟...
现在,要在 LaTeX 中执行此操作,我会执行以下操作
\newglossaryentry{federation-long}
{
name={Federation of StackoVerflow Planets}
text={federation of stackoverflow planets}
first={\textbf{Federation of StackoVerflow Planets}}
description={\dots}
}
\newglossaryentry{federation-short}
{
name={Federation}
text={federation}
first={\textbf{Federation}}
description={\dots}
}
In the year 2075, The \gls{federation-long} overthrew the United States and created a single world state. The \gls{federation-short}, henceforth...
我有理由不直接输入“The Federation”(主要是如果我以后将“Federation of StackOverflow Planets”中的“Federation”更改为例如“Alliance”,那么我必须记得返回并将“The Federation”更改为“The Alliance”)。
问题
是否有一些干净的方法可以在词汇表中分配一个短期术语,就像这样(注意,这是一个例子仅有的)
\newglossaryentry{federation}
{
name={Federation of StackoVerflow Planets}
text={federation of stackoverflow planets}
first={\textbf{Federation of StackoVerflow Planets}}
short={Federation}
description={\dots}
}
In the year 2075, The \gls{federation} overthrew the United States and created a single world state. The \glssh{federation}, henceforth...
答案1
这是我能想到的最简单的方法(使用扩展包glossaries-extra
):
\documentclass{article}
\usepackage{glossaries-extra}
\setabbreviationstyle{long-only-short-only-desc}
\GlsXtrEnableInitialTagging{abbreviation}{\abbrtag}
\renewcommand{\glsxtrtagfont}[1]{\MakeUppercase{#1}}
\renewcommand{\glsfirstlongonlyfont}[1]{%
{% scope
\bfseries
\let\abbrtag\glsxtrtagfont
#1%
}%
}
\newabbreviation
[description={\ldots}]
{federation}{Federation}
{\abbrtag{f}ederation of \abbrtag{s}tacko\abbrtag{v}erflow \abbrtag{p}lanets}
\begin{document}
In the year 2075, The \gls{federation} overthrew the United States and created
a single world state. The \gls{federation}, henceforth...
Explicit use of long form: \glsxtrlong{federation}.
Compare with \glsreset{federation}\gls{federation}.
\printunsrtglossaries
\end{document}