]> git.lyx.org Git - wiki-uploads.git/blob - Examples/Bibunits/bibunits.sty
Import uploads from wiki
[wiki-uploads.git] / Examples / Bibunits / bibunits.sty
1 %%
2 %% This is file `bibunits.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% bibunits.dtx  (with options: `package')
8 %% 
9 %% IMPORTANT NOTICE:
10 %% 
11 %% For the copyright see the source file.
12 %% 
13 %% Any modified versions of this file must be renamed
14 %% with new filenames distinct from bibunits.sty.
15 %% 
16 %% For distribution of the original source see the terms
17 %% for copying and modification in the file bibunits.dtx.
18 %% 
19 %% This generated file may be distributed as long as the
20 %% original source files, as listed above, are part of the
21 %% same distribution. (The sources need not necessarily be
22 %% in the same archive or directory.)
23 %% Package `bibunits' to use with LaTeX2e.
24 %% Copyright (C) 1999, 2000 by Thorsten Hansen. All rights reserved.
25 %%
26 \NeedsTeXFormat{LaTeX2e}
27 \ProvidesPackage{bibunits}
28           [2000/10/10 v2.2 Multiple bibliographies in one document.]
29 \newif\iflabelstoglobalaux \labelstoglobalauxfalse
30 \DeclareOption{labelstoglobalaux}{\labelstoglobalauxtrue}
31 \newif\ifglobalcitecopy
32 \globalcitecopyfalse
33 \DeclareOption{globalcitecopy}{\globalcitecopytrue}
34 \ProcessOptions
35 \newwrite\@bibunitaux
36 \newcount\@bibunitauxcnt \@bibunitauxcnt=0
37 \def\@bibunitname{bu\the\@bibunitauxcnt}
38 \newif\if@starredversion
39 \let\std@cite\cite
40 \DeclareRobustCommand\bu@cite{%
41   \@ifstar
42     {\@starredversiontrue\std@cite}%
43     {\@starredversionfalse\std@cite}%
44 }
45 \AtBeginDocument{%
46   \@ifpackageloaded{natbib}%
47   {%
48     \NAT@set@cites \let\std@@citex\@citex
49     \def\bu@@citex[#1][#2]#3{%
50       \@startbibunitorrelax
51       \leavevmode
52       \begingroup\let\@auxout\@bibunitaux\std@@citex[#1][#2]{#3}\endgroup
53       \ifglobalcitecopy
54         \std@nocite{#3}%
55       \fi
56     }%
57   }%
58   {%
59     \@ifpackageloaded{overcite}%
60     {%
61       \let\std@@citew\@citew
62       \def\bu@@citew#1{%
63         \@startbibunitorrelax
64         \leavevmode
65         {\let\@auxout\@bibunitaux \std@@citew{#1}}%
66         \ifglobalcitecopy
67           \@nocite{#1}%
68         \else
69           \if@starredversion
70             \@nocite{#1}%
71           \fi
72         \fi
73       }
74       \let\std@@citex\@citex
75       \def\bu@@citex[#1]#2{%
76         \@startbibunitorrelax
77         \leavevmode
78         {\let\@auxout\@bibunitaux \std@@citex[#1]{#2}}%
79         \ifglobalcitecopy
80           \@nocite{#2}%
81         \else
82           \if@starredversion
83             \@nocite{#2}%
84           \fi
85         \fi
86       }
87     }%
88     {%
89       \@ifpackageloaded{jurabib}%
90       {%
91          \let\std@@citex\@citex
92         \def\bu@@citex[#1][#2]#3{%
93           \@startbibunitorrelax
94           \leavevmode
95           {\let\@auxout\@bibunitaux \std@@citex[#1][#2]{#3}}%
96           \ifglobalcitecopy
97             \std@nocite{#3}%
98           \else
99             \if@starredversion
100               \std@nocite{#3}%
101             \fi
102           \fi
103         }%
104       }%
105       {%
106         \let\std@@citex\@citex
107         \def\bu@@citex[#1]#2{%
108           \@startbibunitorrelax
109           \leavevmode
110           {\let\@auxout\@bibunitaux \std@@citex[#1]{#2}}%
111           \ifglobalcitecopy
112             \std@nocite{#2}%
113           \else
114             \if@starredversion
115               \std@nocite{#2}%
116             \fi
117           \fi
118         }%
119       }%
120     }%
121   }%
122 }%
123 \let\std@nocite\nocite
124 \def\bu@nocite{%
125   \@ifstar
126     {\@starredversiontrue\@bu@nocite}%
127     {\@starredversionfalse\@bu@nocite}%
128 }
129 \def\@bu@nocite#1{%
130   \@startbibunitorrelax
131   {\let\@auxout\@bibunitaux \std@nocite{#1}}%
132   \ifglobalcitecopy
133     \std@nocite{#1}%
134   \else
135     \if@starredversion
136       \std@nocite{#1}%
137     \fi
138   \fi
139 }
140 \def\bu@bibdata{}
141 \AtBeginDocument{%
142   \iflabelstoglobalaux
143   \else
144     \let\orig@bibliography\bibliography
145     \def\bibliography#1{%
146       \if@filesw
147         \immediate\openout\@bibunitaux bu.aux
148         \immediate\write\@mainaux{\string\@input{bu.aux}}%
149       \fi
150       \orig@bibliography{#1}%
151       \if@filesw
152         \immediate\closeout\@bibunitaux
153       \fi
154     }%
155   \fi
156   \let\std@bibliography\bibliography
157 }
158 \def\bu@bibliography{%
159   \@ifstar
160     {\@starredversiontrue\@bu@bibliography}%
161     {\@starredversionfalse\@bu@bibliography}%
162 }
163 \def\@bu@bibliography#1{%
164   \if@filesw
165     \immediate\write\@auxout{\string\gdef\string\bu@bibdata{#1}}%
166   \fi
167   \gdef\bu@bibdata{#1}%
168   \if@starredversion
169   \else
170     \std@bibliography{#1}%
171   \fi
172 }
173 \def\bu@bibstyle{}
174 \let\std@bibliographystyle\bibliographystyle
175 \def\bu@bibliographystyle{%
176   \@ifstar
177     {\@starredversiontrue\@bu@bibliographystyle}%
178     {\@starredversionfalse\@bu@bibliographystyle}%
179 }
180 \def\@bu@bibliographystyle#1{%
181   \if@filesw
182     \immediate\write\@auxout{\string\gdef\string\bu@bibstyle{#1}}%
183   \fi
184   \gdef\bu@bibstyle{#1}%
185   \if@starredversion
186   \else
187     \std@bibliographystyle{#1}%
188   \fi
189 }
190 \def\bibunit{%
191   \global\let\cite\bu@cite
192   \global\let\@citex\bu@@citex
193   \global\let\@citew\bu@@citew
194   \global\let\nocite\bu@nocite
195   \global\let\@startbibunitorrelax\@startbibunit
196   \global\let\@finishbibunit\relax
197   \@ifnextchar[{\@bibunitx}{\@bibunitx[\bu@bibstyle]}%
198 }
199 \def\@bibunitx[#1]{\gdef\@localbibstyle{#1}}
200 \def\endbibunit{%
201   \global\let\cite\std@cite
202   \global\let\@citex\std@@citex
203   \global\let\@citew\std@@citew
204   \global\let\nocite\std@nocite
205   \@finishbibunit
206   \@input{bu.aux}%
207 }
208 \def\@startbibunit{%
209   \global\let\@startbibunitorrelax\relax
210   \global\let\@finishbibunit\@finishstartedbibunit
211   \global\advance\@bibunitauxcnt 1
212   \if@filesw
213     {\endlinechar-1
214     \@input{\@bibunitname.aux}}%
215     \immediate\openout\@bibunitaux\@bibunitname.aux
216     \immediate\write\@bibunitaux{\string\bibstyle{\@localbibstyle}}%
217   \fi
218 }
219 \let\@finishbibunit\relax
220 \def\@finishstartedbibunit{%
221   \if@filesw
222     \immediate\closeout\@bibunitaux
223   \fi
224 }
225 \let\old@bibunit\@gobble
226 \def\@bibunit{\endbibunit\bibunit\old@bibunit}
227 \def\@endbibunit{}
228 \def\bibliographyunit{%
229   \@endbibunit
230   \@ifnextchar[{\@bibliographyunit}{%
231     \global\let\old@bibunit\@gobble
232     \global\let\bibliography\std@bibliography
233     \global\let\bibliographystyle\std@bibliographystyle
234     \endbibunit
235     \gdef\@endbibunit{}}%
236 }
237 \def\@bibliographyunit[#1]{%
238   \global\let\bibliography\bu@bibliography
239   \global\let\bibliographystyle\bu@bibliographystyle
240   \global\let\old@bibunit#1
241   \global\let#1\@bibunit
242   \gdef\@endbibunit{\global\let#1\old@bibunit}%
243 }
244 \def\putbib{\@ifnextchar[{\@putbib}{\@putbib[\bu@bibdata]}}
245 \def\@putbib[#1]{%
246   \@startbibunitorrelax
247   \if@filesw
248     \immediate\write\@bibunitaux{\string\bibdata{#1}}%
249   \fi
250   \@input@{\@bibunitname.bbl}%
251 }
252 \AtBeginDocument{%
253   \iflabelstoglobalaux
254   \else
255     \let\std@bibitem\@bibitem
256     \let\std@lbibitem\@lbibitem
257     \def\@bibitem#1{%
258       \let\temp@auxout\@auxout
259       \let\@auxout\@bibunitaux
260       \std@bibitem{#1}%
261       \let\@auxout\temp@auxout
262     }
263     \def\@lbibitem[#1]#2{%
264       \let\temp@auxout\@auxout
265       \let\@auxout\@bibunitaux
266       \std@lbibitem[#1]{#2}%
267       \let\@auxout\temp@auxout
268     }
269   \fi
270 }
271 \def\remequivalent#1\from#2{%
272   \let\given=#1%
273   \ifx#2\empty
274   \else
275     \edef#2{\expandafter\plugh#2\plugh}%
276   \fi
277 }
278 \def\plugh\do#1#2{%
279   \ifx#1\given
280   \else
281     \noexpand\do\noexpand#1%
282   \fi
283   \ifx#2\plugh
284     \hgulp\fi\plugh#2%
285 }
286 \def\hgulp\fi\plugh\plugh{\fi}
287 \remequivalent\bibcite\from\@preamblecmds
288 \AtBeginDocument{%
289   \@ifpackageloaded{natbib}%
290     {\renewcommand\bibcite[2]{\global\@namedef{b@#1\@extra@binfo}{#2}}}%
291     {\renewcommand\bibcite[2]{\global\@namedef{b@#1}{#2}}}%
292 }
293 \AtBeginDocument{%
294   \@ifundefined{bbl@redefine}%
295   {}%
296   {%
297     \bbl@redefine\@input#1{%
298       \@safe@activestrue\org@@input{#1}\@safe@activesfalse}%
299     \@ifpackageloaded{natbib}%
300     {%
301       \bbl@redefine\std@@citex[#1][#2]#3{%
302         \@safe@activestrue\org@std@@citex[#1][#2]{#3}\@safe@activesfalse}%
303       \bbl@redefine\bu@@citex[#1][#2]#3{%
304         \@safe@activestrue\org@bu@@citex[#1][#2]{#3}\@safe@activesfalse}%
305     }%
306     {% natbib not loaded
307       \bbl@redefine\std@@citex[#1]#2{%
308         \@safe@activestrue\org@std@@citex[#1]{#2}\@safe@activesfalse}%
309     }%
310   }%
311 }
312 \endinput
313 %%
314 %% End of file `bibunits.sty'.