]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/papers/matita/klusec.sty
ported to kluwer style
[helm.git] / helm / papers / matita / klusec.sty
diff --git a/helm/papers/matita/klusec.sty b/helm/papers/matita/klusec.sty
new file mode 100644 (file)
index 0000000..d1e4594
--- /dev/null
@@ -0,0 +1,625 @@
+%
+%
+\ifcat a\noexpand @\let\next\relax\else \def\next{%
+\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
+\def\filedate{1998/03/13}
+\def\filename{klusec.sty}
+%\changes{1997/07/13}{Inserted mainmatter switch}{}
+%\changes{1997/07/13}{Inserted tocentry in theindex}{}
+%\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}
+%\CodelineIndex         
+%\changes{1997/02/12}{TH: added a space after 'partname'.}{}
+%\newcommand{\Bs}{$\backslash$}
+%\parindent=0pt
+%\parskip=3pt
+%\hfuzz=10pt
+%\MakeShortVerb{\|}
+%\setlength\marginparwidth{0pt}
+%\addtolength{\textwidth}{4pc}
+%\begin{document}
+%\begin{opening}
+%\title{\filename}
+%\runningtitle{\filename\ -- \filedate}
+%\date{\filedate}
+%\author{Kluwer Academic Publishers}
+%\runningauthor{Kluwer Academic Publishers}
+%\institute{~}
+%\begin{abstract}
+%This internal stylefile  defines all sectioning commands used by
+%all kluwer style files. In order to facilitate usage by different
+%stylefiles, most command herein are parameterised. 
+%There is an option to include a definition for \verb!\chapter!
+%(|chapter|).
+%\end{abstract}
+%\end{opening}
+%\tableofcontents
+%\newpage
+%\section{Interface}
+%All `ordinary' sectioning command such as |\section| |\subsection| etc.
+%Have the following macros defined:
+%
+%\begin{tabular}{ll}
+%\Bs{\it X}hang       & (1arg)\\
+%\Bs{\it X}spaceabove\\
+%\Bs{\it X}spaceafter \\
+%\Bs{\it X}flushstyle\\
+%\Bs{\it X}numstyle\\
+%\Bs{\it X}textstyle\\
+%\Bs{\it X}case       & (1arg)
+%\end{tabular}
+
+%Where {\it X} is one of the following:
+
+%\begin{tabular}{ll}
+%C   &chapter\\
+%S   &section\\
+%SS  &subsection\\
+%SSS &subsubsection\\
+%P   &paragraph\\
+%SP  &subparagraph
+%\end{tabular}
+
+%\begin{itemize}
+%\item
+%The {\it X}hang macro encapsulates the number and the separating
+%space. In the default
+%configuration, for instance, |\SShang| sets hanging indentation
+%for the subsection title to the width of the number, resulting in 
+%sections looking like this:
+
+%\end{itemize}
+%\subsection{This is a very long example of an otherwise quite 
+%    ordinary section. I stretched it a lot so you can see the
+%   runover..... }
+%\begin{itemize}
+%\item
+%This is implemented by this line:
+
+%\begin{verbatim}
+%\newcommand{\SShang}[1]{\Forcedhang{#1}}
+%\end{verbatim}
+
+%where the macro \Bs Forcedhang calculates the needed \Bs hangafter. 
+%Another use for this macro could be:
+
+%\begin{verbatim}
+%\renewcommand{\Shang}[1]{\charkern{#1}} 
+%\end{verbatim}
+
+%To get spaced out numbering (somewhat trivial example) or 
+
+%\begin{verbatim}
+%\renewcommand{\Shang}[1]{}
+%\end{verbatim}
+%To force  |\section*| like layout.
+
+%\item
+%\Bs{\it X}spaceabove is a skip value in the vertical direction. 
+%e.g.\\ |\renewcommand{\Pspaceabove}{.5\baselineskip}|
+
+%\item
+%\Bs{\it X}spaceafter is a `real' macro, that is supposed to typeset
+%either a horizontal or a vertical skip. However, this macro can do
+%anything:\\ |\renewcommand{\Pspaceafter}{\hskip 1em}|  
+
+%\item
+%\Bs{\it X}flushstyle is for |\centering| etc.
+
+%\item
+%\Bs{\it X}numstyle and \Bs{\it X}textstyle control things like 
+%sizes and fontshape. These two and \Bs{\it X}flushstyle are inside the
+%same group, so there is no need to define things like |\bfseries|
+%twice in a row.
+
+%\item
+%\Bs{\it X}case behaves identical to \Bs{\it X}hang, but it braces
+%the text of the sectioning command.
+%\end{itemize}
+% \section{Considerations}
+%The following need extra attention:
+%\begin{itemize}
+%\item 
+%|\part|, |\chapter| and |\index| set |\thispagestyle| to the pagestyle with 
+%the same name. This needs to be taken care of in |kluopen.sty| of the 
+% stylefile. This file (\filename) simply |\let|'s them all to |empty|.
+%\item
+%|\sectioncmd| is either  |\section| or |\chapter|. This is more efficient
+% than doing everything twice. The stylefile has to set this like this:\\
+%|\AtBeginDocument{\let\sectioncmd\section}|, or it will fail.
+%
+%\item 
+%|\@secnumdepth| works, for the first time in  any kluwer stylefile that I 
+%know of. It's default value is 4, so only |\subparagraph| does NOT have a
+%section number attached.
+%\item |\sectiondot| and |\chapterdot| contain a dot to be typeset after
+%the number of the section$\|$chapter.
+%\end{itemize}
+% \section{Defaults}
+% The following table contains the default values as set in this
+% file. 
+%
+%{\little
+%\begin{tabular}{llllllll} \hline
+%Type&spaceabove&spacebelow&flushstyle&numstyle&textstyle&hang&case\\ \hline
+%C  &33pt       &vskip 33pt       &centering  &large rm &- &-&-\\
+%S  &2bs+6pt-4pt&vskip 1bs+3pt-2pt&centering  &bf       &- &Forcedhang&-\\
+%SS &1bs+3pt-2pt&vskip 1bs+3pt-2pt&raggedright&rm       &sc&Forcedhang&-\\
+%SSS&1bs+3pt-2pt&vskip 1sp        &raggedright&rm       &it&Forcedhang&-\\
+%P  &1bs+3pt-2pt&hskip .5em       &-         &rm        &it&-&-\\
+%SP &1bs+3pt-2pt&hskip .5em       &-         &rm        &it&-&-\\ \hline
+%\end{tabular}
+%
+% bs = |\baselineskip|
+%}
+% \section{Implementation}  
+%     \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{klusec}[\filedate ]
+\newif\if@chapterdef  \@chapterdeffalse
+\DeclareOption{chapter}{\@chapterdeftrue }
+\ExecuteOptions{}
+\ProcessOptions
+%    \end{macrocode}
+%\newpage\subsection{Part}
+% Definition of |\part|. Not much work is done on this, because it is
+% not used this often, and fairly easy to circumvent (if needed).
+%    \begin{macrocode}
+\newcommand{\part}{%
+  \cleardoublepage
+  \thispagestyle{part}%
+  \hbox{}\vskip 2in
+  \secdef\@part\@spart}
+\def\@part[#1]#2{%
+  \ifnum \c@secnumdepth >-2\relax
+    \refstepcounter{part}%
+    \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
+  \else
+    \addcontentsline{toc}{part}{#1}%
+  \fi
+  \imarkboth{}{}%
+  {\centering
+    \ifnum \c@secnumdepth >-2\relax
+      \huge\bf \partname\ \thepart
+      \par
+      \vskip 20pt 
+    \fi
+    \Huge \bf #1\par
+  }%
+  \@endpart
+  }
+
+\def\@spart#1{{\centering\Huge \bf #1\par}\@endpart}
+\def\@endpart{\vfil\cleardoublepage}                       
+\def\partname{Part}
+\let\ps@part\ps@empty
+%
+%    \end{macrocode}
+%\newpage\subsection{Chapter}
+%    \begin{macrocode}
+               
+\if@chapterdef
+
+  %
+  % Typeset text and number. 
+  %
+  \newcommand{\@makechapterhead}[2]{\vspace*{\Cspaceabove}%
+    {\parindent 0pt \hyphenpenalty 10000
+     \Cflushstyle \Cnumstyle
+     \Chang{#1}%
+     \Ctextstyle \Ccase{#2}\par
+     \nobreak \Cspaceafter \relax
+    }}
+
+  \newcommand{\chapter}{%
+%    \end{macrocode}
+%
+% openright will be handled by the stylefile
+%
+%    \begin{macrocode}
+    \if@openright
+        \cleardoublepage 
+    \else
+       \clearpage
+    \fi
+    \thispagestyle{chapter}%
+    \global\@topnum\z@
+    \@afterindentfalse 
+    \secdef\@chapter\@schapter
+    }
+  \def\@chapter[#1]#2{%
+    \ifnum \c@secnumdepth >\m@ne
+      \refstepcounter{chapter}%
+      \message{\@chapapp\space\thechapter\chapterdot}%
+      \addcontentsline{toc}{chapter}{\protect
+        \numberline{\thechapter}#1}%
+    \else
+      \addcontentsline{toc}{chapter}{#1}%
+    \fi
+    \chaptermark{#1}%
+    \addtocontents{lof}{\protect\addvspace{10pt}}%
+    \addtocontents{lot}{\protect\addvspace{10pt}}%
+    \@makechapterhead{\thechapter\chapterdot\ }{#2}% 
+    \@afterheading
+    }
+  \newcommand{\@schapter}[1]{\@makechapterhead{}{#1} \@afterheading}
+  \newcommand{\Chang}[1]{#1}
+  \newcommand{\Cspaceabove}{33pt}
+  \newcommand{\Cspaceafter}{\vskip 33pt}
+  \newcommand{\Cflushstyle}{\centering} 
+  \newcommand{\Cnumstyle}{\large\rm}
+  \newcommand{\Ctextstyle}{}
+  \newcommand{\Ccase}[1]{#1}
+  \newcommand{\@chapapp}{\chaptername}
+  \newcommand{\chapterdot}{.}
+  \let\ps@chapter\ps@empty
+\fi                    
+%    \end{macrocode}
+%\newpage\subsection{Utility macro's}
+% 
+% The |\@haveatleast| is (loosely) borrowed from the \TeX Book. Because
+% of it's implementation, it will do `raggedbottom'-like things to pages,
+% but the other option turned out to be worse. A page optimizer would come
+% very handy indeed! The penalty is rather high, because we'd rather borrow 
+% some whitespace from the rest of the page.
+% \changes{1997/07/13}{Change of policy: penalty is 0 now}{}
+% \changes{1997/07/13}{nobreak inserted between box and glue}{}
+%    \begin{macrocode}
+\newcommand{\vsecspace}[1]{%
+   \if@nobreak\else
+     \vskip #1\relax \fi}
+\def\Shaveatleast{5\baselineskip}
+\def\SShaveatleast{4\baselineskip}
+\def\SSShaveatleast{4\baselineskip}
+\newcommand{\@haveatleast}[1]{\relax\par \vskip #1 
+     \penalty 0\vskip -#1 \relax }
+\def\@Xsect{%
+    \global\@nobreakfalse
+    \global\@noskipsectrue
+    \everypar{\setbox0\lastbox
+      \global\@noskipsecfalse
+      \begingroup \@Svsechd \endgroup 
+      \everypar{}%
+     }}
+%    \end{macrocode}
+%|\Forcedhang| is named after it's normal usage. However, it is a bit more  
+% general than that, so maybe it will move to some other place eventually.
+% Typesets its argument and sets the current paragraph's |\hangafter| to
+% be the width of the argument.
+%    \begin{macrocode}
+\newcommand{\Forcedhang}[1]{\leavevmode
+    \setbox0=\hbox{#1}\hangindent\wd0
+    \hangafter=1 \box0 }
+%    \end{macrocode}
+%    \begin{macrocode}
+\def\contentsname{Table of Contents}%
+\def\listfigurename{List of Figures}%
+\def\listtablename{List of Tables}%
+\def\chaptername{Chapter}%
+\def\sectionname{Section}%
+\def\appendixname{Appendix}%
+%    \end{macrocode} 
+%\newpage\subsection{Section}
+%    \begin{macrocode}
+\newcommand{\@makesectionhead}[2]{\vsecspace{\Sspaceabove}%
+  {\parindent0pt \hyphenpenalty=10000 \baselineskip12pt
+   \Sflushstyle \Snumstyle                   
+   \Shang{#1}%
+   \Stextstyle \Scase{#2}\par
+   \nobreak \Sspaceafter \relax 
+   }}
+
+\newcommand{\section}{\@haveatleast{\Shaveatleast
+    }\@afterindentfalse \secdef\@section\@ssection}
+
+\def\@section[#1]#2{%
+  \ifnum \c@secnumdepth >\z@
+    \refstepcounter{section}%
+    \addcontentsline{toc}{section}{\protect \numberline{\thesection}#1}%
+  \else
+    \addcontentsline{toc}{section}{#1}%
+  \fi
+  \sectionmark{#1}%
+  \@makesectionhead{\thesection\sectiondot\hskip 0.7em}{#2}%
+  \@afterheading
+  }
+
+\def\@ssection#1{\@makesectionhead{}{#1}\@afterheading}
+
+\newcommand{\Shang}[1]{\Forcedhang{#1}}
+\newcommand{\Sflushstyle}{\centering}
+\newcommand{\Snumstyle}{\normalsize\bf}
+\newcommand{\Stextstyle}{}
+\newcommand{\Sspaceabove}{2\baselineskip plus6pt minus4pt}
+\newcommand{\Sspaceafter}{\vskip 1\baselineskip plus3pt minus2pt}
+\newcommand{\Scase}[1]{#1}
+\newcommand{\sectiondot}{.}
+%    \end{macrocode}
+%\newpage\subsection{Subsection}
+%    \begin{macrocode}
+\newcommand{\@makesubsectionhead}[2]{\vsecspace{\SSspaceabove}% 
+  {\parindent0pt \hyphenpenalty=10000 \baselineskip12pt
+   \SSflushstyle \SSnumstyle
+   \SShang{#1}%
+   \SStextstyle \SScase{#2}\par
+   \nobreak \SSspaceafter \relax
+   }}
+
+\newcommand{\subsection}{\@haveatleast{\SShaveatleast}%
+  \@afterindentfalse \secdef\@subsection\@ssubsection
+  }
+
+\def\@subsection[#1]#2{%
+  \ifnum \c@secnumdepth >\@ne
+    \refstepcounter{subsection}%
+    \addcontentsline{toc}{subsection}{\protect
+      \numberline{\thesubsection}#1}%
+  \else
+    \addcontentsline{toc}{subsection}{#1}%
+  \fi
+  \subsectionmark{#1}
+  \@makesubsectionhead{\thesubsection\sectiondot\hskip 0.7em}{#2}%
+  \@afterheading
+  }
+\def\@ssubsection#1{\@makesubsectionhead{}{#1}\@afterheading}
+
+
+\newcommand{\SShang}[1]{\Forcedhang{#1}}
+\newcommand{\SSflushstyle}{\raggedright}
+\newcommand{\SSnumstyle}{\normalsize\rm}
+\newcommand{\SStextstyle}{\sc}
+\newcommand{\SSspaceabove}{1\baselineskip plus3pt minus2pt}
+\newcommand{\SSspaceafter}{\vskip .8\baselineskip plus2pt minus2pt}
+\newcommand{\SScase}[1]{#1}                           
+%    \end{macrocode}
+%\newpage\subsection{Subsubsection}
+%    \begin{macrocode}
+\newcommand{\@makesubsubsectionhead}[2]{\vsecspace{\SSSspaceabove}%         
+  {\parindent0pt \hyphenpenalty=10000 \baselineskip12pt
+    \SSSflushstyle \SSSnumstyle
+    \SSShang{#1}%
+    \SSStextstyle \SSScase{#2}\par
+    \nobreak \SSSspaceafter \relax
+    }}
+
+\newcommand{\subsubsection}{\@haveatleast{\SSShaveatleast
+    }\@afterindentfalse 
+  \secdef\@subsubsection\@ssubsubsection}
+\def\@subsubsection[#1]#2{%
+  \ifnum \c@secnumdepth >2
+    \refstepcounter{subsubsection}
+    \addcontentsline{toc}{subsubsection}{\protect
+       \numberline{\thesubsubsection}#1}%
+  \else
+     \addcontentsline{toc}{subsubsection}{#1}%
+  \fi
+  \subsubsectionmark{#1}
+  \@makesubsubsectionhead{\thesubsubsection\sectiondot\hskip0.7em}{#2}%
+  \@afterheading
+  }
+\def\@ssubsubsection#1{\@makesubsubsectionhead{}{#1}\@afterheading}
+
+\newcommand{\SSShang}[1]{\Forcedhang{#1}}
+\newcommand{\SSSflushstyle}{\raggedright}
+\newcommand{\SSSnumstyle}{\normalsize\rm}
+\newcommand{\SSStextstyle}{\it}
+\newcommand{\SSSspaceabove}{1\baselineskip plus3pt minus2pt}
+\newcommand{\SSSspaceafter}{\vskip 1sp}
+\newcommand{\SSScase}[1]{#1}
+%    \end{macrocode}
+%\newpage\subsection{Paragraph}
+%    \begin{macrocode}
+\newcommand{\@makeparagraphhead}[2]{%
+    \vsecspace{\Pspaceabove }%               
+ \def\@Svsechd{% 
+    {\Pflushstyle \Pnumstyle
+      \Phang{#1}%
+      \Ptextstyle \Pcase{#2}% 
+      \Pspaceafter \relax }}\@Xsect
+     }
+
+\newcommand{\paragraph}{\par \@afterindentfalse 
+  \secdef\@paragraph\@sparagraph }
+
+\def\@paragraph[#1]#2{%
+  \ifnum \c@secnumdepth >3
+    \refstepcounter{paragraph}%
+    \addcontentsline{toc}{paragraph}{\protect
+       \numberline{\theparagraph}#1}%
+  \else
+    \addcontentsline{toc}{paragraph}{#1}%
+  \fi
+  \paragraphmark{#1}%
+  \@makeparagraphhead{\theparagraph\sectiondot\hskip 0.7em}{#2}%
+  }
+\def\@sparagraph#1{\@makeparagraphhead{}{#1}}
+                                            
+\newcommand{\Pspaceabove}{1\baselineskip plus3pt minus2pt}
+\newcommand{\Phang}[1]{#1}
+\newcommand{\Pflushstyle}{}
+\newcommand{\Pnumstyle}{\normalsize\rm}
+\newcommand{\Ptextstyle}{\it}
+\newcommand{\Pcase}[1]{#1}
+\newcommand{\Pspaceafter}{\hskip 1em}
+%    \end{macrocode}
+%\newpage\subsection{Subparagraph}
+%    \begin{macrocode}
+\newcommand{\@makesubparagraphhead}[2]{%
+     \vskip \SPspaceabove
+ \def\@Svsechd{%
+    {\SPflushstyle \SPnumstyle
+      \SPhang{#1}%
+      \SPtextstyle \SPcase{#2}%
+      \SPspaceafter \relax}}\@Xsect
+     }
+\newcommand{\subparagraph}{\par\@afterindentfalse 
+  \secdef\@subparagraph\@ssubparagraph }
+                                       
+\def\@subparagraph[#1]#2{%
+  \ifnum \c@secnumdepth >4
+    \refstepcounter{subparagraph}%
+    \addcontentsline{toc}{subparagraph}{\protect
+       \numberline{\thesubparagraph}#1}%
+  \else
+    \addcontentsline{toc}{subparagraph}{#1}%
+  \fi
+  \paragraphmark{#1}%
+  \@makesubparagraphhead{\thesubparagraph\sectiondot\hskip 0.7em}{#2}%
+  }            
+\def\@ssubparagraph#1{\@makesubparagraphhead{}{#1}}
+
+\newcommand{\SPspaceabove}{1\baselineskip plus3pt minus2pt}
+\newcommand{\SPhang}[1]{}
+\newcommand{\SPflushstyle}{}
+\newcommand{\SPnumstyle}{\normalsize\rm}
+\newcommand{\SPtextstyle}{\it}
+\newcommand{\SPcase}[1]{#1}
+\newcommand{\SPspaceafter}{\hskip 1em}
+%    \end{macrocode}
+%\newpage\subsection{Counters}
+%    \begin{macrocode}
+\newcounter{part}
+\renewcommand{\thepart}{\Roman{part}}
+\if@chapterdef
+  \newcounter{chapter}
+  \renewcommand{\thechapter}{\arabic{chapter}}
+  \newcounter{section}[chapter]
+  \renewcommand{\thesection}{\thechapter.\arabic{section}}
+\else
+  \newcounter{section}
+  \renewcommand{\thesection}{\arabic{section}}
+\fi
+\newcounter{subsection}[section]
+\newcounter{subsubsection}[subsection]
+\newcounter{paragraph}[subsubsection]
+\newcounter{subparagraph}[paragraph]
+\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
+\renewcommand{\thesubsubsection}{\thesubsection.\arabic{subsubsection}}
+\renewcommand{\theparagraph}{\thesubsubsection.\arabic{paragraph}}
+\renewcommand{\thesubparagraph}{\theparagraph.\arabic{subparagraph}}
+%    \end{macrocode}
+%\newpage\subsection{Table of Contents}
+%    \begin{macrocode}
+\def\@pnumwidth{1.55em}
+\def\@tocrmarg{2.55em}
+\def\@dotsep{10000}
+
+\setcounter{tocdepth}{2}
+\setcounter{secnumdepth}{4}
+%    \end{macrocode}
+%The macro |\imarkboth| is defined in |kluopen.sty|, allowing the current
+% pagestyle and/or stylefile to define the meaning.
+%    \begin{macrocode}
+\def\tableofcontents{\sectioncmd *{\contentsname}%
+  \imarkboth{\contentsname}{\contentsname}%
+  \message{\contentsname}%
+  \@starttoc{toc}\newpage}
+\def\listoffigures{\sectioncmd *{\listfigurename}\imarkboth
+  {\listfigurename}{\listfigurename}%
+  \message{\listfigurename}%
+  \@starttoc{lof}}
+\def\listoftables{\sectioncmd *{\listtablename}\imarkboth
+  {\listtablename}{\listtablename}%
+  \message{\listtablename}%
+  \@starttoc{lot}}
+
+\def\l@figure{\@dottedtocline{1}{1.5em}{2.3em}}
+\let\l@table\l@figure
+
+\def\l@part#1#2{%
+  \addpenalty{-\@highpenalty}
+  \addvspace{2.25em plus 1pt}
+  \begingroup
+     \@tempdima 3em
+     \parindent \z@ \rightskip \@pnumwidth
+     \parfillskip -\@pnumwidth
+     {\large \bf
+       \leavevmode
+       #1\hfil \hbox to\@pnumwidth{\hss #2}}\par
+     \nobreak
+     \global\@nobreaktrue
+     \everypar{\global\@nobreakfalse\everypar{}}
+   \endgroup
+   }
+
+\def\l@chapter#1#2{\addpenalty{-\@highpenalty}
+   \vskip 1.0em plus 1pt
+   \@tempdima 1.5em
+   \begingroup
+     \parindent \z@ \rightskip \@pnumwidth
+     \parfillskip -\@pnumwidth
+     \bf
+     \leavevmode
+     \advance\leftskip\@tempdima
+     \hskip -\leftskip
+     #1\nobreak\hfil \nobreak\hbox to\@pnumwidth{\hss #2}\par
+     \penalty\@highpenalty
+   \endgroup
+   }
+
+\def\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
+\def\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
+\def\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
+\def\l@paragraph{\@dottedtocline{4}{10em}{5em}}
+\def\l@subparagraph{\@dottedtocline{5}{12em}{6em}}
+%    \end{macrocode}
+%\newpage   
+%
+%    \begin{macrocode}
+\newif\if@mainmatter \@mainmattertrue
+\if@chapterdef 
+  \newcommand{\appendix}{\par 
+    \@mainmatterfalse
+    \setcounter{chapter}{0}%
+    \setcounter{section}{0}%
+    \renewcommand{\thechapter}{\Alph{chapter}}%
+    \renewcommand{\@chapapp}{\appendixname}%
+    \message{\appendixname}%
+    }
+\else
+  \newcommand{\appendix}{\par
+    \section*{Appendix}%
+    \setcounter{section}{0}%
+    \setcounter{subsection}{0}%
+    \renewcommand{\thesection}{\Alph{section}}%
+    \message{\appendixname}%
+    }
+\fi
+
+\newenvironment{theindex}{%
+  \columnseprule \z@
+  \columnsep \indexsep
+  \if@chapterdef
+    \twocolumn[\@makechapterhead{}{\indexname}]
+    \addcontentsline{toc}{chapter}{\indexname}%
+  \else
+    \twocolumn[\@makesectionhead{}{\indexname}]
+    \addcontentsline{toc}{section}{\indexname}%
+  \fi
+  \imarkboth{\indexname}{\indexname}%
+  \message{\indexname}%
+  \thispagestyle{index}%
+  \parindent\z@
+  \parskip\z@ plus .3pt\relax
+  \let\item\@idxitem \indexfont
+  }{\onecolumn}   
+\def\indexfont{\footnotesize}
+\let\ps@index\ps@empty
+\def\@idxitem{\par\hangindent 36pt}
+\def\subitem{\par\hangindent 36pt \hspace*{12pt}}
+\def\subsubitem{\par\hangindent 36pt \hspace*{24pt}}
+\def\indexspace{\par \vskip 10pt plus 5pt minus 3pt\relax}
+\def\indexsep{24pt}
+\endinput
+%    \end{macrocode}
+%\PrintIndex
+%\end{document}
+% end of klusec.sty
+
+
+
+