summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/robustindex/robustglossary.sty
blob: f09ed55b37c550b88a1ce8a8450c673281c0abaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% Package robustglossary.sty, Wilberd van der Kallen Feb 2005.
%
% This package is similar to robustindex.sty, but it is much simpler, as it
% does not try to get makeindex to do anything. You are expected to convert
% filename.glo into something usable yourself. This converted file should
% have a different name, so that it can be \input while filename.glo is
% being rewritten. Or you can actually paste entries into the main file, as we
% did in robustsample.tex.
%
% Copyright 2005 Wilberd van der Kallen
%
% This file may be distributed under the conditions of the LaTeX Project Public
% License, either version 1.2 of this license or (at your option) any
% later version.  The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.

\ProvidesPackage{robustglossary}
  [2005/02/23
  glossary entries with pagerefs]

\newcounter{gloctr}%

\newcounter{maxgloctr}% To check if number of \glossary commands has changed.

\newcommand{\glostring}{glo.}%

\def\@wrglossary#1{%
  \stepcounter{gloctr}%
  \stepcounter{gloctr}%
  \@bsphack \protected@write \@auxout {}{%
     \string \newlabel {\glostring\thegloctr}{{\relax }{\thepage }%
     \ifx\ifHy@bookmarks\undefined\else{\relax }{page.\thepage }{}\fi%
     }%
  }%
  \@esphack
  \protected@write
    \@glossaryfile {}{\string \glossaryentry
    {#1}{\string\glopageref{\thegloctr}}}%
  \endgroup
  \@esphack
}%

\newcommand{\glopageref}[1]{%
   \ifnum\c@maxgloctr<#1\relax\setcounter{maxgloctr}{#1}\fi
   \pageref{\glostring#1}%
}%

\AtEndDocument{%
   \ifnum\c@gloctr=\c@maxgloctr
   \else
      \ifnum\c@gloctr=0%
         \PackageWarning{robustglossary}{%
	    Package needs \string\make glossary in preamble. Detected%
	 }%
      \else
         \PackageWarning{robustglossary}{%
            Glossary not up to date. Detected%
         }%
      \fi
   \fi
}%

\relax