summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/margbib/margbib.dtx
blob: a37d84ec6f9bf25d67ad93b32d6af8b141f11c67 (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
% \iffalse meta-comment
%
% This file is part of the MARGBIB package, a package for displaying
% bibliography tags in the margins. Copyright (C) 1997 Karsten Tinnefeld.
% 
% This file is NOT part of the LaTeX2e system, but intended for use with it.
% 
% This document is free software; you can redistribute it and/or modify it
% under the terms of the GNU Library General Public License as published by
% the Free Software Foundation; either version 2 of the License, or (at your
% option) any later version.
%
% This document is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
% more details.
%
%  You should have received a copy of the GNU General Public License somehow;
%  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
%  Cambridge, MA 02139, USA.
%
% INSTALLATION:
%%%%%%%%%%%%%%%
%
% Install this style by running the file `margbib.ins' thro' TeX. This will
% create the file `margbib.sty' and, if your docstrip.cfg is set up the right
% way (has a \BaseDirectory{<path to my texmf directory>}, see the
% docstrip-documentation), automatically moved to \$TEXMF/tex/latex/misc.
%
% The documentation is created by running `latex margbib.dtx`.
%
\NeedsTeXFormat{LaTeX2e}
%<*dtx>
\ProvidesFile{margbib.dtx}
%</dtx>
%<!driver>\ProvidesPackage{margbib}
%<driver>\ProvidesFile{margbib.drv}
%  \fi
%  \ProvidesFile{margbib.dtx}
  [1997/11/11 1.0c Bib-Items into the margins]
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{margbib}
\GetFileInfo{margbib.dtx}
\def\docdate{1997/11/10}
\RecordChanges
\begin{document}
  \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%  \CheckSum{55}
%
%  {\makeatletter\@ifundefined{AmS}
%    {\gdef\AmS{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
%          \hbox{$\mathcal M$}\kern-.2em\mathcal S$}}}{}}
%  \def\KOMAScript{\textsf{KOMA-Script}}
%  \def\refname{Example}
%
%  \date{printed \today}
%  \title{The \texttt{margbib} document style\thanks{%
%      This file has version number \fileversion,
%      last revised \filedate, documentation dated \docdate.}}
%  \author{Karsten Tinnefeld\\\texttt{tinnefeld@irb.cs.uni-dortmund.de}}
%  \maketitle
%
%  \begin{abstract}
%    This document describes the \texttt{margbib} document style. This style
%    redefines the \texttt{thebibliography} environment in order to move the
%    bibliography labels into the borders.
%  \end{abstract}
%
% \section{Introduction}
%
%  Why the |margbib| style? Many typesetters say that text is only readable
%  when it is not wider than, say, about 70 letters. This limit is very tight,
%  provided typesetting on one column ISO A4 paper, the usual European
%  paper size. Thus there is a tradeoff between readability in normal text
%  paragraphs and the amount of trouble in line breaking especially of
%  bibliographies, where masses of names and declarative title words
%  discourage easy hyphenation. Large tags in all ``speaking'' citation styles
%  such as |alpha| or |abbrv| make it even harder as the books' label sizes
%  increase.
%
%  Therefore, this style takes the label off the normal paragraph and places
%  it right beside the text in the margin. Since the normal |\marginpar|
%  command has problems with its output routine in case |twoside| is
%  used---first the marginalium is set, then a compound paragraph is possibly
%  put onto the next page---we employ the |marn.sty| created in 1993 by Donald
%  Arseneau. It ensures right placing of the marginal note in this case. This
%  is done utilising the |.aux|-file, but who does not re\TeX\ each 
%  document twice or thrice?
%
%  This document style has been tested with the normal \LaTeXe\ base, the
%  \AmS\ and the \KOMAScript\ documents. It works---most important---with the
%  twoside option and the use of normal |\marginpar|s, for problems therewith
%  cf. the documentation to |marn.sty|. I have found one minor caveat: it does
%  not print out this famous ``labels have changed, please re\TeX!'' message
%  in case of modifications, so my AUC \TeX\footnote{AUC \TeX\ is Per
%  Abrahamsen's famous \TeX\ mode for Emacs.}\ makes wrong proposals about
%  what to do next. Minor, as I said.
%
%  \section{Remark}
% 
%  The \AmS\ bibliography styles make the paragraph text some degrees smaller
%  than regular. This package keeps this font size in paragraph text, but sets
%  the margin labels in normal font. This does not look that great, but
%  whoever wants to combine both is encouraged to fix it.
%
%  \begin{thebibliography}{Knu86}
%    \bibitem[Knu86]{knuth86:_texbook}
%      Donald~E. Knuth.
%      \newblock {\em The \TeX{}book}, volume~A of {\em Computers \&
%        Typesetting}.
%      \newblock American Mathematical Society, Reading MA, 1986.
%
%    \bibitem[Mit97]{mittelbach97}
%      Frank Mittelbach.
%      \newblock {\em The |doc| and |shortvrb| packages}.
%      \newblock Gutenbach Universit{\"a}t Mainz, February 5th, 1997.
%  \end{thebibliography}
%
%  \StopEventually{}
%
%  \section{The Code}
%
%  \changes{v1.0b}{1997/11/10}{Only require |marn.sty| when available.}
%
%  Let us look whether the document style |marn| by Donald Arseneau
%  exists. This will avoid difficulties in |twoside|-mode. If so, we
%  load the package, otherwise output a warning and make do with
%  |\marginpar|.
% 
%    \begin{macrocode}
\IfFileExists{marn.sty}{%
  \RequirePackage{marn}
  }{%
  \PackageWarning{margbib}{%
    marn package unavailable -- using \string\marginpar}%
  \let\marn\marginpar}
%    \end{macrocode}
%
%  \begin{macro}{\bibitem}
%    This redefines |\bibitem| and the two subcommands (with and without the
%    optional tag) to move our label information into the borders. We could
%    leave out the first line of the following code for all the examined
%    styles, after all, but since the |@|-commands are not said to persist,
%    this redundancy may be future's benefit.
%
%    \begin{macrocode}
\def\bibitem{\@ifnextchar[\@lbibitem\@bibitem}
\def\@lbibitem[#1]#2{\item[]\if@filesw
  {\makebox{}\marn{\@biblabel{#1}}%
    \let\protect\noexpand
    \immediate
    \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
\def\@bibitem#1{\item[]\if@filesw\immediate\write\@auxout
  {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}    
%    \end{macrocode}
%  \end{macro}
% 
%  \begin{environment}{thebibliography}
%    In order to broaden our text to the whole |\item|less width, we have to
%    redefine the |thebibliography| environment. For the sake of its
%    document-dependent facilities, we first steal the code and then
%    manipulate it: The shape of the paragraph is simply reset.
%
%    Why override the given environment instead of defining a new? For those
%    who write bibliographies one after the other by themselves, this is no
%    problem. But \BibTeX\ generates |thebibliography| environments, and
%    nothing else. Thus it is only a question of working with |margbib.sty| or
%    without. Whoever wanted to have \emph{different} forms of bibliographies
%    in one document, e. g. using |chapterbib|, might possibly have cramped
%    her style.
%
%    \begin{macrocode}
\let\m@rgbib=\thebibliography
\let\endm@rgbib=\endthebibliography
\renewenvironment{thebibliography}[1]{%
  \begin{m@rgbib}{#1}
    \parshape=0\relax
    }{%
  \end{m@rgbib}
  }    
%    \end{macrocode}
%  \end{environment}
%
%\Finale