summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bibtopicprefix/bibtopicprefix.dtx
blob: 992d8f7c87597f94d21b12247804b7be15554e34 (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
% \iffalse
\NeedsTeXFormat{LaTeX2e}[1996/10/24]
%<package>\ProvidesPackage{bibtopicprefix}
%<package>         [2006/10/22 v1.10 BibTopicPrefix Package (MS)]
%
%<*driver>
\ProvidesFile{bibtopicprefix.drv}
      [2006/10/18 v1.00 Driver for BibTopicPrefix Package (MS)]
\documentclass{ltxdoc}
\usepackage{url}
\usepackage{bibtopicprefix}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\GetFileInfo{bibtopicprefix.sty}
\EnableCrossrefs
\RecordChanges    % Gather update information
%%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
\CodelineIndex    % Index code by line number
\OnlyDescription  % comment out for implementation details
%%\OldMakeIndex   % use if your MakeIndex is pre-v2.9
\setcounter{IndexColumns}{2}
\setlength{\IndexMin}{40ex}
\setlength{\columnseprule}{.4pt}
\addtolength{\oddsidemargin}{1cm}
\addtolength{\textwidth}{-1cm}
\begin{document}
   \DocInput{bibtopicprefix.dtx}
\end{document}
%</driver>
%
% Copyright 2006 by Martin Schr"oder
% 
% 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 this
% license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Martin Schr"oeder.
%
% This work consists of the files bibtopicprefix.dtx and
% bibtopicprefix.ins and the derived file bibtopicprefix.sty
%
% For error reports in case of UNCHANGED versions see bibtopicprefix.ins
%
% \fi
%
% \CheckSum{119}
% ^^A$Id: bibtopicprefix.dtx,v 1.3 2006/10/21 22:52:26 ms Exp $
%
%% \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         \~}
%%
%
%  \pagestyle{headings}
%
%  \newcommand{\bs}           {\texttt{\symbol{'134}}}
%  \newcommand*{\env}[1]      {\textsf{#1}}
%  \newcommand*{\option}[1]   {\textsf{#1}}
%  \newcommand*{\package}[1]  {\textsf{#1}}
%  \newcommand*{\bst}[1]      {\textsf{#1}}
%  \newcommand*{\NEWfeature}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New feature\\#1}}
%  \newcommand*{\NEWdescription}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New description\\#1}}
%
%  \renewcommand{\thefootnote}{\ensuremath{\fnsymbol{footnote}}}
%
% ^^A -----------------------------
%
%  \title{\unskip
%     The \textsf{BibTopicPrefix}-package^^A
%     \thanks{^^A
%        The version number of this file is \fileversion,
%        last revised \filedate.}^^A
%     }
%  \author{Martin Schr\"oder\\[0.5ex]
%          \normalsize  Cr\"usemannallee 3\\
%          \normalsize  28213 Bremen\\
%          \normalsize  Germany\\
%          \normalsize  martin@oneiros.de}
%  \date{\filedate}
%  \maketitle
%
% ^^A -----------------------------
%
%  \begin{abstract}
%     This package provides a way to prefix references from
%     bibliographies produced by the \package{bibtopic}
%     package\cite{bibtopic}.
%  \end{abstract}
%
%
% ^^A -----------------------------
%
%  \tableofcontents
%
% ^^A -----------------------------
%
%  \section{Introduction}
%  ^^A
% Suppose you want to split your literature in your document into
% parts (this can be done with the \package{bibtopic} package) and you
% want to make this split visible in the references in the document.
%
% This package loads \package{bibtopic} with the right option and then
% defines a command \cs{bibprefix} which should be used inside the
% \env{btSect} environment, whose argument is inserted before every
% reference (e.\,g. [1] becomes [\meta{prefix}1]).
%
%
% ^^A -----------------------------
%
%  \section{Usage}
%  ^^A
%  \DescribeMacro{\bibtopic}
% Add an \mbox{\cs{usepackage\{}\package{bibtopicprefix}\texttt{\}}}
% to your document and insert the command \cs{bibprefix}\marg{prefix}
% at the start of every \env{btSect} environment.
%  \begin{quote}
%\begin{verbatim}
%\begin{btSect}{adlit}
%  \renewcommand{\bibprefix}{AD}
%  \section{Applicable Documents}
%  \btPrintCited
%\end{btSect}
%\begin{btSect}{rdlit}
%  \renewcommand{\bibprefix}{RD}
%  \section{Reference Documents}
%  \btPrintCited
%\end{btSect}
%\end{verbatim}
%  \end{quote}
% The package works of course best with bibliography styles that
% produce numerical references (like \bst{plain}).
%
%
% ^^A -----------------------------
%
% \section{Required packages}
% ^^A
% This package requires the following package:
% \begin{description}
%   \item[\normalfont\package{bibtopic}\cite{bibtopic}]
%     It is loaded with the right option so that all bibliographies
%     are numbered indepedently.
%   \item[\normalfont\package{scrlfile}\cite{scrlfile}]
%     \changes{v1.10}{2006/10/22}{Use \package{scrlfile}}
%     This is used internally to handle the
%     \package{hyperref}\cite{hyperref} package.
% \end{description}
%
%
% ^^A -----------------------------
%
% \StopEventually{^^A
%
%
% ^^A -----------------------------
%
% \section{Acknowledgements}
% ^^A
% Developement of this package was financed by the von Hoerner \&
% Sulger GmbH.
%
% ^^A -----------------------------
%
% \begin{thebibliography}{1}
%   \bibitem{babel}
%     Johannes Braams
%     \newblock Babel, a multilingual package for use with \LaTeX's
%       standard document classes
%     \newblock \url{CTAN: tex-archive/macros/latex/required/babel/}.
%   \bibitem{bibtopic}
%     Pierre Basso and Stefan Ulrich
%     \newblock \textsf{bibtopic.sty}
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/bibtopic/}.
%   \bibitem{hyperref}
%     Sebastian Rahtz and Heiko Oberdiek
%     \newblock Hypertext marks in \LaTeX{}
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/hyperref/}.
%   \bibitem{scrlfile}
%     Markus Kohm
%     \newblock \textsf{scrlfile.sty}
%     \newblock Part of KOMA-Script.
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/koma-script/}.
% \end{thebibliography}
% }
%
% ^^A -----------------------------
%
%  \section{The implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Loading packages}
%  ^^A
%  We need the \package{scrlfile} package\cite{scrlfile}.
%   \changes{v1.10}{2006/10/22}{Load \package{scrlfile}}
%    \begin{macrocode}
\RequirePackage{scrlfile}
%    \end{macrocode}
%  We need the \package{bibtopic} package\cite{bibtopic} and we have
%  to use the \option{sectcntreset} option to number every
%  bibliography seperately.
%    \begin{macrocode}
\RequirePackage[sectcntreset]{bibtopic}
%    \end{macrocode}
%
% ^^A -----------------------------
%
%  \subsection{The macros}
%  ^^A
% \begin{macro}{\bibprefix}
% \cs{bibprefix} defines the prefix for all references henceforce.
%    \begin{macrocode}
\newcommand{\bibprefix}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@bibitem}
% We want to redefine \cs{\@bibitem} to add our prefix.
% To do this we need to distinguish three cases: the use of the
% \package{hyperref} package, the use of the \package{babel} package
% and the default.
%
% We handle the \package{hyperref} package by activating our code
% after \package{hyperref} with the help of \cs{AfterPackage*} from
% \package{scrlfile}.
%   \changes{v1.10}{2006/10/22}{Handle \package{hyperref}}
%    \begin{macrocode}
\AfterPackage*{hyperref}{%
  \CheckCommand*{\@bibitem}[1]{%
    \@skiphyperreftrue\H@item\@skiphyperreffalse
    \Hy@raisedlink{%
      \hyper@anchorstart{cite.#1}\relax\hyper@anchorend}%
    \if@filesw
      \begingroup
        \let\protect\noexpand
        \immediate\write\@auxout{%
          \string\bibcite{#1}{%
            \the\value{\@listctr}}%
        }%
      \endgroup
    \fi
    \ignorespaces
    }%
  \renewcommand*{\@bibitem}[1]{%
    \@skiphyperreftrue\H@item\@skiphyperreffalse
    \Hy@raisedlink{%
      \hyper@anchorstart{cite.#1}\relax\hyper@anchorend}%
    \if@filesw
      \begingroup
        \let\protect\noexpand
        \immediate\write\@auxout{%
          \string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}%
        }%
      \endgroup
    \fi
    \ignorespaces
    }%
  }%
%    \end{macrocode}
%
% If \package{hyperref} is not used, we must distinguish between
% \package{babel} and the default. \package{babel} saves \cs{@bibitem}
% as \cs{org@@bibitem}, so we have to redefine that. 
%   \changes{v1.10}{2006/10/22}{Handle \package{babel}}
%    \begin{macrocode}
\@ifpackageloaded{hyperref}{}{%
  \@ifpackageloaded{babel}
    {%
      \CheckCommand*{\org@@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
      \renewcommand*{\org@@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
    }{%
      \CheckCommand*{\@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
      \renewcommand*{\@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
    }%
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@biblabel}
% We redefine \cs{\@biblabel} to add our prefix.
%    \begin{macrocode}
\renewcommand*{\@biblabel}[1]{[\bibprefix#1]}
%    \end{macrocode}
% \end{macro}
%
%
% ^^A -----------------------------
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%  \Finale
% ^^A vim:tw=70:ts=2:et