]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/kluref.sty
ocaml 3.09 transition
[helm.git] / helm / papers / matita / kluref.sty
1 %
2 %
3 \ifcat a\noexpand @\let\next\relax\else \def\next{%
4 \documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
5 \NeedsTeXFormat{LaTeX2e}
6 \def\filename{kluref.sty}
7 \def\filedate{1998/03/17}
8 %\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
9 %\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
10 %\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\refstepcounter}
11 %\DoNotIndex{\normalsize,\numberline,\protect,\endinput}
12 %\changes{1998/03/17}{TH: Fixed optional argument to cite for numreferences}
13 %\changes{1997/02/18}{TH: Toggled lines for cite definition and citation write (3x)}
14 %\CodelineIndex
15 %\newcommand{\Bs}{}
16 %\parindent=0pt
17 %\parskip=3pt
18 %\hfuzz=10pt
19 %\addtolength{\textwidth}{4pc}
20 %\MakeShortVerb{\|}  
21 %\begin{document}
22 %\begin{article}
23 %\begin{opening}
24 %\title{\filename}
25 %\date{\filedate}
26 %\author{Kluwer Academic Publishers\surname{}}
27 %\institute{~}
28 %\begin{abstract}
29 %This internal stylefile provides commands for references. Options are
30 %|openbib|, |numreferences| and |namedreferences|. This documentation
31 %is compiled on |kluwer.cls| to give some examples.
32 %\end{abstract}
33 %\end{opening}
34 %\tableofcontents
35 %\newpage
36 %\section{Interface}
37 % This file provides |namedreferences| and |numreferences| options
38 % for the stylefiles. |namedreferences| use the syntax that is
39 % explained in the |named.sty| package, but will be repeated
40 % below. |numreferences| we wrote ourselves, the major difference with
41 % standard \LaTeX\ iss that the brackets in the `references' section
42 % have turned into a dot.  
43 % \subsection{Named references} 
44 % This presumes that the reference list you use is sorted
45 % alphabetically. The general chape of the references section is this:
46
47 % \begin{verbatim}
48 % \begin{thebibliography}{}
49 % \bibitem[\protect\citeauthoryear{author's name}{year}]{key} 
50 % \end{verbatim}
51 % In a `real' example this is what it looks like: 
52 % \begin{verbatim}
53 % \begin{thebibliography}{}
54 %\bibitem[\protect\citeauthoryear{Bisogni~Jr and Arroyo}{1991}]{BJA91}
55 %J.J. Bisogni~Jr and S.L. Arroyo.
56 %\newblock The effect of carbon dioxide equilibrium on p{H} in dilute lakes.
57 %\newblock {\em Water Research}, 25(2):185--190, 1991.
58 % \end{verbatim}
59 % This entry was generated by \BibTeX, using the file |named.bst|
60 % to do the formatting and sorting. This method of generating
61 % references is highly recommended, because it tends to prevent
62 % errors. (The |\protect| is only needed if the output is in an
63 % external file, like the |.bbl| file.) Until we have a `private'
64 % |.bst| file, |named.bst| is the best option.
65 %
66 % Allthough keying this sort of thing in is quite tedious, It also has
67 % some advantages: this allows you to use some `special' |\cite|
68 % commands that are normally not available. The following shows what
69 % the respective commands output on the previous example:
70 %
71 % \begin{tabular}{ll} \hline
72 %Call:                &Produces:\\ \hline
73 %|\cite{BJA91}|       &\cite{BJA91}\\
74 %|\cite*{BJA91}|      &\cite*{BJA91}\\
75 %|\shortcite{BJA91}|  &\shortcite{BJA91}\\
76 %|\citeyear{BJA91}|   &\citeyear{BJA91}\\
77 %|\inlinecite{BJA91}| &\inlinecite{BJA91}\\
78 %|\opencite{BJA91}|   &\opencite{BJA91}
79 %\end{tabular}
80 %\section{Implementation}
81 % From the options follows that the default value is
82 % |namedreferences|.                           
83
84 %    \begin{macrocode}
85 \ProvidesPackage{kluref}[\filedate ]
86 \newif\if@numreferences 
87 \DeclareOption{namedreferences}{\@numreferencesfalse}
88 \DeclareOption{numreferences}{\@numreferencestrue}
89 %    \end{macrocode}
90 %
91 % openbib is ignored (for now ?). 
92 %
93 %    \begin{macrocode}
94 \DeclareOption{openbib}{}
95 \ExecuteOptions{namedreferences}
96 \ProcessOptions*
97 %    \end{macrocode}
98
99 %
100 % |\sectioncmd| is either |\section| or |\chapter|, depending on the used
101 % major stylefile. Same goes for |\Uppercase|, with regard to pagestyles.
102 %
103 %
104 %    \begin{macrocode}
105 \newenvironment{thebibliography}[1]{%
106   \sectioncmd*{\refname}\imarkboth{\bibname}{\bibname}%
107   \footnotesize
108   \message{\refname}
109   \def\bibwidthlabel{\releft#1\reright}%
110 %    \end{macrocode}
111 %  |\releft| and |\reright| are usually empty, but they can be defined
112 %  to contain brackets, for instance. This is only useful using
113 %  |numreferences|.
114 %
115 % The list and counter are defined below. They vary for the different
116 % options. 
117 %    \begin{macrocode}
118   \list{\kapbib@counter}{\kapbib@list}
119   \let\makelabel\@biblabel
120   \def\newblock{\hskip .11em plus .33em minus .07em}%
121   \sloppy
122   \clubpenalty10000
123   \widowpenalty10000
124   \sfcode`\.=1000\relax
125   }{\endlist}
126 %    \end{macrocode}
127
128 % \subsection{Some utilities} 
129 %
130 % |\refname| and |\bibname| are not |\providecommand|'s to allow for 
131 % already existing definitions, because  we do need to be absolutely
132 % sure we are in control. That's why they are inside 
133 % |\AtBeginDocument|, to circumvent the |babel| package.
134 %
135 % I should ask for french/german names, though.
136 %
137 %    \begin{macrocode}
138 \AtBeginDocument{%
139   \def\refname{References}%
140   \def\bibname{References}}
141 %    \end{macrocode}
142
143
144 %
145 % |\releft| and |\reright| are around the text inside the optional
146 % argument to |\bibitem|. Together with |\redot|, this allows the 
147 % following hack: 
148 %
149 %\begin{verbatim}
150 %\documentclass[numreferences]{kluwer}
151 %\renewcommand{\releft}{[}
152 %\renewcommand{\reright}{]}
153 %\renewcommand{\redot}{}
154 %\begin{document}
155 %......
156 %\begin{thebibliography}{abs}
157 %\bibitem[abs]{key}...
158 %\end{verbatim}
159 %... and the references will look identical to \LaTeX\ Article 
160 % `namedreferences', except for size. Note that this will only work
161 % using numreferences.
162 %
163 % |\coleft| and |\ccright| are the same sort of thing, they allow you
164 % to change the braces around |\cite| commands into something else.
165
166 % This is a hook for klups.sty (oldstyle numerals)
167 %    \begin{macrocode}                           
168 \def\i@oldseries{}
169 %    \end{macrocode}
170 %    \begin{macrocode}
171 \newlength{\bibhang}
172 \setlength{\bibhang}{14pt}
173 \newcommand{\redot}{.}
174 \newcommand{\releft}{}
175 \newcommand{\reright}{}
176 \newcommand{\coleft}{(}
177 \newcommand{\ccright}{)}
178 \let\oldcite\cite 
179 %    \end{macrocode}
180 % \newpage\subsection{Numbered references}
181 %    \begin{macrocode}
182 \def\numreferences{%
183   \typeout{KAP -- Numbered references}%
184   \def\kapbib@counter{\arabic{enumiv}}%
185   \def\labelsepwidth{1em}%
186   \def\kapbib@list{%
187     \setlength{\labelsep}{\labelsepwidth}%
188     \settowidth{\labelwidth}{\@biblabel{\bibwidthlabel}}%
189     \setlength{\leftmargin}{\labelwidth}%
190     \addtolength{\leftmargin}{\labelsep}%
191     \setlength{\itemindent}{0pt}%
192     \setlength{\itemsep}{0pt}%
193     \setlength{\parsep}{0pt}%
194     \usecounter{enumiv}%
195     \let\makelabel\kap@biblabel}%
196 %    \end{macrocode}
197 %  This makes flush right labels
198 %    \begin{macrocode}
199   \def\@biblabel##1{\hfill\releft##1\redot\reright}%
200 %    \end{macrocode}
201 % |\@bibitem| writes out either |\bibcite{key}{number}| or
202 % |\bibcite{number}{number}| in case there is no key given. This
203 % allows |\cite{2}| without a key.
204 %    \begin{macrocode}
205   \def\@bibitem##1{\item               
206     \def\@tempa{##1}%
207     \ifx\@tempa\empty
208       \if@filesw
209       \immediate\write\@auxout 
210       {\string\bibcite{\thearticle \the\value{\@listctr}}%
211                         {\the\value{\@listctr}}}%
212       \fi
213     \else
214       \if@filesw
215       \immediate\write\@auxout 
216       {\string\bibcite{\thearticle ##1}{\the\value{\@listctr}}}%
217       \fi
218     \fi 
219     \ignorespaces
220     }%
221 %    \end{macrocode}
222 % |\@lbibitem| handles the optional argument version. 
223 %
224 % If no key
225 % is given, we presume numbered references are really wanted. (It would
226 % be a bit strange to have entries like |\bibitem[A95]{}| and
227 % to reference using a counter as in |\cite{1}|). 
228 %                                     
229 %    \begin{macrocode}
230   \def\@lbibitem[##1]##2{%
231     \def\@biblabel####1{####1}%
232     \let\makelabel\@biblabel
233     \def\@tempa{##2}%
234     \ifx\@tempa\empty          
235       \item[\@biblabel{\hfill\releft 
236           \arabic{\@listctr}\redot\reright}]%
237       \if@filesw
238         {\def\protect####1{\string ####1\space}\immediate
239         \write\@auxout{\string\bibcite{\thearticle \the\value{\@listctr}}%
240         {\the\value{\@listctr}}}}%
241       \fi
242 %    \end{macrocode}
243 % Otherwise, typeset the argument and write out both argument and key
244 % to the |.aux| file.
245 %    \begin{macrocode}
246     \else
247       \item[\@biblabel{\hfill\releft ##1\redot\reright}]%
248       \if@filesw 
249         {\def\protect####1{\string ####1\space}\immediate
250         \write\@auxout{\string\bibcite{\thearticle ##2}{##1}}}%
251       \fi  
252     \fi  
253     \ignorespaces
254     }%
255 %    \end{macrocode}
256 % Now allow some |namedreferences| commands to a least mean something.
257 %    \begin{macrocode}
258   \let\@internalcite\oldcite
259   \let\shortcite\@internalcite
260   \let\citeauthor\@internalcite
261   \let\citeyear\@internalcite
262   \let\inlinecite\@internalcite
263   \let\opencite\@internalcite
264   \let\cite\@internalcite
265   \def\citeauthoryear##1##2{}%
266 %    \end{macrocode}
267 % To end: relatively standard definition of |\@citex|. 
268 %    \begin{macrocode}
269 \def\@citex[##1]##2{%                        
270   \let\@citea\@empty
271   \@cite{\@for\@citeb:=##2\do
272     {\@citea\def\@citea{,\penalty\@m\ }%
273      \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
274      \edef\gl@citeb{\expandafter\@firstofone\@citeb}%
275      \edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
276      \@ifundefined{b@\@citeb}{%
277         \@ifundefined{b@\gl@citeb}{%
278             \mbox{\reset@font\bfseries ?}%
279             \G@refundefinedtrue
280             \@latex@warning
281             {Citation `\@citeb' on page \thepage \space undefined}}%
282             {\hbox{\csname b@\gl@citeb\endcsname}}}%
283          {\hbox{\csname b@\@citeb\endcsname}}%
284        }}{##1}}
285 }
286 %    \end{macrocode}
287 %\newpage \subsection{Named references}
288 %    \begin{macrocode}                       
289 \def\namedreferences{%
290   \typeout{KAP -- Named references}%
291 %    \end{macrocode}
292 % This (having no optional argument and/or key) 
293 % is typically one of those things that happen if you switch from
294 % |num| to |named|. Just write out something to indicate that there
295 % may be a problem.  
296 %
297 %    \begin{macrocode}
298   \def\@bibitem##1{\item
299     \def\@tempa{##1}%
300     \ifx\@tempa\empty                              
301       \if@filesw \immediate\write\@auxout{%
302         \string\bibcite{\thearticle ??}{??}}\fi
303     \else
304       \if@filesw \immediate\write\@auxout{%
305         \string\bibcite{\thearticle ##1}{??}}\fi
306     \fi
307     \ignorespaces
308     }%
309 %    \end{macrocode}
310 % Not having a key probably indicates that the optional argument is
311 % also wrong, but hey, we can't do everything. At least now |\cite|
312 % is something useful if you can count very well...
313 %
314 % It is also possible
315 % that the optional argument is empty, but that is never a problem
316 % because it will not be typeset anyway (|\@biblabel| will gobble the 
317 % argument).  
318 %
319 % 21/3/1997 inserted increment of |\@listctr| to prevent multiply 
320 % defined labels.
321 %    \begin{macrocode}
322   \def\@lbibitem[##1]##2{\item[\@biblabel{##1}\hfill]%
323     \def\@tempa{##2}%   
324     \stepcounter{\@listctr}%
325     \ifx\@tempa\empty
326       \if@filesw{\def\protect####1{\string ####1\space}\immediate
327        \write\@auxout{\string\bibcite{\thearticle 
328         \the\value\@listctr}{##1}}}\fi
329     \else
330       \if@filesw{\def\protect####1{\string ####1\space}\immediate
331        \write\@auxout{\string\bibcite{\thearticle ##2}{##1}}}\fi
332     \fi
333     \ignorespaces
334     }% 
335 \def\labelsepwidth{1em}%
336 %    \end{macrocode}
337 % Here is the list again. |\bibhang| allows control over the amount 
338 % of hanging indentation.
339 %    \begin{macrocode}
340 \def\kapbib@counter{\relax }%
341   \def\kapbib@list{%
342     \setlength{\labelsep}{0em}%
343     \setlength{\labelwidth}{0pt}%
344     \setlength{\itemindent}{-\bibhang}%
345     \setlength{\itemsep}{0pt}%
346     \setlength{\parsep}{0pt}%
347     \usecounter{enumiv}%                        
348     \setlength{\leftmargin}{\bibhang}%
349     \i@oldseries
350     }%
351 %    \end{macrocode}
352 % Gobble |\@biblabel|. Also, save meaning of |\cite| for later use.
353 %    \begin{macrocode}
354   \def\@biblabel##1{}%
355   \let\@internalcite\oldcite
356 %    \end{macrocode}
357 % Differences between these |\cite| commands can be seen above.
358 %    \begin{macrocode}
359   \def\cite{\@ifstar{\citeyear}{\klu@cite}}%
360                                                        
361   \def\klu@cite{\def\@citeseppen{1000}%       
362     \def\@cite####1####2{\coleft{####1\if@tempswa , ####2\fi}\ccright}%
363     \def\citeauthoryear####1####2{{\rm\i@oldseries ####1, ####2}}\@internalcite }%
364
365   \def\shortcite{\def\@citeseppen{1000}%
366     \def\@cite####1####2{\coleft{####1\if@tempswa , ####2\fi}\ccright}%
367     \def\citeauthoryear####1####2{{\rm\i@oldseries ####2}}\@internalcite }%
368
369   \def\citeauthor##1{\def\@citeseppen{1000}%
370     \def\@cite####1####2{{####1\if@tempswa , ####2\fi}}%
371     \def\citeauthoryear####1####2{\rm ####1}\@citedata{##1}}%
372
373   \def\citeyear##1{\def\@citeseppen{1000}%
374     \def\@cite####1####2{{####1\if@tempswa , ####2\fi}}%
375     \def\citeauthoryear####1####2{{\rm\i@oldseries ####2}}\@citedata{##1}}%
376                                                        
377   \def\opencite##1{\citeauthor{##1}, \citeyear{##1}}%
378
379   \def\inlinecite##1{\citeauthor{##1} (\citeyear{##1})}%
380 %    \end{macrocode}
381 % This is rather tricky stuff, these macros  come from |named.sty| and
382 % I remember that I understood them once, but not any more,
383 % apparantly. Checking this is left as an exersize to the reader.
384 %    \begin{macrocode}
385 \def\@citedata##1{%    
386     \@tempswafalse%
387   \let\@citea\@empty
388   \@cite{\@for\@citeb:=##1\do
389     {\@citea\def\@citea{,\penalty\@citeseppen\ }%
390      \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
391      \edef\gl@citeb{\expandafter\@firstofone\@citeb}%
392      \edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
393      \@ifundefined{b@\@citeb}{%
394         \@ifundefined{b@\gl@citeb}{%
395             \mbox{\reset@font\bfseries ?}%
396             \G@refundefinedtrue
397             \@latex@warning
398             {Citation `\@citeb' on page \thepage \space undefined}}%
399             {\csname b@\gl@citeb\endcsname}}%
400          {\csname b@\@citeb\endcsname}}}{}}
401 \def\@citex[##1]##2{%    
402   \let\@citea\@empty
403   \@cite{\@for\@citeb:=##2\do
404     {\@citea\def\@citea{;\penalty\@citeseppen\ }%
405      \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
406      \edef\gl@citeb{\expandafter\@firstofone\@citeb}%
407      \edef\@citeb{\thearticle\expandafter\@firstofone\@citeb}%
408      \@ifundefined{b@\@citeb}{%
409         \@ifundefined{b@\gl@citeb}{%
410             \mbox{\reset@font\bfseries ?}%
411             \G@refundefinedtrue
412             \@latex@warning
413             {Citation `\@citeb' on page \thepage \space undefined}}%
414             {\csname b@\gl@citeb\endcsname}}%
415          {\csname b@\@citeb\endcsname}}}{##1}}
416 %    \end{macrocode}
417 % Allow |\citeauthoryear| in |\write|       
418 %    \begin{macrocode}
419 \def\citeauthoryear##1##2{\string\citeauthoryear{##1}{##2}}}
420 %%%%%%%%%%%%%%%%%%%%%%%%%
421 \if@numreferences
422     \numreferences
423 \else
424     \namedreferences
425 \fi
426 \endinput
427 %    \end{macrocode}
428 %\begin{thebibliography}{}
429 %\bibitem[\citeauthoryear{Bisogni~Jr and Arroyo}{1991}]{BJA91}%
430 %J.J. Bisogni~Jr and S.L. Arroyo.
431 %\newblock The effect of carbon dioxide equilibrium on p{H} in dilute lakes.
432 %\newblock {\em Water Research}, 25(2):185--190, 1991.
433 %\end{thebibliography}
434 %\PrintIndex   
435 %\end{article}
436 %\end{document}
437 % end of kluref.sty
438
439
440
441