-
Notifications
You must be signed in to change notification settings - Fork 0
/
authorindex.sty
125 lines (125 loc) · 5.73 KB
/
authorindex.sty
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
118
119
120
121
122
123
124
125
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{authorindex}[2002/09/13 make index of authors cited in a work]
% \ainame and \aipages determine the format of the author name and the page
% list, respectively, and are to be \renewcommand-ed explicitly by the user.
% \aibibpage and \aifirstpage are styles for pages where works appear in the
% references and where the author is the first author of the work, respectively
\def\ainame#1{#1}
\def\aitop#1{#1}
\def\airep#1{#1}
\def\aifirst#1{#1}
\def\aipages#1{#1}
\def\aibibpage#1{#1}
\def\aifirstpage#1{#1}
% The following stuff can be changed via options to \usepackage
\newcommand\aisize{}
\def\@ainamefmt{}
\def\@aieditors{0}
\def\@aiwhat{pages}
% These Options will be handled directly by LaTeX
\DeclareOption{small}{\renewcommand\aisize{\small}}
\DeclareOption{normal}{\renewcommand\aisize{\normalsize}}
% These Options will go to the perl script and be used to build the .bst file.
\let\aioptions\@gobble
\DeclareOption{editors}{\renewcommand\@aieditors{2}}
\DeclareOption{avoideditors}{\renewcommand\@aieditors{1}}
\DeclareOption{onlyauthors}{\renewcommand\@aieditors{0}}
\DeclareOption{fullname}{\renewcommand\@ainamefmt{{vv }{ll}{, ff}{, jj}}}
\DeclareOption{lastname}{\renewcommand\@ainamefmt{{vv }{ll}}}
\DeclareOption{firstabbrev}{\renewcommand\@ainamefmt{{vv }{ll}{, f.}{, jj}}}
\DeclareOption{all}{\def\@aiwhich{9999}\def\@aitrunc{9999}}
\DeclareOption{onlyfirst}{\def\@aiwhich{1}\def\@aitrunc{1}}
\DeclareOption{miniindex}{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\aiinbibflag}\fi}}%
\DeclareOption{nocompress}{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\ainocompressflag}\fi}}%
\DeclareOption{pages}{\renewcommand\@aiwhat{pages}}
\DeclareOption{biblabels}{\renewcommand\@aiwhat{labels}}
\DeclareOption{withbib}{\AtBeginDocument{%
\let\@aiobibitem=\@bibitem\let\@aiolbibitem=\@lbibitem%
\def\@lbibitem[#1]#2{\@aiolbibitem[#1]{#2}%
\if@filesw{\protected@write\@auxout{}
{\string\bibpage{#2}{\theaipage}}}\fi\ignorespaces}%
\def\@bibitem#1{\@aiobibitem{#1}%
\if@filesw{\protected@write\@auxout{}
{\string\bibpage{#1}{\theaipage}}}\fi\ignorespaces}}}%
\ExecuteOptions{normal,fullname,all}
\ProcessOptions
% make sure options and filename are transfered to the perl script.
\expandafter\AtBeginDocument{\if@filesw\immediate{%
\write\@auxout{%
\string\aioptions{\@aieditors|\@ainamefmt|\@aiwhich|\@aitrunc|\@aiwhat}}%
\write\@auxout{\string\aifilename{\jobname.ain}}}%
\fi%
\def\aipagetypeorder{\@notprerr}% Generate error messages when used outside
\def\aimaxauthors{\@notprerr}% preamble.
\def\authorindexstyle{\@notprerr}%
\def\aisee{\@notprerr}%
\def\aitwosuffix{\@notprerr}%
\def\ainamefmt{\@notprerr}}
% Define commands to be put in the .aux file and only used by the perl script.
\let\pagetypeorder\@gobble
\let\aiseestring\@gobble
\let\aitwostring\@gobble
\let\ainocompressflag\relax
\let\aiinbibflag\relax
\let\aistyle\@gobble
\let\citationpage\@gobbletwo
\let\bibpage\@gobbletwo
\let\aiexplicit\@gobbletwo
\let\aifilename\@gobble
% By default, the numbers that appear in the index are the same that appear on
% the pages. In case this does not suffice for everybody (for example, in a 2
% volume book, one might want the volume number appear in the index, but not
% in the page numbering) one can redefine this:
\def\theaipage{\thepage}
% determine the relative order of different numbering types (roman, arabic,...)
\def\aipagetypeorder#1{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\pagetypeorder{#1}}\fi}}%
% determine string by which first author is cross referenced
\def\aisee#1{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\aiseestring{#1}}\fi}}%
% determine string for abbreviation of two subsequent pages
\def\aitwosuffix#1{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\aitwostring{#1}}\fi}}%
% determines representation of miniindices
\def\aibibindex#1{\{\textbf{#1}\}}
\def\bibindex#1{\ifx\\#1\\\@bsphack\@esphack\else\aibibindex{#1}\fi}
% \authorindexstyle{x} writes \aistyle{x} to the .aux-file. x later will be
% used to select the x.bst as the bibstyle used to generate the author list
% from the database (overriding the generated .bst file).
\def\authorindexstyle#1{\AtBeginDocument{%
\if@filesw\immediate\write\@auxout{\string\aistyle{#1}}\fi}}
% determine formating and order of names
\def\ainamefmt#1{\def\@ainamefmt{#1}}
% Allow for other max. number of authors apart from 1 and 9999.
% First Argument lets us determine to how many authors to truncate the list.
\def\aimaxauthors{\@ifnextchar[\@aitruncmaxauthors\@aimaxauthors}
\def\@aitruncmaxauthors[#1]#2{\def\@aitrunc{#1}\def\@aiwhich{#2}}
\def\@aimaxauthors#1{\def\@aitrunc{#1}\def\@aiwhich{#1}}
% \aicite behaves similar to cite, but additionally writes for each key given
\def\@aicitey#1{%
\@for\@citeb:=#1\do
{\protected@write\@auxout{}%
{\string\citationpage{\@citeb}{\theaipage}}}}
\def\@aicitex[#1]#2{\@citex[#1]{#2}\@aicitey{#2}}
% \aicite behaves similar to cite, but additionally writes for each key given
\DeclareRobustCommand\aicite{%
\@ifnextchar [{\@tempswatrue\@aicitex}{\@tempswafalse\@aicitex[]}}%
\let\@oldnocite=\nocite
\def\ainocite#1{\@aicitey{#1}\@oldnocite{#1}}
\def\aionly{\@aicitey}
% \aimention gets authors BibTeX author name format to be included in the
% author index without having any reference of a work of that author.
\def\aimention#1{\@bsphack%
\protected@write\@auxout{}{\string\aiexplicit{#1}{\theaipage}}\@esphack}
% include author index
\newcommand\printauthorindex{\@input@{\jobname.ain}}
% the theauthorindex environment
\newenvironment{theauthorindex}{%
\raggedright%
\setlength{\leftskip}{1em}%
\setlength{\parindent}{-1em}%
\def\item[##1]{\par\hspace{0mm}\ainame{##1}}
\aisize}{\par}
\endinput