1

I'm trying to find a way to create a cross-reference to a particular glossary. I have several glossaries that I refer to in-text, and I would like to be able to link to a specific glossary whenever I refer to it in the text. To be clear, I don't want to link to a specific entry in a glossary, but to the glossary itself. Ideally, the link would take the reader to the first page of the specific glossary I intend.

I suppose I could get around this by cheating and linking to the first entry of the glossary and having it display the name of the glossary instead of the regular entry name, but before I did that I was hoping to find out if there is a general way to do this. Any suggestions would be appreciated.

  • 1
    Please provide a compilable document – user31729 Aug 4 '16 at 13:40
3

It would help if you could provide a minimal working example (MWE), but it sounds like you're looking for the numberedsection package option.

MWE:

\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[numberedsection=nameref]{glossaries}

\makeglossaries

\loadglsentries{example-glossaries-brief}
\glsaddall

\begin{document}
\chapter{Sample}

Reference \nameref{main}.

\printglossaries

\end{document}

The label generated by the numberedsection=nameref option defaults to the glossary label. In the above, the glossary's label is main, so it's referenced with \nameref{main}.

Numbered glossaries need numberedsection=autolabel instead:

\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[numberedsection=autolabel]{glossaries}

\makeglossaries

\loadglsentries{example-glossaries-brief}
\glsaddall

\begin{document}
\chapter{Sample}

Reference \ref{main}.

\printglossaries

\end{document}

In both cases you can use \pageref instead for the page number.

Edit: All this option does is add \label{main} to the start of the glossary after the glossary heading¹ so you can use any of the usual cross-referencing mechanisms. The hyperref package provides \hyperref[label]{text}, so you can also do:

\hyperref[main]{link to main glossary}

¹It's actually \label{\glsautoprefix main}} but \glsautoprefix does nothing by default.

  • This is exactly the answer I was searching for @Nicola Talbot. Is there a way to link to a glossary with \nameref, but have it display something other than the name of the glossary? Similar to the command \glslink{#1}{#2}? – user1201 Aug 8 '16 at 17:29
  • @user1201 I've edited my answer. – Nicola Talbot Aug 15 '16 at 9:56

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.