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

glossaries: acronyms with link on the short form on first use

594 views
Skip to first unread message

Leo Liu

unread,
Jul 22, 2014, 3:46:27 AM7/22/14
to
A few years I asked a similar question and got an answer as in:

http://comp.text.tex.narkive.com/vwuM6DE8/is-this-feature-from-acronym-available-in-glossaries

but it stops working in TeXlive 2014. How to make that example work?

Thanks,
Leo

Nicola Talbot

unread,
Jul 26, 2014, 8:17:30 AM7/26/14
to
The glossaries package now has a more flexible way of defining custom
acronym styles. You can achieve the same effect using the
"hyperfirst=false" package option to switch off the hyperlink on first
use and define a new acronym style that inserts a hyperlink for the
short version when the full form is used:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[hyperfirst=false]{glossaries}

\makeglossaries

\newacronymstyle{linkshort}
{%
% use the "long-short" display style:
\GlsUseAcrEntryDispStyle{long-short}%
}
{%
% use the "long-short" style definitions:
\GlsUseAcrStyleDefs{long-short}%
% adjust the full form so that it has a hyperlink for the short part:
\renewcommand*{\genacrfullformat}[2]{%
\glsentrylong{##1}##2\space
(\glshyperlink[\protect\firstacronymfont{\glsentryshort{##1}}]{##1})%
}%
% same for the plural form:
\renewcommand*{\genplacrfullformat}[2]{%
\glsentrylongpl{##1}##2\space
(\glshyperlink[\protect\firstacronymfont{\glsentryshortpl{##1}}]{##1})%
}%
}

% apply this new style
\setacronymstyle{linkshort}

% now define the acronyms
\newacronym{gnu}{GNU}{Gnu is Not Unix}

\begin{document}

First use: \gls{gnu}. Next use: \gls{gnu}.

Full form: \acrfull*{gnu}.

\printglossaries
\end{document}

This has the advantage that you no longer need to mess around with
internal commands, as I had to do in my reply to your linked post, but
note that the starred version is needed for \acrfull in this case.

Regards
Nicola Talbot
--
Home: http://www.dickimaw-books.com/
Creating a LaTeX Minimal Example:
http://www.dickimaw-books.com/latex/minexample/

Leo Liu

unread,
Jul 26, 2014, 11:14:26 AM7/26/14
to
On 2014-07-26 13:17 +0100, Nicola Talbot wrote:
> The glossaries package now has a more flexible way of defining custom
> acronym styles. You can achieve the same effect using the
> "hyperfirst=false" package option to switch off the hyperlink on first
> use and define a new acronym style that inserts a hyperlink for the
> short version when the full form is used:

Thank you. BTW, is it possible to put this style in glossaries?

Leo

Nicola Talbot

unread,
Jul 26, 2014, 6:22:31 PM7/26/14
to
No, I'm sorry. I don't want any of the predefined styles to depend on
the hyper setting. I can, however, add it to the faq.

Leo Liu

unread,
Jul 28, 2014, 10:24:42 PM7/28/14
to
On 2014-07-26 23:22 +0100, Nicola Talbot wrote:
> No, I'm sorry. I don't want any of the predefined styles to depend on
> the hyper setting. I can, however, add it to the faq.

No problem.

BTW, what in general is the difference between the regular and starred
versions of a command? I only find scattered pieces in the glossaries
user manual.

Thanks,
Leo

Nicola Talbot

unread,
Jul 29, 2014, 7:42:45 AM7/29/14
to
From chapter 6. "Links to Glossary Entries"
(http://mirror.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sec:glslink):

> There is also a starred version:
>
> \glslink*[<options>]{<label>}{<text>}
>
> which is equivalent to \glslink, except it sets hyper=false.
> Similarly, all the following commands described in this section also
> have a starred version that disables the hyperlink.

So \glslink*{foo}{bar} is equivalent to \glslink[hyper=false]{foo}{bar}
and \gls*{foo} is equivalent to \gls[hyper=false]{foo} where hyper=false
disables the hyperlink for that instance.

Leo Liu

unread,
Jul 29, 2014, 2:58:47 PM7/29/14
to
On 2014-07-29 19:42 +0800, Nicola Talbot wrote:
> So \glslink*{foo}{bar} is equivalent to
> \glslink[hyper=false]{foo}{bar} and \gls*{foo} is equivalent to
> \gls[hyper=false]{foo} where hyper=false disables the hyperlink for
> that instance.

Thank you.

Leo
0 new messages