%%
%% This is file `nccsect.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nccsect.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% This file is a generated file from the sources of the `ncctools'
%% bundle.
%% 
%% You are not allowed to modify this file.
%% 
%% You are allowed to distribute this file if and only if
%% it is distributed with the corresponding source files in
%% the `ncctools' bundle.
%% 
%% For the copying and distribution conditions of the source files,
%% see the README file distributed with the ncctools bundle.
%%
%% File: nccsect.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{nccsect}
         [2006/01/20 v1.6 Extended Section, Caption, and TOC Handling (NCC)]
\RequirePackage{afterpackage}
\@ifpackageloaded{nccthm}{}{%
  \def\NCC@secskip#1{%
    \if@noskipsec \leavevmode \fi \par
    \if@nobreak \everypar{}\else
      \addpenalty\@secpenalty
      \addvspace{#1}%
    \fi
  }
  \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex}
}
\newcommand{\runinsectionskip}{\NCC@secskip{\NCC@runskip}}
\newif\ifNCC@nosectag
\newif\ifNCC@secstartag
\newif\ifNCC@nosecmark
\newif\ifNCC@noaux
\let\NCC@global\global
\def\NCC@sec@reset@controls{%
  \NCC@global\NCC@nosectagfalse
  \NCC@global\NCC@secstartagfalse
  \NCC@global\let\NCC@sectag\relax
  \NCC@global\NCC@nosecmarkfalse
  \NCC@global\let\NCC@secmark\relax
  \NCC@global\NCC@noauxfalse
}
\NCC@sec@reset@controls
\newcommand{\norunninghead}{\NCC@global\NCC@nosecmarktrue}
\newcommand*{\runninghead}[1]{\NCC@global\def\NCC@secmark##1{##1{#1}}}
\newcommand{\noheadingtag}{\NCC@global\NCC@nosectagtrue}
\newcommand{\headingtag}{%
  \@ifstar{\NCC@global\NCC@secstartagtrue\NCC@setsectag}{\NCC@setsectag}%
}
\def\NCC@setsectag#1{\NCC@global\def\NCC@sectag{#1}}
\newcommand{\skipwritingtoaux}{\NCC@global\NCC@noauxtrue}
\def\NCC@makesection#1#2#3#4{%
  \ifNCC@secstartag
    \let\@svsec\NCC@sectag
    \NCC@make{}%
  \else
    \ifx\NCC@sectag\relax
      \ifNCC@nosectag
        \edef\NCC@restsec{%
          \noexpand\c@secnumdepth \the\c@secnumdepth\relax
        }%
        \c@secnumdepth -1000
      \else
        \let\NCC@restsec\relax
        \ifnum#2>\c@secnumdepth \else\refstepcounter{#1}\fi
      \fi
    \else
      \expandafter\let\expandafter\NCC@thesec\csname the#1\endcsname
      \def\NCC@restsec{%
        \expandafter\let\csname the#1\endcsname\NCC@thesec
      }%
      \expandafter\let\csname the#1\endcsname\NCC@sectag
      \protected@edef\@currentlabel{\NCC@sectag}%
    \fi
    \ifnum #2>\c@secnumdepth
      \let\@svsec\@empty
    \else
      \protected@edef\@svsec{%
        \protect\NCC@makesectag{\csname the#1\endcsname}%
      }%
    \fi
    \let\NCC@makemark\@empty
    \@ifundefined{#1mark}{}{%
      \ifx\NCC@secmark\relax
        \ifNCC@nosecmark \else
          \def\NCC@makemark{\csname #1mark\endcsname{#3}}%
        \fi
      \else
        \let\NCC@savesecmark\NCC@secmark
        \def\NCC@makemark{%
          \NCC@savesecmark{\csname #1mark\endcsname}%
          \let\NCC@savesecmark\relax
        }%
      \fi
    }%
    \ifNCC@noaux
      \NCC@make{\NCC@makemark \NCC@restsec}%
    \else
      \NCC@make{\NCC@makemark #4\NCC@restsec}%
    \fi
  \fi
  \NCC@sec@reset@controls
}
\newcommand{\indentaftersection}{\@afterindenttrue}
\newcommand{\noindentaftersection}{\@afterindentfalse}
\newcommand*{\SectionTagSuffix}[1]{\def\NCC@asecnum{#1}}
\@onlypreamble\SectionTagSuffix
\newcommand*\sectiontagsuffix[2][]{%
  \expandafter\def\csname NCC@asecnum@#1\endcsname{\def\NCC@asecnum{#2}}%
}
\let\NCC@asecnum@\@empty
\def\NCC@setsectionsuffix#1{%
  \edef\@tempa{NCC@asecnum@\NCC@secname{#1}}%
  \@ifundefined{\@tempa}{%
    \let\NCC@asecnumset\NCC@asecnum@
  }{%
    \expandafter\let\expandafter\NCC@asecnumset\csname\@tempa\endcsname
  }%
}
\newcommand*{\RunningSectionSuffix}[1]{\def\NCC@asectitle{\unskip#1}}
\@onlypreamble\RunningSectionSuffix
\def\NCC@preparesectag#1#2{\def\NCC@makesectag##1{#1#2##1\NCC@asecnum}}
\def\NCC@secname#1{%
  \ifcase#1main\or section\or subsection\or subsubsection\or
    paragraph\or subparagraph\else section@\romannumeral#1\fi
}
\def\NCC@startsection#1#2#3#4#5#6{%
  \@tempskipa #4\relax
  \ifdim \@tempskipa <\z@ \@temskipa -\@tempskipa \fi
  \NCC@secskip \@tempskipa
  \secdef{\NCC@sect{#1}{#2}{#3}{#4}{#5}{#6}}{\NCC@ssect{#3}{#4}{#5}{#6}}%
}
\def\NCC@ssect#1#2#3#4#5{%
  \let\@svsec\@empty
  \NCC@makesec{#1}{#4}{#5}{#3}{}%
  \NCC@sec@reset@controls
}
\def\NCC@sect#1#2#3#4#5#6[#7]#8{%
  \def\NCC@make{\NCC@makesec{#3}{#6}{#8}{#5}}%
  \NCC@makesection{#1}{#2}{#7}{%
    \addcontentsline{toc}{\NCC@secname{#2}}{%
      \ifnum #2>\c@secnumdepth \else
        \numberline{\csname the#1\endcsname}%
      \fi
      #7%
    }%
  }%
}
\def\NCC@makesect#1#2#3#4#5{%
  \@tempskipa #4\relax
  \ifdim \@tempskipa>\z@
    \begingroup \normalfont
      \NCC@asecnumset
      \NCC@secttitle{#2}{\NCC@hangfrom{\hskip #1\relax\@svsec}}%
        {\interlinepenalty \@M\ignorespaces #3\@@par}
    \endgroup
    #5%
  \else
    \def\@svsechd{{\normalfont
      \NCC@asecnumset
      \def\norunningsuffix{\protect\NCC@nosecsuffix}%
      \NCC@secptitle{#2}{\hskip #1\relax{\@svsec}}%
        {\ignorespaces #3\NCC@asectitle}#5}}%
  \fi
  \@xsect{#4}%
}
\def\NCC@secttitle#1#2#3{#1{#2#3}}
\def\NCC@secptitle#1#2#3{#1{#2#3}}
\newcommand*\norunningsuffix{}
\def\NCC@nosecsuffix{\let\NCC@asectitle\@empty}
\def\NCC@hangfrom{%
  \NCC@setsecmargins{\z@skip}{\z@skip}\NCC@hangsecstyle{\z@}{}%
}
\def\NCC@setsecmargins#1#2{%
  \leftskip\z@skip \rightskip\z@skip
  \parfillskip\@flushglue
  \let\\\@normalcr
  \NCC@adjsecmargins{#1}{#2}%
  \NCC@secmarginshook
}
\def\NCC@adjsecmargins#1#2{%
  \setlength\@tempskipa{#1}\advance\leftskip\@tempskipa
  \setlength\@tempskipb{#2}\advance\rightskip\@tempskipb
  \advance\@tempskipa -1\@tempskipa \advance\@tempskipb -1\@tempskipb
  \advance\@tempskipa -\@tempskipb \advance\parfillskip\@tempskipa
}
\def\NCC@hangsecstyle#1#2#3{%
  \setlength\@tempdima{#1}%
  \setbox\@tempboxa\hbox{#3}%
  \ifdim \wd\@tempboxa > \@tempdima
    \hangindent\wd\@tempboxa \noindent \box\@tempboxa
  \else
    \hangindent\@tempdima
    \noindent \makebox[\@tempdima][#2]{\unhbox\@tempboxa}%
  \fi
}
\newcommand*\adjustsectionmargins[2]{%
  \NCC@global\def\NCC@secmarginshook{\NCC@adjsecmargins{#1}{#2}}
}
\g@addto@macro\NCC@sec@reset@controls{%
  \NCC@global\let\NCC@secmarginshook\@empty
}
\let\NCC@secmarginshook\@empty
\newcommand*\newplainsectionstyle[2]{%
  \@ifnextchar[{\NCC@newplainsec{#1}{#2}}{\NCC@newplainsec{#1}{#2}[l]}%
}
\def\NCC@newplainsec#1#2[#3]#4#5{%
  \def\@tempa{#3}\def\@tempb{c}%
  \ifx\@tempa\@tempb
    \expandafter\newcommand\csname NCC@sec@#1\endcsname
      {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
        \let\\\@centercr \advance\parfillskip -\@flushglue
        \setlength\parindent{#2}}}%
  \else
    \def\@tempb{r}%
    \ifx\@tempa\@tempb
      \expandafter\newcommand\csname NCC@sec@#1\endcsname
        {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}%
          \let\\\@centercr \advance\parfillskip -\@flushglue
          \advance\parfillskip -\@flushglue
          \setlength\parindent{#2}}}%
    \else
      \expandafter\newcommand\csname NCC@sec@#1\endcsname
        {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\setlength\parindent{#2}}}%
    \fi
  \fi
}
\@onlypreamble\newplainsectionstyle
\@onlypreamble\NCC@newplainsec
\newcommand*\newhangsectionstyle[2]{%
  \@ifnextchar[{\NCC@newhangsec{#1}{#2}}{\NCC@newhangsec{#1}{#2}[l]}%
}
\def\NCC@newhangsec#1#2[#3]#4#5{%
  \expandafter\newcommand\csname NCC@sec@#1\endcsname
    {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\NCC@hangsecstyle{#2}{#3}}}%
}
\@onlypreamble\newhangsectionstyle
\@onlypreamble\NCC@newhangsec
\newhangsectionstyle{hangindent}{\z@}{\z@skip}{\z@skip}
\newhangsectionstyle{hangindent*}{\z@}{\z@skip}{\@flushglue}
\newhangsectionstyle{hangparindent}{\z@}{\parindent}{\z@skip}
\newhangsectionstyle{hangparindent*}{\z@}{\parindent}{\@flushglue}
\newplainsectionstyle{parindent}{\z@}{\parindent}{\z@skip}
\newplainsectionstyle{parindent*}{\z@}{\parindent}{\@flushglue}
\newplainsectionstyle{center}{\z@}[c]{\@flushglue}{\@flushglue}
\newplainsectionstyle{centerlast}{\z@}[c]{\@flushglue}{-\@flushglue}
\newcommand*{\sectionstyle}[2][]{%
  \@ifundefined{NCC@sec@#2}{%
    \PackageError{nccsect}{Unknown section style `#2'}{}%
  }{%
    \expandafter\def\csname NCC@secstyle@#1\endcsname{%
      \csname NCC@sec@#2\endcsname
    }%
  }%
}
\def\NCC@setsectionstyle#1{%
  \edef\@tempa{NCC@secstyle@\NCC@secname{#1}}%
  \@ifundefined{\@tempa}{\NCC@secstyle@}{\csname\@tempa\endcsname}%
}
\def\NCC@makesecx#1#2#3#4#5{%
  \begingroup\normalfont
    \NCC@asecnumset
    \NCC@secxtitle{#2}{\protect\NCC@sec{\@svsec}}
      {\interlinepenalty \@M\ignorespaces #3\@@par}%
  \endgroup #5%
  \par \nobreak \vskip #4\relax \@afterheading \ignorespaces
}
\def\NCC@secxtitle#1#2#3{#1{#2#3}}
\providecommand*\partmark[1]{\markboth{}{}}
\@ifundefined{chapter}{%
  \def\NCC@startmainsec#1#2#3#4#5{%
    \NCC@preparesectag{\leavevmode#2}{\partname\nobreakspace}%
    \NCC@secskip{#3}%
    \secdef{\NCC@part{#1}{#4}{#5}}{\NCC@spart{#1}{#4}{#5}}%
  }
  \def\NCC@spart#1#2#3#4{%
    \let\@svsec\@empty
    \NCC@makepart{#1}{#3}{#4}{#2}{}%
    \NCC@sec@reset@controls
  }
  \def\NCC@part#1#2#3[#4]#5{%
    \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
    \NCC@makesection{part}{\z@}{#4}{%
      \addcontentsline{toc}{part}{%
        \ifnum \c@secnumdepth>\m@ne \numberline{\thepart}\fi
        #4%
      }%
    }%
  }
  \def\NCC@makepart#1#2#3#4#5{%
    \begingroup \normalfont
      \NCC@asecnumset
      \NCC@makeparttitle{#1}{#2}{#3}%
    \endgroup
    #5%
    \par\nobreak \vskip #4\relax \@afterheading \ignorespaces
  }
  \def\NCC@makeparttitle#1#2#3{%
    \ifx\@svsec\@empty \else
      \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak
    \fi
    \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
  }
  \def\NCC@partsection{\NCC@mainsection}
}{
  \def\NCC@startmainsec#1#2#3#4#5{%
    \NCC@startchap
    \NCC@preparesectag{\leavevmode#2}{\@chapapp\nobreakspace}%
    \secdef{\NCC@chapter{#1}{#3}{#4}{#5}}{\NCC@schapter{#1}{#3}{#4}{#5}}%
  }
  \def\NCC@startchap{%
    \if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}\global\@topnum\z@
  }
  \def\NCC@schapter#1#2#3#4#5{%
    \let\@svsec\@empty
    \NCC@makechapter{#1}{#2}{#4}{#5}{#3}{}%
    \NCC@sec@reset@controls
  }
  \def\NCC@chapter#1#2#3#4[#5]#6{%
    \@ifundefined{if@mainmatter}{}{\if@mainmatter\else\noheadingtag\fi}%
    \def\NCC@make{\NCC@makechapter{#1}{#2}{#4}{#6}{#3}}%
    \NCC@makesection{chapter}{\z@}{#5}{%
      \typeout{\@chapapp\space\thechapter.}%
      \addcontentsline{toc}{chapter}{%
        \ifnum \c@secnumdepth>\m@ne
          \numberline{\NCC@thetocchapter}\fi
        #5%
      }%
      \NCC@infloats{\addtocontents{\@nameuse{ext@\@captype}}%
                      {\protect\runinsectionskip}}%
    }%
  }
  \newcommand\beforechapter[1]{\gdef\NCC@beforechapter{#1}}
  \beforechapter{}
  \def\NCC@thetocchapter{\thechapter}
  \def\NCC@makechapter#1#2#3#4#5#6{%
    \if@twocolumn
      \@topnewpage[\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}]%
    \else
      \NCC@makechaphead{#1}{#2}{#3}{#4}{#5}%
    \fi
    \NCC@makechapfinal{#6}%
    \@afterheading
    \ignorespaces
  }
  \let\NCC@makechapfinal\@firstofone
  \def\NCC@makechapfinalgobble#1{%
    \let\NCC@makechapmark\NCC@makemark
    \def\NCC@makemark{%
      \let\NCC@temp\@chapapp
      \let\@chapapp\@gobble
      \NCC@makechapmark
      \let\@chapapp\NCC@temp
    }%
    #1%
  }
  \@onlypreamble\NCC@makechapfinalgobble
  \def\NCC@makechaphead#1#2#3#4#5{%
    \ifx\NCC@beforechapter\@empty
      \StartFromTextArea \vskip #2%
    \else
      \begingroup
        \@twocolumnfalse
        \let\NCC@global\@empty
        \NCC@sec@reset@controls
        \normalfont \NCC@beforechapter \par
      \endgroup
      \beforechapter{}%
    \fi
    \begingroup \normalfont
      \NCC@asecnumset
      \NCC@makechaptitle{#1}{#3}{#4}%
    \endgroup
    \par\nobreak \vskip #5\relax
  }
  \def\NCC@makechaptitle#1#2#3{%
    \ifx\@svsec\@empty \else
      \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}%
    \fi
    \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}%
  }
  \newcommand*\epigraph[1][\NCC@epigraphwidth]{\NCC@epigraph{#1}}
  \newcommand*\epigraphparameters[5]{%
    \def\NCC@epigraphwidth{#2}%
    \long\def\NCC@epigraph##1##2##3{
      \beforechapter{\def\epigraphwidth{##1}%
        #1\par
        \NCC@makeepigraph{#3}{##2}{#4{##3}}\par
        #5%
      }%
    }%
  }
  \long\def\NCC@makeepigraph#1#2#3{%
    \@begin@tempboxa\vtop{\setlength{\hsize}{\epigraphwidth}%
        \@parboxrestore{#2\@@par}#3\@@par
      }%
      \setlength\@tempdima{#1}\advance\@tempdima -\totalheight
      \ifdim\@tempdima>\z@
        \advance\@tempdima\depth
        \dp\@tempboxa\@tempdima
      \fi
      \leavevmode\box\@tempboxa
    \@end@tempboxa
  }
  \def\NCC@startpart{%
    \if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
  }
  \def\NCC@spart#1#2#3#4{%
    \let\@svsec\@empty
    \NCC@makepart{#1}{#3}{#4}{#2}{}%
    \NCC@sec@reset@controls
  }
  \def\NCC@part#1#2#3[#4]#5{%
    \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}%
    \NCC@makesection{part}{\m@ne}{#4}{%
      \addcontentsline{toc}{part}{%
        \ifnum \c@secnumdepth>-2
          \numberline{\NCC@thetocpart}\fi
        #4%
      }%
    }%
  }
  \def\NCC@thetocpart{\thepart}
  \def\NCC@makepart#1#2#3#4#5{%
    \if@twocolumn \onecolumn \@tempswatrue \else \@tempswafalse \fi
    \begingroup\normalfont
      \NCC@asecnum@
      \NCC@makeparttitle{#1}{#2}{#3}%
    \endgroup
    \NCC@makepartfinal{#5}#4%
    \if@tempswa \twocolumn \fi
  }
  \let\NCC@makepartfinal\@firstofone
  \def\NCC@makepartfinalgobble#1{%
    \let\NCC@makepartmark\NCC@makemark
    \def\NCC@makemark{%
      \let\NCC@temp\partname
      \let\partname\@gobble
      \NCC@makepartmark
      \let\partname\NCC@temp
    }%
    #1%
  }
  \@onlypreamble\NCC@makepartfinalgobble
  \def\NCC@makeparttitle#1#2#3{#1%
    \ifx\@svsec\@empty \else
      {\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak \fi
    \interlinepenalty \@M #2{#3\@@par}
  }
}
\newcommand*{\CaptionTagSuffix}[1]{\def\NCC@acapnum{#1}}
\@onlypreamble\CaptionTagSuffix
\newcommand*\captiontagsuffix[2][]{%
  \NCC@prepare@capkey{suffix}{#1}{\def\NCC@acapnum{#2}}%
}
\let\NCC@capsuffix@\@empty

\newcommand*\captionstyle[1][]{%
  \NCC@set@capkey{style}{style}{#1}%
}
\newcommand*\captiontagstyle[1][]{%
  \NCC@set@capkey{tag}{tag style}{#1}%
}
\newcommand*\captionwidth[2][]{%
  \NCC@prepare@capkey{width}{#1}{\setlength{\@tempdima}{#2}}%
}
\def\NCC@set@capkey#1#2#3#4{%
  \@ifundefined{NCC@makecap#1@#4}
  {\PackageError{nccsect}{Unknown caption #2 `#4'}{}%
  }{%
    \edef\@tempa{\noexpand\NCC@prepare@capkey{#1}{#3}{%
        \expandafter\noexpand\csname NCC@makecap#1@#4\endcsname
      }%
    }%
    \@tempa
  }%
}
\def\NCC@prepare@capkey#1#2{%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty
    \ifx\@captype\@undefined \else \let\@tempa\@captype \fi
  \fi
  \expandafter\def\csname NCC@cap#1@\@tempa\endcsname
}
\def\NCC@apply@cap#1{%
  \@ifundefined{NCC@cap#1@\@captype}%
    {\let\@tempa\@empty}{\let\@tempa\@captype}%
  \csname NCC@cap#1@\@tempa\endcsname
}
\def\NCC@startcaption#1#2#3{%
  \secdef{\NCC@caption{#1}{#2}{#3}}{\NCC@scaption{#1}{#2}{#3}}%
}
\long\def\NCC@scaption#1#2#3#4{%
  \let\@svsec\@empty
  \NCC@makecaption{#3}{#1}{#4}{#2}{}%
  \NCC@sec@reset@controls
}
\long\def\NCC@caption#1#2#3[#4]#5{%
  \def\NCC@make{\NCC@makecaption{#3}{#1}{#5}{#2}}%
  \NCC@makesection{\@captype}{\z@}{#4}{%
    \begingroup
      \let\centering\@empty
      \addcontentsline{\@nameuse{ext@\@captype}}{\@captype}{%
        \ifnum \c@secnumdepth>\m@ne
          \numberline{\@nameuse{the\@captype}}\fi
        #4%
      }%
    \endgroup
  }%
}
\long\def\NCC@makecaption#1#2#3#4#5{%
  \begingroup\par\normalfont
    #1{}\addvspace{#2}\noindent
    \ifx\@svsec\@empty \@tempcnta\z@ \else \@tempcnta\@ne \fi
    \def\@tempa{#3}%
    \ifx\@tempa\@empty \else \advance\@tempcnta\tw@ \fi
    \ifnum\@tempcnta=\z@ \else
      \NCC@apply@cap{suffix}%
      \NCC@apply@cap{width}%
      \NCC@vtopcap{\@parboxrestore\NCC@apply@cap{tag}{#3}\@@par}\par
      \setlength\@tempskipa{#4}%
      \ifdim\@tempskipa=\z@ \else \vskip \@tempskipa\fi
    \fi
  \endgroup
  #5%
}
\def\NCC@vtopcap#1{%
  \ifdim\@tempdima>\linewidth
    \@tempskipa \leftskip \advance\@tempskipa -1\@tempskipa
    \@tempskipb \rightskip \advance\@tempskipb \parfillskip
    \advance\@tempskipb -1\@tempskipb
    \vtop{\hb@xt@\linewidth{%
      \NCC@ifzeroskip\@tempskipa{}{\hss}%
      \vtop{\hsize\@tempdima#1}%
      \NCC@ifzeroskip\@tempskipb{}{\hss}%
    }}%
  \else
    \vtop{\hsize\@tempdima#1}%
  \fi
}
\def\NCC@ifzeroskip#1{%
  \edef\@tempa{\the#1}\edef\@tempb{\the\z@skip}%
  \ifx\@tempa\@tempb
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\long\def\NCC@makecaptag@para#1{%
  \ifnum\@tempcnta<\thr@@ \let\NCC@acapnum\@empty\fi
  \NCC@apply@cap{style}{{\@svsec}\ignorespaces#1}%
}
\def\NCC@makecaptag@left{\NCC@separate@captag\raggedright}
\def\NCC@makecaptag@center{\NCC@separate@captag\centering}
\def\NCC@makecaptag@right{\NCC@separate@captag\raggedleft}
\long\def\NCC@separate@captag#1#2{%
  \ifodd\@tempcnta
    {\let\NCC@acapnum\@empty #1\@svsec\@@par}%
  \fi
  \ifnum\@tempcnta>\@ne
    \ifnum\@tempcnta=\thr@@ \vskip .5ex\fi
    \NCC@apply@cap{style}{#2}%
  \fi
}
\long\def\NCC@makecapstyle@default#1{%
  \setbox\@tempboxa\vtop{\hsize\linewidth\@parboxrestore#1\@@par}%
  \ifdim\dp\@tempboxa<\baselineskip \centering#1%
  \else \box\@tempboxa \fi
}
\long\def\NCC@makecapstyle@para#1{#1}
\long\def\NCC@makecapstyle@left#1{\raggedright#1}
\long\def\NCC@makecapstyle@right#1{\raggedleft#1}
\long\def\NCC@makecapstyle@center#1{\centering#1}
\long\def\NCC@makecapstyle@centerlast#1{%
  \leftskip\@flushglue \rightskip -\@flushglue
  \parfillskip\z@\@plus 2fil\relax#1%
}
\newcommand*{\RegisterFloatType}[1]{%
  \edef\NCC@floatlist{\NCC@floatlist{#1}}%
}
\let\NCC@floatlist\@empty
\@onlypreamble\RegisterFloatType
\def\NCC@infloats#1{%
  \@tempcnta\z@
  \let\NCC@temp \@captype
  \expandafter \@tfor \expandafter \@captype
    \expandafter :\expandafter =\NCC@floatlist \do
  {\advance\@tempcnta\@ne #1}%
  \let\@captype\NCC@temp
}
\newcommand{\DeclareSection}{\@ifstar{\NCC@dsecx}{\NCC@dsec}}
\def\NCC@dsec#1#2{%
  \@ifnextchar[{\NCC@dsect{#1}{#2}}{\NCC@dsect{#1}{#2}[\z@skip]}%
}
\@onlypreamble\DeclareSection
\@onlypreamble\NCC@dsec
\def\NCC@dsect#1#2[#3]#4#5#6#7{%
  \ifnum#1>\z@
    \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
      \NCC@setsectionsuffix{#1}%
      \NCC@preparesectag{#4}{}%
      \let\NCC@makesec\NCC@makesect
      \NCC@startsection{#2}{#1}{#3}{#5}{#6}{#7}}%
  \else
    \ifnum#1=\z@
      \def\NCC@mainsection{%
        \NCC@setsectionsuffix\z@
        \let\NCC@secmain\@empty
        \NCC@startmainsec{%
          \NCC@hangfrom{\hskip #3}\NCC@adjsecmargins{}\@flushglue
          \ignorespaces}%
          {#4}{#5}{#6}{#7}%
      }%
    \else
      \NCC@dsecf{#2}{#4}{#5}{#6}{#7}%
    \fi
  \fi
}
\@onlypreamble\NCC@dsect
\def\NCC@dsecx#1#2#3#4#5#6{%
  \ifnum#1>\z@
    \expandafter\def\csname NCC@section\romannumeral#1\endcsname{%
      \NCC@setsectionsuffix{#1}%
      \NCC@setsectionstyle{#1}%
      \NCC@preparesectag{#3}{}%
      \let\NCC@makesec\NCC@makesecx
      \NCC@startsection{#2}{#1}{\z@}{#4}{#5}{#6}}%
  \else
    \ifnum#1=\z@
      \def\NCC@mainsection{%
        \NCC@setsectionsuffix\z@
        \NCC@setsectionstyle\z@
        \let\NCC@secsave\NCC@sec \let\NCC@sec\NCC@secflush
        \def\NCC@secmain{\protect\NCC@sec{}}%
        \NCC@startmainsec{}{#3}{#4}{#5}{#6}%
      }%
    \else
      \NCC@dsecf{#2}{#3}{#4}{#5}{#6}%
    \fi
  \fi
}
\@onlypreamble\NCC@dsecx
\def\NCC@secflush#1{\NCC@secsave{#1}%
  \@tempskipa\leftskip \advance\@tempskipa\rightskip
  \advance\@tempskipa -1\@tempskipa
  \NCC@ifzeroskip\@tempskipa{%
    \advance\rightskip \parfillskip \parfillskip \z@skip
  }{}%
  \ignorespaces
}
\def\NCC@dsecf#1#2#3#4#5{%
  \expandafter\def\csname NCC@cap@#1\endcsname{%
    \def\NCC@makesectag####1{#2{\csname #1name\endcsname}%
      \nobreakspace####1\NCC@acapnum}%
    \NCC@startcaption{#3}{#4}{#5}%
  }%
}
\@onlypreamble\NCC@dsectf
\@ifundefined{chapter}{}{%
  \newcommand\DeclarePart[4]{%
    \def\NCC@partsection{%
      \NCC@startpart
      \NCC@preparesectag{\leavevmode#3}{\partname\nobreakspace}%
      \secdef{\NCC@part{#1}{#2}{#4}}{\NCC@spart{#1}{#2}{#4}}%
    }%
  }
  \@onlypreamble\DeclarePart
}
\long\def\@makecaption#1#2{%
  \begingroup
    \skipwritingtoaux
    \addtocounter\@captype\m@ne
    \csname NCC@cap@\@captype\endcsname[]{#2}%
  \endgroup
}
\AfterPackage{supertabular}{%
  \long\def\ST@caption#1[#2]#3{\par%
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
      {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
    \begingroup\centering
      \def\@captype{#1}%
      \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
    \endgroup
  }
}
\AfterPackage{xtab}{%
  \long\def\ST@caption#1[#2]#3{\par%
    \@initisotab
    \addcontentsline{\csname ext@#1\endcsname}{#1}%
      {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
    \begingroup\centering
      \def\@captype{#1}%
      \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
    \endgroup
    \global\advance\ST@pageleft -\PWSTcapht
    \ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}%
  }
}
\AfterPackage{longtable}{%
  \def\LT@makecaption#1#2#3{%
    \LT@mcol\LT@cols c{\hbox to\z@{\hss
      \parbox[t]\LTcapwidth{\centering\def\@captype{table}%
        \ifx#1\@gobble \NCC@cap@table*{#3}%
        \else \@makecaption{\fnum@table}{#3}%
        \fi
      }%
      \hss
    }}%
  }
}
\newcommand*{\DeclareTOCEntry}[5]{%
  \@ifnextchar[{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}}%
               {\NCC@dtoc{#1}{#2}{#3}{#4}{#5}[\NCC@nexttocnum{#3}{#4}]}%
}
\def\NCC@dtoc#1#2#3#4#5[#6]{%
  \ifnum#1<\z@
    \@tempswatrue
    \NCC@infloats{%
      \ifnum#1=-\@tempcnta
        \expandafter\def\csname l@\@captype\endcsname
          {\NCC@tocentry\z@{#2}{#3}{#4}{#5}}%
        \@tempswafalse
        \@break@tfor
      \fi
    }%
    \if@tempswa
      \@tempcnta#1\relax
      \@tempcnta -\@tempcnta
      \PackageError{nccsect}%
        {Float type registration number \the\@tempcnta\space
         is out of range}{}%
    \fi
  \else
    \ifnum#1>\z@
      \edef\@tempa{\noexpand\def\expandafter\noexpand
                   \csname l@\NCC@secname{#1}\endcsname}%
    \else
      \@ifundefined{chapter}{\def\@tempa{\def\l@part}}%
                            {\def\@tempa{\def\l@chapter}}%
    \fi
    \@tempa{\NCC@tocentry{#1}{#2}{#3}{#4}{#5}}%
    \@tempcnta #1\relax \advance\@tempcnta\@ne
    \expandafter\def\csname l@tocskip@\romannumeral\@tempcnta
      \endcsname{\NCC@tocadj{\NCC@tocnumprototype{#5}{#6}}}%
  \fi
}
\@onlypreamble\DeclareTOCEntry
\@onlypreamble\NCC@dtoc
\def\NCC@nexttocnum#1#2{#1#2\NCC@atocnum}
\def\NCC@tocnumprototype#1#2{\let\applystyle\@firstoftwo#1{#2}}
\def\NCC@tocadj#1{%
  \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo#1}%
  \advance\@tempdimb\@tempdima
}
\@ifundefined{chapter}{}{%
  \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}{%
        \TOCMarginDrift{1fil}%
        \addpenalty{-\@highpenalty}#1%
      }{#3}{#4}{#5}{##1}{\hss##2}%
      \nobreak \vskip #2\relax
      \@nobreaktrue
      \everypar{\@nobreakfalse\everypar{}}%
    }%
  }
  \@onlypreamble\DeclareTOCPart
  \@onlypreamble\NCC@dtocpart
}
\def\NCC@tocentry#1#2#3#4#5#6#7{%
  \ifnum #1>\c@tocdepth \else
    \par\begingroup\normalfont #2%
      \let\applystyle\@firstoftwo
      \@tempdimb\z@ \@tempcnta #1\relax
      \@whilenum \@tempcnta >\z@\do
        {\@nameuse{l@tocskip@\romannumeral \@tempcnta}%
         \advance\@tempcnta\m@ne}%
      \NCC@preparetocnum{#5}{#3}%
      \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo\NCC@maketocnum{#4}}%
      \@dottedtocline{#1}{\@tempdimb}{\@tempdima}%
        {\let\NCC@atocdo\@secondoftwo\NCC@tocentrytitle{#5}{#6\unskip}}%
        {\let\applystyle\@secondoftwo#5{#7}}%
      \@nobreakfalse
    \endgroup
  \fi
}
\def\NCC@preparetocnum#1#2{%
  \def\NCC@maketocnum##1{\NCC@atocdo{#1}{}{#2##1\NCC@atocnum}}%
}
\def\NCC@tocentrytitle#1#2{#1{\ignorespaces#2}}
\DeclareRobustCommand*\numberline[1]{%
  \setbox\@tempboxa\hbox{\NCC@maketocnum{#1}}%
  \ifdim \wd\@tempboxa > \@tempdima
    \box\@tempboxa
  \else
    \hb@xt@\@tempdima{\unhbox\@tempboxa\hfil}%
  \fi
  \ignorespaces
}
\def\NCC@maketocnum#1{#1\NCC@atocnum}
\let\NCC@atocdo\@secondoftwo
\newcommand*{\NumberlineSuffix}[2]{\def\NCC@atocnum{\NCC@atocdo{#1}{#2}}}
\@onlypreamble\NumberlineSuffix
\newcommand*\TOCMarginDrift[1]{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty \let\NCC@tocdrift\@empty
  \else \def\NCC@tocdrift{\@plus #1\relax}\fi
}
\newcommand*{\PnumPrototype}[1]{\def\NCC@pnum{#1}\NCC@setpnum}
\@onlypreamble\PnumPrototype
\def\NCC@setpnum{%
  \settowidth\@tempdima{\NCC@pnum}%
  \edef\@pnumwidth{\the\@tempdima}%
  \advance\@tempdima 1em
  \edef\@tocrmarg{\the\@tempdima \noexpand\NCC@tocdrift}%
}
\newcommand*{\SetTOCStyle}[1]{\def\NCC@tocstyle{#1}}
\@onlypreamble\SetTOCStyle
\let\NCC@latexstarttoc\@starttoc
\def\@starttoc#1{%
  \begingroup
    \normalfont \NCC@tocstyle \NCC@setpnum
    \NCC@latexstarttoc{#1}%
  \endgroup
}
\@ifpackageloaded{textarea}{}{%
  \newcommand\StartFromTextArea{\par
    {\parskip\z@ \strut\par}\vskip -\baselineskip
  }
  \newcommand\StartFromHeaderArea{%
    \StartFromTextArea
    \vskip -\headsep \vskip -\ht\strutbox
  }
}
\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}
\newcommand*\aftersectionvspace[1]{%
  \ifvmode \if@nobreak
    \vskip -\lastskip \vskip #1\relax
  \fi \fi
}
\newcommand*{\startsection}[1]{%
  \ifnum#1>\z@
    \def\@tempa{\csname NCC@section\romannumeral#1\endcsname}%
  \else
    \ifnum#1=\z@
      \def\@tempa{\NCC@mainsection}%
    \else
      \def\@tempa{\NCC@partsection}%
    \fi
  \fi
  \@tempa
}
\def\part{\startsection\m@ne}
\def\section{\startsection\@ne}
\def\subsection{\startsection\tw@}
\def\subsubsection{\startsection\thr@@}
\def\paragraph{\startsection4}
\def\subparagraph{\startsection5}
\AtBeginDocument{%
  \def\caption{%
    \ifx\@captype\@undefined
      \@latex@error{\noexpand\caption outside float}\@ehd
      \expandafter\@gobble
    \else
      \expandafter\@firstofone
    \fi
    {\csname NCC@cap@\@captype\endcsname}%
  }%
  \@ifundefined{abovecaptionskip}{\def\abovecaptionskip{\z@}}%
               {\abovecaptionskip\z@}%
  \@ifundefined{belowcaptionskip}{\def\belowcaptionskip{\z@}}%
               {\belowcaptionskip\z@}%
}
\RegisterFloatType{figure}
\RegisterFloatType{table}
\DeclareSection{-2}{table}{}{\z@}{10pt}{}
\DeclareSection{-1}{figure}{}{10pt}{\z@}{}
\DeclareSection*1{section}{}%
                {3.5ex \@plus 1ex \@minus .2ex}%
                {2.3ex \@plus .2ex}{\Large\bff}
\DeclareSection*2{subsection}{}%
                {3.25ex \@plus 1ex \@minus .2ex}%
                {1.5ex \@plus .2ex}{\large\bff}
\DeclareSection*3{subsubsection}{}%
                {3ex \@plus 1ex \@minus .2ex}%
                {1.5ex \@plus .2ex}{\normalsize\bff}
\DeclareSection4{paragraph}{}%
                {\NCC@runskip}{-1em}{\normalsize\bff}
\DeclareSection5{subparagraph}[\parindent]{}%
                {\NCC@runskip}{-1em}{\normalsize\bff}
\@ifundefined{chapter}{
  \DeclareSection*0{part}{\Large\bff}%
                  {5ex \@plus 1ex \@minus .2ex}%
                  {4ex \@plus .2ex}{\huge\bff}
  \DeclareTOCEntry{-2}{}{}{9}{}% table
  \DeclareTOCEntry{-1}{}{}{9}{}% figure
  \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}}{}{III}{\bff}[]
  \DeclareTOCEntry1{\runinsectionskip}{}{9}{}
  \DeclareTOCEntry2{}{}{9.9}{}
  \DeclareTOCEntry3{}{}{9.9.9}{}
}{
  \newcommand*{\ChapterPrefixStyle}[1]{%
    \def\NCC@thetocchapter{\thechapter}%
    \let\NCC@makechapfinal\NCC@makechapfinalgobble
    \@for\@tempa:=#1\do{%
      \@ifundefined{NCC@chapin@\@tempa}{%
        \PackageError{nccsect}{Unknown style `\@tempa'\MessageBreak
        Only the `toc' and `header' styles are allowed}{}%
      }{\csname NCC@chapin@\@tempa\endcsname}%
    }%
  }
  \def\NCC@chapin@toc{\def\NCC@thetocchapter{\@chapapp\ \thechapter}}
  \def\NCC@chapin@header{\let\NCC@makechapfinal\@firstofone}
  \@onlypreamble\ChapterPrefixStyle
  \@onlypreamble\NCC@chapin@toc
  \@onlypreamble\NCC@chapin@header
  \def\chapter{\startsection\z@}
  \DeclarePart{\StartFromTextArea\vfil\centering}%
              {\vfil\newpage \if@twoside\if@openright
                 \mbox{}\thispagestyle{empty}\newpage\fi\fi}%
              {\vspace{4ex}\huge\bff}{\Huge\bff}
  \DeclareSection*0{chapter}{\vspace{3ex}\huge\bff}{10ex}%
                  {8ex \@plus .2ex}{\Huge\bff}
  \DeclareTOCEntry{-2}{}{}{9.9}{}% table
  \DeclareTOCEntry{-1}{}{}{9.9}{}% figure
  \DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}\def\@dotsep{1000}}
                 {}{II}{\large\bff}
  \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}%
                    \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}
  \DeclareTOCEntry1{}{}{9.9}{}[9.9]
  \DeclareTOCEntry2{}{}{9.9.9}{}[9.9.9]
  \DeclareTOCEntry3{}{}{}{}[\qquad]
  \epigraphparameters{\StartFromHeaderArea\small\raggedleft}%
                     {.45\linewidth}{5\baselineskip}%
                     {\raggedleft\itshape}{\vspace{2ex}}
}
\DeclareTOCEntry4{}{}{}{}[\qquad]
\DeclareTOCEntry5{}{}{}{}[\qquad]
\noindentaftersection
\sectionstyle{hangindent}
\SectionTagSuffix{\quad}
\RunningSectionSuffix{}
\captionwidth{\linewidth}
\captionstyle{default}
\captiontagstyle{para}
\CaptionTagSuffix{:\hskip .7em \@plus .2em \@minus .1em}
\NumberlineSuffix{\quad}{\enskip}
\PnumPrototype{99}
\TOCMarginDrift{}
\SetTOCStyle{}
\endinput
%%
%% End of file `nccsect.sty'.
