我在用glossaries-extra
。
如何在不改变首次使用标志的情况下,在每一章(或部分)中第一次使用首字母缩略词或词汇表条目后抑制超链接?我发现此解决方案,不适用于首字母缩略词和这个,它提供了一种不雅且丑陋的修补程序和另一种不适用于章节或章节的解决方案。我不想在每个章节/节中重置首次使用标志,以避免重复首字母缩略词的解释。
有没有一种不是黑客攻击的解决方案?
梅威瑟:
\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym]{glossaries-extra}
\RestoreAcronyms
\newacronym{ex}{EX}{example}
\newglossaryentry{foobar}
{
name={foobar},
description={The FOOBAR blaa},
}
\makeglossaries
\begin{document}
\section{First section}
I explain \gls{ex} completely. But the second one here is short and has no more hyperlink: \gls{ex}.
Moreover, this is hyperlinked: \gls{foobar}, but this one is not: \gls{foobar}.
\section{Second section}
This \gls{ex} is short and with a hyperlink and this one is short and without a link: \gls{ex}.
\Gls{foobar} is linked, but \gls{foobar} is not.
\newpage
\printglossaries
\end{document}
答案1
使用glossaries-extra
v1.26 (2018-01-05)¹ 您可以执行以下操作:
\documentclass{article}
\usepackage{hyperref}
\usepackage[acronym]{glossaries-extra}
\makeglossaries
\GlsXtrEnableLinkCounting[section]{general,acronym}
% disable hyperlink if link count is greater than 1:
\renewcommand*{\glslinkpresetkeys}{%
\ifnum\GlsXtrLinkCounterValue{\glslabel}>1
\setkeys{glslink}{hyper=false}%
\fi
}
\setabbreviationstyle[acronym]{long-short}
\newacronym{ex}{EX}{example}
\newglossaryentry{foobar}
{
name={foobar},
description={The FOOBAR blaa},
}
\begin{document}
\section{First section}
I explain \gls{ex} completely. But the second one here is short and
has no more hyperlink: \gls{ex}.
Moreover, this is hyperlinked: \gls{foobar}, but this one is not:
\gls{foobar}.
\section{Second section}
This \gls{ex} is short and with a hyperlink and this one is short
and without a link: \gls{ex}.
\Gls{foobar} is linked, but \gls{foobar} is not.
This link is forced on: \gls+{foobar}.
\newpage
\printglossaries
\end{document}
这种新的 link² 计数方法独立于首次使用标志,因此不会干扰缩写。的可选参数\GlsXtrEnableLinkCounting
是主计数器的名称(section
在本例中)。
¹我刚刚将此版本上传到 CTAN,因此需要等待几天才能分发。
²术语“链接”是指由 和 之类的命令(而不是(可能由 或可能不由)使用)\@gls@link
使用的底层内部命令。\gls
\glstext
\hyperlink
\@gls@link