2

I would like to have the default behaviour of hyperref for all links excepted the ones from glossaries: for them, they should be still links but without borders

I started playing with \hypersetup{linkbordercolor = white... options but when I saw that \cref was also impacted by link* options I tried more specific commands:

\renewcommand*{\glstextformat}[1]{\hypersetup{linkbordercolor  = white}{#1}\hypersetup{linkbordercolor  = black}}

or

\renewcommand*{\glsentryfmt}{
\hypersetup{linkbordercolor  = white}\glshyperlink[\glsgenentryfmt]{\glslabel}\hypersetup{linkbordercolor  = black}%
}

But those renewcommands doesn't do anything

UPDATE

I was using an external files for glossaries entries and in fact those was acronyms not regular entries. So my solution and the one gave was not working due to the mix of acronyms and regular entries. I finally came with a solution, which -I hope- is correct; so if you could review it I would greatly appreciate Thx:

\usepackage[linkbordercolor={black}]{hyperref} 

[...]

\defglsentryfmt{% 
\ifglsacronym%
\hypersetup{linkbordercolor  = white}\glshyperlink[\glsgenacfmt]{\glslabel} %
\else
\hypersetup{linkbordercolor  = white}\glshyperlink[\glsgenentryfmt]{\glslabel}%
\fi
}
  • let me share my discovery: \loadglsentries blows up the renewcommands – flop25 Feb 25 '16 at 22:41
  • @flop25: No, it does not, unless you do something weird, but you did not really provide a compilable document :-( – user31729 Feb 25 '16 at 23:18
  • @flop25: I asked you to provide a compilable document, not just fragments. I won't check fragments only – user31729 Feb 26 '16 at 13:48
  • my solution works so if you don't want to check if there is no harmful side-effects that's mainly for future readers. Thx anyway for your time – flop25 Feb 26 '16 at 15:38
2

This works out of the box for me -- the grouping of \glsentryfmt does not require a reset of the linkborder color after the \glslabel has been used.

\documentclass{article}

\usepackage{xcolor}
\usepackage[linkbordercolor={black}]{hyperref} 
\usepackage{cleveref}
\usepackage{glossaries}

\newglossaryentry{foo}{%
  name={Foo},
  description={A foobar}
}

\renewcommand*{\glsentryfmt}{%
  \hypersetup{linkbordercolor  = white}\glshyperlink[\glsgenentryfmt]{\glslabel}%
}

\makeglossaries

\begin{document}
\section{Foo} \label{FOO}

In \Cref{FOO} we saw that \gls{foo}

\clearpage

\printglossaries
\end{document}

enter image description here

Update A version that uses \thepagecolor (for the rare case of non-white page colours)

\documentclass{article}

\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage[linkbordercolor={black}]{hyperref}
\usepackage{cleveref}
\usepackage{glossaries}

\newglossaryentry{foo}{%
  name={Foo},
  description={A foobar}
}


\makeatletter
\renewcommand*{\glsentryfmt}{%
  \hypersetup{linkbordercolor  = \thepagecolor}\glshyperlink[\glsgenentryfmt]{\glslabel}%
}
\makeatother

\makeglossaries

\begin{document}
\pagecolor{yellow}

\section{Foo} \label{FOO}

In \Cref{FOO} we saw that \gls{foo}

\clearpage

\printglossaries
\end{document}
  • try with \loadglsentries{foo} and let the fun begin – flop25 Feb 25 '16 at 22:38
  • @flop25: Well, what do you mean? It works with \loadglsentries{filename} of course as well. – user31729 Feb 25 '16 at 23:17
  • I dig much deeper and found out the cause and a probable solution Could you check plz? Thx for your answers – flop25 Feb 26 '16 at 10:28
  • also see tex.stackexchange.com/a/296552/99343 for another solution – wrtlprnft Feb 29 '16 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.