# Page number of glossary

I want to reference the glossary from within the text (I'm using the glossaries package). However, since the glossaries are produced using \printglossaries, I can't just put a \label command where it needs to be. Putting a \label command just before or just after the \printglossaries command doesn't work: It gives the wrong page number.

I browsed through the glossaries manual, but didn't find anything about labels or references.

-

Use the etoolbox package to patch glossaries' internal \@glossarysection macro.

EDIT: In case you were wondering what \@@glossaryseclabel is doing: If you load the glossaries package with the numberedsection=autolabel option, glossaries will a) be numbered b) feature an automatic label that uses the glossary type. In this case you could refer to the different glossaries with, e.g., \ref{main} or \pageref{acronym}. See section 2.2. of the glossaries manual for details. For unnumbered glossaries, use my hack below. (Naturally, \refwon't work correctly because there's no sectioning number to refer to, but \pageref will.)

\documentclass{book}

\usepackage{glossaries}
\makeglossaries

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@glossarysection}{%
\@@glossaryseclabel%
}{%
\@@glossaryseclabel%
\label{\glsautoprefix\@glo@type}% "main" for main glossary, "acronym" for list of acronyms
}{}{}
\makeatother

\newglossaryentry{electrolyte}{name=electrolyte,%
description={solution able to conduct electric current}}

\begin{document}


Thanks! It works, but I had to add the numberedsection=autolabel option to \usepackage{glossaries}. –  daniel kullmann Jan 5 '12 at 9:55
@danielkullmann Please try again -- the whole point of my hack is to make at least \pageref work for unnumbered glossaries. –  lockstep Jan 5 '12 at 9:58
The new version works for me as well, but again only with numberedsection=autolabel. And my glossary is still unnumbered, maybe because I also have the option nonumberlist? –  daniel kullmann Jan 5 '12 at 21:09