]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/papers/matita/klumath.sty
ported to kluwer style
[helm.git] / helm / papers / matita / klumath.sty
diff --git a/helm/papers/matita/klumath.sty b/helm/papers/matita/klumath.sty
new file mode 100644 (file)
index 0000000..9ef1c5c
--- /dev/null
@@ -0,0 +1,463 @@
+%
+%
+\ifcat a\noexpand @\let\next\relax\else \def\next{%
+\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
+\def\filedate{1998/03/13}
+\def\filename{klumath.sty}
+%\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
+%\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
+%\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\refstepcounter}
+%\DoNotIndex{\normalsize,\numberline,\protect,\endinput}
+%\DoNotIndex{\@compare,\ifx,\global}
+%\CodelineIndex
+%\newcommand{\Bs}{$\backslash$}
+%\parindent=0pt
+%\parskip=3pt
+%\hfuzz=10pt
+%\MakeShortVerb{\|}
+%\setlength{\marginparwidth}{0in}
+%\addtolength{\textwidth}{4pc}
+%\begin{document}
+%\begin{opening}
+%\title{\filename}
+%\date{\filedate}
+%\author{T. \surname{Hoekwater}}
+%\institute{Kluwer Academic Publishers}
+%\begin{abstract}
+% The math environments |varequation| and |subequation|, and the
+% |mathsec| and |mathchap| options have been moved here. 
+% These are  intended for large articles or books.
+%
+% This package also implements theorem-like environment
+% support. There is one option: |thms|, which also defines the
+% theorems, instead of just controlling layout for user defined
+% theorems. This option is only supplied for backward compatibility,
+% use is deprecated.   
+%\end{abstract} 
+%\end{opening}
+%\tableofcontents
+%\newpage\section{Usage notes}
+%\subsection{Math environments}
+% Two environments are defined to use with equations: |varequation|
+% and\\ |subequation|. 
+%
+%  For |varequation|, there is one argument needed to be typeset as the
+%  `equation counter'. Usage example: 
+%\begin{verbatim}
+%\begin{varequation}{A.345}
+%...  
+%\end{varequation}
+%\end{verbatim}
+%results in: 
+%\begin{varequation}{A.345}
+%...  
+%\end{varequation}
+% This environment does not step the equation counter.
+% 
+% For |subequation|,
+% there is one {\it optional\/} argument, that allows selecting the formatted
+% layout of the added part of the equation number. Example usage:
+%\begin{verbatim}
+%\begin{subequation}[alph] % this is also the default value
+%\begin{equation}
+%...    
+%\end{equation}
+%\end{subequation}
+%\end{verbatim}  
+%
+% There are four package options, namely:
+% \begin{itemize}
+% \item[leqno] For equation numbers on the left.
+% \item[fleqn] For flush left equations.
+%\item[mathsec] For numbering within sections.
+%\item[mathchap] For numbering within chapters. 
+% (make sure the chapter counter is defined before you use this one)                                             
+% \end{itemize}
+%
+% There are two user settings:
+% \begin{itemize}
+% \item |\mathindent| controls the amount of left indentation of
+%    equations under |fleqn|. 
+% \item |\eqnoindent| controls indentation for equation numbers. 
+% This only makes sense when used together with flush left equations, in 
+% which case it will move the equation counter from the right side to 
+% the left, with the specified indentation from the margin.                                                                     
+%                                                         
+% \end{itemize}
+%
+% \subsection{Theorems}
+% This part of the stylefile is a bit strange, because it doesn't really do
+% much. For the theorem part, all it does is redefining the internal
+% \LaTeX\ command from |\newtheorem| to recognize some common
+% strings. Then it tries to extract meaning from the string it has
+% found, and typesets the entire theorem accordingly. 
+%
+% All this has the following effect: If you define something like 
+%\begin{verbatim}
+%\newtheorem{thm}{THEOREM}[subsubsection] 
+%\end{verbatim}
+% It will still be typeset according to the rules defined in the
+% stylefile you're using, regardless of the environment name and the
+% used counter. 
+%
+% At this time, the following ``names'' are recognized: 
+%
+%\begin{tabular}{lllll} \hline
+%THEOREM & COROLLARY & LEMMA & CLAIM\\
+%ALGORITHM & DEFINITION & EXAMPLE & REMARK\\
+%PROBLEM & CONJECTURE & PROPOSITION & \\[6pt]
+%Remark & Note & Summary & Case & Criterion\\ \hline
+%\end{tabular}
+%
+% The case distinction is significant here, so please note that
+% |REMARK| and |Remark| are typeset differently.
+%
+% \subsection{Proof environments}
+%
+% The stylefile defines the environments |pf|  and |pf*| for use in
+% proofs. |pf*| requires one argument, to be used as the `name' of the
+% proof. Example usage:
+%\begin{verbatim}
+%\begin{thm}
+%......  
+%\end{thm}
+%\begin{pf*}{Proofs}  
+%....
+%\end{pf*}\qed
+%\end{verbatim}
+%\begin{pf*}{Proofs}  
+%....
+%\end{pf*}\qed
+% |\qed| Typesets an open box on the right margin.
+%
+%\newpage\section{Implementation}
+%    \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{klumath}[\filedate ]
+\DeclareOption{leqno}{\AtEndOfPackage{\varleqno}}                       
+\DeclareOption{fleqn}{\AtEndOfPackage{\varfleqn}}      
+\DeclareOption{mathsec}{%
+   \def\theequation{\arabic{section}.\arabic{equation}}}
+\DeclareOption{mathchap}{%
+   \def\theequation{\arabic{chapter}.\arabic{equation}}}
+\newif\if@thms \@thmsfalse
+\DeclareOption{thms}{\@thmstrue } 
+\DeclareOption{secthm}{\AtEndOfPackage{\if@thms
+    \renewcommand{\thethm}{\thesection.\arabic{thm}.}%
+    \renewcommand{\thecrit}{\thesection.\arabic{crit}.}%            
+    \renewcommand{\therem}{\thesection.\arabic{rem}.}%
+    \renewcommand{\theNote}{\thesection.\arabic{Note}.}%
+    \renewcommand{\thesumm}{\thesection.\arabic{summ}.}%
+    \renewcommand{\thecase}{\thesection.\arabic{case}.}%
+    \fi
+    }}                    
+\ExecuteOptions{}
+\ProcessOptions 
+%    \end{macrocode}
+% \subsection{Math environments} 
+% First off is |varequation|. Doesn't step any counters, and it has one
+% argument to define the `equationnumber' to be used.  The option
+% |\eqnoindent| allows fooling around with the location of the number.
+% 
+%    \begin{macrocode}
+\newdimen\eqnoindent
+\eqnoindent=0pt
+\def\varequation#1{$$ \gdef\curr@vareq{#1}}
+\def\endvarequation{\eqno \var@eqnnum $$\global\@ignoretrue }
+\def\var@eqnnum{\reset@font\normalcolor  (\curr@vareq)}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\def\varleqno{%
+   \def\@eqnnum{\hbox to .01\p@{}%
+     \rlap{\reset@font\rmfamily\normalcolor
+     \hskip -\displaywidth (\theequation)}}%
+   \def\var@eqnnum{\hbox to .01\p@{}%
+     \rlap{\reset@font\rmfamily\normalcolor
+     \hskip -\displaywidth (\curr@vareq)}}%
+}%
+%    \end{macrocode}      
+% For |fleqn|, |varequation| has to be redefined, because it uses a
+% trivlist.
+%    \begin{macrocode}                                  
+\def\varfleqn{%
+  \newdimen\mathindent
+  \mathindent\leftmargini
+  \def\varequation##1{%
+    \@beginparpenalty\predisplaypenalty
+    \@endparpenalty\postdisplaypenalty                  
+    \gdef\curr@vareq{##1}\trivlist 
+    \item[]\leavevmode
+    \hbox to\linewidth\bgroup $ \displaystyle              
+    \hskip\mathindent }%
+  \def\endvarequation{$\hfil \displaywidth\linewidth 
+    \ifdim \eqnoindent =\z@ 
+       \llap{\hbox{\var@eqnnum}}%
+     \else                                
+       \llap{\hbox to 2pc{\var@eqnnum\hss}\kern \displaywidth
+        \kern -\eqnoindent}%
+     \fi
+     \egroup  \endtrivlist}%
+%
+  \def\[{\relax \ifmmode\@badmath
+         \else \trivlist 
+         \@beginparpenalty\predisplaypenalty
+         \@endparpenalty\postdisplaypenalty
+         \item[]\leavevmode
+         \hbox to\linewidth\bgroup $\m@th\displaystyle %$
+         \hskip\mathindent\bgroup \fi}%
+  \def\]{\relax \ifmmode \egroup $\hfil \egroup \endtrivlist % $
+         \else \@badmath \fi }%
+%
+  \renewenvironment{equation}%
+    {\@beginparpenalty\predisplaypenalty
+     \@endparpenalty\postdisplaypenalty
+     \refstepcounter{equation}%
+     \trivlist \item[]\leavevmode
+       \hbox to\linewidth\bgroup $\m@th% $
+         \displaystyle
+         \hskip\mathindent}%
+        {$\hfil % $
+         \displaywidth\linewidth
+    \ifdim \eqnoindent =\z@ 
+       \llap{\hbox{\@eqnnum}}%
+     \else
+       \llap{\hbox to 2pc{\@eqnnum\hss}\kern \displaywidth
+        \kern -\eqnoindent}%
+     \fi
+       \egroup
+     \endtrivlist}%
+%
+  \renewenvironment{eqnarray}{%
+    \stepcounter{equation}%
+    \def\@currentlabel{\p@equation\theequation}%
+    \global\@eqnswtrue\m@th
+    \global\@eqcnt\z@
+    \tabskip\mathindent
+    \let\\=\@eqncr
+    \setlength{\abovedisplayskip}{\topsep}%
+    \ifvmode
+      \addtolength{\abovedisplayskip}{\partopsep}%
+    \fi
+    \addtolength{\abovedisplayskip}{\parskip}%
+    \setlength{\belowdisplayskip}{\abovedisplayskip}%
+    \setlength{\belowdisplayshortskip}{\abovedisplayskip}%
+    \setlength{\abovedisplayshortskip}{\abovedisplayskip}%
+    $$\everycr{}\halign to\linewidth% $$
+    \bgroup
+      \hskip\@centering
+      $\displaystyle\tabskip\z@skip{####}$\@eqnsel&%
+      \global\@eqcnt\@ne \hskip \tw@\arraycolsep \hfil${####}$\hfil&%
+      \global\@eqcnt\tw@ \hskip \tw@\arraycolsep
+        $\displaystyle{####}$\hfil \tabskip\@centering&%
+      \global\@eqcnt\thr@@
+           \llap \bgroup 
+          \ifdim \eqnoindent =\z@ \else
+         \hbox to 2pc \bgroup \fi 
+              ####\ifdim \eqnoindent =\z@ 
+              \egroup \else \hss\egroup\kern \displaywidth
+        \kern -\eqnoindent\egroup
+     \fi \tabskip\z@skip\cr}%
+      {\@@eqncr
+    \egroup
+    \global\advance\c@equation\m@ne$$% $$
+    \global\@ignoretrue
+    }}                   
+%    \end{macrocode}
+% |subequation| is a lot smarter, it implements subnumbering by
+% moving the current value of the |equation| counter to a fixed place,
+% then resets |equation| and restarts numbering. 
+%
+%  Now the equation number consists of the `fixed' part and the
+%  updated new part. 
+%
+%    \begin{macrocode}
+\def\subequation{\@ifnextchar[{\@subequation}{\@subequation[alph]}}
+\def\@subequation[#1]{\refstepcounter{equation}%
+%    \end{macrocode}
+% |\@testoption| is needed because we would like to have 
+% $$\hfill (1.1)$$
+% with a dot, but 
+%$$\hfill (1a)$$ without.  
+% 
+%    \begin{macrocode}
+  \def\@testoption{arabic}%
+  \def\@testparam{#1}%
+  \begingroup
+%    \end{macrocode}
+% Save old values
+%    \begin{macrocode}
+  \edef\old@equation{\the\c@equation}%
+  \edef\old@theequation{\theequation}%
+  \setcounter{equation}{0}%
+%    \end{macrocode}
+% If the optional arg. == arabic; typeset a dot in between.
+%    \begin{macrocode}
+  \ifx\@testoption\@testparam
+    \def\theequation{\old@theequation.\csname #1\endcsname{equation}}
+  \else
+    \def\theequation{\old@theequation\csname #1\endcsname{equation}}
+  \fi}
+%    \end{macrocode}
+% Restore old values
+%    \begin{macrocode}
+\def\endsubequation{%
+  \setcounter{equation}{\old@equation}%
+  \endgroup
+  \global\@ignoretrue}
+%    \end{macrocode}
+%\section{Theorems}
+% \subsection{Fixed macros}
+%    \begin{macrocode}
+\newif\if@novspace
+\let\@thmscase\uppercase
+\newdimen\theoremsep
+\theoremsep\z@
+\def\thmdot{.}
+\def\@stylehead{\rm }
+\def\@styletext{\em }
+\let\@dispcase\relax  
+\newdimen\dispsep
+\dispsep\parindent
+\def\dispdot{.}
+\def\@disphead{\it }
+\def\@disptext{\rm }
+%    \end{macrocode}
+% Definition of the |pf| and |pf*| environments. These take into
+% account the value of |\if@novspace| that is set by the theorem-like
+% environments. 
+%    \begin{macrocode} 
+\def\newproof#1#2{% 
+  \expandafter\def\csname #1\endcsname{\par
+    \if@novspace \vskip-\lastskip
+    \else \addvspace{1\baselineskip 
+            \@plus 0.5\baselineskip \@minus 0.1\baselineskip}%
+    \fi \indent
+    {\it #2.\/} \ignorespaces }%
+   \expandafter\def\csname end#1\endcsname
+   {\par \addvspace{1\baselineskip \@plus 0.5\baselineskip \@minus 
+        0.1\baselineskip}%
+    \global\@novspacefalse
+    }}
+\newproof{pf}{Proof}
+
+%    \end{macrocode}
+% |pf*| has an argument that allow on-the-spot redefinition of
+% |\proofname|. 
+%    \begin{macrocode}
+\@namedef{pf*}#1{\par
+                 \begingroup
+                 \def\proofname{#1}\pf
+                 \endgroup
+                 \ignorespaces}
+\@namedef{endpf*}{\endpf}
+%    \end{macrocode}
+% |\qed| takes into account whether it is called during math mode or
+% text mode. This is important because outside of math mode there will
+% usually be a line to much in the output.
+%    \begin{macrocode}
+\def\qed{\relax
+     \ifmmode
+       ~\hfill\Box
+     \else
+        \unskip\nobreak ~\hfill$\Box$%
+      \fi \par}
+%    \end{macrocode}
+%|\@begintheorem| and |\@opargbegintheorem| do the real work.  Both
+%have roughly the same layout: 
+%    \begin{macrocode}
+\def\@begintheorem#1#2{\trivlist  
+    \global\@novspacetrue \itemindent\theoremsep 
+     \item[\kern\labelsep 
+     {\@stylehead\@thmscase{#1}\ #2\thmdot\/}]\ \@styletext}
+\def\@opargbegintheorem#1#2#3{\trivlist \labelsep\z@  
+      \global\@novspacetrue \itemindent\theoremsep 
+      \item[\kern \labelsep {\@stylehead\@thmscase{#1}\ #2\thmdot\ 
+      (#3). \/}]\ \@styletext}
+\def\@endtheorem{\endtrivlist}     
+\def\rmtheorem#1{% 
+    \expandafter\g@addto@macro\csname #1\endcsname{\rmfamily\upshape }%
+    }
+%    \end{macrocode}
+%
+% |\newdisplay|.
+%
+% This is taken from |ltthm.dtx|. It echoes the redefinitions
+% for theorems. 
+%    \begin{macrocode} 
+\def\newdisplay#1{\@ifnextchar[{\@odisp{#1}}{\@ndisp{#1}}}
+\def\@ndisp#1#2{%
+  \@ifnextchar[{\@xndisp{#1}{#2}}{\@yndisp{#1}{#2}}}
+\def\@xndisp#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
+  {\@definecounter{#1}\@newctr{#1}[#3]%                     
+      \expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
+        \csname the#3\endcsname \@dispcountersep \@dispcounter{#1}}%
+\global\@namedef{#1}{%
+  \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
+\def\@yndisp#1#2{\expandafter\@ifdefinable\csname #1\endcsname
+{\@definecounter{#1}%
+\expandafter\xdef\csname the#1\endcsname{\@dispcounter{#1}}%
+\global\@namedef{#1}{%
+  \@disp{#1}{#2}}\global\@namedef{end#1}{\@enddisplay}}}
+\def\@odisp#1[#2]#3{%
+  \@ifundefined{c@#2}{\@nocounterr{#2}}%
+  {\expandafter\@ifdefinable\csname #1\endcsname
+  {\global\@namedef{the#1}{\@nameuse{the#2}}%
+\global\@namedef{#1}{\@disp{#2}{#3}}%
+\global\@namedef{end#1}{\@enddisplay}}}}
+\def\@disp#1#2{\refstepcounter         
+    {#1}\@ifnextchar[{\@ydisp{#1}{#2}}{\@xdisp{#1}{#2}}}
+\def\@xdisp#1#2{\@begindisplay{#2}{\csname the#1\endcsname}\ignorespaces}
+\def\@ydisp#1#2[#3]{\@opargbegindisplay{#2}{\csname
+       the#1\endcsname}{#3}\ignorespaces}
+\def\@dispcounter#1{\noexpand\arabic{#1}}
+\def\@dispcountersep{.}
+\def\@begindisplay#1#2{\trivlist
+    \global\@novspacefalse \itemindent\dispsep
+        \item[{\@disphead 
+        \@dispcase{#1}\ #2\dispdot \/}]\@disptext}
+\def\@opargbegindisplay#1#2#3{\trivlist
+      \global\@novspacefalse
+      \itemindent \dispsep
+      \item[{\@disphead \@dispcase{#1}\ #2\dispdot\ 
+      (\@dispcase{#3})\/}]\@disptext}
+\def\@enddisplay{\endtrivlist}     
+%    \end{macrocode}
+%    \begin{macrocode}
+\if@thms
+  \newtheorem{thm}{THEOREM}
+  \newtheorem{cor}[thm]{COROLLARY} 
+  \newtheorem{lem}[thm]{LEMMA}
+  \newtheorem{claim}[thm]{CLAIM}
+  \newtheorem{conj}[thm]{CONJECTURE}
+  \newtheorem{prop}[thm]{PROPOSITION}
+  \newtheorem{exer}[thm]{EXERCISE}
+  \newtheorem{REM}[thm]{REMARK}
+  \newtheorem{prob}[thm]{PROBLEM}
+  \newtheorem{alg}{ALGORITHM}
+  \rmtheorem{alg}
+  \newtheorem{defn}[thm]{DEFINITION}
+  \rmtheorem{defn}
+  \newtheorem{exmp}[thm]{EXAMPLE}
+  \rmtheorem{exmp}
+  \newdisplay{crit}{Criterion}
+  \newdisplay{rem}{Remark}
+  \newdisplay{Note}{Note}
+  \newdisplay{summ}{Summary}
+  \newdisplay{case}{Case}
+\fi
+\arraycolsep = 3pt
+\endinput
+%    \end{macrocode}
+% \IndexParms{\hbadness=10000}
+%\PrintIndex
+%\end{document}
+% end of klumath.sty
+
+
+
+
+
+
+
+