Latest news 2020-07-03: SmashWords sale (ends 31st July 2020): 50% off crime/SF novel The Private Enemy and 100% off (free!) I’ve Heard the Mermaid Sing.

glossaries package FAQ

Categories:

FAQ Search Tips

How can I make just the short form a hyperlink? 🔗

If you switch off the hyperlink on first use (using the hyperfirst=false package option), you can create a custom acronym style that inserts the link around just the short form:

\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}

Note that if you are using glossaries-extra, it uses a completely different abbreviation mechanism so the above won’t work. However, you can simply use an abbreviation style such as short-postlong-user.

Last modified: 2020-06-27 16:45:13.


Category: glossaries package
Topic: Referencing Terms