]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/klumath.sty
ocaml 3.09 transition
[helm.git] / helm / papers / matita / klumath.sty
1 %
2 %
3 \ifcat a\noexpand @\let\next\relax\else \def\next{%
4 \documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
5 \def\filedate{1998/03/13}
6 \def\filename{klumath.sty}
7 %\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
8 %\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
9 %\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\refstepcounter}
10 %\DoNotIndex{\normalsize,\numberline,\protect,\endinput}
11 %\DoNotIndex{\@compare,\ifx,\global}
12 %\CodelineIndex
13 %\newcommand{\Bs}{$\backslash$}
14 %\parindent=0pt
15 %\parskip=3pt
16 %\hfuzz=10pt
17 %\MakeShortVerb{\|}
18 %\setlength{\marginparwidth}{0in}
19 %\addtolength{\textwidth}{4pc}
20 %\begin{document}
21 %\begin{opening}
22 %\title{\filename}
23 %\date{\filedate}
24 %\author{T. \surname{Hoekwater}}
25 %\institute{Kluwer Academic Publishers}
26 %\begin{abstract}
27 % The math environments |varequation| and |subequation|, and the
28 % |mathsec| and |mathchap| options have been moved here. 
29 % These are  intended for large articles or books.
30 %
31 % This package also implements theorem-like environment
32 % support. There is one option: |thms|, which also defines the
33 % theorems, instead of just controlling layout for user defined
34 % theorems. This option is only supplied for backward compatibility,
35 % use is deprecated.   
36 %\end{abstract} 
37 %\end{opening}
38 %\tableofcontents
39 %\newpage\section{Usage notes}
40 %\subsection{Math environments}
41 % Two environments are defined to use with equations: |varequation|
42 % and\\ |subequation|. 
43 %
44 %  For |varequation|, there is one argument needed to be typeset as the
45 %  `equation counter'. Usage example: 
46 %\begin{verbatim}
47 %\begin{varequation}{A.345}
48 %...  
49 %\end{varequation}
50 %\end{verbatim}
51 %results in: 
52 %\begin{varequation}{A.345}
53 %...  
54 %\end{varequation}
55 % This environment does not step the equation counter.
56
57 % For |subequation|,
58 % there is one {\it optional\/} argument, that allows selecting the formatted
59 % layout of the added part of the equation number. Example usage:
60 %\begin{verbatim}
61 %\begin{subequation}[alph] % this is also the default value
62 %\begin{equation}
63 %...    
64 %\end{equation}
65 %\end{subequation}
66 %\end{verbatim}  
67 %
68 % There are four package options, namely:
69 % \begin{itemize}
70 % \item[leqno] For equation numbers on the left.
71 % \item[fleqn] For flush left equations.
72 %\item[mathsec] For numbering within sections.
73 %\item[mathchap] For numbering within chapters. 
74 % (make sure the chapter counter is defined before you use this one)                                             
75 % \end{itemize}
76 %
77 % There are two user settings:
78 % \begin{itemize}
79 % \item |\mathindent| controls the amount of left indentation of
80 %    equations under |fleqn|. 
81 % \item |\eqnoindent| controls indentation for equation numbers. 
82 % This only makes sense when used together with flush left equations, in 
83 % which case it will move the equation counter from the right side to 
84 % the left, with the specified indentation from the margin.                                                                     
85 %                                                         
86 % \end{itemize}
87 %
88 % \subsection{Theorems}
89 % This part of the stylefile is a bit strange, because it doesn't really do
90 % much. For the theorem part, all it does is redefining the internal
91 % \LaTeX\ command from |\newtheorem| to recognize some common
92 % strings. Then it tries to extract meaning from the string it has
93 % found, and typesets the entire theorem accordingly. 
94 %
95 % All this has the following effect: If you define something like 
96 %\begin{verbatim}
97 %\newtheorem{thm}{THEOREM}[subsubsection] 
98 %\end{verbatim}
99 % It will still be typeset according to the rules defined in the
100 % stylefile you're using, regardless of the environment name and the
101 % used counter. 
102 %
103 % At this time, the following ``names'' are recognized: 
104 %
105 %\begin{tabular}{lllll} \hline
106 %THEOREM & COROLLARY & LEMMA & CLAIM\\
107 %ALGORITHM & DEFINITION & EXAMPLE & REMARK\\
108 %PROBLEM & CONJECTURE & PROPOSITION & \\[6pt]
109 %Remark & Note & Summary & Case & Criterion\\ \hline
110 %\end{tabular}
111 %
112 % The case distinction is significant here, so please note that
113 % |REMARK| and |Remark| are typeset differently.
114 %
115 % \subsection{Proof environments}
116 %
117 % The stylefile defines the environments |pf|  and |pf*| for use in
118 % proofs. |pf*| requires one argument, to be used as the `name' of the
119 % proof. Example usage:
120 %\begin{verbatim}
121 %\begin{thm}
122 %......  
123 %\end{thm}
124 %\begin{pf*}{Proofs}  
125 %....
126 %\end{pf*}\qed
127 %\end{verbatim}
128 %\begin{pf*}{Proofs}  
129 %....
130 %\end{pf*}\qed
131 % |\qed| Typesets an open box on the right margin.
132 %
133 %\newpage\section{Implementation}
134 %    \begin{macrocode}
135 \NeedsTeXFormat{LaTeX2e}
136 \ProvidesPackage{klumath}[\filedate ]
137 \DeclareOption{leqno}{\AtEndOfPackage{\varleqno}}                       
138 \DeclareOption{fleqn}{\AtEndOfPackage{\varfleqn}}      
139 \DeclareOption{mathsec}{%
140    \def\theequation{\arabic{section}.\arabic{equation}}}
141 \DeclareOption{mathchap}{%
142    \def\theequation{\arabic{chapter}.\arabic{equation}}}
143 \newif\if@thms \@thmsfalse
144 \DeclareOption{thms}{\@thmstrue } 
145 \DeclareOption{secthm}{\AtEndOfPackage{\if@thms
146     \renewcommand{\thethm}{\thesection.\arabic{thm}.}%
147     \renewcommand{\thecrit}{\thesection.\arabic{crit}.}%            
148     \renewcommand{\therem}{\thesection.\arabic{rem}.}%
149     \renewcommand{\theNote}{\thesection.\arabic{Note}.}%
150     \renewcommand{\thesumm}{\thesection.\arabic{summ}.}%
151     \renewcommand{\thecase}{\thesection.\arabic{case}.}%
152     \fi
153     }}                    
154 \ExecuteOptions{}
155 \ProcessOptions 
156 %    \end{macrocode}
157 % \subsection{Math environments} 
158 % First off is |varequation|. Doesn't step any counters, and it has one
159 % argument to define the `equationnumber' to be used.  The option
160 % |\eqnoindent| allows fooling around with the location of the number.
161
162 %    \begin{macrocode}
163 \newdimen\eqnoindent
164 \eqnoindent=0pt
165 \def\varequation#1{$$ \gdef\curr@vareq{#1}}
166 \def\endvarequation{\eqno \var@eqnnum $$\global\@ignoretrue }
167 \def\var@eqnnum{\reset@font\normalcolor  (\curr@vareq)}
168 %    \end{macrocode}
169 %
170 %    \begin{macrocode}
171 \def\varleqno{%
172    \def\@eqnnum{\hbox to .01\p@{}%
173      \rlap{\reset@font\rmfamily\normalcolor
174      \hskip -\displaywidth (\theequation)}}%
175    \def\var@eqnnum{\hbox to .01\p@{}%
176      \rlap{\reset@font\rmfamily\normalcolor
177      \hskip -\displaywidth (\curr@vareq)}}%
178 }%
179 %    \end{macrocode}      
180 % For |fleqn|, |varequation| has to be redefined, because it uses a
181 % trivlist.
182 %    \begin{macrocode}                                  
183 \def\varfleqn{%
184   \newdimen\mathindent
185   \mathindent\leftmargini
186   \def\varequation##1{%
187     \@beginparpenalty\predisplaypenalty
188     \@endparpenalty\postdisplaypenalty                  
189     \gdef\curr@vareq{##1}\trivlist 
190     \item[]\leavevmode
191     \hbox to\linewidth\bgroup $ \displaystyle              
192     \hskip\mathindent }%
193   \def\endvarequation{$\hfil \displaywidth\linewidth 
194     \ifdim \eqnoindent =\z@ 
195        \llap{\hbox{\var@eqnnum}}%
196      \else                                
197        \llap{\hbox to 2pc{\var@eqnnum\hss}\kern \displaywidth
198         \kern -\eqnoindent}%
199      \fi
200      \egroup  \endtrivlist}%
201 %
202   \def\[{\relax \ifmmode\@badmath
203          \else \trivlist 
204          \@beginparpenalty\predisplaypenalty
205          \@endparpenalty\postdisplaypenalty
206          \item[]\leavevmode
207          \hbox to\linewidth\bgroup $\m@th\displaystyle %$
208          \hskip\mathindent\bgroup \fi}%
209   \def\]{\relax \ifmmode \egroup $\hfil \egroup \endtrivlist % $
210          \else \@badmath \fi }%
211 %
212   \renewenvironment{equation}%
213     {\@beginparpenalty\predisplaypenalty
214      \@endparpenalty\postdisplaypenalty
215      \refstepcounter{equation}%
216      \trivlist \item[]\leavevmode
217        \hbox to\linewidth\bgroup $\m@th% $
218          \displaystyle
219          \hskip\mathindent}%
220         {$\hfil % $
221          \displaywidth\linewidth
222     \ifdim \eqnoindent =\z@ 
223        \llap{\hbox{\@eqnnum}}%
224      \else
225        \llap{\hbox to 2pc{\@eqnnum\hss}\kern \displaywidth
226         \kern -\eqnoindent}%
227      \fi
228        \egroup
229      \endtrivlist}%
230 %
231   \renewenvironment{eqnarray}{%
232     \stepcounter{equation}%
233     \def\@currentlabel{\p@equation\theequation}%
234     \global\@eqnswtrue\m@th
235     \global\@eqcnt\z@
236     \tabskip\mathindent
237     \let\\=\@eqncr
238     \setlength{\abovedisplayskip}{\topsep}%
239     \ifvmode
240       \addtolength{\abovedisplayskip}{\partopsep}%
241     \fi
242     \addtolength{\abovedisplayskip}{\parskip}%
243     \setlength{\belowdisplayskip}{\abovedisplayskip}%
244     \setlength{\belowdisplayshortskip}{\abovedisplayskip}%
245     \setlength{\abovedisplayshortskip}{\abovedisplayskip}%
246     $$\everycr{}\halign to\linewidth% $$
247     \bgroup
248       \hskip\@centering
249       $\displaystyle\tabskip\z@skip{####}$\@eqnsel&%
250       \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${####}$\hfil&%
251       \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
252         $\displaystyle{####}$\hfil \tabskip\@centering&%
253       \global\@eqcnt\thr@@
254            \llap \bgroup 
255           \ifdim \eqnoindent =\z@ \else
256          \hbox to 2pc \bgroup \fi 
257               ####\ifdim \eqnoindent =\z@ 
258               \egroup \else \hss\egroup\kern \displaywidth
259         \kern -\eqnoindent\egroup
260      \fi \tabskip\z@skip\cr}%
261       {\@@eqncr
262     \egroup
263     \global\advance\c@equation\m@ne$$% $$
264     \global\@ignoretrue
265     }}                   
266 %    \end{macrocode}
267 % |subequation| is a lot smarter, it implements subnumbering by
268 % moving the current value of the |equation| counter to a fixed place,
269 % then resets |equation| and restarts numbering. 
270 %
271 %  Now the equation number consists of the `fixed' part and the
272 %  updated new part. 
273 %
274 %    \begin{macrocode}
275 \def\subequation{\@ifnextchar[{\@subequation}{\@subequation[alph]}}
276 \def\@subequation[#1]{\refstepcounter{equation}%
277 %    \end{macrocode}
278 % |\@testoption| is needed because we would like to have 
279 % $$\hfill (1.1)$$
280 % with a dot, but 
281 %$$\hfill (1a)$$ without.  
282
283 %    \begin{macrocode}
284   \def\@testoption{arabic}%
285   \def\@testparam{#1}%
286   \begingroup
287 %    \end{macrocode}
288 % Save old values
289 %    \begin{macrocode}
290   \edef\old@equation{\the\c@equation}%
291   \edef\old@theequation{\theequation}%
292   \setcounter{equation}{0}%
293 %    \end{macrocode}
294 % If the optional arg. == arabic; typeset a dot in between.
295 %    \begin{macrocode}
296   \ifx\@testoption\@testparam
297     \def\theequation{\old@theequation.\csname #1\endcsname{equation}}
298   \else
299     \def\theequation{\old@theequation\csname #1\endcsname{equation}}
300   \fi}
301 %    \end{macrocode}
302 % Restore old values
303 %    \begin{macrocode}
304 \def\endsubequation{%
305   \setcounter{equation}{\old@equation}%
306   \endgroup
307   \global\@ignoretrue}
308 %    \end{macrocode}
309 %\section{Theorems}
310 % \subsection{Fixed macros}
311 %    \begin{macrocode}
312 \newif\if@novspace
313 \let\@thmscase\uppercase
314 \newdimen\theoremsep
315 \theoremsep\z@
316 \def\thmdot{.}
317 \def\@stylehead{\rm }
318 \def\@styletext{\em }
319 \let\@dispcase\relax  
320 \newdimen\dispsep
321 \dispsep\parindent
322 \def\dispdot{.}
323 \def\@disphead{\it }
324 \def\@disptext{\rm }
325 %    \end{macrocode}
326 % Definition of the |pf| and |pf*| environments. These take into
327 % account the value of |\if@novspace| that is set by the theorem-like
328 % environments. 
329 %    \begin{macrocode} 
330 \def\newproof#1#2{% 
331   \expandafter\def\csname #1\endcsname{\par
332     \if@novspace \vskip-\lastskip
333     \else \addvspace{1\baselineskip 
334             \@plus 0.5\baselineskip \@minus 0.1\baselineskip}%
335     \fi \indent
336     {\it #2.\/} \ignorespaces }%
337    \expandafter\def\csname end#1\endcsname
338    {\par \addvspace{1\baselineskip \@plus 0.5\baselineskip \@minus 
339         0.1\baselineskip}%
340     \global\@novspacefalse
341     }}
342 \newproof{pf}{Proof}
343
344 %    \end{macrocode}
345 % |pf*| has an argument that allow on-the-spot redefinition of
346 % |\proofname|. 
347 %    \begin{macrocode}
348 \@namedef{pf*}#1{\par
349                  \begingroup
350                  \def\proofname{#1}\pf
351                  \endgroup
352                  \ignorespaces}
353 \@namedef{endpf*}{\endpf}
354 %    \end{macrocode}
355 % |\qed| takes into account whether it is called during math mode or
356 % text mode. This is important because outside of math mode there will
357 % usually be a line to much in the output.
358 %    \begin{macrocode}
359 \def\qed{\relax
360      \ifmmode
361        ~\hfill\Box
362      \else
363         \unskip\nobreak ~\hfill$\Box$%
364       \fi \par}
365 %    \end{macrocode}
366 %|\@begintheorem| and |\@opargbegintheorem| do the real work.  Both
367 %have roughly the same layout: 
368 %    \begin{macrocode}
369 \def\@begintheorem#1#2{\trivlist  
370     \global\@novspacetrue \itemindent\theoremsep 
371      \item[\kern\labelsep 
372      {\@stylehead\@thmscase{#1}\ #2\thmdot\/}]\ \@styletext}
373 \def\@opargbegintheorem#1#2#3{\trivlist \labelsep\z@  
374       \global\@novspacetrue \itemindent\theoremsep 
375       \item[\kern \labelsep {\@stylehead\@thmscase{#1}\ #2\thmdot\ 
376       (#3). \/}]\ \@styletext}
377 \def\@endtheorem{\endtrivlist}     
378 \def\rmtheorem#1{% 
379     \expandafter\g@addto@macro\csname #1\endcsname{\rmfamily\upshape }%
380     }
381 %    \end{macrocode}
382 %
383 % |\newdisplay|.
384 %
385 % This is taken from |ltthm.dtx|. It echoes the redefinitions
386 % for theorems. 
387 %    \begin{macrocode} 
388 \def\newdisplay#1{\@ifnextchar[{\@odisp{#1}}{\@ndisp{#1}}}
389 \def\@ndisp#1#2{%
390   \@ifnextchar[{\@xndisp{#1}{#2}}{\@yndisp{#1}{#2}}}
391 \def\@xndisp#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
392   {\@definecounter{#1}\@newctr{#1}[#3]%                     
393       \expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
394         \csname the#3\endcsname \@dispcountersep \@dispcounter{#1}}%
395 \global\@namedef{#1}{%
396   \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
397 \def\@yndisp#1#2{\expandafter\@ifdefinable\csname #1\endcsname
398 {\@definecounter{#1}%
399 \expandafter\xdef\csname the#1\endcsname{\@dispcounter{#1}}%
400 \global\@namedef{#1}{%
401   \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
402 \def\@odisp#1[#2]#3{%
403   \@ifundefined{c@#2}{\@nocounterr{#2}}%
404   {\expandafter\@ifdefinable\csname #1\endcsname
405   {\global\@namedef{the#1}{\@nameuse{the#2}}%
406 \global\@namedef{#1}{\@disp{#2}{#3}}%
407 \global\@namedef{end#1}{\@enddisplay}}}}
408 \def\@disp#1#2{\refstepcounter         
409     {#1}\@ifnextchar[{\@ydisp{#1}{#2}}{\@xdisp{#1}{#2}}}
410 \def\@xdisp#1#2{\@begindisplay{#2}{\csname the#1\endcsname}\ignorespaces}
411 \def\@ydisp#1#2[#3]{\@opargbegindisplay{#2}{\csname
412        the#1\endcsname}{#3}\ignorespaces}
413 \def\@dispcounter#1{\noexpand\arabic{#1}}
414 \def\@dispcountersep{.}
415 \def\@begindisplay#1#2{\trivlist
416     \global\@novspacefalse \itemindent\dispsep
417         \item[{\@disphead 
418         \@dispcase{#1}\ #2\dispdot \/}]\@disptext}
419 \def\@opargbegindisplay#1#2#3{\trivlist
420       \global\@novspacefalse
421       \itemindent \dispsep
422       \item[{\@disphead \@dispcase{#1}\ #2\dispdot\ 
423       (\@dispcase{#3})\/}]\@disptext}
424 \def\@enddisplay{\endtrivlist}     
425 %    \end{macrocode}
426 %    \begin{macrocode}
427 \if@thms
428   \newtheorem{thm}{THEOREM}
429   \newtheorem{cor}[thm]{COROLLARY} 
430   \newtheorem{lem}[thm]{LEMMA}
431   \newtheorem{claim}[thm]{CLAIM}
432   \newtheorem{conj}[thm]{CONJECTURE}
433   \newtheorem{prop}[thm]{PROPOSITION}
434   \newtheorem{exer}[thm]{EXERCISE}
435   \newtheorem{REM}[thm]{REMARK}
436   \newtheorem{prob}[thm]{PROBLEM}
437   \newtheorem{alg}{ALGORITHM}
438   \rmtheorem{alg}
439   \newtheorem{defn}[thm]{DEFINITION}
440   \rmtheorem{defn}
441   \newtheorem{exmp}[thm]{EXAMPLE}
442   \rmtheorem{exmp}
443   \newdisplay{crit}{Criterion}
444   \newdisplay{rem}{Remark}
445   \newdisplay{Note}{Note}
446   \newdisplay{summ}{Summary}
447   \newdisplay{case}{Case}
448 \fi
449 \arraycolsep = 3pt
450 \endinput
451 %    \end{macrocode}
452 % \IndexParms{\hbadness=10000}
453 %\PrintIndex
454 %\end{document}
455 % end of klumath.sty
456
457
458
459
460
461
462
463