summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/index/bibref.sty
blob: 62b985b18f8307028909599b6546e1d09140178d (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     filename        = "bibref.sty",
%%%     version         = "1.0beta",
%%%     date            = "29 September 1995",
%%%     time            = "14:36:27 EDT",
%%%     author          = "David M. Jones",
%%%     address         = "MIT Laboratory for Computer Science
%%%                        Room NE43-316
%%%                        545 Technology Square
%%%                        Cambridge, MA 02139
%%%                        USA",
%%%     telephone       = "(617) 253-5936",
%%%     FAX             = "(617) 253-3480",
%%%     checksum        = "21394 117 377 3498",
%%%     email           = "dmjones@theory.lcs.mit.edu",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "",
%%%     supported       = "yes",
%%%     abstract        = "",
%%%     docstring       = "The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert
%%%                        Solovay's checksum utility.",
%%%  }
%%% ====================================================================

%%  This is an experimental package to support back references from
%%  reference sections to the pages where individual items are cited.
%%  I.e., the reference section would
%%
%%      Zofia Adamowicz.  A sharp version of the bounded
%%      {Matijasevich} conjecture and the end-extension problem.
%%      Journal of Symbolic Logic}, 57(2):597--616, June 1992.  (pages
%%      1, 3-5, 54)
%%
%%  if that item were cited on pages 1, 3, 4, 5 and 54.
%%
%%  To use this feature, you'll need to make a small change to your
%%  BibTeX bibliography style file.  In the standard styles, all that
%%  is needed is to modify the function fin.entry as follows:
%%
%%      FUNCTION {fin.entry}
%%      { add.period$
%%        write$
%%          "\bibref{" cite$ "}" * * write$ % added line
%%        newline$
%%      }
%%
%%  Then load the bibref package by adding
%%
%%      \usepackage{bibref}
%%
%%  to your document preamble, and run LaTeX as normal.  After running
%%  LaTeX, invoke makeindex as follows:
%%
%%      makeindex -s bibref.ist -o <jobname>.bnd <jobname>.bdx
%%
%%  The next time you run LaTeX, the back-references should magically
%%  appear.
%%
%%  See plaintst.tex and xplain.bst for an example.

\RequirePackage{index}

\newindex{@bib}{bdx}{bnd}{}

\newcommand{\biblabel}[2]{%
    \global\@namedef{br@#1}{#2}%
}

\newcommand{\bibref}[1]{%
    \unskip\space
    \@ifundefined{br@#1}{%
%        (\textbf{??})%
    }{%
        \edef\reserved@a{\@nameuse{br@#1}}%
        \afterassignment\@bibref\count@\reserved@a\relax\@nil
    }%
}

\def\@bibref#1\@nil{%
    \if\relax#1%
        (page~\reserved@a)%
    \else
        (pages~\reserved@a)%
    \fi
}

\let\@@cite\cite

\renewcommand{\cite}[2][]{%
    \@for\@citea:=#2\do{%
        \edef\reserved@a{%
            \noexpand\index[@bib]{\@citea}%
        }%
        \reserved@a
    }%
    \def\reserved@a{#1}%
    \ifx\reserved@a\@empty
        \@@cite{#2}%
    \else
        \@@cite[#1]{#2}%
    \fi
}

\renewcommand{\bibliography}[1]{%
    \if@filesw
        \immediate\write\@auxout{\string\bibdata{#1}}%
      \fi
      \@input@{\jobname.bnd}%
      \@input@{\jobname.bbl}%
}

\endinput