Debian Codegraph @

texmf-dist/doc/generic/librarian/authoryear.tex

raw
1 % This file is distributed with the librarian package
2 % as an example bibliographic style. Most of it is explained
3 % in librarian-doc.pdf. It produces author (year) citations,
4 % using letter prefixes to distinguish similar entries.
5 %
6 % Author: Paul Isambert.
7 % E-mail: zappathustra AT free DOT fr
8 % Comments and suggestions are welcome.
9 % Date: April 2010.
10
11 \ifx\RetrieveFieldIn\undefined
12 \errmessage{You should load librarian first}
13 \expandafter\endinput
14 \fi
15
16 %%% Replace this definitions by yours.
17 \def\italics#1{{\it#1}}
18 \chardef\namelimit=3
19 \def\leftcitemark{(} \def\rightcitemark{)}
20 \def\etalii{\italics{ et alii}}
21
22 %%% The \cite command.
23 \def\terminator{\terminator} \def\empty{} \def\space{ }
24 \def\cite#1{%
25 \def\prevauthor{}%
26 \readcite#1,\terminator,%
27 }
28 \def\readcite#1,{%
29 \def\temp{#1}%
30 \ifx\temp\terminator
31 \rightcitemark
32 \let\tail\relax
33 \else
34 \let\tail\readcite
35 \unless\ifx\temp\empty
36 \Cite{#1}{main}\makecitation{}%
37 \fi
38 \fi\tail
39 }
40 \def\makecitation{%
41 \RetrieveFieldIn{name}\temp
42 \ifx\temp\prevauthor
43 , % Necessary space, as everywhere in this file.
44 \else
45 \unless\ifx\prevauthor\empty
46 \rightcitemark,
47 \fi
48 \RetrieveFieldIn{namenumber}\tempcount
49 \ReadName\makecitename~\leftcitemark%
50 \fi
51 \RetrieveFieldIn{name}\prevauthor
52 \RetrieveField{year}\csname\EntryKey @suffix\endcsname
53 }
54
55 \def\othersname{others}
56 \def\makecitename{%
57 \ifx\Lastname\othersname
58 \etalii
59 \else
60 \ifnum\tempcount>\namelimit
61 \ifnum\NameCount=1
62 \unless\ifx\Von\empty \Von~\fi
63 \Lastname\etalii
64 \fi
65 \else
66 \unless\ifnum\NameCount=1
67 \ifnum\NameCount=\tempcount\relax \space and \else, \fi
68 \fi
69 \unless\ifx\Von\empty \Von~\fi
70 \Lastname
71 \fi
72 \fi
73 }%
74
75 \def\editor{editor}
76 \parindent0pt
77 \sfcode`\.=\numexpr(\the\sfcode`\.+1)
78 \def\conditionalstop{%
79 \unless\ifnum\spacefactor=\sfcode`\.
80 .%
81 \fi
82 }
83
84 %%% Typesetting entries.
85 \def\MakeReference{%
86 \par\noindent
87 \RetrieveFieldIn{namenumber}\tempcount
88 \ReadName\makerefname
89 \RetrieveFieldIn{nametype}\temp
90 \ifx\temp\editor
91 \RetrieveFieldIn{namenumber}\temp
92 \ifnum\temp>1
93 \space (eds.)%
94 \else
95 \space (ed.)%
96 \fi
97 \fi
98 \space \leftcitemark\RetrieveField{year}\csname\EntryKey @suffix\endcsname\rightcitemark\space
99 \compareentries
100 \RetrieveFieldIn{entrytype}\temp
101 \typesetref\temp\conditionalstop
102 }
103 \newcount\sameentrycount
104 \def\compareentries{%
105 \ifequalentry
106 \advance\sameentrycount1
107 \WriteImmediateInfo{%
108 \noexpand\expandafter\def\noexpand\csname\EntryKey @suffix\noexpand\endcsname{\toletter}%
109 }%
110 \else
111 \sameentrycount=0
112 \fi
113 }
114 \def\toletter{%
115 \ifcase\sameentrycount
116 \or a\or b\or c\or d\or e\or f\or g\or h%
117 \or i\or j\or k\or l\or m\or n\or o\or p%
118 \or q\or r\or s\or t\or u\or v\or w\or x%
119 \or y\or z\fi
120 }
121
122 %%% These are for names in the bibliography.
123 \def\makerefname{%
124 \ifx\Lastname\othersname
125 \etalii
126 \else
127 \ifnum\NameCount=1
128 \unless\ifx\Von\empty \Von\space \fi
129 \Lastname, \Firstname
130 \unless\ifx\Junior\empty, \Junior \fi
131 \else
132 \ifnum\NameCount=\tempcount\relax \space and \else , \fi
133 \Firstname
134 \unless\ifx\Von\empty \space\Von \fi
135 \space\Lastname
136 \unless\ifx\Junior\empty , \Junior \fi
137 \fi
138 \fi
139 }
140 \def\makeedname{%
141 \ifx\Lastname\othersname
142 \etalii
143 \else
144 \unless\ifnum\NameCount=1
145 \ifnum\NameCount=\tempcount\relax \space and \else , \fi
146 \fi
147 \Firstname
148 \unless\ifx\Von\empty \space\Von \fi
149 \space\Lastname
150 \unless\ifx\Junior\empty , \Junior \fi
151 \fi
152 }
153
154 %%% Here entries are defined.
155 \def\typesetref#1{%
156 \ifcsname#1@entrytype\endcsname
157 \csname#1@entrytype\endcsname
158 \else
159 \errmessage{Unknown entry type: `#1'}%
160 \fi
161 }
162 \def\createtype#1{%
163 \expandafter\def\csname#1@entrytype\endcsname
164 }
165 \def\booktitle#1{\setbooktitle{\RetrieveField{#1}}}
166 \def\setbooktitle#1{\italics{#1}}
167 \def\articletitle#1{\setarticletitle{\RetrieveField{#1}}}%
168 \def\setarticletitle#1{`#1'}
169 \def\addcomma#1{, #1}
170 \def\addjournal#1{\addcomma{{\setbooktitle{#1}}}}
171 \def\addcolon#1{: #1}
172 \def\addpar#1{(#1)}
173 \def\addbook#1{, in \setbooktitle{#1}}
174 \def\addeditor#1{%
175 \RetrieveFieldIn{editornumber}\tempcount
176 , edited by \ReadEditor\makeedname}
177 \def\inbook#1{%
178 , chapter #1%
179 }
180 \def\crossref#1{%
181 , in \cite{#1}%
182 \WriteImmediateInfo{\noexpand\Cite{#1}{main}{}{}}%
183 }
184
185 %%% The following do not pretend to show how entries
186 %%% should be typeset.
187 \createtype{book}{%
188 \booktitle{title}%
189 \TypesetField{publisher}\addcomma{}%
190 \TypesetField{address}\addcolon{}%
191 }%
192 \createtype{article}{%
193 \articletitle{title}%
194 \TypesetField{journal}\addjournal{}%
195 \TypesetField{volume}\addcomma{}%
196 \TypesetField{number}\addpar{}%
197 \TypesetField{pages}\addcomma{}%
198 }
199 \createtype{inbook}{%
200 \booktitle{title}%
201 \TypesetField{chapter}\inbook{%
202 \TypesetField{pages}\addcomma{}%
203 }%
204 \TypesetField{publisher}\addcomma{}%
205 \TypesetField{address}\addcolon{}%
206 }%
207 \createtype{incollection}{%
208 \articletitle{title}%
209 \TypesetField{crossref}\crossref{%
210 \TypesetField{booktitle}\addbook{}%
211 \TypesetField{editor}\addeditor{}%
212 \TypesetField{pages}\addcomma{}%
213 \TypesetField{publisher}\addcomma{}%
214 \TypesetField{address}\addcolon{}%
215 }%
216 }
217 \createtype{inproceedings}{%
218 \articletitle{title}%
219 \TypesetField{booktitle}\addbook{}%
220 \TypesetField{editor}\addeditor{}%
221 \TypesetField{pages}\addcomma{}%
222 \TypesetField{address}\addcomma{}%
223 }
224 \createtype{conference}{%
225 \articletitle{title}%
226 \TypesetField{booktitle}\addbook{}%
227 \TypesetField{editor}\addeditor{}%
228 \TypesetField{pages}\addcomma{}%
229 \TypesetField{address}\addcomma{}%
230 }
231 \createtype{mastersthesis}{%
232 \booktitle{title}%
233 , Master's thesis%
234 \TypesetField{organization}\addcomma{}{}%
235 }
236 \createtype{phdthesis}{%
237 \booktitle{title}%
238 , PhD dissertation%
239 \TypesetField{organization}\addcomma{}{}%
240 }
241 \createtype{proceedings}{%
242 \booktitle{title}%
243 \TypesetField{publisher}\addcomma{%
244 \TypesetField{organisation}\addcomma{}%
245 }%
246 \TypesetField{address}\addcolon{}%
247 }
248 \createtype{techreport}{%
249 \booktitle{title}%
250 , technical report%
251 \TypesetField{institution}\addcomma{}%
252 }
253 \createtype{booklet}{%
254 \booktitle{title}%
255 \TypesetField{howpublished}\addcomma{}%
256 }
257 \createtype{manual}{%
258 \booktitle{title}%
259 \TypesetField{organization}\addcomma{}%
260 }
261 \createtype{misc}{%
262 \booktitle{title}%
263 \TypesetField{howpublished}\addcomma{}%
264 }
265 \SortingOrder{name,year}{lfvj}
266 \endinput