glossaries package FAQ
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
.
2020-06-27 16:45:13
Permalink: https://www.dickimaw-books.com/faq.php?id=182
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=shorthyper
Category: glossaries package
Topic:
Referencing Terms