summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/multibibliography/multibibliography.dtx
blob: 6786a624a50ee9371b5a11348cdb55f350287009 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
% \iffalse
% $Id: multibibliography.dtx,v 1.8 2013-05-16 02:47:54 boris Exp $
%
%% Copyright 2013, Michael Cohen <mcohen@u-aizu.ac.jp>
%% Yannis Haralambous <yannis.haralambous@telecom-bretagne.eu>
%% Boris Veytsman <borisv@lk.net>
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any 
%% later version.
%% The latest version of the license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2003/06/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Michael Cohen
%%
%% This work consists of the file multibibliography.dtx, the
%% derived file multibibliography.sty, and the files
%% chronological.bst and multibibliography.pl
%%
%<*gobble> 
% \fi
% \CheckSum{193}
%
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~} 
%
%\iffalse
%    \begin{macrocode}
\documentclass{ltxdoc}
\usepackage[breaklinks,colorlinks,linkcolor=black,citecolor=black,
            pagecolor=black,urlcolor=black]{hyperref}
\usepackage{multibibliography}
\PageIndex
\CodelineIndex
\RecordChanges
\EnableCrossrefs
\begin{document}
  \DocInput{multibibliography.dtx}
\end{document}
%    \end{macrocode}
%</gobble> 
% \fi
% \MakeShortVerb{|}
% \GetFileInfo{multibibliography.sty}
% 
% \title{The Multibibliography Package\thanks{\copyright 2013 Michael
% Cohen and Yannis Haralambous}} 
% \author{Michael Cohen\thanks{mcohen@u-aizu.ac.jp} \and 
%   Yannis Haralambous\thanks{yannis.haralambous@telecom-bretagne.eu}
%   \and Boris Veytsman \thanks{borisv@lk.net}}
% \date{\filedate, \fileversion}
% \maketitle
%
% \begin{abstract}
%   Conventional standards for bibliography styles entail a forced
%   choice between index and name/year citations and corresponding
%   references.  We reject this false dichotomy, and describe a
%   multibibliography, comprising alphabetic, sequenced, and even
%   chronological orderings of references.  An extended inline
%   citation format is also proposed to integrate such heterogeneous
%   styles, and is usable and useful even without separate
%   bibliographies.
% \end{abstract}
% \changes{v1.02}{2013/03/26}{Fixed the bug in multibibliography.pl
% that prevented correct handling of accents} 
%
% \tableofcontents
%
% \clearpage
%
%\section{Introduction}
%\label{sec:intro}
%
%  This package illustrates our novel system for a multibibliography, which
%  combines alphabetic, sequenced, and chronological ordering of
%  references.  The rationale for the system is provided in the
%  enclosed TUG paper.  This package provides the code for the
%  system.  
%
%\section{User Interface}
%\label{sec:interface}
%
% The installation of the class follows the usual
% practice~\cite{TeXFAQ} for \LaTeX{} packages:
% \begin{enumerate}
% \item Run \textsf{latex} on |multibibliography.ins|.  This will produce the file
% |multibibliography.sty|.
% \item Put the file |multibibliography.sty| to
% the place where \LaTeX{} can find it (see
% \cite{TeXFAQ} or the documentation for your \TeX{}
% system).\label{item:install}
% \item Put the file |chronological.bst| to the place where Bib\TeX\
% can find it (see
% \cite{TeXFAQ} or the documentation for your \TeX{}
% system).
% \item Put the file |multibibliography.pl| into the place where
% binaries are stored on your system.
% \item Update the database of file names.  Again, see \cite{TeXFAQ}
% or the documentation for your \TeX{} system for the system-specific
% details.\label{item:update}
% \item The files |multibibliography.pdf| and |tug-paper.pdf| provide
%   the documentation for the package
% \end{enumerate}
% As an alternative to items~\ref{item:install} and~\ref{item:update}
% you can just put the files in the working directory where your
% |.tex| file is.
% 
% 
%
% To use this package, add to the preamble of your document
% the line |\usepackage{multibibliography}|.  After |latex|'ing the
% file, instead of running
% \begin{verbatim}
% bibtex FILE
% \end{verbatim}
% run
% \begin{verbatim}
% multibibliography.pl FILE.tex
% \end{verbatim}
% Then proceed in the usual way (run |latex| until the labels converge).
% 
% \DescribeMacro{\bibliographysequence}
% \DescribeMacro{\bibliographytimeline}
% The file defines two new commands:
% \cmd{\bibliographysequence}\marg{bib-files} and
% \cmd{\bibliographytimeline}\marg{bib-files} which are similar to the
% standard |\bibliography| command, but produce the reference lists
% ordered according to the sequence of citations or chronologically.
% They use |unsrt.bst| and |chronological.bst| styles
% correspondingly.  An example of usage can be found in the file
% |tug-paper.tex|:
% \begin{verbatim}
% \renewcommand\refname{References sorted by name}
% \bibliographystyle{apalike}
% \bibliography{multibibliography}
%
% \renewcommand\refname{References sorted by appearance}
% \bibliographysequence{multibibliography}
%
% \renewcommand\refname{References sorted by year}
% \bibliographytimeline{multibibliography}
%
% \end{verbatim}
% 
%
%\StopEventually{\clearpage
% \bibliography{multibibliography}
% \bibliographystyle{unsrt}}
%
% \clearpage
% 
% \section{Implementation}
% \label{sec:implementation}
% 
%
%\subsection{Declarations}
%\label{sec:decl}
% 
%  We start with declaration, who we are:
%
%
%    \begin{macrocode}
%<style>\NeedsTeXFormat{LaTeX2e}
%<*gobble>
\ProvidesFile{multibibliography.dtx}
%</gobble>
%<style>\ProvidesPackage{multibibliography}
%<*style>
[2013/03/26 v1.02 Multibibliography support for LaTeX]
%    \end{macrocode}
%
%
%
%\subsection{Hyperref Patching}
%\label{sec:hyperref}
%
% \begin{macro}{\NAT@parse}
% \changes{v1.01}{2013/02/28}{Introduced the command} 
%   Hyperref redefines a lot of bibliography related commands.
%   Fortunately, there is a mechanism in hyperref to prevent this: if
%   hyperref sees natbib, it defers to it.  Well, we can dupe hyperref
%   into thinking natbib is loaded:
%    \begin{macrocode}
\providecommand\NAT@parse[1]{}
%    \end{macrocode}   
% \end{macro}
% 
% \begin{macro}{\@extra@binfo}
% \changes{v1.01}{2013/02/28}{Introduced the command} 
%   This is a hook defined by natbib.  We preserve it just in case:
%    \begin{macrocode}
\providecommand*\@extra@binfo{}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@extra@b@citeb}
% \changes{v1.01}{2013/02/28}{Introduced the command} 
%   Another natbib hook:
%    \begin{macrocode}
\providecommand*\@extra@b@citeb{}
%    \end{macrocode}
%   
% \end{macro}
%
% \begin{macro}{\@BIBLABEL}
% \changes{v1.01}{2013/02/28}{Introduced the command} 
%   This is a hyperref hook
%    \begin{macrocode}
\providecommand*{\@BIBLABEL}{\@biblabel}
%    \end{macrocode}
%   
% \end{macro}
%
%
%   In case hyperref is not loaded, we provide some noops
%    \begin{macrocode}
\AtBeginDocument{
  \ifx\hyper@@link\@undefined
  \providecommand\@skiphyperreftrue{}%
  \providecommand\@skiphyperreffalse{}%
  \let\H@item\item
  \providecommand\Hy@raisedlink[1]{#1}%
  \let\hyper@anchorstart\@gobble
  \providecommand\hyper@@link[4][]{#4}%
  \providecommand{\hyper@anchorend}{}%
  \providecommand{\@currentHref}{}%
  \fi}
%    \end{macrocode}
%   
%
%\subsection{Checking for backref}
%\label{sec:backref}
%
% \begin{macro}{\if@BR@tocstarted}
% \changes{v1.02}{2013/03/26}{Added macro} 
%   Backref rewrites |.brf| file with each iteration.  So we need to
%   make sure we call |\BR@starttoc| no more than once
%    \begin{macrocode}
\newif\if@BR@tocstarted
\@BR@tocstartedfalse
%    \end{macrocode}
%   
% \end{macro}
%
%
% \begin{macro}{\if@backref@loaded}
% \changes{v1.02}{2013/03/26}{Added macro} 
%   We need to check whether backref is loaded:
%    \begin{macrocode}
\newif\if@backref@loaded
\AtBeginDocument{%
  \@ifpackageloaded{backref}{\@backref@loadedtrue    
    \let\BR@starttoc@orig\BR@starttoc
    \def\BR@starttoc{\if@BR@tocstarted\else
      \BR@starttoc@orig\@BR@tocstartedtrue\fi}
}{\@backref@loadedfalse}}
%    \end{macrocode}
%   
% \end{macro}
%
%\subsection{Creating Bibliography Labels}
%\label{sec:MBbibcite}
%
% \begin{macro}{\MBbibcite}
% \changes{v1.01}{2013/02/28}{Introduced the command} 
% \changes{v1.02}{2013/03/26}{Added backref code} 
%   The standard |\bibcite| command has two arguments:  the label and
%   the typeset represenation.  Our command has four arguments:
%   sequence number, name, date, label.  We also write |\backcite| to
%   the aux file if backref is called.
%    \begin{macrocode}
\def\MBbibcite#1#2#3#4{%
  \@newl@bel{b}{#1\@extra@binfo}{%
    \hyper@@link[cite]{}{cite.#1\@extra@b@citeb}{#3},
    \hyper@@link[cite]{}{cite.#1\@extra@b@citeb-timeline}{#4}:
    \hyper@@link[cite]{}{cite.#1\@extra@b@citeb-sequence}{#2}%    
    \if@filesw
    \if@backref@loaded\phantomsection
    \immediate\write\@mainaux{%
      \string\backcite{#1}{{\thepage}{\@currentlabel}{\@currentHref}}}\fi\fi
  }%
}%
%    \end{macrocode}
%   
% \end{macro}
%
%\subsection{Bibliography Commands}
%\label{sec:default}
%
% The default command is defined for references sorted by
% name---it is invoked by |\bibliography|.
%
% \begin{macro}{\@lbibitem}
% \changes{v1.01}{2013/02/28}{Redefined} 
% \changes{v1.02}{2013/03/26}{Added interlinks} 
%   By default |\@lbibitem| typesets the optional argument, creates a
%   hyperanchor and writes a command into the aux file.  The following
%   uses hyperref code:
%    \begin{macrocode}
  \def\@lbibitem[#1]#2{%
    \gdef\MB@sequence{}%
    \gdef\MB@name{}%
    \gdef\MB@name{}%
    \def\MBlabel##1##2##3{##2, 
      \hyper@@link[cite]{}{cite.#2\@extra@b@citeb-timeline}{##3}: 
      \hyper@@link[cite]{}{cite.#2\@extra@b@citeb-sequence}{##1}%
      \gdef\MB@sequence{##1}%
      \gdef\MB@name{##2}%
      \gdef\MB@date{##3}%
    }%
    \@skiphyperreftrue
    \H@item[%
      \ifx\Hy@raisedlink\@empty
        \hyper@anchorstart{cite.#2\@extra@b@citeb}%
          \@BIBLABEL{#1}%
        \hyper@anchorend
      \else
        \Hy@raisedlink{%
          \hyper@anchorstart{cite.#2\@extra@b@citeb}\hyper@anchorend
        }%
        \@BIBLABEL{#1}%
      \fi
      \hfill
    ]%
    \@skiphyperreffalse
    \if@filesw
      \begingroup
        \let\protect\noexpand
        \immediate\write\@auxout{%
          \string\MBbibcite{#2}{\MB@sequence}{\MB@name}{\MB@date}%
        }%
      \endgroup
    \fi
    \ignorespaces
  }
%    \end{macrocode}
%   
% \end{macro}
%
%
%
% \begin{macro}{\bibliographysequence}
% \changes{v1.01}{2013/02/28}{Added hyperref-compatible code} 
% \changes{v1.02}{2013/03/26}{Added interlinks} 
%   When we order by sequence, we do not write anything to the aux
%   file
%    \begin{macrocode}
\def\bibliographysequence#1{%
  \def\@lbibitem[##1]##2{%
    \def\MBlabel####1####2####3{####1: 
      \hyper@@link[cite]{}{cite.##2\@extra@b@citeb}{####2}, 
      \hyper@@link[cite]{}{cite.##2\@extra@b@citeb-timeline}{####3}}%
    \@skiphyperreftrue
    \H@item[%
      \ifx\Hy@raisedlink\@empty
        \hyper@anchorstart{cite.##2\@extra@b@citeb-sequence}%
          \@BIBLABEL{##1}%
        \hyper@anchorend
      \else
        \Hy@raisedlink{%
          \hyper@anchorstart{cite.##2\@extra@b@citeb-sequence}\hyper@anchorend
        }%
        \@BIBLABEL{##1}%
      \fi
      \hfill
    ]%
    \@skiphyperreffalse
    \ignorespaces
  }
  \@input@{\jobname-sequence.bbl}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bibliographytimeline}
% \changes{v1.01}{2013/02/28}{Added hyperref-compatible code} 
% \changes{v1.02}{2013/03/26}{Added interlinks} 
%   This is the ordering by timeline:
%    \begin{macrocode}
\def\bibliographytimeline#1{%
  \def\@lbibitem[##1]##2{%
    \def\MBlabel####1####2####3{%
      \hyper@@link[cite]{}{cite.##2\@extra@b@citeb}{####2}, 
      ####3:       
      \hyper@@link[cite]{}{cite.##2\@extra@b@citeb-sequence}{####1}}%
    \@skiphyperreftrue
    \H@item[%
      \ifx\Hy@raisedlink\@empty
        \hyper@anchorstart{cite.##2\@extra@b@citeb-timeline}%
          \@BIBLABEL{##1}%
        \hyper@anchorend
      \else
        \Hy@raisedlink{%
          \hyper@anchorstart{cite.##2\@extra@b@citeb-timeline}\hyper@anchorend
        }%
        \@BIBLABEL{##1}%
      \fi
      \hfill
    ]%
    \@skiphyperreffalse
    \ignorespaces
  }
  \@input@{\jobname-timeline.bbl}}
%    \end{macrocode}
%   
% \end{macro}
%
%\subsection{Ending the Style}
%\label{sec:end}
%
%
%
%    \begin{macrocode}
%</style>
%    \end{macrocode}
%\Finale
%\clearpage
%
%\PrintChanges
%\clearpage
%\PrintIndex
%
\endinput