TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I print the section instead the pagenumber in glossar/index like \nameref it does. Would be nice to have something like:
enter image description here



% Syntax: \newperson{label}{forename}{surname}
     sort={#3},% sort on surname
     text={#2\ #3},% title \space surname
     user1={#2},% forname
     user2={#3},% surname








share|improve this question
get mananaged to print section numbers instead of pages with set of the counter value: \usepackage[counter=section]{glossaries} – Megachip Nov 22 '12 at 13:41
up vote 7 down vote accepted

The location has to be written to the external file as a number (formatted using standard counter commands such as \arabic, \roman or \alph) otherwise makeindex will reject the entry. Even if you use xindy, you'd have to define a location style and list the mappings between all the section numbers and their titles. The following example writes the section number to the external file as normal but defines a set of mappings from section number to section title and redefines \glsnumberformat to fetch the corresponding title given the section number. However, even this isn't straightforward as the argument to \glsnumberformat may contain a list separated by \delimN or \delimR (Edit: I've changed the example to have multiple glossaries):



\newglossary{glossary2}{gls2}{glo2}{Glossary 2}[page]
\newglossary{glossary3}{gls3}{glo3}{Glossary 3}[section]



% adapt toc section command to get number -> title map


     % numbered section, save title
     % unnumbered section, do nothing

% also need to take into account any glossary entries at the start
% of the chapter before the first section


     % numbered chapter, save title
     % unnumbered chapter, do nothing


    \hyperlink{section.#1}{#1}% undefined so just display section number






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

 name=sample2,description={a second example}}

 name=sample3,description={a third example}}


\chapter{Sample Chapter}

\gls{sample}. \gls{sample2}.

\section{First section}


\section{Second section}
\gls{sample}. \gls{sample2}.

\section{Third section}

\section{Fourth section}
\gls{sample}. \gls{sample3}.

\section{Fifth section}








Image of sample glossary


You need to consider the possibility that the reader may want to print out the document and read the hardcopy, in which case this design makes it difficult to look up the reference, as you're forcing the reader to search through the table of contents to find the appropriate page number. At least with a section number the reader can make an intuitive guess as to whereabouts roughly the section is within the document.

Since I consider this poor document design style, I'm reluctant to add it as a feature, but the above should work if you really want to do it.

share|improve this answer
you made my day, thx a lot. I belive this solution did not work, if i will use multiple glossaries? As you already mentioned this would be poor design. The whole document will also use a normal glossary as glossary, but there would be also 2 glossaries which will build up as descriped in this question. shall i post a new question for this problem? – Megachip Mar 16 '13 at 23:50
@Megachip You could redefine \glsnumberformat just before you display the glossary (using \printglossary) – Nicola Talbot Mar 17 '13 at 0:13
ok, but with 'counter=section' i'll force all glossaries to that format, correct? – Megachip Mar 17 '13 at 18:56
@Megachip no, you'll only get that format if \glsnumberformat has the definition as shown in my example when \printglossary occurs. In my example I defined it in the preamble so it's in effect through the whole document, but if you change it back using \renewcommand{\glsnumberformat}[1]{#1} the next \printglossary will display as normal. – Nicola Talbot Mar 17 '13 at 18:59
Sorry, did not describe it proper. i have one main glossar where references are set to page numbers and than i need 2 glossaries which needs the described style. – Megachip Mar 17 '13 at 19:49

The following did not work, but cause there seems no solution for this problem, i undeleted it. Possible it could help to found some solutions...

Get the following solution, which seems to work mostly: Add the following code to glossaries.sty



And activate it with:


Didn't know why, but seems not working for refs on the first page :( Possible someone could post a solution without editing glossaries or Nicola could add such a feature to

share|improve this answer
This solution did not work correct, but hopefully it will help to find a working one. – Megachip Nov 22 '12 at 23:14

Your Answer


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.