Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the glossaries package. I created a custom glossary called foo with the title, "My Foo Glossary Title":

\newglossary[fgg]{foo}{fgs}{fgo}{My Foo Glossary}

Ideally, I'd like to make a reference to this glossary in my text using \nameref or \autoref, such that it looks like "...please see My Foo Glossary." via something resembling the following code:

...please see \nameref{foo}.

This doesn't work....

I understand that I needed to add a label to the glossary in order to reference it (isn't it already labelled somehow -- it has to have a label if it is on the Table of Contents page, right?). I redefined the \glossarypreamble macro as follows:

\renewcommand*{\glossarypreamble}{%
\label{\currentglossary}%
}

Then I was able to link to it as follows:

...please see \autoref{foo}.

Trouble is, this produces the text "Appendix A.3" rather than "My Foo Glossary". How can I get the link to display the text equivalent to \glossarytoctitle?

Thanks in advance!

share|improve this question
1  
Does my answer solve your issue? –  karlkoeller Nov 15 '13 at 17:16
    
Absolutely -- and that wasn't a very intrusive way of doing it, either! Thanks so much for your help! :-) –  jvriesem Nov 15 '13 at 23:44
    
You're welcome. Happy it helped. –  karlkoeller Nov 16 '13 at 8:07

2 Answers 2

up vote 4 down vote accepted

Try the following code:

% arara: pdflatex: {synctex: yes}
% arara: makeglossaries
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: yes}

\documentclass{article}

\usepackage[colorlinks]{hyperref}

\usepackage{glossaries}

\newglossary[fgg]{foo}{fgs}{fgo}{My Foo Glossary}

\makeglossaries

\newglossaryentry{fooentry}{name={foo entry},description={foo description},type=foo}
\newglossaryentry{mainentry}{name={main entry},description={main description}}

\begin{document}

\noindent \Gls{fooentry} is an entry from \nameref{glo:foo}, while \gls{mainentry} is an entry from \nameref{glo:main}.

\bigskip

\printglossary[type=foo]
\makeatletter
\def\@currentlabelname{\@glotype@foo@title}
\label{glo:foo}
\makeatother

\printglossary[type=main]
\makeatletter
\def\@currentlabelname{\@glotype@main@title}
\label{glo:main}
\makeatother

\end{document} 

Output:

enter image description here

The trick is to use a separate \printglossary for each glossary and to add, after each of them, e.g. after the "foo" glossary, the code

\makeatletter
\def\@currentlabelname{\@glotype@foo@title}
\label{glo:foo}
\makeatother

and refer to it as \nameref{glo:foo}.

Here \@glotype@foo@title contains the name of the glossary and \@currentlabelname is where the name title for \nameref is internally stored.

share|improve this answer
    
Worked like a charm! Thanks a bunch for your time. –  jvriesem Nov 19 '13 at 7:17

Version 4.02 (which I've just uploaded to CTAN) now has an extra value for the numberedsection package option: numberedsection=nameref. This uses an unnumber section (or chapter, depending on the class) but inserts \label{\glsautoprefixtype} after the section heading. You may need to wait a few days before the new version appears in the TeX distributions, but once it's available you can do:

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex
\documentclass{article}

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

\newglossary[fgg]{foo}{fgs}{fgo}{My Foo Glossary}

\makeglossaries

\newglossaryentry{sample}{name={sample},description={an example}}

\newglossaryentry{sample2}{type=foo,name={sample2},description={another example}}

\begin{document}

Reference \gls{sample} and \gls{sample2}.

Reference main glossary: \nameref{main}.

Reference foo glossary: \nameref{foo}.

\printglossaries


\end{document}

Produces:

Image of resulting document

(\glsautoprefix defaults to nothing, but can be redefined to avoid conflicts with other labels.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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