Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

glossaries question -- turning off hyperlinks for some first use glossary entries

15 views
Skip to first unread message

Dave94705

unread,
May 1, 2009, 11:17:14 AM5/1/09
to
I am using glossaries with hyperlinks but for some entries I want to
automatically turn off the links for those entries' first use. For
example if I have the acronym PCH for Pacific Coast Highway and have
first={Pacific Coast Highway (PCH)} I do not want that linked back to
the glossary entry while for subsequent uses when only PCH comes up I
want PCH linked back.

I have tried first={\glsdisablehyper {Pacific Coast Highway (PCH)}}
but that doesn't do the trick. Any suggestions on how to automate
this? Thanks, ds

Nicola Talbot

unread,
May 2, 2009, 8:57:30 AM5/2/09
to

You can't use \glsdisplayhyper in first (or any of the other keys) as
it's too late to disable the link by the time the text is used. It
would be easier if you want the same effect for all entries on first
use, but if you only want the effect for a subset of the entries, then
you could try the following example which stores the list of required
acronym labels in \nohyplist and redefines \@gls@link to check if the
entry being used is in that list and it's the first use.

\documentclass{article}

\usepackage{xstring}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\makeglossaries

\newacronym{sample}{sample}{A Sample Acronym}
\newacronym{sample2}{sample2}{Another Sample}
\newacronym{sample3}{sample3}{A Third Sample}

\makeatletter
\def\nohyplist{,sample,sample3,}

\renewcommand*{\@gls@link}[3][]{%
\glsdoifexists{#2}%
{%
\def\glslabel{#2}%
\def\@glsnumberformat{glsnumberformat}%
\edef\@gls@counter{\csname glo@#2@counter\endcsname}%
\KV@glslink@hypertrue
\ifglsused{#2}{}{%
\IfSubStr{\nohyplist}{,#2,}{\KV@glslink@hyperfalse}{}%
}%
\setkeys{glslink}{#1}%
\edef\theglsentrycounter{\expandafter\noexpand
\csname the\@gls@counter\endcsname}%
\@do@wrglossary{#2}%
\ifKV@glslink@hyper
\@glslink{glo:#2}{\glstextformat{#3}}%
\else
\glstextformat{#3}\relax
\fi
}%
}
\makeatother

\begin{document}
\gls{sample}. \gls{sample2}. \gls{sample3}.

\gls{sample}. \gls{sample2}. \gls{sample3}.

\newpage

\printglossaries
\end{document}

Regards
Nicola Talbot
--
Home: http://theoval.cmp.uea.ac.uk/~nlct/
LaTeX Related Information: http://theoval.cmp.uea.ac.uk/~nlct/latex/
Creating a LaTeX Minimal Example:
http://theoval.cmp.uea.ac.uk/~nlct/latex/minexample/

0 new messages