\ProvidesFile{nccbook.clo}
         [2005/06/19 v1.05 Book subclass (NCC)]
%
% \changes{v1.00}{2002/03/24}{This version is uploaded to CTAN}
% \changes{v1.01}{2003/01/12}{Bug in \ChapterPrefixStyle{toc} fixed}
% \changes{v1.02}{2004/12/06}{Replace \NCC@null with \StartFromTextArea}
% \changes{v1.03}{2004/12/12}{Modify part generation commands}
% \changes{v1.04}{2005/03/23}{Remove \skipwritingtoaux in index head}
% \changes{v1.04}{2005/06/08}{Introduce the \DeclarePart command}
% \changes{v1.04}{2005/06/08}{Introduce the \DeclareTOCPart command}
% \changes{v1.05}{2005/06/19}{Page break after \l@part is forbidden}
% \changes{v1.05}{2005/06/19}{New optional parameter in \DeclareTOCPart}
% 
\@addtoreset{footnote}{chapter}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{2}
\def\NCC@tochead#1{\noheadingtag\skipwritingtoaux\chapter{#1}}
\def\NCC@idxhead#1{%
  \twocolumn \noheadingtag\chapter{#1}%
}
%
% \frontmatter, \mainmatter, \backmatter
%
\newif\if@mainmatter \@mainmattertrue
\newcommand\frontmatter{%
  \@mainmatterfalse\pagenumbering{roman}%
}
\newcommand\mainmatter{%
  {\@openrighttrue\openrightorany}%
  \@mainmattertrue
  \pagenumbering{arabic}%
}
\newcommand\backmatter{%
  \openrightorany \@mainmatterfalse
}
%
% Control of appearance chapter name in header and toc:
%
% \ChapterPrefixStyle{header,toc}
%
% The parameter list can contain two words: header and/or toc.
% Using them you set prefix style for header and/or toc respectively.
%
\newcommand{\@chapapp}{\chaptername}
\newcommand*{\ChapterPrefixStyle}[1]{%
  \def\NCC@thetocchapter{\thechapter}%
  \def\NCC@theheadchapter{\thechapter}%
  \@for\@tempa:=#1\do
    {\csname NCC@chapin@\@tempa\endcsname}%
}
\def\NCC@chapin@toc{\def\NCC@thetocchapter{\@chapapp\ \thechapter}}
\def\NCC@chapin@header{\def\NCC@theheadchapter{\@chapapp\ \thechapter}}
\@onlypreamble\ChapterPrefixStyle
\@onlypreamble\NCC@chapin@toc
\@onlypreamble\NCC@chapin@header
\ChapterPrefixStyle{} % no prefix by default
%
% \ps@headings, \ps@myheadings
%
\def\ps@headings{\NCC@setpsheading
  \def\partmark##1{%
    \NCC@firstmark{\ifnum \c@secnumdepth>-2\relax
        \partname\ \thepart.\enskip \fi
      \ignorespaces##1}}%
  \def\chaptermark##1{%
    \NCC@firstmark{\ifnum \c@secnumdepth>\m@ne
         \if@mainmatter \NCC@theheadchapter.\enskip \fi \fi
       \ignorespaces##1}}%
  \def\sectionmark##1{%
    \NCC@secondmark{\ifnum\c@secnumdepth>\z@\thesection.\enskip\fi
      \ignorespaces##1}}%
}  
\def\ps@myheadings{\NCC@setpsheading
  \let\partmark   \@gobble
  \let\chaptermark\@gobble
  \let\sectionmark\@gobble
}
%
% \appendix
%
\newcommand{\appendix}{\par
  \setcounter{chapter}{-1}\stepcounter{chapter}%
  \gdef\@chapapp{\appendixname}%
  \gdef\thechapter{\@Alph\c@chapter}%
}
%
% thebibliography
%
\newenvironment{thebibliography}{%
  \noheadingtag \chapter{\bibname}\biblist[0]%
}{\endbiblist}
%
% Redefine start chapter hook
%
\def\NCC@startchap{%
  \openrightorany
  \thispageheading{}%
  \global\@topnum\z@
}
%
% \DeclarePart{BEFORE}{AFTER}{PREFIX}{STYLE}
%
\newcommand\DeclarePart[4]{%
  \def\part{%
    \openrightorany
    \thispageheading{}%
    \def\NCC@makesectag####1{\leavevmode#3\partname\nobreakspace####1}%
    \secdef\@part\@spart
  }%
  \def\NCC@makepart##1##2{%
    \if@twocolumn  \onecolumn \@tempswatrue \else \@tempswafalse \fi
    \begingroup\normalfont
      #1%
      \ifx\@svsec\@empty \else {\@svsec\par}\nobreak \fi
      \interlinepenalty \@M
      #4{##1}\par
    \endgroup
    ##2#2%
    \if@tempswa \twocolumn \fi
  }
}
\@onlypreamble\DeclarePart
\def\@spart#1{%
  \let\@svsec\@empty
  \NCC@makepart{#1}{}%
  \NCC@sec@reset@controls
  \NCC@defaultsectag
}
\def\@part[#1]#2{%
  \def\NCC@make{\NCC@makepart{#2}}%
  \NCC@makesection{part}{\m@ne}{#1}{%
    \addcontentsline{toc}{part}{%
      \ifnum \c@secnumdepth>-2
        \protect\numberline{\partname\ \thepart}\fi
      #1%
    }%
  }%
  \NCC@defaultsectag
}
%
% \DeclareTOCPart{ACTION}[AFTERSKIP]{PREFIX}{PROTOTYPE}{STYLE}
%
\newcommand*\DeclareTOCPart[1]{%
  \@ifnextchar[{\NCC@dtocpart{#1}}{\NCC@dtocpart{#1}[\NCC@runskip]}%
}
\def\NCC@dtocpart#1[#2]#3#4#5{%
  \def\l@part##1##2{%
    \NCC@tocentry{-1}{%
      \setlength\@tempdimb\@tocrmarg
      \edef\@tocrmarg{\the\@tempdimb plus 1fil}%
      \addpenalty{-\@highpenalty}#1%
    }{#3}{#4}{#5}{##1}{\hss##2}%
    \nobreak \vskip #2\relax
    \@nobreaktrue
    \everypar{\@nobreakfalse\everypar{}}%
  }%
}
\@onlypreamble\DeclareTOCPart
\@onlypreamble\NCC@dtocpart
%
% Defaults
%
\ifNCC@small
  \DeclarePart{\StartFromTextArea\vspace{\stretch{.5}}\centering}
              {\vfill\newpage}{\vspace{1.5em}\Large\bff}{\huge\bff}
\else
  \DeclarePart{\StartFromTextArea\vspace{\stretch{.5}}\centering}
              {\vfill\newpage}{\vspace{2em}\LARGE\bff}{\Huge\bff}
\fi
\DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}\def\@dotsep{1000}}
               {}{\partname\ II}{\large\bff}
\endinput
