Disable hyperlinks in some entries for glossaries
For these "frequently appearing" entries use the starred versions of glossaries
' user commands (e.g. \gls*
) which suppress hyperlinks.
\documentclass{article}
\usepackage{hyperref}
\usepackage{glossaries}
\makeglossaries
\newglossaryentry{electrolyte}{name=electrolyte,
description={solution able to conduct electric current}}
\newglossaryentry{pi}{name={\ensuremath{\pi}},
description={ratio of circumference of circle to its diameter},sort=pi}
\begin{document}
Some text about \gls{electrolyte} and \gls*{pi}.
\printglossaries
\end{document}
If you upgrade to the latest version of glossaries
(v4.09 at time of writing), you can hook into the mechanism that sets the default value of the hyper
key when using an entry. Here's a simple example that just disables the hyperlink for a specific entry (ut
):
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
% dummy entries copied from example-glossaries-brief.tex
\newglossaryentry{lorem}{name={lorem},description={ipsum}}
\newglossaryentry{dolor}{name={dolor},description={sit}}
\newglossaryentry{amet}{name={amet},description={consectetuer}}
\newglossaryentry{adipiscing}{name={adipiscing},description={elit}}
\newglossaryentry{ut}{name={ut},description={purus}}
\newglossaryentry{elit}{name={elit},description={vestibulum}}
\renewcommand*{\glslinkcheckfirsthyperhook}{%
\ifdefstring\glslabel{ut}%
{\setkeys{glslink}{hyper=false}}%
{}%
}
\begin{document}
Use the entries: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Use the entries again: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Force the hyperlink on: \gls+{ut} or \gls[hyper=true]{ut}.
\printglossaries
\end{document}
This produces:
For a more generalised solution, you could have a list of all the labels of entries that shouldn't have a hyperlink (using, for example, the internal list macros provided by etoolbox
) or you could use, say, the user1
key when defining the entry to identify it as one that shouldn't have a hyperlink. For example:
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
% dummy entries copied from example-glossaries-brief.tex
\newglossaryentry{lorem}{name={lorem},description={ipsum}}
\newglossaryentry{dolor}{name={dolor},description={sit},user1={off}}
\newglossaryentry{amet}{name={amet},description={consectetuer},user1={off}}
\newglossaryentry{adipiscing}{name={adipiscing},description={elit}}
\newglossaryentry{ut}{name={ut},description={purus},user1={off}}
\newglossaryentry{elit}{name={elit},description={vestibulum}}
\renewcommand*{\glslinkcheckfirsthyperhook}{%
% Get the value of the user1 field
\glsletentryfield{\thisvalue}{\glslabel}{useri}%
% Test this value
\ifdefstring\thisvalue{off}%
{\setkeys{glslink}{hyper=false}}%
{}%
}
\begin{document}
Use the entries: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Use the entries again: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Force the hyperlink on: \gls+{ut} or \gls+{dolor}.
\printglossaries
\end{document}
This produces:
Another possibility is to allow the hyperlink on first use and then disable it for subsequent use:
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
% dummy entries copied from example-glossaries-brief.tex
\newglossaryentry{lorem}{name={lorem},description={ipsum}}
\newglossaryentry{dolor}{name={dolor},description={sit},user1={off}}
\newglossaryentry{amet}{name={amet},description={consectetuer},user1={off}}
\newglossaryentry{adipiscing}{name={adipiscing},description={elit}}
\newglossaryentry{ut}{name={ut},description={purus},user1={off}}
\newglossaryentry{elit}{name={elit},description={vestibulum}}
\renewcommand*{\glslinkcheckfirsthyperhook}{%
\ifglsused{\glslabel}
{%
% Get the value of the user1 field
\glsletentryfield{\thisvalue}{\glslabel}{useri}%
% Test this value
\ifdefstring\thisvalue{off}%
{\setkeys{glslink}{hyper=false}}%
{}%
}%
{}%
}
\begin{document}
Use the entries: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Use the entries again: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Force the hyperlink on: \gls+{ut} or \gls+{dolor}.
\printglossaries
\end{document}
This produces:
Edit: A simpler method is provided with the glossaries-extra
extension package. With this package you can assign a category to each entry. The default value is general
but can be overridden through the use of the category
key. This is just a label (avoid special characters) used to identify particular groups of entries independent of the identifiers type
and parent
. (For example, \newabbreviation
sets the category to abbreviation
and \newacronym
sets the category to acronym
.)
Categories can have associated attributes. The nohyper
attribute indicates that the hyperlink should default to off for those entries. For example, I can have a common
category (indicating common terms) that has the nohyper
attribute on:
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}
\makeglossaries
\glssetcategoryattribute{common}{nohyper}{true}
% dummy entries copied from example-glossaries-brief.tex
\newglossaryentry{lorem}{name={lorem},description={ipsum}}
\newglossaryentry{dolor}{name={dolor},description={sit},category={common}}
\newglossaryentry{amet}{name={amet},description={consectetuer},category={common}}
\newglossaryentry{adipiscing}{name={adipiscing},description={elit}}
\newglossaryentry{ut}{name={ut},description={purus},category={common}}
\newglossaryentry{elit}{name={elit},description={vestibulum}}
\begin{document}
Use the entries: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Use the entries again: \gls{lorem}, \gls{dolor}, \gls{amet},
\gls{adipiscing}, \gls{ut}, \gls{elit}.
Force the hyperlink on: \gls+{ut} or \gls+{dolor}.
\printglossaries
\end{document}