我正在使用一个自定义命令\addacronym
,为每个首字母缩略词创建两个词汇表条目:
- 主条目和
- 从缩写到主条目的交叉引用。
我还必须\glsseeitemformat
通过调用重新定义命令来将交叉引用链接的文本更改为首字母缩略词的长版本\acrlong
。
问题是此命令会为主词汇表术语添加新的条目位置。我该如何避免这种情况?
以下是 MWE:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
% A new command creates two glossary entries for each acronym (the main entry
% and a cross-reference from abbreviation to the main entry).
% Syntax: \addacronym[options]{label}{abbreviation}{long}{description}
\newcommand{\addacronym}[5][]{
% Create the main glossary entry with \newacronym
% \newacronym[key-val list]{label}{abbrv}{long}
\newacronym[
name={#4 (#3)},
description={#5},
#1 % pass additional options to \newglossaryentry
]
{#2}{#3}{#4}
% Create a cross-reference from the abbreviation to the main glossary entry by
% creating an auxiliary glossary entry (note: we set the label of this entry
% to '<original label>_auxiliary' to avoid clashes)
\newglossaryentry{#2_auxiliary}{
name={#3},
sort={#3},
description={\makefirstuc{#4}},
see=[See:]{#2}
}
}
% Change the text of the cross-reference links to long versions of the acronyms
\renewcommand*{\glsseeitemformat}[1]{\emph{\acrlong{#1}}.}
\addacronym
{sample} % label
{ABR} % abbreviation
{long version of the acronym}
{Description of the acronym}
\begin{document}
The first occurrence of the acronym would look like:
\gls{sample}.
Further occurrences would look like: \gls{sample}.
\newpage
\printglossaries
\end{document}
它生成两页。第一页:
第二页:
我想要删除的入口位置被红色划掉了。
答案1
\glsentrylong
只显示与长版本相关的文本,而不对其进行索引或创建超链接,因此您可以使用\glsentrylong
而不是\acrlong
。如果您还想要超链接,您可以\glsentrylong
在 的可选参数中使用\glshyperlink
。示例:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
% A new command creates two glossary entries for each acronym (the main entry
% and a cross-reference from abbreviation to the main entry).
% Syntax: \addacronym[options]{label}{abbreviation}{long}{description}
\newcommand{\addacronym}[5][]{
% Create the main glossary entry with \newacronym
% \newacronym[key-val list]{label}{abbrv}{long}
\newacronym[
name={#4 (#3)},
description={#5},
#1 % pass additional options to \newglossaryentry
]
{#2}{#3}{#4}
% Create a cross-reference from the abbreviation to the main glossary entry by
% creating an auxiliary glossary entry (note: we set the label of this entry
% to '<original label>_auxiliary' to avoid clashes)
\newglossaryentry{#2_auxiliary}{
name={#3},
sort={#3},
description={\makefirstuc{#4}},
see=[See:]{#2}
}
}
% Change the text of the cross-reference links to long versions of the acronyms
\renewcommand*{\glsseeitemformat}[1]{\emph{\glshyperlink[\glsentrylong{#1}]{#1}}.}
\addacronym
{sample} % label
{ABR} % abbreviation
{long version of the acronym}
{Description of the acronym}
\begin{document}
The first occurrence of the acronym would look like:
\gls{sample}.
Further occurrences would look like: \gls{sample}.
\newpage
\printglossaries
\end{document}
得出的结果为: