2

I'm using

\definecolor{citeC}{rgb}{0.00,0.32,0}
\definecolor{refC}{rgb}{0,0,0.75}
\usepackage[pdftex,colorlinks=true,urlcolor=refC,linkcolor=refC,citecolor=citeC]{hyperref}
\usepackage[acronym,nonumberlist]{glossaries}

for my acronyms. When I define an example acronym i.e.

\newacronym{UBL}{UBL}{Urban Boundary Layer}

and then use it for the first time

\gls{UBL}

this will create a hyperlink like

enter image description here

which links from the whole word "Urban Boundary Layer" and from the acronym "(UBL)". Is there any possibility to only link from the acronym itself? Like:

enter image description here

I want my links to be colored but I dont want the whole word to be colored. So I thought the best way would be to remove the hyperref from the first part of the acronym? How can I do that?

1 Answer 1

4

The simplest method is to use the glossaries-extra extension package. If the nohyperfirst attribute is set, this will switch off the hyperlink on first use. The long-postshort-user abbreviation style can then be used with the short part put in a hyperlink (\glsxtruserparen is only used on first use to put the short part in parentheses). Subsequent use behaves as normal.

MWE:

\documentclass{article}

\usepackage{color}
\definecolor{refC}{rgb}{0,0,0.75}

\usepackage[colorlinks,linkcolor=refC]{hyperref}
\usepackage[acronym,nonumberlist]{glossaries-extra}

\makeglossaries

\setabbreviationstyle[acronym]{long-postshort-user}

\glssetcategoryattribute{acronym}{nohyperfirst}{true}

\renewcommand*{\glsxtruserparen}[2]{%
  \glsxtrfullsep{#2}% space between long part and parenthetical material
  (\glshyperlink[#1]{#2})%
}

\newacronym{UBL}{UBL}{Urban Boundary Layer}

\begin{document}
First: \gls{UBL}.

Next: \gls{UBL}.

\printglossaries

\end{document}

image of document

(If you get an undefined abbreviation style or undefined control sequence error, then you need to update your version of glossaries-extra.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .