Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using the glossaries package a lot in my thesis. There are some entries which appear very frequently throughout the whole document. I would like to disable hyperlinking for these entries but keep it for all other entries.

I have tried putting \glsdisablehyper just before the frequent entries to no avail.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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}
share|improve this answer
2  
Is there anyway to disable them (from the command definition?), as I don't want to go through the document and change them all. Thanks for the answer by the way –  Wolfgang Kerzendorf Aug 17 '11 at 1:32

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:

Image of resulting document

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:

Image of resulting document

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:

Image of resulting document

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.