% \iffalse meta-comment
%
% Copyright 1994 the LaTeX3 project and the individual authors.
% All rights reserved. For further copyright information see the file
% legal.txt, and any other copyright indicated in this file.
% 
% This file is part of the LaTeX2e system.
% ----------------------------------------
% 
%  This system is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
% 
% IMPORTANT NOTICE:
% 
% For error reports in case of UNCHANGED versions see bugs.txt.
% 
% Please do not request updates from us directly.  Distribution is
% done through Mail-Servers and TeX organizations.
% 
% You are not allowed to change this file.
% 
% You are allowed to distribute this file under the condition that
% it is distributed together with all files mentioned in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% You are NOT ALLOWED to distribute this file alone.  You are NOT
% ALLOWED to take money for the distribution or use of either this
% file or a changed version, except for a nominal charge for copying
% etc.
% \fi
%
% \iffalse
%%% File: ltsect
%<*driver>
% \fi
\ProvidesFile{ltsect.dtx}[1994/11/17 v1.0i LaTeX Kernel (Sectioning)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltsect.dtx}
\title{\filename}
\date{\filedate}
 \author{%
  Johannes Braams\and
  David Carlisle\and
  Alan Jeffrey\and
  Leslie Lamport\and
  Frank Mittelbach\and
  Chris Rowley\and
  Rainer Sch\"opf}

\begin{document}
\maketitle
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \CheckSum{372}
%
% \section{Sectioning Commands}
%
% This file defines the declarations such as |\author| which are used by
% |\maketitle|. |\maketitle| itself is defined by each class, not in the
% \LaTeX\ kernel.
%
% The second part of the file defines the generic commands used for
% defining sectioning commands such as |\chapter|. Again the actual
% document level commands are defined in the class files, in terms of
% these commands.
%
% \StopEventually{}
%
%
% \changes{v1.0a}{1994/03/04}{Initial version, split from latex.dtx}
% \changes{v1.0b}{1994/03/28}{Split further from ltherest.dtx}
% \changes{v1.0d}{1994/05/21}{Use new error commands}
% \changes{v1.0f}{1994/10/12}{Doc. typos}
% \changes{v1.0g}{1994/10/18}{Added \cs{normalcolor}}
% \changes{v1.0i}{1994/11/17}
%         {\cs{@tempa} to \cs{reserved@a}}
% 
%
%    \begin{macrocode}
%<*2ekernel>
\message{title,}
%    \end{macrocode}
%
% \subsection{The Title}
%
% \begin{oldcomments}
% The user defines the title, author, date by the declarations
% \title{NAME}, \author{NAME} and \date{DATE}.
% Inside these, he can use the \thanks
% command to make footnoted acknowledgements, notice of address, etc.
% The \maketitle command produces the actual title.
% Note: multiple authors are separated with the \and command.
% \end{oldcomments}
%
%  \begin{macro}{\title}
%  \begin{macro}{\@title}
% \changes{LaTeX2e}{1993/12/11}{Added default}
%    |\title| for use in |\maketitle|. If not given |\maketitle| will
%    produce an error message.
%    \begin{macrocode}
\def\title#1{\gdef\@title{#1}}
\def\@title{\@latex@error{No \noexpand\title given}\@ehc}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\author}
%  \begin{macro}{\@author}
% \changes{LaTeX2e}{1993/12/11}{Added default}
%    |\author| for use in |\maketitle|. If not given |\maketitle| will
%    produce a warning message.
%    \begin{macrocode}
\def\author#1{\gdef\@author{#1}}
\def\@author{\@latex@warning@no@line{No \noexpand\author given}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\date}
%  \begin{macro}{\@date}
%    |\date| for use in |\maketitle|. If not given |\maketitle| will
%    produce |\today| as the default.
%    \begin{macrocode}
\def\date#1{\gdef\@date{#1}}
\gdef\@date{\today}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \changes{1.0h}{1994/11/04}{(ASAJ) Added \cs{protected@xdef} to
%    \cs{thanks}.} 
%
% \begin{oldcomments}
%    \begin{macrocode}
\def\thanks#1{\footnotemark
    \protected@xdef\@thanks{\@thanks
        \protect\footnotetext[\the\c@footnote]{#1}}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@thanks{}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\and{%%                             % \begin{tabular}
\end{tabular}\hskip 1em \@plus.17fil%
\begin{tabular}[t]{c}%% \end{tabular}
}
%    \end{macrocode}
%
%    \begin{macrocode}
\message{sectioning,}
%    \end{macrocode}
%
% \end{oldcomments}
%
% \subsection{Sectioning}
%
% \begin{oldcomments}
%
% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
%            optional * [ALTHEADING]{HEADING}
%    Generic command to start a section.
%    NAME      : e.g., 'subsection'
%    LEVEL     : a number, denoting depth of section -- e.g., chapter=1,
%                 section = 2, etc.
%    INDENT    : Indentation of heading from left margin
%    BEFORESKIP: Absolute value = skip to leave above the heading.
%                If negative, then paragraph indent of text following
%                heading is suppressed.
%    AFTERSKIP : if positive, then skip to leave below heading, else
%                negative of skip to leave to right of run-in heading.
%    STYLE     : commands to set style
%  If '*' missing, then increments the counter.  If it is present, then
%  there should be no [ALTHEADING] argument.
%  Uses the counter 'secnumdepth' whose value is the highest section
%  level that is to be numbered.
%
%  WARNING: The \@startsection command should be at the same or higher
%  grouping level as the text that follows it.  For example, you
%  should NOT do something like
%      \def\foo{ \begingroup ...
%                   \paragraph{...}
%                 \endgroup}
%
% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE} ==
%    BEGIN
%     IF  @noskipsec = T  THEN  \leavevmode  FI  
%                               % true if previous section% had no body.
%                                                
%     \par
%     \@tempskipa  := BEFORESKIP
%     @afterindent := T
%     IF \@tempskipa < 0  THEN  \@tempskipa  := -\@tempskipa
%                               @afterindent := F
%     FI
%     IF @nobreak = true
%       THEN \everypar == null
%       ELSE \addpenalty{\@secpenalty}
%            \addvspace{\@tempskipa}
%     FI
%     IF * next
%       THEN \@ssect{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
%       ELSE \@dblarg{\@sect
%                   {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}}
%     FI
% END
%
% \@sect{NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[ARG1]{ARG2}
%           ==
%   BEGIN
%    IF LEVEL > \c@secnumdepth
%      THEN \@svsec :=L null
%      ELSE \refstepcounter{NAME}
%           \@svsec :=L BEGIN \@seccntformat{#1} END
%    FI
%    IF AFTERSKIP > 0
%      THEN \begingroup
%              STYLE
%              \@hangfrom{\hskip INDENT\@svsec}
%              {\interlinepenalty 10000 ARG2\par}
%           \endgroup
%           \NAMEmark{ARG1}
%           \addcontentsline{toc}{NAME}
%              { IF  LEVEL > \c@secnumdepth
%                  ELSE \protect\numberline{\theNAME}  FI
%                ARG1 }
%      ELSE \@svsechd == BEGIN  STYLE
%                               \hskip INDENT\@svsec
%                               ARG2
%                               \NAMEmark{ARG1}
%                               \addcontentsline{toc}{NAME}
%                                  { IF  LEVEL > \c@secnumdepth
%                                      ELSE 
%                                        \protect\numberline{\theNAME}
%                                      FI
%                                    ARG1 }
%                        END
%    FI
%    \@xsect{AFTERSKIP}
% END
%
% \@xsect{AFTERSKIP} ==
%  BEGIN
%    IF AFTERSKIP > 0
%      THEN \par \nobreak
%           \vskip AFTERSKIP
%           \@afterheading
%      ELSE @nobreak :=G F
%           @noskipsec :=G T
%           \everypar{ IF @noskipsec = T
%                        THEN @noskipsec :=G F
%                             \clubpenalty :=G 10000
%                             \hskip -\parindent
%                             \begingroup
%                               \@svsechd
%                             \endgroup
%                             \unskip
%                             \hskip -AFTERSKIP \relax 
%                                           %% relax added 14 Jan 91
%                        ELSE \clubpenalty :=G \@clubpenalty
%                             \everypar := NULL
%                      FI
%                    }
%    FI
%
%   END
%
% \@seccntformat{NAME} ==
%   BEGIN
%    \theNAME
%    \hskip 1em
%   END
%
% \@ssect{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}{ARG} ==
%   BEGIN
%    IF AFTERSKIP > 0
%      THEN \begingroup
%             STYLE
%             \@hangfrom{\hskip INDENT}{\interlinepenalty 10000 ARG\par}
%           \endgroup
%      ELSE \@svsechd == BEGIN STYLE
%                              \hskip INDENT
%                              ARG
%                        END
%    FI
%    \@xsect{AFTERSKIP}
%   END
%
% \@afterheading ==
%  BEGIN
%    @nobreak :=G true
%    \everypar := BEGIN  IF @nobreak = T
%                          THEN @nobreak  :=G false
%                               \clubpenalty :=G 10000
%                               IF @afterindent = F
%                                 THEN remove \lastbox
%                               FI
%                          ELSE \clubpenalty :=G \@clubpenalty
%                               \everypar := NULL
%                       FI
%                 END
%  END
%
% \@secpenalty : The penalty (usually negative) put before a section
%                heading unless it immediately follows another one.
%
%    \begin{macrocode}
\newcount\@secpenalty
\@secpenalty = -300
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\if@noskipsec \@noskipsectrue
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\@startsection#1#2#3#4#5#6{\if@noskipsec \leavevmode \fi
   \par \@tempskipa #4\relax
   \@afterindenttrue
   \ifdim \@tempskipa <\z@
     \@tempskipa -\@tempskipa \@afterindentfalse
   \fi
   \if@nobreak \everypar{}\else
     \addpenalty{\@secpenalty}\addvspace{\@tempskipa}\fi \@ifstar
     {\@ssect{#3}{#4}{#5}{#6}}%
     {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
%    \end{macrocode}
%
% \end{oldcomments}
% \begin{macro}{\@sect}
% \changes{LaTeX2.09}{1992/08/25}
%         {(FMi) replaced explicit setting of \cmd{\@svsec}
%               by call to \cmd{\@seccntformat}}
% \changes{LaTeX2.09}{1993/08/05}
%         {(RmS) Made sure that \cmd\protect works correctly in
%               expansion of \cmd\the counter}
% \changes{1.0h}{1994/11/04}
%         {(ASAJ) Added \cs{protected@edef}.}
%    \begin{macrocode}
\def\@sect#1#2#3#4#5#6[#7]#8{%
     \ifnum #2>\c@secnumdepth
       \let\@svsec\@empty\else
       \refstepcounter{#1}%
       \protected@edef\@svsec{\@seccntformat{#1}}%
     \fi
     \@tempskipa #5\relax
      \ifdim \@tempskipa>\z@
        \begingroup #6\relax
          \@hangfrom{\hskip #3\relax\@svsec}%
                    {\interlinepenalty \@M #8\par}%
        \endgroup
       \csname #1mark\endcsname{#7}\addcontentsline
         {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                      \protect\numberline{\csname the#1\endcsname}\fi
                    #7}\else
        \def\@svsechd{#6\hskip #3\relax  %% \relax added 2 May 90
                   \@svsec #8\csname #1mark\endcsname
                      {#7}\addcontentsline
                           {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                           \protect\numberline{\csname the#1\endcsname}%
                                     \fi
                       #7}}\fi
     \@xsect{#5}}
%    \end{macrocode}
% \end{macro}
% \begin{oldcomments}
%
%    \begin{macrocode}
\def\@seccntformat#1{\csname the#1\endcsname\hskip 1em}
%    \end{macrocode}
%
% RmS 92/08/19: corrected bug: stretch and shrink in argument to \hskip
%               previously not negated
%    \begin{macrocode}
\def\@xsect#1{\@tempskipa #1\relax
      \ifdim \@tempskipa>\z@
       \par \nobreak
       \vskip \@tempskipa
       \@afterheading
    \else \global\@nobreakfalse \global\@noskipsectrue
       \everypar{\if@noskipsec \global\@noskipsecfalse
                   \clubpenalty\@M \hskip -\parindent
                   \begingroup \@svsechd \endgroup \unskip
                   \@tempskipa #1\relax
                   \hskip -\@tempskipa
                  \else \clubpenalty \@clubpenalty
                    \everypar{}\fi}\fi\ignorespaces}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@ssect#1#2#3#4#5{\@tempskipa #3\relax
   \ifdim \@tempskipa>\z@
     \begingroup #4\@hangfrom{\hskip #1}{\interlinepenalty \@M #5\par}%
     \endgroup
   \else \def\@svsechd{#4\hskip #1\relax #5}\fi
    \@xsect{#3}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\if@afterindent \@afterindenttrue
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@afterheading{\global\@nobreaktrue
      \everypar{\if@nobreak
                   \global\@nobreakfalse
                   \clubpenalty \@M
                   \if@afterindent \else {\setbox\z@\lastbox}\fi
                 \else \clubpenalty \@clubpenalty
                    \everypar{}\fi}}
%    \end{macrocode}
%
% \end{oldcomments}
%
% \begin{macro}{\@hangfrom}
% |\@hangfrom{TEXT}| : Puts TEXT in a box, and makes a hanging 
% indentation of the following material up to the first |\par|.
% Should be used in vertical mode.
% \changes{v1.0a}{1994/03/07}{(DPC)Extra groups for colour}
%    \begin{macrocode}
\def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
      \hangindent \wd\@tempboxa\noindent\box\@tempboxa}
%    \end{macrocode}
% \end{macro}
%
% \begin{oldcomments}
%
%    \begin{macrocode}
\newcount\c@secnumdepth
\newcount\c@tocdepth
%    \end{macrocode}
%
% \secdef{UNSTARCMDS}{STARCMDS} :
%    When defining a \chapter or \section command without using
%    \@startsection, you can use \secdef as follows:
%     \def\chapter { ... \secdef \CMDA \CMDB }
%     \def\CMDA    [#1]#2{ ... }  % Command to define \chapter[...]{...}
%     \def\CMDB    #1{ ... }      % Command to define \chapter*{...}
%
%    \begin{macrocode}
\def\secdef#1#2{\@ifstar{#2}{\@dblarg{#1}}}
%    \end{macrocode}
%
% Initializations
%
%    \begin{macrocode}
\def\sectionmark#1{}
\def\subsectionmark#1{}
\def\subsubsectionmark#1{}
\def\paragraphmark#1{}
\def\subparagraphmark#1{}
%    \end{macrocode}
%
%    \begin{macrocode}
\message{contents,}
%    \end{macrocode}
%
% \end{oldcomments}
%
% \subsection{Table of Contents etc}
%
% \begin{oldcomments}
%
% CONVENTIONS:
%   \tf@foo = file number for output for table foo.  The file is
%             opened only if @filesw = true.
%
%   \contentsline{TYPE}{ENTRY}{PAGE}
%       Macro to produce a TYPE entry in a table of contents, etc.
%       It will appear in the .TOC or other file.  For example,
%       The entry for subsection 1.4.3 in the table of contents might
%       be produced by:
%       \contentsline{subsection}
%               {\makebox{30pt}[r]{1.4.3} Gnats and Gnus}{22}
%       The \protect command causes command sequences to be written
%       without expanding them.
%
%   \l@TYPE{ENTRY}{PAGE}
%       Macro defined by document style for making an entry of
%       type TYPE in a table of contents, etc.  E.g., the document
%       style should define \l@chapter, \l@section, etc.
%
%   \addcontentsline{TABLE}{TYPE}{ENTRY}
%     User command for adding his own entry to a table of contents, etc.
%     It adds the entry
%         \contentsline{TYPE}{ENTRY}{page}
%     to the .TABLE file.
%
%   \addtocontents{TABLE}{TEXT} : Adds TEXT to the .TABLE file, with no
%      page number.
%
%  Note: When used in the ENTRY or TEXT of one of the above commands,
%  \protect causes the following control sequence to be written
%  on the file without being expanded.  The sequence will be expanded
%  when the table of contents entry is processed.
%
%  SURPRISE: \index, \glossary,  and \label are no-ops inside an
%  \addcontentsline or \addtocontents command argument.  This could
%  cause a problem if the user puts an \index or \label into one of the
%  commands he writes, or into the optional 'short version' argument of
%  a \section or \caption command.
%
%
% \@starttoc{EXT} : 
%      Used to define \tableofcontents, \listoffigures, etc.--
%      e.g., \@starttoc{lof} is used in \listoffigures.  This command
%      reads the .EXT file and sets up to write the new .EXT file.
%
% \@starttoc{EXT} ==
%   BEGIN
%     \begingroup
%        \makeatletter
%        read file \jobname.EXT
%        IF @filesw = true
%          THEN  open \jobname.EXT as file \tf@EXT
%        FI
%        @nobreak :=G FALSE  %% added 24 May 89
%     \endgroup
%   END
%
% RmS 92/01/14: added \immediate to \openout as all \write commands
%               are also executed \immediate
%    \begin{macrocode}
\def\@starttoc#1{\begingroup
  \makeatletter
  \@input{\jobname.#1}\if@filesw 
  \expandafter\newwrite\csname tf@#1\endcsname
             \immediate\openout
                 \csname tf@#1\endcsname \jobname.#1\relax
  \fi \global\@nobreakfalse \endgroup}
%    \end{macrocode}
%
%
% \changes{v1.0c}{1994/05/20}{Correct setting of \cs{protect}.}
% \changes{v1.0h}{1994/11/04}{Added \cs{protected@write} to
%    \cs{addcontentsline}.  ASAJ.}
%
%    \begin{macrocode}
\def\addcontentsline#1#2#3{%
  \protected@write\@auxout
      {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
      {\string\@writefile{#1}%
           {\protect\contentsline{#2}{#3}{\thepage}}}%
}
%    \end{macrocode}
%
% \changes{v1.0c}{1994/05/20}{Correct setting of \cs{protect}.}
% \changes{v1.0h}{1994/11/04}{Added \cs{protected@write} to
%    \cs{addtocontents}.  ASAJ.}
%
%    \begin{macrocode}
\long\def\addtocontents#1#2{%
  \protected@write\@auxout
      {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
      {\string\@writefile{#1}{#2}}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\contentsline#1{\csname l@#1\endcsname}
%    \end{macrocode}
%
% \@dottedtocline{LEVEL}{INDENT}{NUMWIDTH}{TITLE}{PAGE} :
%   Macro to produce a table of contents line with the following
%   parameters:
%     LEVEL    : If LEVEL > \c@tocdepth, then no line produced.
%     INDENT   : Total indentation from the left margin.
%     NUMWIDTH : Width of box for number if the TITLE has a
%                \numberline command.
%                As of 25 Jan 88, this is also the amount of extra
%                indentation added to second and later lines of a
%                multiple line entry. 
%     TITLE    : Contents of entry.
%     PAGE     : Page number.
%
%  Uses the following parameters, which must be set by the document
%  style. They should be defined with \def's.
%    \@pnumwidth : Width of box in which page number is set.
%    \@tocrmarg  : Right margin indentation for all but last line of
%                  multiple-line entries.
%    \@dotsep    : Separation between dots, in mu units.
%                  Should be \def'd to a number like 2 or 1.7
%
% \end{oldcomments}
% \begin{macro}{\@dottedtocline}
% \changes{LaTeX2.09}{1991/09/29}
%         {(RmS) added \cmd{\reset@font} for page number}
% \changes{v1.0e}{1994/05/25}{Put braces around argument 4
%          (the actual toc entry) to avoid font (and possibly other)
%           changes leaking out to the leaders.}
% \changes{v1.0g}{1994/10/18}{Added \cs{normalcolor} for page number}
%    \begin{macrocode}
\def\@dottedtocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else
  \vskip \z@ \@plus.2\p@
  {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
    \parindent #2\relax\@afterindenttrue
   \interlinepenalty\@M
   \leavevmode
   \@tempdima #3\relax
   \advance\leftskip \@tempdima \hbox{}\hskip -\leftskip
    {#4}\nobreak\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep
       mu$}\hfill \nobreak
           \hbox to\@pnumwidth{%
             \hfil\reset@font\rmfamily \normalcolor #5}\par}\fi}
%    \end{macrocode}
% \end{macro}
% \begin{oldcomments}
%
% Note: \nobreak's added 7 Jan 86 to prevent bad line break that
% left the page number dangling by itself at left edge of a new line.
%
% Changed 25 Jan 88 to use \leftskip instead of \hangindent so
% leaders of multiple-line contents entries would line up properly.
%
% \numberline{NUMBER} : For use in a \contentsline command.
%   It puts NUMBER flushleft in a box of width \@tempdima
%   (Before 25 Jan 88 change, it also added \@tempdima to the hanging
%   indentation.)
%
%    \begin{macrocode}
\def\numberline#1{\hbox to\@tempdima{#1\hfil}}
%</2ekernel>
%    \end{macrocode}
% \end{oldcomments}
%
% \Finale
%
