\def\fileversion{v34}
\def\filedate{2000/12/13}
% minitoc.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Jean-Pierre Drucbert
% ONERA/Toulouse/SRI
% Office national d'\'etudes et de recherches a\'erospatiales
% Centre de Toulouse
% Service r\'eseaux et informatique
% Complexe scientifique de Rangueil
% 2, Avenue \'Edouard Belin
% BP 4025
% F-31055 TOULOUSE CEDEX
% FRANCE
%
% Phone +33-62-25-25-15
%
% Email: drucbert@onecert.fr
%
% Please send me any (constructive) suggestions and comments.

% mtc31hyp.sty (version v31href): (renamed minitoc.sty, version 31 (JPFD))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Patched by Heiko Oberdiek <oberdiek@ruf.uni-freiburg.de>
% to work with _and_ without hyperref.sty.
% The forth argument of hyperref's \contentsline
% is transparently passed through.
% It uses the patches of v30href (see below).
% Additions and changes are marked with %%HO.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% mtc30hyp.sty (version v30href):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Patched by Heiko Oberdiek <oberdiek@ruf.uni-freiburg.de>
% to work with hyperref.sty.
% It uses the patches of v28href (see below).
% Additions and changes are marked with %%HO.
% Bug fix: \stepcounter{mtc} removed in
%          starchapter part of \PTC@contentsline.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% minitoc-hyper.sty (version v28href):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Temporarily patched by Bernd Jaehne [Bernd.Jaehne@aeon.de]
% and Didier Verna [verna@inf.enst.fr] to
% work with hyperref.sty from s.rahtz@elsevier.co.uk
% using input from Tony Roberts [aroberts@usq.edu.au]
% For changes see comments %%BJ and %DV
%
% However: this patch works only when  hyperref.sty is used,
% otherwise errors occur. Thus it may be advisable to add code
% so that minitoc runs both in standard and hyperref mode.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% History (contains some obsolete things... it is NOT
% the REAL documentation)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% minitoc.sty --- redefines the \chapter command to display a
%  mini-table-of-contents at the beginning of every chapter.
%  Oct-90       Original version, by Nigel Ward.
%  Nov-91       Revised to reuse \chapter, \section, \subsection
%               commands transparently, generate toc-file-name
%               automatically,
%               assorted other cleanup.  Dan Jurafsky
%  Jun/Jul-93   New design, to avoid allocating a newwrite
%               for each chapter (!)
%               Added \chapterend to terminate the scope of a minitoc.
%               (IF YOU FORGOT PUTTING \chapterend at the end
%               of EACH chapter, an entry for the next chapter
%               will appear in each minitoc.) (Thanks to Yufan Hu).
%               Replaced ``minipage'' environnement by a ``verse''
%               environnement, to allow a minitoc split across pages.
%               All the layout of the minitoc is in the
%               \minitableofcontents command, so if someboby wants
%               to redefine that layout, he has just to
%               rewrite it (and only it).
%
%               You can inhibit the minitoc for the next chapter
%               by preceding it with \minitocno. (\minitocyes
%               is useless for the user: it is implicit AFTER
%               the \chapter* pseudo-chapters).
%
%               Problems: you MUST have \chapterend to terminate each
%               chapter with a minitoc.
%               How about avoiding this constraint?
%
%               The depth of the minitoc is user-adjustable with
%               the counter `minitocdepth' (as `tocdepth' for the table
%               of contents).
%               At least three passes (3!!!) of LaTeX are necessary to
%               get correct minitoc's (the first pass creates the
%               .mtcX files, the second uses them (but they may
%               contain wrong page numbers) and recreates them,
%               the third should be ok).
%
%               Works with \chapter[xxx]{yyy} and floating bodies.
%               Works with two columns (but the minitoc is composed in
%               one column; how to make it to spread over the two
%               column?)
%               Some mods added to work with xr.sty (external
%               references). xr.sty version 5 is much more tolerant.
%   05Jul93     Version 2
%               Added compatibility with hangcaption.sty (the option
%               hangcaption (if present) must be given BEFORE minitoc
%               option.)
%               BEWARE to options modifying \@caption
%               Version 3 not released (buggy)
%   09Jul93     Version 4
%               Added \if@realch to avoid contentslines from
%               pseudo-chapters to go into the toc!
%               The option file mtcoff.sty allows to use a latex
%               document with minitoc commands and to make them
%               transparent: just replace the minitoc option by
%               mtcoff.
%   13Jul93     Version 5
%               Added a selection mechanism to not write spurious
%               things in the minitoc's.
%   15Jul93     Version 6
%               Fixed problems about chapters in the toc,
%               removed obsolete \caption stuff (filters are better)
%               added compatibility with toch.sty
%               (toch.sty makes a table of chapters. If used,
%               must be loaded BEFORE minitoc.sty)
%   22Jul93     Version 7 (MAJOR DIFFERENCES)
%               Completely rewritten, using tricks from xr.sty
%               (the version 5, by David Carlisle). The info
%               for minitocs is directly stolen from the .toc
%               file.
%               \chapterend and \minitocno are suppressed
%               \minitoc, \dominitoc and \faketableofcontents added
%   29Jul93     Version 8
%               Spacing adjustements.
%   04Aug93     Version 9
%               Added mods for MS-DOS (search MS-DOS, uncomment;
%               search UNIX, comment out). MS-DOS allows only
%               3 characters for extensions in file names
%               (what a pity!).
%   05Aug93     Version 10
%               Works with appendices.
%               Detects obsolete versions of latex.tex.
%               (\@inputcheck or \reset@font not defined).
%   18Aug93     Version 11
%               Added \mtcSfont, font for section entries,
%               \mtcSSfont for subsection entries,
%               \mtcSSSfont for subsubsection entries,
%               \mtcPfont for paragraph entries,
%               \mtcSPfont for subparagraph entries.
%
%   16Dec93     Version 12
%               Use \kern's in place of \vspace*'s,
%               and added penalties (\nopagebreak) to
%               avoid a page break just before last \mtc@rule.
%               Also added a \samepage environnement.
%               Removed old commented out lines from
%               previous versions.
%
%   17Dec93     Version 13
%               Added minilof and minilot stuff.
%               For MS-DOS, uncomment the definition of \SHORTEXT.
%
%   03Jan94     Version 14
%               Corrected space under minitoc/lof/lot and added a
%               \raggedright to avoid ``underfull'' warnings.
%               Corrected some spacing problems (avoiding ~'s).
%               \mtifont changed from \normalsize\bf to
%               \large\bf.
%               Some mods suggested by Donald Arseneau (thanks):
%               \@newread becomes \newread, not outer
%               version of \newread.
%               \empty replaced by \relax in the spare definition
%               of \reset@font.
%               Removed \clubpenalty=10000 and \widowpenalty=10000
%               (done by \samepage), and \noindent.
%               Simplified processing of optional argument in
%               \minitoc, \minilof and \minilot.
%
%   27Jan94     Version 15
%               Added parttoc, partlof and partlot for books,
%               with commands and parameters parallel to
%               those for mini-things.
%
%               Added secttoc, sectlof and sectlot for articles,
%               with commands and parameters parallel to
%               those for mini-things.
%
%   02Feb94     Version 16
%               Bug fixes (typos).
%
%   23Jun94     Version 17
%               Keyword 'n' (null) synonym of 'e' (empty).
%               Compatibility with LaTeX ``2e''.
%               Thanks to Denis Roegel (who found
%               the problem) and Frank Mittelbach
%               (who gave the hints to solve).
%
%   26Jun94     Version 18
%               Make minitoc really compatible with latex2e
%               Introduce the language files as options
%               Thanks to Michel Goossens (via Frank Mittelbach)
%               who was inspired by the code of babel (Johannes Braams).
%
%   16Aug94     Version 19
%               Added stuff for numbering of chapters (parts,
%               sections) not starting at 1.
%               \firstchapteris etc. commands added.
%               \mtcrule, \nomtcrule etc. commands added.
%               Corrected a bug in \c@mti.
%               Corrected mtcswedish.sty (Jan Michel Rynning)
%               Corrected appendix in articles
%
%   25Aug94     Version 20
%               Corrected spacing before and after minitocs
%               and siblings.
%               Added \mtcpagenumbers and \nomtcpagenumbers
%               (and siblings) to make minitocs with/without
%               page numbers. Default: page numbers.
%               Corrected (difficult bug) appendix in articles.
%               Corrected vertical spacing.
%               Corrected a problem with chapters numbered
%               with (uppercase) roman numbers.
%
%   07Sep94     Version 21
%               Corrected typos in minitoc.sty and minitoc.tex.
%
%   10Oct94     Version 22
%               Corrected typos in minitoc.sty.
%
%   08Nov94     Version 23
%               Added a missing line in \sectlof@.
%               Works with document classes resetting
%               chapter (or section) number at each part.
%               (Thanks to Denis Roegel)
%               Removed stuff for \firstchapteris and co.
%               These commands are obsolete.
%               Removed appendix stuff.
%
%   21Dec94     Version 24
%               The \protect commands have been removed from
%               the .toc, .lot and .lot files, so some internal
%               macros have been corrected to be compatible
%               with the LaTeX2e release of December 1994.
%               Thanks to Denis Roegel who did the work.
%
%   13Sep96     Version 25
%               Updated mtcnorsk.sty and added mtcnynorsk.sty
%                on a suggestion from Dag Langmyhr (dag@ifi.uio.no).
%
%   14Nov96     Version 26
%               Language specific commands are now names <language>.mld
%               (in place of mtc<language>.sty) because they are not
%               packages and it makes shorter names.
%               Added breton, estonian, germanb, greek, irish,
%               russianb, scottish, lower and upper sorbian;
%               renamed esperanto into esperant like in Babel.
%
%   20Dec96     Version 27
%               Corrections for starred sectionning commands.
%               english.mld loaded as default language.
%               Added vietnam.mld.
%               Added arab.mld.
%               Renamed minitocoff.sty into mtcoff.sty to
%               keep the name short.
%
%   29Oct97     Version 28
%               Added afrikaan(s) language
%               Added brazil language
%               Added ethiopia(n) language
%               Added autoconfiguration of extensions
%               Added shortext option
%               Added COFFEE stuff
%               Added \addstarred stuff (for starchapter stuff)
%               Fixed bug in parttocs.
%
%   17Nov98     Version 28
%               15Jun98: a typo corrected by Donald Arseneau:
%                 {\let@dottedtocline\@undottedtocline}{}
%               should probably be
%                 {\let\@dottedtocline\@undottedtocline}{}
%                      ^
%                      |
%               Thanks to him.
%
%               Added thebahasa language
%
%   03Dec98     Version 28
%                Added the tight option
%
%   16Mar99     Version 29
%               Added the bicig, buryat, mongol and russianc languages
%   28Jun99     Added the armenian language (from ArmTeX)
%   23Jul99     Added the dotted/undotted options (default: dotted)
%   29Jul99     Added the lithuanian language
%
%   06Dec99     Version 30
%               Added the basque, ngermanb, serbian, ukraineb,
%               and welsh languages.
%               Corrected a bug on \sltname definition (mlt->slt).
%
%   04Avr2000   Version 31
%               Added compatibility with hyperref.sty,
%               thanks to Heiko Oberdiek <oberdiek@ruf.uni-freiburg.de>,
%               who has also simplified some code and fixed the
%               infamous \chapter* bug.
%
%   08Aug2000   Version 32
%               Added commands:
%                     \before|part|toc
%                     \after |    |lof
%                            |    |lot
%               and
%                     \thispagepart|toc|style
%                                  |lof|
%                                  |lot|
%
%               Documentation improved by Stefan Ulrich
%               <ulrich@cis.uni-muenchen.de>.
%
%               \nomtcrule corrected
%
%   07Dec2000   Version 33
%               Added commands:
%                     \mtcadd|chapter|[title]
%                            |section|
%                            |part|
%
%   These commands add stuff in the .toc, .lof and .lot files for
%   the \chapter* (\section* and \part*) problem. From a suggestion
%   by Karl F. Everitt (everitt@chem.skin1.chem.wisc.edu).
%
%   08Dec2000   Version 33
%               Corrected a feature in \mtcaddchapter & co.
%               with a blank optionnal argument.
%
%   13Dec2000b  Version 34
%
%   Jean-Pierre F. Drucbert
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}[1996/06/01]%
%%% This file will not work with latex2.09
\ProvidesPackage{minitoc}[\filedate\space\fileversion\space
                        Package minitoc, patched for hyperref]
\typeout{*** minitoc package, version 34 ***}%
%%HO: <begin>
\typeout{*** patched for hyperref ***}%
\AtBeginDocument{%
  \@ifpackageloaded{hyperref}{%
    \def\toclevel@xpart{1000}%
    \def\toclevel@xchapter{1000}%
    \def\toclevel@xsect{1000}%
    \let\toclevel@starchapter\toclevel@chapter
    \let\toclevel@starsection\toclevel@section
    \let\toclevel@starsubsection\toclevel@subsection
    \let\toclevel@starsubsubsection\toclevel@subsubsection
    \let\toclevel@starparagraph\toclevel@paragraph
    \let\toclevel@starsubparagraph\toclevel@subparagraph
  }{}%
}
%%HO: <end>
\@ifundefined{part}{%
}{%
  \typeout{*** part level macros available ***}
  \let\mtc@svspart\@spart %28d
  \def\@spart{\stepcounter{ptc}\mtc@svspart} %28d
  \let\mtc@svpart\@part %23
  \def\@part{%
    \stepcounter{ptc}%
    \mtc@svpart
  }%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% v33 2000/12/08
% Some macros for testing an empty argument.            % v33 2000/12/08
% (from ifmtarg.sty, Peter R. Wilson and                % v33 2000/12/08
%  Donald Arseneau)                                     % v33 2000/12/08
\begingroup                                             % v33 2000/12/08
\catcode`\Q=3                                           % v33 2000/12/08
\long\gdef\mtc@ifmtarg#1{%                              % v33 2000/12/08
\mtc@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}        % v33 2000/12/08
\long\gdef\mtc@xifmtarg#1#2Q#3#4#5\@nil{#4}             % v33 2000/12/08
% \long\gdef\mtc@ifnotmtarg#1{%                         % v33 2000/12/08
% \mtc@xifmtarg#1QQ\@firstofone\@gobble\@nil}           % v33 2000/12/08
\endgroup                                               % v33 2000/12/08
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% v33 2000/12/08
% Add a \part* and its title in the toc         % v33 2000/12/07
\newcommand{\mtcaddpart}[1][]{%                 % v33 2000/12/07
    \mtc@ifmtarg{#1}{%                          % v33 2000/12/08
    \addcontentsline{toc}{xpart}{}%             % v33 2000/12/07
    }{%                                         % v33 2000/12/08
    \addcontentsline{toc}{part}{#1}%            % v33 2000/12/07
    }                                           % v33 2000/12/08
    \addcontentsline{lof}{xpart}{}%             % v33 2000/12/07
    \addcontentsline{lot}{xpart}{}%             % v33 2000/12/07
    \adjustptc%                                 % v33 2000/12/07
}                                               % v33 2000/12/07
} %23
\@ifundefined{chapter}{%
  \@ifundefined{section}{%
    \typeout{*** no section or chapter level macros available ***}%
    \typeout{*** PLEASE VERIFY YOUR MAIN DOCUMENT CLASS ***}%
  }{%
    \typeout{*** section level macros available ***}%
    \let\mtc@svsection\section %23
    \def\section{\stepcounter{stc}\mtc@svsection} %23
    \let\mtc@svss\@ssect %23
%v25 \def\@ssect{\addtocounter{stc}{-1}\mtc@svss} %23
% Add a \section* and its title in the toc      % v33 2000/12/07
\newcommand{\mtcaddsection}[1][]{%              % v33 2000/12/07
    \mtc@ifmtarg{#1}{%                          % v33 2000/12/08
    \addcontentsline{toc}{xsection}{}%          % v33 2000/12/08
    }{%                                         % v33 2000/12/08
    \addcontentsline{toc}{section}{#1}%         % v33 2000/12/07
    }%                                          % v33 2000/12/08
    \addcontentsline{lof}{xsection}{}%          % v33 2000/12/07
    \addcontentsline{lot}{xsection}{}%          % v33 2000/12/07
    \adjuststc%                                 % v33 2000/12/07
}                                               % v33 2000/12/07
  }%
}{%
  \typeout{*** chapter level macros available ***}
  \let\mtc@svchapter\@chapter %23
  \def\@chapter{\stepcounter{mtc}\mtc@svchapter} %23
% Add a \chapter* and its title in the toc      % v33 2000/12/07
\newcommand{\mtcaddchapter}[1][]{%              % v33 2000/12/07
    \mtc@ifmtarg{#1}{%                          % v33 2000/12/08
    \addcontentsline{toc}{xchapter}{}%          % v33 2000/12/07
    }{%                                         % v33 2000/12/08
    \addcontentsline{toc}{chapter}{#1}%         % v33 2000/12/07
    }%                                          % v33 2000/12/08
    \addcontentsline{lof}{xchapter}{}%          % v33 2000/12/07
    \addcontentsline{lot}{xchapter}{}%          % v33 2000/12/07
    \adjustmtc%                                 % v33 2000/12/07
}                                               % v33 2000/12/07
}
\newwrite\tf@mtc  % a file descriptor to write minitocs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% AUTOCONFIG (v28)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\typeout{*** Autoconfiguration of extensions ***}
\newif\if@longextensions\@longextensionsfalse

%---------------------------------
%The order of the writes is vital!
%---------------------------------
\immediate\openout\tf@mtc \jobname.mtc1
\immediate\write\tf@mtc{\string\@longextensionstrue}
\immediate\closeout\tf@mtc

\immediate\openout\tf@mtc \jobname.mtc
\immediate\write\tf@mtc{\string\@longextensionsfalse}
\immediate\closeout\tf@mtc

\input{\jobname.mtc1}

% Cover our tracks (scratch the files!):
\immediate\openout\tf@mtc \jobname.mtc
\immediate\closeout\tf@mtc

\immediate\openout\tf@mtc \jobname.mtc1
\immediate\closeout\tf@mtc


\if@longextensions
\typeout{*** Long extensions (Unix-like) will be used ***}
\else
\typeout{*** Short extensions (MSDOS-like) will be used ***sight***}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% v27 : claim the type of system!
\if@longextensions%
\typeout%
{==> this version is configured for UNIX-like (long extensions) file names.}%
\else
\typeout{==> this version is configured for MSDOS-like (8+3) file names.}
\fi
%
% Option tight: the flag (1998/12/03)
\newif\iftightmtc \tightmtcfalse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%not outer version of \newread
\def\newread{\alloc@6\read\chardef\sixt@@n}
\@ifundefined{@inputcheck}%
  {\typeout{Your version of latex.tex is obsolete.}%
  \typeout{Trying to continue...}\newread\@inputcheck\relax}{}
\@ifundefined{reset@font}%
  {\typeout{Your version of latex.tex is very obsolete.}%
  \typeout{Trying to continue... crossing fingers.}%
  \let\reset@font\relax}{}

\newtoks\mtc@toks
\def\mtc@string{\relax}
\newbox\mtc@strutbox
\setbox\mtc@strutbox=\hbox{\vrule height2.5ex
      depth1.8ex width\z@}
\def\mtc@strut{\relax\ifmmode\copy\mtc@strutbox\else\unhcopy\mtc@strutbox\fi}
\def\mtc@v{\leavevmode%
     \mtc@strut\vphantom{Lp$^{l^l}_{p_p}$}}  % a pseudo-strut ?
% \@BBR discourages page breaks
\def\@BBR{\unpenalty\nopagebreak[4]}
% Modified version to ignore the dots and the page number.              % 17b
\def\@undottedtocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else             % 17b
  \vskip \z@ plus.2\p@                                                  % 17b
  {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip    % 17b
    \parindent #2\relax\@afterindenttrue                                % 17b
   \interlinepenalty\@M                                                 % 17b
   \leavevmode                                                          % 17b
   \@tempdima #3\relax \advance\leftskip \@tempdima \hbox{}%            % 17b
   \hskip -\leftskip                                                    % 17b
    #4\nobreak\hfill \nobreak                                           % 17b
           \null\par}\fi}                                               % 17b
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%17b
\def\mtcpagenumbers{\let\mtc@pgno\null}         %17b
\mtcpagenumbers %default                        %17b
\def\nomtcpagenumbers{\let\mtc@pgno\relax}      %17b
\def\stcpagenumbers{\let\stc@pgno\null}         %17b
\stcpagenumbers %default                        %17b
\def\nostcpagenumbers{\let\stc@pgno\relax}      %17b
\def\ptcpagenumbers{\let\ptc@pgno\null}         %17b
\ptcpagenumbers %default                        %17b
\def\noptcpagenumbers{\let\ptc@pgno\relax}      %17b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%17b
\def\mlfpagenumbers{\let\mlf@pgno\null}         %17b
\mlfpagenumbers %default                        %17b
\def\nomlfpagenumbers{\let\mlf@pgno\relax}      %17b
\def\slfpagenumbers{\let\slf@pgno\null}         %17b
\slfpagenumbers %default                        %17b
\def\noslfpagenumbers{\let\slf@pgno\relax}      %17b
\def\plfpagenumbers{\let\plf@pgno\null}         %17b
\plfpagenumbers %default                        %17b
\def\noplfpagenumbers{\let\plf@pgno\relax}      %17b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%17b
\def\mltpagenumbers{\let\mlt@pgno\null}         %17b
\mltpagenumbers %default                        %17b
\def\nomltpagenumbers{\let\mlt@pgno\relax}      %17b
\def\sltpagenumbers{\let\slt@pgno\null}         %17b
\sltpagenumbers %default                        %17b
\def\nosltpagenumbers{\let\slt@pgno\relax}      %17b
\def\pltpagenumbers{\let\plt@pgno\null}         %17b
\pltpagenumbers %default                        %17b
\def\nopltpagenumbers{\let\plt@pgno\relax}      %17b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%17b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%32
\let\beforeparttoc\cleardoublepage              %32
\let\beforepartlof\cleardoublepage              %32
\let\beforepartlot\cleardoublepage              %32
\let\afterparttoc\cleardoublepage               %32
\let\afterpartlof\cleardoublepage               %32
\let\afterpartlot\cleardoublepage               %32
\def\thispageparttocstyle{\thispagestyle{empty}}%32
\def\thispagepartlofstyle{\thispagestyle{empty}}%32
\def\thispagepartlotstyle{\thispagestyle{empty}}%32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%32
% if you don't want a table of contents, but want minitocs,
% you need to create the .toc file, without inputing it
% into your document. This command is a stripped off version
% of \tableofcontents
\def\faketableofcontents{\fake@starttoc{toc}}
% idem for list of figures
\def\fakelistoffigures{\fake@starttoc{lof}}
% idem for list of tables
\def\fakelistoftables{\fake@starttoc{lot}}
\def\fake@starttoc#1{\begingroup
  \makeatletter
  \if@filesw \expandafter\newwrite\csname tf@#1\endcsname
             \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
  \fi \global\@nobreakfalse \endgroup}
%%
\global\let\mtc@markboth\markboth
\global\let\@mkboth\markboth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%v30 starchapters
\def\addst@rred#1#2{%
  \addcontentsline{toc}{star#1}{#2}%
  \@ifundefined{c@ptc}{}{%
    \expandafter\ifx\csname #1\endcsname\part
      \stepcounter{ptc}%
    \fi
  }%
  \@ifundefined{c@mtc}{}{%
    \expandafter\ifx\csname #1\endcsname\chapter
      \stepcounter{mtc}%
    \fi
  }%
  \@ifundefined{c@stc}{}{%
    \expandafter\ifx\csname #1\endcsname\section
      \@ifundefined{chapter}{\stepcounter{stc}}{}%
    \fi
  }%
%%%<ESSAI
%  \@ifundefined{c@mtc}{}{%
%    \expandafter\ifx\csname #1\endcsname\starchapter
%      \stepcounter{mtc}%
%    \fi
%  }%
%  \@ifundefined{c@stc}{}{%
%    \expandafter\ifx\csname #1\endcsname\starsection
%      \@ifundefined{chapter}{\stepcounter{stc}}{}%
%    \fi
%  }%
%%%>ESSAI
}
\@ifundefined{chapter}{%
\gdef\addstarredsection#1{\addst@rred{section}{#1}}
}{%
\def\The@chapter{\arabic{mtc}} %23
\def\firstchapteris#1%
  {\typeout{^^JWARNING*** \string\firstchapteris}%
   \typeout{ is an obsolete command^^J}}
\newcounter{mtc}  % counter of minitocs
\setcounter{mtc}{0}
\def\adjustmtc{\stepcounter{mtc}}  %32
\gdef\themtc{\arabic{mtc}}
\newcounter{minitocdepth} % analog to tocdepth, but for minitocs
\setcounter{minitocdepth}{2} % default value
\def\mtc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@} % the \hrule is .4pt high

\newlength\mtcindent % indentation (left/right) of minitocs
\mtcindent=24pt      % defaut value
\def\mtcfont{\small\rm}    % font for the minitoc
\def\mtcSfont{\small\bf}   % font for the minitoc (sections)
\def\mtcSSfont{\mtcfont}   % font for the minitoc (subsections)
\def\mtcSSSfont{\mtcfont}  % font for the minitoc (subsubsections)
\def\mtcPfont{\mtcfont}    % font for the minitoc (paragraphs)
\def\mtcSPfont{\mtcfont}   % font for the minitoc (subparagraphs)
\def\mlffont{\mtcfont}     % font for the minilof (figures)
\def\mltfont{\mtcfont}     % font for the minilot (tables)
\def\mtifont{\large\bf}    % font for titles
\def\coffeefont{\small\sl} % font for COFFEE breaks

% Centering, flushleft, flushright or empty titles.
\def\c@mti#1{\null\hfill #1\hfill\null}
\def\l@mti#1{\null #1\hfill\null}
\def\r@mti#1{\null\hfill #1\null}
\def\e@mti#1{\relax}
\def\n@mti#1{\relax}

% Default: titles on left
\let\do@mtitc\l@mti
\let\df@mtitc\l@mti
\let\do@mtilf\l@mti
\let\df@mtilf\l@mti
\let\do@mtilt\l@mti
\let\df@mtilt\l@mti

%v27 Language dependent names: default values. Now
%v27 english.mld is loaded first.
%v27 \@ifundefined{mtctitle}{\def\mtctitle{Contents}}{\relax}
%v27 \@ifundefined{mlftitle}{\def\mlftitle{Figures}}{\relax}
%v27 \@ifundefined{mlttitle}{\def\mlttitle{Tables}}{\relax}

\def\mtc@verse{\let\\=\@centercr
  \list{}{\itemsep\z@\itemindent \z@\listparindent \itemindent
  \iftightmtc
          \parsep\z@ % 19981203
  \fi
          \leftmargin\mtcindent
          \rightmargin\leftmargin}\item[]}
\def\endmtc@verse{\nopagebreak[4]\endlist}

% this command must be used after \chapter
% if you need a minitoc (no automatic minitoc)
\def\minitoc{\@ifnextchar[{\minitoc@}{\minitoc@[d]}}

\def\minitoc@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@mtitc\e@mti
        \else\if #1n\let\do@mtitc\n@mti
        \else\if #1c\let\do@mtitc\c@mti
        \else\if #1l\let\do@mtitc\l@mti
        \else\if #1r\let\do@mtitc\r@mti
        \else\if #1d\let\do@mtitc\df@mtitc
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\mtcfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent %%
        \ifx\mtc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtitc{\mtc@v\mtctitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtitc{\mtc@v\mtctitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\mtcindent
        \rightmargin\mtcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        \begin{mtc@verse}\c@tocdepth=\c@minitocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{mtc@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions
\def\@tocfile{mtc\The@chapter}%  % UNIX
\else
\def\@tocfile{M\The@chapter}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{mtc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\mtc@bottom@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
\def\mtc@bottom@rule{%\kern-3\p@%
  \ifx\mtc@rule\relax\relax\else  % 2000/08/08 v32 pb \nomtcrule
  \vskip 5pt%
  \hrule width \columnwidth \kern2.6\p@\fi}
        % some space under the minitoc

% Added in version #13
% this command must be used after \chapter
% if you need a minilof (no automatic minilof)
\def\minilof{\@ifnextchar[{\minilof@}{\minilof@[d]}}

\def\minilof@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@mtilf\e@mti
        \else\if #1n\let\do@mtilf\n@mti
        \else\if #1c\let\do@mtilf\c@mti
        \else\if #1l\let\do@mtilf\l@mti
        \else\if #1r\let\do@mtilf\r@mti
        \else\if #1d\let\do@mtilf\df@mtilf
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\mlffont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\mtc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtilf{\mtc@v\mlftitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtilf{\mtc@v\mlftitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\mtcindent
        \rightmargin\mtcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for minilof
        \begin{mtc@verse}%\c@tocdepth=\c@minitocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{mlf@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions%
\def\@tocfile{mlf\The@chapter}%  % UNIX
\else
\def\@tocfile{F\The@chapter}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{mtc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\mtc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
        % some space under the minilof

% Added in version #13
% this command must be used after \chapter
% if you need a minilot (no automatic minilot)
\def\minilot{\@ifnextchar[{\minilot@}{\minilot@[d]}}

\def\minilot@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@mtilt\e@mti
        \else\if #1n\let\do@mtilt\n@mti
        \else\if #1c\let\do@mtilt\c@mti
        \else\if #1l\let\do@mtilt\l@mti
        \else\if #1r\let\do@mtilt\r@mti
        \else\if #1d\let\do@mtilt\df@mtilt
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\mltfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\mtc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtilt{\mtc@v\mlttitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\mtifont\do@mtilt{\mtc@v\mlttitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\mtcindent
        \rightmargin\mtcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for minilot
        \begin{mtc@verse}%\c@tocdepth=\c@minitocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{mlt@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions%
\def\@tocfile{mlt\The@chapter}%  % UNIX
\else
\def\@tocfile{T\The@chapter}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{mtc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\mtc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
        % some space under the minilot

% I use a depth of 10000 to inhibit the printing of
% that contentsline.
\def\l@xchapter{\@dottedtocline{\@M}{1em}{2.3em}}
\def\xchapter{xchapter}

\let\sv@chapter\@chapter
\def\@chapter[#1]#2{\sv@chapter[{#1}]{#2}\relax%
\addcontentsline{lof}{xchapter}{#1}%
\addcontentsline{lot}{xchapter}{#1}%
\ignorespaces% %% Added 2000/05/02 (Adam Lewenberg <ahl@uakron.edu>)
}

% tricky code to deal with \chapter*
\let\mtc@schapter\@schapter
\def\@schapter{%
\addtocontents{toc}{\protect\chapterend}\mtc@schapter%
}
\def\@schapter{%
\addtocontents{toc}{\protect\chapterbegin}\mtc@schapter%
}
\let\chapterend\relax
\let\chapterbegin\relax

%v28b
\@ifundefined{chapter}%
{\@ifundefined{section}{}{\def\addstarredsection#1{\addst@rred{section}{#1}}}}
{\def\addstarredchapter#1{\addst@rred{chapter}{#1}}}
\@ifundefined{part}{}%
{\def\addstarredpart#1{\addst@rred{part}{#1}}}

% for havlick COFFEE
\def\addcoffeeline#1#2#3{%
  \addtocontents{#1}{\protect\coffeeline{#2}{#3}{\null}}}
\def\coffeeline#1{\csname l@#1\endcsname}
\newcommand*\l@coffee{\@Undottedtocline{1}{1.5em}{2.3em}}
\def\@Undottedtocline#1#2#3#4#5{%
%\typeout{UNDOT}
  \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 \null\nobreak\hskip -\leftskip
     {\coffeefont #4}\nobreak
%     \leaders\hbox{$\m@th
%        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
%        mu$}%
%        \hfill
     \nobreak\null
%     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
     \par}%
  \fi}

% The same but with the page number
%

\def\@Undottedtoclinep#1#2#3#4#5{%
%\typeout{UNDOT}
  \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 \null\nobreak\hskip -\leftskip
     {#4}\nobreak
%     \leaders\hbox{$\m@th
%        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
%        mu$}%
        \hfill
     \nobreak\null
     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
     \par}%
  \fi}

\let\appendixmtc\relax

%
% Hacks to remove the dots in the minitocs
% Bug fixed 2000/04/26 v31
% about optional argument
%

\newif\ifundottedmtc\undottedmtcfalse
\@ifundefined{chapter}{}{%
\let\sv@minitoc@\minitoc@
\def\minitoc@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@minitoc@[#1]}}
\let\sv@minilof@\minilof@
\def\minilof@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@minilof@[#1]}}
\let\sv@minilot@\minilot@
\def\minilot@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@minilot@[#1]}}}

\@ifundefined{part}{}{%
\let\sv@parttoc@\parttoc@
\def\parttoc@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@parttoc@[#1]}}
\let\sv@partlof@\partlof@
\def\partlof@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@partlof@[#1]}}
\let\sv@partlot@\partlot@
\def\partlot@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@partlot@[#1]}}}


\@ifundefined{chapter}{%
\@ifundefined{section}{}{%
\let\sv@secttoc@\secttoc@
\def\secttoc@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@secttoc@[#1]}}
\let\sv@sectlof@\sectlof@
\def\sectlof@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@sectlof@[#1]}}
\let\sv@sectlot@\sectlot@
\def\sectlot@[#1]{{\ifundottedmtc\let\@dottedtocline\@Undottedtoclinep\fi
\sv@sectlot@[#1]}}}}{}


% this command extracts info from the .toc file
% and create the .mtcN files (.mtc -> .M on MS-DOS)
\def\@dominitoc#1{{%
  \makeatletter
  \setcounter{mtc}{0} % START VALUE
  \MTC@next#1.toc\relax\\}\setcounter{mtc}{0}} %23: raz
% this command extracts info from the .lof file
% and create the .mlfN files (.mlf -> .F on MS-DOS)
\def\@dominilof#1{{%
  \makeatletter
  \setcounter{mtc}{0} % START VALUE
  \MLF@next#1.lof\relax\\}\setcounter{mtc}{0}} %23: raz
% this command extracts info from the .lot file
% and create the .mltN files (.mlt -> .T on MS-DOS)
\def\@dominilot#1{{%
  \makeatletter
  \setcounter{mtc}{0} % START VALUE
  \MLT@next#1.lot\relax\\}\setcounter{mtc}{0}} %23: raz

\def\dominitoc{\@ifnextchar[{\dominitoc@}{\dominitoc@[l]}}
\def\dominilof{\@ifnextchar[{\dominilof@}{\dominilof@[l]}}
\def\dominilot{\@ifnextchar[{\dominilot@}{\dominilot@[l]}}

\def\dominitoc@[#1]{%
\if #1e\let\df@mtitc\e@mti%
\else\if #1n\let\df@mtitc\n@mti%
\else\if #1c\let\df@mtitc\c@mti%
\else\if #1l\let\df@mtitc\l@mti%
\else\if #1r\let\df@mtitc\r@mti%
\fi\fi\fi\fi\fi%
\@@dominitoc}

\def\dominilof@[#1]{%
\if #1e\let\df@mtilf\e@mti%
\else\if #1n\let\df@mtilf\n@mti%
\else\if #1c\let\df@mtilf\c@mti%
\else\if #1l\let\df@mtilf\l@mti%
\else\if #1r\let\df@mtilf\r@mti%
\fi\fi\fi\fi\fi%
\@@dominilof}

\def\dominilot@[#1]{%
\if #1e\let\df@mtilt\e@mti%
\else\if #1n\let\df@mtilt\n@mti%
\else\if #1c\let\df@mtilt\c@mti%
\else\if #1l\let\df@mtilt\l@mti%
\else\if #1r\let\df@mtilt\r@mti%
\fi\fi\fi\fi\fi%
\@@dominilot}

\def\@@dominitoc{\@dominitoc{\jobname}\immediate\closeout\tf@mtc}
\def\@@dominilof{\@dominilof{\jobname}\immediate\closeout\tf@mtc}
\def\@@dominilot{\@dominilot{\jobname}\immediate\closeout\tf@mtc}

\def\MTC@next#1\relax#2\\{%
  \edef\MTC@list{#2}%
  \MTC@loop{#1}%
}
\def\MTC@toc{%
  \ifx\MTC@list\@empty\else\expandafter\MTC@explist\fi
}


\def\MTC@contentsline#1#2#3#4{% %%HO/BJ: 4 instead of 3 parameters
  \gdef\themtc{\arabic{mtc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\chapter
    \stepcounter{mtc}% % the mtc counter simulates the chapter counter
    \if@longextensions%
      \typeout{Writing\space\jobname.mtc\themtc}%     % UNIX
      \def\mtcname{\jobname.mtc\themtc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.M\themtc}%       % MS-DOS
      \def\mtcname{\jobname.M\themtc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .mtcN .mtc->.M on MS-DOS
    \immediate\openout\tf@mtc=\mtcname % open next .mtcN (.mtc->.M if MS-DOS)
  \fi
  \mtc@toks{\noexpand\leavevmode #2}%
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\section
    \MTC@WriteContentsline{#1}{mtcS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\coffee
    \MTC@WriteCoffeeline{#1}{#3}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsection
    \MTC@WriteContentsline{#1}{mtcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsubsection
    \MTC@WriteContentsline{#1}{mtcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\paragraph
    \MTC@WriteContentsline{#1}{mtcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subparagraph
    \MTC@WriteContentsline{#1}{mtcSP}{#3}{#4}%
  \fi
% Added v25: \starchapter and co.
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\starchapter
    \stepcounter{mtc}% % the mtc counter simulates the chapter counter
    \if@longextensions
      \typeout{Writing\space\jobname.mtc\themtc}%     % UNIX
      \def\mtcname{\jobname.mtc\themtc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.M\themtc}%       % MS-DOS
      \def\mtcname{\jobname.M\themtc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .mtcN .mtc->.M on MS-DOS
    \immediate\openout\tf@mtc=\mtcname % open next .mtcN (.mtc->.M if MS-DOS)
  \fi
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\starsection
    \MTC@WriteContentsline{#1}{mtcS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsection
    \MTC@WriteContentsline{#1}{mtcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsubsection
    \MTC@WriteContentsline{#1}{mtcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starparagraph
    \MTC@WriteContentsline{#1}{mtcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubparagraph
    \MTC@WriteContentsline{#1}{mtcSP}{#3}{#4}%
  \fi
}

\def\MTC@explist{\expandafter\MTC@next\MTC@list\\}
\def\MTC@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JMINITOCS NOT PREPARED.^^J}%
    \expandafter\MTC@toc
  \else
    \typeout{PREPARING MINITOCS FROM #1}%
    \expandafter\MTC@read
  \fi
}
\def\MTC@read{%
  \read\@inputcheck to\MTC@line
  \expandafter\MTC@test\MTC@line.....\MTC@% %%HO: . added
}%
%%HO/BJ: now patch \MTC@test,
%%HO/BJ: call \MTC@contentsline with 4 instead of 3 parameters
\long\def\MTC@test#1#2#3#4#5#6\MTC@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \MTC@contentsline{#2}{#3}{#4}{#5}%
    %%HO/BJ: 4. parameter added by Tony Roberts
    \let\mtc@string\relax
  \else\ifx#1\@input
    \edef\MTC@list{\MTC@list#2\relax}%
  \else\ifx#1\chapterend % \chapter* closes .mtcN (.mtc->.M on MS-DOS)
    \immediate\closeout\tf@mtc
    \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\chapterbegin
    \addtocounter{mtc}{-1}% % \chapter* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck
    \expandafter\MTC@toc
  \else
    \expandafter\MTC@read
  \fi
}%

\def\MLF@next#1\relax#2\\{%
  \edef\MLF@list{#2}%
  \MLF@loop{#1}}
\def\MLF@lof{%
  \ifx\MLF@list\@empty\else\expandafter\MLF@explist\fi}

\def\MLF@contentsline#1#2#3#4{% %%HO: added #4
  \gdef\themtc{\arabic{mtc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\xchapter
    \stepcounter{mtc}% % the mtc counter simulates the chapter counter
    \if@longextensions%
      \typeout{Writing\space\jobname.mlf\themtc}%     % UNIX
      \def\mlfname{\jobname.mlf\themtc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.F\themtc}%       % MS-DOS
      \def\mlfname{\jobname.F\themtc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .mlfN .mlf->.F on MS-DOS
    \immediate\openout\tf@mtc=\mlfname % open next .mlfN (.mlf->.F if MS-DOS)
  \fi
  % extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\figure
    \mtc@toks{\noexpand\leavevmode#2}%
    \MTC@WriteContentsline{#1}{mlf}{#3}{#4}%
  \fi
}

\def\MLF@explist{\expandafter\MLF@next\MLF@list\\}
\def\MLF@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JMINILOFS NOT PREPARED.^^J}%
    \expandafter\MLF@lof
  \else
    \typeout{PREPARING MINILOFS FROM #1}%
    \expandafter\MLF@read\fi}
\def\MLF@read{%
  \read\@inputcheck to\MLF@line
  \expandafter\MLF@test\MLF@line.....\MLF@% %%HO: . added
  }%
\long\def\MLF@test#1#2#3#4#5#6\MLF@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \MLF@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\MLF@list{\MLF@list#2\relax}%
  \else\ifx#1\chapterend % \chapter* closes .mlfN (.mlf->.F on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\chapterbegin
    \addtocounter{mtc}{-1}% % \chapter* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\MLF@lof
  \else\expandafter\MLF@read\fi}%

\def\MLT@next#1\relax#2\\{%
  \edef\MLT@list{#2}%
  \MLT@loop{#1}}
\def\MLT@lot{%
  \ifx\MLT@list\@empty\else\expandafter\MLT@explist\fi}

\def\MLT@contentsline#1#2#3#4{% %%HO: #4 added
  \gdef\themtc{\arabic{mtc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\xchapter
    \stepcounter{mtc}% % the mtc counter simulates the chapter counter
    \if@longextensions%
      \typeout{Writing\space\jobname.mlt\themtc}%     % UNIX
      \def\mltname{\jobname.mlt\themtc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.T\themtc}%       % MS-DOS
      \def\mltname{\jobname.T\themtc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .mltN .mlt->.T on MS-DOS
    \immediate\openout\tf@mtc=\mltname % open next .mltN (.mlt->.T if MS-DOS)
  \fi
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\table
     \mtc@toks{\noexpand\leavevmode#2}%
     \MTC@WriteContentsline{#1}{mlt}{#3}{#4}%
  \fi
}

\def\MLT@explist{\expandafter\MLT@next\MLT@list\\}
\def\MLT@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JMINILOTS NOT PREPARED.^^J}%
    \expandafter\MLT@lot
  \else
    \typeout{PREPARING MINILOTS FROM #1}%
    \expandafter\MLT@read\fi}
\def\MLT@read{%
  \read\@inputcheck to\MLT@line
  \expandafter\MLT@test\MLT@line.....\MLT@% %%HO: . added
  }%
\long\def\MLT@test#1#2#3#4#5#6\MLT@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \MLT@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\MLT@list{\MLT@list#2\relax}%
  \else\ifx#1\chapterend % \chapter* closes .mltN (.mlt->.T on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\chapterbegin
        \addtocounter{mtc}{-1}% % \chapter* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\MLT@lot
  \else\expandafter\MLT@read\fi}%
} % end of chapter level

%%HO: new \MTC@WriteContentsline:
%%HO: * makes definition of \MTC@contentsline shorter
%%HO: * extra \edef level removed.
\def\mtc@dot{.}
\def\MTC@WriteContentsline#1#2#3#4{%
  % #1: #1 of \MTC@contentsline
  % #2: font shorthand ==> \csname #2font\endcsname
  % #3: #3 of \MTC@contentsline
  % #4: #4 of \MTC@contentsline
  \def\mtc@param{#4}%
  \immediate\write\tf@mtc{%
    {%
      \string\reset@font
      \expandafter\string\csname #2font\endcsname
      \string\mtc@string
      \string\contentsline{#1}%
      {\the\mtc@toks}%
      {%
        \string\reset@font
        \expandafter\string\csname #2font\endcsname
        \space #3%
      }%
      \ifx\mtc@dot\mtc@param
      \else
        {#4}% %%HO/BJ: #4 is hyperlink
      \fi
    }%
  }%
}
\def\MTC@WriteCoffeeline#1#2#3{%
  % #1: #1 of \MTC@contentsline
  % #2: #3 of \MTC@contentsline
  \immediate\write\tf@mtc{%
    {%
      \string\reset@font
      \string\coffeefont
      \string\mtc@string
%COFFEE \string\textbf{#1}%
      {\the\mtc@toks}%
      {%
        \string\reset@font
        \string\coffeefont
        \space #3%
      }%
    }%
  }%
}

%%%%%%%%%%%%%%%%%%%%%%%%%
%%
% If \part is defined (book or article-like document),
% the following macros are allowed
% Sometimes, we need to make a difference between book and
% article (is \chapter defined?), to have a different layout.
\@ifundefined{part}{}%
{%
\def\xpart{xpart}
\def\ypart{ypart}
\def\Thepart{\arabic{ptc}} %v28c ; that \arabic{part}
\def\firstpartis#1%
  {\typeout{^^JWARNING*** \string\firstpartis}%
   \typeout{ is an obsolete command^^J}}
\newcounter{ptc}  % counter of parttocs
\setcounter{ptc}{0}
\def\adjustptc{\stepcounter{ptc}}  %32
\def\theptc{\arabic{ptc}}
\newcounter{parttocdepth} % analog to tocdepth, but for parttocs
\setcounter{parttocdepth}{2}

\@ifundefined{chapter}{%
\def\ptc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@}% the \hrule is .4pt high
}{\let\ptc@rule\relax} % no rule before/after parttoc/partlof/partlot
                       % for books

\newlength\ptcindent % indentation (left/right) of parttocs
\@ifundefined{chapter}{\ptcindent=24pt}{\ptcindent=0pt} % defaut value

\@ifundefined{chapter}{%
\def\ptcfont{\small\rm}    % font for the parttoc
\def\ptcSfont{\small\bf}   % font for the parttoc (sections)
\def\ptcSSfont{\ptcfont}   % font for the parttoc (subsections)
\def\ptcSSSfont{\ptcfont}  % font for the parttoc (subsubsections)
\def\ptcPfont{\ptcfont}    % font for the parttoc (paragraphs)
\def\ptcSPfont{\ptcfont}   % font for the parttoc (subparagraphs)
\def\plffont{\ptcfont}     % font for the partlof (figures)
\def\pltfont{\ptcfont}     % font for the partlot (tables)
\def\ptifont{\large\bf}    % font for titles
}{%
\def\ptcfont{\normalsize\rm}    % font for the parttoc
\def\ptcCfont{\normalsize\bf}   % font for the parttoc (chapters)
\def\ptcSfont{\normalsize\rm}   % font for the parttoc (sections)
\def\ptcSSfont{\ptcfont}   % font for the parttoc (subsections)
\def\ptcSSSfont{\ptcfont}  % font for the parttoc (subsubsections)
\def\ptcPfont{\ptcfont}    % font for the parttoc (paragraphs)
\def\ptcSPfont{\ptcfont}   % font for the parttoc (subparagraphs)
\def\plffont{\ptcfont}     % font for the partlof (figures)
\def\pltfont{\ptcfont}     % font for the partlot (tables)
\def\ptifont{\Huge\bf}     % font for titles
}

% Centering, flushleft, flushright or empty titles.
\@ifundefined{chapter}{%
\def\c@pti#1{\null\hfill #1\hfill\null}
\def\l@pti#1{\null #1\hfill\null}
\def\r@pti#1{\null\hfill #1\null}
\def\e@pti#1{\relax}
\def\n@pti#1{\relax}
}{%
\def\e@pti#1{\relax}
\def\n@pti#1{\relax}
\def\l@pti#1{\if@twocolumn
    \@topnewpage[\@makephead@l{#1}]%
    \else
    \@makephead@l{#1}%
    \@afterheading
    \fi}
\def\@makephead@l#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright
     \ptifont
     #1\par
     \nobreak
     \vskip 40\p@
    }}
\def\r@pti#1{\if@twocolumn
    \@topnewpage[\@makephead@r{#1}]%
    \else
    \@makephead@r{#1}%
    \@afterheading
    \fi}
\def\@makephead@r#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedleft
     \ptifont
     #1\par
     \nobreak
     \vskip 40\p@
    }}
\def\c@pti#1{\if@twocolumn
    \@topnewpage[\@makephead@c{#1}]%
    \else
    \@makephead@c{#1}%
    \@afterheading
    \fi}
\def\@makephead@c#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \centering
     \ptifont
     #1\par
     \nobreak
     \vskip 40\p@
    }}%
}

% Default: titles on left
\let\do@ptitc\l@pti
\let\df@ptitc\l@pti
\let\do@ptilf\l@pti
\let\df@ptilf\l@pti
\let\do@ptilt\l@pti
\let\df@ptilt\l@pti

%v27 % Language dependent names: default values
%v27 \@ifundefined{chapter}{%
%v27 \@ifundefined{ptctitle}{\def\ptctitle{Contents}}{\relax}
%v27 \@ifundefined{plftitle}{\def\plftitle{Figures}}{\relax}
%v27 \@ifundefined{plttitle}{\def\plttitle{Tables}}{\relax}}%
%v27 {%
%v27 \@ifundefined{ptctitle}{\def\ptctitle{Table of Contents}}{\relax}
%v27 \@ifundefined{plftitle}{\def\plftitle{List of Figures}}{\relax}
%v27 \@ifundefined{plttitle}{\def\plttitle{List of Tables}}{\relax}
%v27 }

\def\ptc@verse{\let\\=\@centercr
  \list{}{\itemsep\z@\itemindent \z@\listparindent \itemindent
          \leftmargin\ptcindent
          \rightmargin\leftmargin}\item[]}
\def\endptc@verse{\nopagebreak[4]\endlist}

% this command must be used after \part
% if you need a parttoc (no automatic parttoc)
\def\parttoc{\@ifnextchar[{\parttoc@}{\parttoc@[d]}}

\def\parttoc@[#1]{%
        \@ifundefined{chapter}{}{\beforeparttoc %32 Yannick Michou (corr. typo)
        \global\let\mtc@markboth\markboth
        \global\let\@mkboth\markboth
%        \thispagestyle{empty}
        \thispageparttocstyle %32
        \mtc@markboth{\uppercase{\ptctitle}}{\uppercase{\ptctitle}}%
        }%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@ptitc\e@pti
        \else\if #1n\let\do@ptitc\n@pti
        \else\if #1c\let\do@ptitc\c@pti
        \else\if #1l\let\do@ptitc\l@pti
        \else\if #1r\let\do@ptitc\r@pti
        \else\if #1d\let\do@ptitc\df@ptitc
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\ptcfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \nopagebreak[4]%
        \ifx\ptc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptitc{\mtc@v\ptctitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptitc{\mtc@v\ptctitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\ptcindent
        \rightmargin\ptcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        \begin{ptc@verse}\c@tocdepth=\c@parttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{ptc@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions%
\def\@tocfile{ptc\Thepart}%  % UNIX
\else
\def\@tocfile{P\Thepart}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{ptc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\ptc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\@ifundefined{chapter}{\pagebreak[1]\vspace*{-1ex}}%
        {\afterparttoc}}                  %32

% this command must be used after \part
% if you need a partlof (no automatic partlof)
\def\partlof{\@ifnextchar[{\partlof@}{\partlof@[d]}}

\def\partlof@[#1]{%
        \@ifundefined{chapter}{}{\beforepartlof %32
        \global\let\mtc@markboth\markboth
        \global\let\@mkboth\markboth
%        \thispagestyle{empty}
        \thispagepartlofstyle                   %32
        \mtc@markboth{\uppercase{\plftitle}}{\uppercase{\plftitle}}%
        }%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@ptilf\e@pti
        \else\if #1n\let\do@ptilf\n@pti
        \else\if #1c\let\do@ptilf\c@pti
        \else\if #1l\let\do@ptilf\l@pti
        \else\if #1r\let\do@ptilf\r@pti
        \else\if #1d\let\do@ptilf\df@ptilf
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\plffont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\ptc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptilf{\mtc@v\plftitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptilf{\mtc@v\plftitle}}\\
        \@ifundefined{chapter}{\hline}{}
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\ptcindent
        \rightmargin\ptcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for partlof
        \begin{ptc@verse}%\c@tocdepth=\c@parttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{plf@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions%
\def\@tocfile{plf\Thepart}%  % UNIX
\else
\def\@tocfile{G\Thepart}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{ptc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\ptc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\@ifundefined{chapter}{\pagebreak[1]\vspace*{-1ex}}%
        {\afterpartlof}}                   %32

% Added in version #13
% this command must be used after \part
% if you need a minilot (no automatic partlot)
\def\partlot{\@ifnextchar[{\partlot@}{\partlot@[d]}}

\def\partlot@[#1]{%
        \@ifundefined{chapter}{}{\beforepartlot   %32
        \global\let\mtc@markboth\markboth
        \global\let\@mkboth\markboth
%        \thispagestyle{empty}
        \thispagepartlotstyle                     %32
        \mtc@markboth{\uppercase{\plttitle}}{\uppercase{\plttitle}}%
        }%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@ptilt\e@pti
        \else\if #1n\let\do@ptilt\n@pti
        \else\if #1c\let\do@ptilt\c@pti
        \else\if #1l\let\do@ptilt\l@pti
        \else\if #1r\let\do@ptilt\r@pti
        \else\if #1d\let\do@ptilt\df@ptilt
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\pltfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\ptc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptilt{\mtc@v\plttitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\ptifont\do@ptilt{\mtc@v\plttitle}}\\
        \@ifundefined{chapter}{\hline}{}
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\ptcindent
        \rightmargin\ptcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for partlot
        \begin{ptc@verse}%\c@tocdepth=\c@parttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{plt@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
\if@longextensions%
\def\@tocfile{plt\Thepart}%  % UNIX
\else
\def\@tocfile{U\Thepart}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{ptc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\ptc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\@ifundefined{chapter}{\pagebreak[1]\vspace*{-1ex}}%
        {\afterpartlot}}                     %32

% I use a depth of 10000 to inhibit the printing of
% that contentsline.
\def\l@xpart{\@dottedtocline{\@M}{1.0em}{2.3em}}
\def\l@ypart{\@dottedtocline{0}{1.0em}{2.3em}}
\def\l@pchapter{\@dottedtocline{1}{1.0em}{2.3em}}
\def\l@psection{\@dottedtocline{2}{1.0em}{2.3em}}

\def\pchapter{pchapter}
\def\psection{psection}

%v28d \let\sv@part\@part
\let\sv@part\mtc@svpart %28d
\def\@part[#1]#2{\sv@part[{#1}]{#2}\relax%
\addcontentsline{lof}{xpart}{#1}%
\addcontentsline{lot}{xpart}{#1}%
\addcontentsline{toc}{xpart}{#1}%v28c
\stepcounter{ptc}%
}

%v28d
%\let\sv@spart\mtc@svspart
\let\sv@spart\@spart
\def\@spart{\stepcounter{ptc}\sv@spart}

% tricky code to deal with \part*
\let\ptc@spart\@spart
\def\@spart{%
\addtocontents{toc}{\protect\partend}\ptc@spart%
}
\def\@spart{%
\addtocontents{toc}{\protect\partbegin}\ptc@spart%
}
\let\partend\relax
\let\partbegin\relax

\let\appendixmtc\relax

% this command extracts info from the .toc file
% and create the .ptcN files (.ptc -> .P on MS-DOS)
\def\@doparttoc#1{{%
  \makeatletter
  \setcounter{ptc}{0} % START VALUE
  \PTC@next#1.toc\relax\\}\setcounter{ptc}{0}} %23; raz
% this command extracts info from the .lof file
% and create the .plfN files (.plf -> .G on MS-DOS)
\def\@dopartlof#1{{%
  \makeatletter
  \setcounter{ptc}{0} % START VALUE
  \PLF@next#1.lof\relax\\}\setcounter{ptc}{0}} %23: raz
% this command extracts info from the .lot file
% and create the .pltN files (.plt -> .U on MS-DOS)
\def\@dopartlot#1{{%
  \setcounter{ptc}{0} % START VALUE
  \makeatletter
  \PLT@next#1.lot\relax\\}\setcounter{ptc}{0}} %23: raz

\def\doparttoc{\@ifnextchar[{\doparttoc@}{\doparttoc@[l]}}
\def\dopartlof{\@ifnextchar[{\dopartlof@}{\dopartlof@[l]}}
\def\dopartlot{\@ifnextchar[{\dopartlot@}{\dopartlot@[l]}}

\def\doparttoc@[#1]{%
\if #1e\let\df@ptitc\e@pti%
\else\if #1n\let\df@ptitc\n@pti%
\else\if #1c\let\df@ptitc\c@pti%
\else\if #1l\let\df@ptitc\l@pti%
\else\if #1r\let\df@ptitc\r@pti%
\fi\fi\fi\fi\fi%
\@@doparttoc}

\def\dopartlof@[#1]{%
\if #1e\let\df@ptilf\e@pti%
\else\if #1n\let\df@ptilf\n@pti%
\else\if #1c\let\df@ptilf\c@pti%
\else\if #1l\let\df@ptilf\l@pti%
\else\if #1r\let\df@ptilf\r@pti%
\fi\fi\fi\fi\fi%
\@@dopartlof}

\def\dopartlot@[#1]{%
\if #1e\let\df@ptilt\e@pti%
\else\if #1n\let\df@ptilt\n@pti%
\else\if #1c\let\df@ptilt\c@pti%
\else\if #1l\let\df@ptilt\l@pti%
\else\if #1r\let\df@ptilt\r@pti%
\fi\fi\fi\fi\fi%
\@@dopartlot}

\def\@@doparttoc{\@doparttoc{\jobname}\immediate\closeout\tf@mtc}
\def\@@dopartlof{\@dopartlof{\jobname}\immediate\closeout\tf@mtc}
\def\@@dopartlot{\@dopartlot{\jobname}\immediate\closeout\tf@mtc}

\def\PTC@next#1\relax#2\\{%
  \edef\PTC@list{#2}%
  \PTC@loop{#1}}
\def\PTC@toc{%
  \ifx\PTC@list\@empty\else\expandafter\PTC@explist\fi}

\def\PTC@contentsline#1#2#3#4{% %%HO/DV: 4 instead of 3 parameters
  \expandafter\ifx\csname #1\endcsname\part
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.ptc\theptc}%     % UNIX
      \def\ptcname{\jobname.ptc\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.P\theptc}%       % MS-DOS
      \def\ptcname{\jobname.P\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .ptcN .ptc->.P on MS-DOS
    \immediate\openout\tf@mtc=\ptcname % open next .ptcN (.ptc->.P if MS-DOS)
  \fi
%%%%%%%%%%%%%%%%%%%%%%
% v28c: starpart added
%%%%%%%%%%%%%%%%%%%%%%
  \expandafter\ifx\csname #1\endcsname\starpart\relax
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.ptc\theptc}%     % UNIX
      \def\ptcname{\jobname.ptc\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.P\theptc}%       % MS-DOS
      \def\ptcname{\jobname.P\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .ptcN .ptc->.P on MS-DOS
    \immediate\openout\tf@mtc=\ptcname % open next .ptcN (.ptc->.P if MS-DOS)
  \fi
%%%%%%%%%%%%%%%%%%%%%%
  \mtc@toks{\noexpand\leavevmode #2}%
% extracts and writes info for chapters, sections, etc.
  \expandafter\ifx\csname #1\endcsname\chapter
    \MTC@WriteContentsline{#1}{ptcC}{#3}{#4}%
  \fi
%19990316
  \expandafter\ifx\csname #1\endcsname\pchapter
    \MTC@WriteContentsline{#1}{ptcC}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\section
    \MTC@WriteContentsline{#1}{ptcS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\coffee
    \MTC@WriteCoffeeline{#1}{#3}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsection
    \MTC@WriteContentsline{#1}{ptcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsubsection
    \MTC@WriteContentsline{#1}{ptcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\paragraph
    \MTC@WriteContentsline{#1}{ptcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subparagraph
    \MTC@WriteContentsline{#1}{ptcSP}{#3}{#4}%
  \fi
% Added v25: \starchapter & co.
% extracts and writes info for chapters, sections, etc.
% v28a 960123
  \expandafter\ifx\csname #1\endcsname\starchapter
%%HO: the following line should be disabled:
%%    \stepcounter{mtc}% % the mtc counter simulates the chapter counter
    \MTC@WriteContentsline{#1}{ptcC}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsection
    \MTC@WriteContentsline{#1}{ptcS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsection
    \MTC@WriteContentsline{#1}{ptcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsubsection
    \MTC@WriteContentsline{#1}{ptcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starparagraph
    \MTC@WriteContentsline{#1}{ptcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubparagraph
    \MTC@WriteContentsline{#1}{ptcSP}{#3}{#4}%
  \fi
}

\def\PTC@explist{\expandafter\PTC@next\PTC@list\\}
\def\PTC@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JPARTTOCS NOT PREPARED.^^J}%
    \expandafter\PTC@toc
  \else
    \typeout{PREPARING PARTTOCS FROM #1}%
    \expandafter\PTC@read\fi}
\def\PTC@read{%
  \read\@inputcheck to\PTC@line
  \expandafter\PTC@test\PTC@line.....\PTC@% %%HO: . added
  }%
\long\def\PTC@test#1#2#3#4#5#6\PTC@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \PTC@contentsline{#2}{#3}{#4}{#5}%
    %%HO/DV: 4 instead of 3 parameters
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\PTC@list{\PTC@list#2\relax}%
  \else\ifx#1\partend % \part* closes .ptcN (.ptc->.P on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\partbegin
     \addtocounter{ptc}{-1}% % \part* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\PTC@toc
  \else\expandafter\PTC@read\fi}%

\def\PLF@next#1\relax#2\\{%
  \edef\PLF@list{#2}%
  \PLF@loop{#1}}
\def\PLF@lof{%
  \ifx\PLF@list\@empty\else\expandafter\PLF@explist\fi}

\def\PLF@contentsline#1#2#3#4{% %%HO: #4 added
  \expandafter\ifx\csname #1\endcsname\xpart
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.plf\theptc}%     % UNIX
      \def\plfname{\jobname.plf\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.G\theptc}%       % MS-DOS
      \def\plfname{\jobname.G\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .plfN .plf->.G on MS-DOS
    \immediate\openout\tf@mtc=\plfname % open next .plfN (.plf->.G if MS-DOS)
  \fi
  \expandafter\ifx\csname #1\endcsname\ypart
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.plf\theptc}%     % UNIX
      \def\plfname{\jobname.plf\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.G\theptc}%       % MS-DOS
      \def\plfname{\jobname.G\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .plfN .plf->.G on MS-DOS
    \immediate\openout\tf@mtc=\plfname % open next .plfN (.plf->.G if MS-DOS)
  \fi
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\figure
    \mtc@toks{\noexpand\leavevmode#2}%
    \MTC@WriteContentsline{#1}{plf}{#3}{#4}%
  \fi
}

\def\PLF@explist{\expandafter\PLF@next\PLF@list\\}
\def\PLF@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JPARTLOFS NOT PREPARED.^^J}%
    \expandafter\PLF@lof
  \else
    \typeout{PREPARING PARTLOFS FROM #1}%
    \expandafter\PLF@read\fi}
\def\PLF@read{%
  \read\@inputcheck to\PLF@line
  \expandafter\PLF@test\PLF@line.....\PLF@% %%HO: . added
  }%
\long\def\PLF@test#1#2#3#4#5#6\PLF@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \PLF@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\PLF@list{\PLF@list#2\relax}%
  \else\ifx#1\partend % \part* closes .plfN (.plf->.G on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\partbegin
     \addtocounter{ptc}{-1}% % \part* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\PLF@lof
  \else\expandafter\PLF@read\fi}%

\def\PLT@next#1\relax#2\\{%
  \edef\PLT@list{#2}%
  \PLT@loop{#1}}
\def\PLT@lot{%
  \ifx\PLT@list\@empty\else\expandafter\PLT@explist\fi}

\def\PLT@contentsline#1#2#3#4{% %%HO: #4 added
  \expandafter\ifx\csname #1\endcsname\xpart
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.plt\theptc}%     % UNIX
      \def\pltname{\jobname.plt\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.U\theptc}%       % MS-DOS
      \def\pltname{\jobname.U\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .pltN .plt->.U on MS-DOS
    \immediate\openout\tf@mtc=\pltname % open next .pltN (.plt->.U if MS-DOS)
  \fi
  \expandafter\ifx\csname #1\endcsname\ypart
    \stepcounter{ptc}% % the ptc counter simulates the part counter
    \if@longextensions%
      \typeout{Writing\space\jobname.plt\theptc}%     % UNIX
      \def\pltname{\jobname.plt\theptc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.U\theptc}%       % MS-DOS
      \def\pltname{\jobname.U\theptc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .pltN .plt->.U on MS-DOS
    \immediate\openout\tf@mtc=\pltname % open next .pltN (.plt->.U if MS-DOS)
  \fi
% extracts and writes info for chapters, sections, etc.
  \expandafter\ifx\csname #1\endcsname\table
    \mtc@toks{\noexpand\leavevmode#2}%
    \MTC@WriteContentsline{#1}{plt}{#3}{#4}%
  \fi
}

\def\PLT@explist{\expandafter\PLT@next\PLT@list\\}
\def\PLT@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JPARTLOTS NOT PREPARED.^^J}%
    \expandafter\PLT@lot
  \else
    \typeout{PREPARING PARTLOTS FROM #1}%
    \expandafter\PLT@read\fi}
\def\PLT@read{%
  \read\@inputcheck to\PLT@line
  \expandafter\PLT@test\PLT@line.....\PLT@% %%HO: . added
  }%
\long\def\PLT@test#1#2#3#4#5#6\PLT@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \PLT@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\PLT@list{\PLT@list#2\relax}%
  \else\ifx#1\partend % \part* closes .pltN (.plt->.U on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\partbegin
     \addtocounter{ptc}{-1}% % \part* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\PLT@lot
  \else\expandafter\PLT@read\fi}%
} % end of part stuff

%%%%%%%%%%%%%%%%%%%%%%%
%%% If \chapter is not defined but \section is, then
%%% the following macros are available (for article-like documents).
%%% Braces are inscrutable!
\@ifundefined{chapter}%
{% CAS \chapter inconnu
\@ifundefined{section}{}{%
\def\firstsectionis#1%
  {\typeout{^^JWARNING*** \string\firstsectionis}%
   \typeout{ is an obsolete command^^J}}
\newcounter{stc}  % counter of secttocs
\setcounter{stc}{0}
\def\adjuststc{\stepcounter{stc}}  %32
\newcounter{secttocdepth} % analog to tocdepth, but for secttocs
\setcounter{secttocdepth}{2}

% rule before/after secttoc/sectlof/sectlot
\def\stc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@} % the \hrule is .4pt high

\newlength\stcindent % indentation (left/right) of secttocs
\stcindent=24pt      % defaut value
\def\stcfont{\small\rm}    % font for the secttoc
\def\stcSSfont{\normalsize\bf}   % font for the secttoc (subsections)
\def\stcSSSfont{\stcfont}  % font for the secttoc (subsubsections)
\def\stcPfont{\stcfont}    % font for the secttoc (paragraphs)
\def\stcSPfont{\stcfont}   % font for the secttoc (subparagraphs)
\def\slffont{\stcfont}     % font for the sectlof (figures)
\def\sltfont{\stcfont}     % font for the sectlot (tables)
\def\stifont{\Large\bf}    % font for titles

% Centering, flushleft, flushright or empty titles.
\def\c@sti#1{\null\hfill #1\hfill\null}
\def\l@sti#1{\null #1\hfill\null}
\def\r@sti#1{\null\hfill #1\null}
\def\e@sti#1{\relax}
\def\n@sti#1{\relax}

% Default: titles on left
\let\do@stitc\l@sti
\let\df@stitc\l@sti
\let\do@stilf\l@sti
\let\df@stilf\l@sti
\let\do@stilt\l@sti
\let\df@stilt\l@sti

%v27 % Language dependent names: default values
%v27 \@ifundefined{stctitle}{\def\stctitle{Contents}}{\relax}
%v27 \@ifundefined{slftitle}{\def\slftitle{Figures}}{\relax}
%v27 \@ifundefined{slttitle}{\def\slttitle{Tables}}{\relax}

\def\stc@verse{\let\\=\@centercr
  \list{}{\itemsep\z@\itemindent \z@\listparindent \itemindent
          \leftmargin\stcindent
          \rightmargin\leftmargin}\item[]}
\def\endstc@verse{\nopagebreak[4]\endlist}

% this command must be used after \section
% if you need a secttoc (no automatic secttoc)
\def\secttoc{\@ifnextchar[{\secttoc@}{\secttoc@[d]}}

\def\secttoc@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@stitc\e@sti
        \else\if #1n\let\do@stitc\n@sti
        \else\if #1c\let\do@stitc\c@sti
        \else\if #1l\let\do@stitc\l@sti
        \else\if #1r\let\do@stitc\r@sti
        \else\if #1d\let\do@stitc\df@stitc
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\stcfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\stc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stitc{\mtc@v\stctitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stitc{\mtc@v\stctitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\stcindent
        \rightmargin\stcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        \begin{stc@verse}\c@tocdepth=\c@secttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{stc@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
   \gdef\thestc{\arabic{stc}} %23
\if@longextensions%
\def\@tocfile{stc\thestc}%  % UNIX
\else
\def\@tocfile{S\thestc}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{stc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\stc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
        % some space under the secttoc

% this command must be used after \section
% if you need a sectlof (no automatic sectlof)
\def\sectlof{\@ifnextchar[{\sectlof@}{\sectlof@[d]}}

\def\sectlof@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@stilf\e@sti
        \else\if #1n\let\do@stilf\n@sti
        \else\if #1c\let\do@stilf\c@sti
        \else\if #1l\let\do@stilf\l@sti
        \else\if #1r\let\do@stilf\r@sti
        \else\if #1d\let\do@stilf\df@stilf
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\slffont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\stc@rule\relax % correction 07Nov94 v23
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stilf{\mtc@v\slftitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stilf{\mtc@v\slftitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\stcindent
        \rightmargin\stcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for sectlof
        \begin{stc@verse}%\c@tocdepth=\c@secttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{slf@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
   \gdef\thestc{\arabic{stc}} %23
\if@longextensions%
\def\@tocfile{slf\thestc}%  % UNIX
\else
\def\@tocfile{H\thestc}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{stc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\stc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
        % some space under the secttoc

% Added in version #13
% this command must be used after \section
% if you need a sectlot (no automatic sectlot)
\def\sectlot{\@ifnextchar[{\sectlot@}{\sectlot@[d]}}

\def\sectlot@[#1]{%
        \relax\begin{samepage}% we begin a local group here, using samepage
        \if #1e\let\do@stilt\e@sti
        \else\if #1n\let\do@stilt\n@sti
        \else\if #1c\let\do@stilt\c@sti
        \else\if #1l\let\do@stilt\l@sti
        \else\if #1r\let\do@stilt\r@sti
        \else\if #1d\let\do@stilt\df@stilt
        \fi\fi\fi\fi\fi\fi
        \raggedright % added #14
        \parskip=\z@%
        \reset@font\sltfont%
        \parindent=\z@%
        \nopagebreak[4]%
        \kern-0.8\baselineskip\nopagebreak[4]%
        \par\noindent
        \ifx\stc@rule\relax
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stilt{\mtc@v\slttitle}}\\
        \end{tabular}\else
        \begin{tabular}{@{}p{\columnwidth}@{}}
        {\reset@font\stifont\do@stilt{\mtc@v\slttitle}}\\\hline
        \end{tabular}\fi
        \nopagebreak[4]\null\leavevmode\vrule width \z@
        height \z@ depth \z@\\\@BBR%
        \leftmargin\stcindent
        \rightmargin\stcindent
        \itemindent=\z@\labelwidth=\z@%
        \labelsep=\z@\listparindent=\z@%
        % depth does not matter for sectlot
        \begin{stc@verse}%\c@tocdepth=\c@secttocdepth%
        \leavevmode\\\@BBR% this blank line is necessary to avoid
                % a wild negative indentation
        \vskip -.5\baselineskip
\begingroup
  \makeatletter
  \@ifundefined{slt@pgno}%
  {\let\@dottedtocline\@undottedtocline}{}
    \gdef\thestc{\arabic{stc}}
\if@longextensions%
\def\@tocfile{slt\thestc}\else%  % UNIX
\def\@tocfile{V\thestc}%    % MS-DOS
\fi
  \@input{\jobname.\@tocfile}\if@filesw
  \fi%
  \global\@nobreakfalse\endgroup
        \end{stc@verse}%
        \kern0.\baselineskip%
        \nopagebreak[4]\stc@rule\null\leavevmode\\%
        \vskip-1.0\baselineskip
        \vrule width \z@ height \z@
        depth \z@\end{samepage}% %## the \\ is essential
        \par\pagebreak[1]\vspace*{-1ex}}%
        % some space under the secttoc

% I use a depth of 10000 to inhibit the printing of
% that contentsline.
\def\l@xsect{\@dottedtocline{\@M}{1.0em}{2.3em}}
\def\l@schapter{\@dottedtocline{1}{1.0em}{2.3em}}

\def\xsect{xsect}
\def\schapter{schapter}

\let\sv@sect\@sect
\gdef\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2=1
\addcontentsline{lof}{xsect}{#7}%
\addcontentsline{lot}{xsect}{#7}%
\fi
\sv@sect{#1}{#2}{#3}{#4}{#4}{#5}{#6}[{#7}]{#8}}

\def\@sect#1#2#3#4#5#6[#7]#8{
\expandafter
\ifx\csname #1\endcsname\section\relax % ADDED
\addcontentsline{lof}{xsect}{#7}%        ADDED
\addcontentsline{lot}{xsect}{#7}%        ADDED
\fi                             %        ADDED
\ifx\csname #1\endcsname\starsection\relax % ADDED v25
\addcontentsline{lof}{xsect}{#7}%        ADDED v25
\addcontentsline{lot}{xsect}{#7}%        ADDED v25
\fi                             %        ADDED v25
\ifnum #2>\c@secnumdepth
     \let\@svsec\@empty\else
     \refstepcounter{#1}\edef\@svsec{\csname the#1\endcsname\hskip 1em}\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}}

% tricky code to deal with \section*
\let\stc@ssect\@ssect
\def\@ssect{%
\addtocontents{toc}{\protect\sectend}\stc@ssect%
}
\def\@ssect{%
\addtocontents{toc}{\protect\sectbegin}\stc@ssect%
}
\let\sectend\relax
\let\sectbegin\relax

\let\appendixmtc\relax

% this command extracts info from the .toc file
% and create the .stcN files (.stc -> .S on MS-DOS)
\def\@dosecttoc#1{{%
  \makeatletter
  \setcounter{stc}{0} % START VALUE
  \STC@next#1.toc\relax\\}\setcounter{stc}{0}} %23: raz
% this command extracts info from the .lof file
% and create the .slfN files (.slf -> .H on MS-DOS)
\def\@dosectlof#1{{%
  \makeatletter
  \setcounter{stc}{0} % START VALUE
  \SLF@next#1.lof\relax\\}\setcounter{stc}{0}} %23: raz
% this command extracts info from the .lot file
% and create the .sltN files (.slt -> .V on MS-DOS)
\def\@dosectlot#1{{%
  \setcounter{stc}{0} % START VALUE
  \makeatletter
  \SLT@next#1.lot\relax\\}\setcounter{stc}{0}} %23: raz

\def\dosecttoc{\@ifnextchar[{\dosecttoc@}{\dosecttoc@[l]}}
\def\dosectlof{\@ifnextchar[{\dosectlof@}{\dosectlof@[l]}}
\def\dosectlot{\@ifnextchar[{\dosectlot@}{\dosectlot@[l]}}

\def\dosecttoc@[#1]{%
\if #1e\let\df@stitc\e@sti%
\else\if #1n\let\df@stitc\n@sti%
\else\if #1c\let\df@stitc\c@sti%
\else\if #1l\let\df@stitc\l@sti%
\else\if #1r\let\df@stitc\r@sti%
\fi\fi\fi\fi\fi%
\@@dosecttoc}

\def\dosectlof@[#1]{%
\if #1e\let\df@stilf\e@sti%
\else\if #1n\let\df@stilf\n@sti%
\else\if #1c\let\df@stilf\c@sti%
\else\if #1l\let\df@stilf\l@sti%
\else\if #1r\let\df@stilf\r@sti%
\fi\fi\fi\fi\fi%
\@@dosectlof}

\def\dosectlot@[#1]{%
\if #1e\let\df@stilt\e@sti%
\else\if #1n\let\df@stilt\n@sti%
\else\if #1c\let\df@stilt\c@sti%
\else\if #1l\let\df@stilt\l@sti%
\else\if #1r\let\df@stilt\r@sti%
\fi\fi\fi\fi\fi%
\@@dosectlot}

\def\@@dosecttoc{\@dosecttoc{\jobname}\immediate\closeout\tf@mtc}
\def\@@dosectlof{\@dosectlof{\jobname}\immediate\closeout\tf@mtc}
\def\@@dosectlot{\@dosectlot{\jobname}\immediate\closeout\tf@mtc}

\def\STC@next#1\relax#2\\{%
  \edef\STC@list{#2}%
  \STC@loop{#1}}
\def\STC@toc{%
  \ifx\STC@list\@empty\else\expandafter\STC@explist\fi}

\def\STC@contentsline#1#2#3#4{% %%HO: #4 added
  \gdef\thestc{\arabic{stc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\section
    \stepcounter{stc}% % the stc counter simulates the section counter
%%    \gdef\thestc{\arabic{stc}} %% HO: removed
    \if@longextensions%
      \typeout{Writing\space\jobname.stc\thestc}%     % UNIX
      \def\stcname{\jobname.stc\thestc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.S\thestc}%       % MS-DOS
      \def\stcname{\jobname.S\thestc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .stcN .stc->.S on MS-DOS
    \immediate\openout\tf@mtc=\stcname % open next .stcN (.stc->.S if MS-DOS)
  \fi
  %%%
  \mtc@toks{\noexpand\leavevmode #2}%
% COFFEE
  \expandafter\ifx\csname #1\endcsname\coffee
    \MTC@WriteCoffeeline{#1}{#3}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsection
    \MTC@WriteContentsline{#1}{stcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subsubsection
    \MTC@WriteContentsline{#1}{stcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\paragraph
    \MTC@WriteContentsline{#1}{stcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\subparagraph
    \MTC@WriteContentsline{#1}{stcSP}{#3}{#4}%
  \fi
% Added v25: \starsection and co.
  \ifx\csname #1\endcsname\starsection
    \stepcounter{stc}% % the stc counter simulates the section counter
    \gdef\thestc{\arabic{stc}}
    \if@longextensions%
      \typeout{Writing\space\jobname.stc\thestc}%     % UNIX
      \def\stcname{\jobname.stc\thestc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.S\thestc}%       % MS-DOS
      \def\stcname{\jobname.S\thestc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .stcN .stc->.S on MS-DOS
    \immediate\openout\tf@mtc=\stcname % open next .stcN (.stc->.S if MS-DOS)
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsection
    \MTC@WriteContentsline{#1}{stcSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubsubsection
    \MTC@WriteContentsline{#1}{stcSSS}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starparagraph
    \MTC@WriteContentsline{#1}{stcP}{#3}{#4}%
  \fi
  \expandafter\ifx\csname #1\endcsname\starsubparagraph
    \MTC@WriteContentsline{#1}{stcSP}{#3}{#4}%
  \fi
}

\def\STC@explist{\expandafter\STC@next\STC@list\\}
\def\STC@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JSECTTOCS NOT PREPARED.^^J}%
    \expandafter\STC@toc
  \else
    \typeout{PREPARING SECTTOCS FROM #1}%
    \expandafter\STC@read\fi}
\def\STC@read{%
  \read\@inputcheck to\STC@line
  \expandafter\STC@test\STC@line.....\STC@% %%HO: . added
  }%
\long\def\STC@test#1#2#3#4#5#6\STC@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \STC@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\STC@list{\STC@list#2\relax}%
  \else\ifx#1\sectend % \section* closes .stcN (.stc->.S on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\sectbegin
     \addtocounter{stc}{-1}% % \section* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\STC@toc
  \else\expandafter\STC@read\fi}%

\def\SLF@next#1\relax#2\\{%
  \edef\SLF@list{#2}%
  \SLF@loop{#1}}
\def\SLF@lof{%
  \ifx\SLF@list\@empty\else\expandafter\SLF@explist\fi}

\def\SLF@contentsline#1#2#3#4{% %%HO: #4 added
  \gdef\thestc{\arabic{stc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\xsect
    \stepcounter{stc}% % the stc counter simulates the section counter
%%    \gdef\thestc{\arabic{stc}} %%HO: removed
    \if@longextensions%
      \typeout{Writing\space\jobname.slf\thestc}%     % UNIX
      \def\slfname{\jobname.slf\thestc}%              % UNIX
    \else
      \typeout{Writing\space\jobname.G\thestc}%       % MS-DOS
      \def\slfname{\jobname.H\thestc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .slfN .slf->.H on MS-DOS
    \immediate\openout\tf@mtc=\slfname % open next .slfN (.slf->.H if MS-DOS)
  \fi
  \mtc@toks{\noexpand\leavevmode #2}%
% extracts and writes info for sections, etc.
  \expandafter\ifx\csname #1\endcsname\figure
    \MTC@WriteContentsline{#1}{slf}{#3}{#4}%
  \fi
}

\def\SLF@explist{\expandafter\SLF@next\SLF@list\\}
\def\SLF@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JSECTLOFS NOT PREPARED.^^J}%
    \expandafter\SLF@lof
  \else
    \typeout{PREPARING SECTLOFS FROM #1}%
    \expandafter\SLF@read\fi}
\def\SLF@read{%
  \read\@inputcheck to\SLF@line
  \expandafter\SLF@test\SLF@line.....\SLF@% %%HO: . added
  }%
\long\def\SLF@test#1#2#3#4#5#6\SLF@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \SLF@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\SLF@list{\SLF@list#2\relax}%
  \else\ifx#1\sectend % \section* closes .slfN (.slf->.H on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\sectbegin
     \addtocounter{stc}{-1}% % \section* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\SLF@lof
  \else\expandafter\SLF@read\fi}%

\def\SLT@next#1\relax#2\\{%
  \edef\SLT@list{#2}%
  \SLT@loop{#1}}
\def\SLT@lot{%
  \ifx\SLT@list\@empty\else\expandafter\SLT@explist\fi}

\def\SLT@contentsline#1#2#3#4{% %%HO: #4 added
  \gdef\thestc{\arabic{stc}}% %%HO: space removed
  \expandafter\ifx\csname #1\endcsname\xsect
    \stepcounter{stc}% % the stc counter simulates the section counter
%%    \gdef\thestc{\arabic{stc}} %%HO: removed
    \if@longextensions%
      \typeout{Writing\space\jobname.slt\thestc}%     % UNIX
      \def\sltname{\jobname.slt\thestc}%              % UNIX %bug mlt->slt
    \else
      \typeout{Writing\space\jobname.V\thestc}%       % MS-DOS
      \def\sltname{\jobname.V\thestc}%                % MS-DOS
    \fi
    \immediate\closeout\tf@mtc % close current .sltN .slt->.V on MS-DOS
    \immediate\openout\tf@mtc=\sltname % open next .sltN (.slt->.V if MS-DOS)
  \fi
% extracts and writes info for subsections, etc.
  \expandafter\ifx\csname #1\endcsname\table
    \MTC@WriteContentsline{#1}{slt}{#3}{#4}%
  \fi
}

\def\SLT@explist{\expandafter\SLT@next\SLT@list\\}
\def\SLT@loop#1{\openin\@inputcheck#1\relax
  \ifeof\@inputcheck
    \typeout{^^JNo file #1^^JSECTLOTS NOT PREPARED.^^J}%
    \expandafter\SLT@lot
  \else
    \typeout{PREPARING SECTLOTS FROM #1}%
    \expandafter\SLT@read\fi}
\def\SLT@read{%
  \read\@inputcheck to\SLT@line
  \expandafter\SLT@test\SLT@line.....\SLT@% %%HO: . added
  }%
\long\def\SLT@test#1#2#3#4#5#6\SLT@{% %%HO: #6 added
  \ifx#1\contentsline
    \let\mtc@string\string
    \SLT@contentsline{#2}{#3}{#4}{#5}% %%HO: #4 added
    \let\mtc@string\relax
  \else\ifx#1\@input
     \edef\SLT@list{\SLT@list#2\relax}%
  \else\ifx#1\sectend % \section* closes .sltN (.slt->.V on MS-DOS)
     \immediate\closeout\tf@mtc
     \immediate\openout\tf@mtc=\jobname.bmt % and opens a scratch file
  \else\ifx#1\sectbegin
     \addtocounter{stc}{-1}% % \section* has done a parasite increment
  \fi\fi\fi\fi
  \ifeof\@inputcheck\expandafter\SLT@lot
  \else\expandafter\SLT@read\fi}%
}%
}% FIN CAS \chapter inconnu: \secttoc &co. permis
{} % CAS \chapter connu: pas de \secttoc & co.

\@ifundefined{section}{}{\let\l@listof\l@section} %v27
\@ifundefined{chapter}{}{\let\l@listof\l@chapter} %v27
\@ifundefined{part}{}{\let\l@starpart\l@part}
\@ifundefined{chapter}{}{\let\l@starchapter\l@chapter}
\@ifundefined{section}{}{\let\l@starsection\l@section}
\@ifundefined{subsection}{}{\let\l@starsubsection\l@subsection}
\@ifundefined{subsubsection}{}{\let\l@starsubsubsection\l@subsubsection}
\@ifundefined{paragraph}{}{\let\l@starparagraph\l@paragraph}
\@ifundefined{subparagraph}{}{\let\l@starsubparagraph\l@subparagraph}

\def\noptcrule{\let\ptc@rule\relax}
\def\nomtcrule{\let\mtc@rule\relax}
\def\nostcrule{\let\stc@rule\relax}
\def\ptcrule{\def\ptc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@}} % the \hrule is .4pt high
\def\mtcrule{\def\mtc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@}} % the \hrule is .4pt high
\def\stcrule{\def\stc@rule{\kern-3\p@%
  \hrule width \columnwidth \kern2.6\p@}} % the \hrule is .4pt high

%v28b
% init counters
\AtBeginDocument{%
\@ifundefined{c@ptc}{}{\setcounter{ptc}{0}}
\@ifundefined{c@mtc}{}{\setcounter{mtc}{0}}
\@ifundefined{c@stc}{}{\setcounter{stc}{0}}}

%\@ifundefined{c@ptc}{}{\setcounter{ptc}{0}}
%\@ifundefined{c@mtc}{}{\setcounter{mtc}{0}}
%\@ifundefined{c@stc}{}{\setcounter{stc}{0}}

%%% tight option
\DeclareOption{tight}{\tightmtctrue}
\DeclareOption{loose}{\tightmtcfalse} % default

%%% undotted option
\DeclareOption{undotted}{\undottedmtctrue}
\DeclareOption{dotted}{\undottedmtcfalse} % default

%%%% Language dependent part
\DeclareOption{american}{\input{english.mld}}
\DeclareOption{arab}{\input{arab.mld}}   %v27
\DeclareOption{arabic}{\input{arab.mld}}   %v27
\DeclareOption{armenian}{\input{armenian.mld}} %v29
\DeclareOption{austrian}{\input{german.mld}}
\DeclareOption{bahasa}{\input{bahasa.mld}} %v28
\DeclareOption{basque}{\input{basque.mld}} %v30
\DeclareOption{brazil}{\input{brazil.mld}} %v28
\DeclareOption{bicig}{\input{bicig.mld}} %v29
\DeclareOption{breton}{\input{breton.mld}} %v26
\DeclareOption{buryat}{\input{buryat.mld}} %v29
\DeclareOption{catalan}{\input{catalan.mld}}
\DeclareOption{croatian}{\input{croatian.mld}}
\DeclareOption{czech}{\input{czech.mld}}
\DeclareOption{danish}{\input{danish.mld}}
\DeclareOption{dutch}{\input{dutch.mld}}
\DeclareOption{afrikaans}{\input{afrikaan.mld}} %v28
\DeclareOption{afrikaan}{\input{afrikaan.mld}} %v28
\DeclareOption{english}{\input{english.mld}}
\DeclareOption{esperant}{\input{esperant.mld}} %v26
\DeclareOption{esperanto}{\input{esperant.mld}} %v26
\DeclareOption{ethiopia}{\input{ethiopia.mld}} %v28
\DeclareOption{ethiopian}{\input{ethiopia.mld}} %v28
\DeclareOption{finnish}{\input{finnish.mld}}
\DeclareOption{francais}{\input{french.mld}}
\DeclareOption{french}{\input{french.mld}}
\DeclareOption{galician}{\input{galician.mld}}
\DeclareOption{german}{\input{german.mld}}
\DeclareOption{germanb}{\input{germanb.mld}} %v26
\DeclareOption{greek}{\input{greek.mld}} %v26
\DeclareOption{hungarian}{\input{magyar.mld}}
\DeclareOption{irish}{\input{irish.mld}} %v26
\DeclareOption{italian}{\input{italian.mld}}
\DeclareOption{lithuanian}{\input{lithuanian.mld}} %v29
\DeclareOption{lsorbian}{\input{lsorbian.mld}} %v26
\DeclareOption{magyar}{\input{magyar.mld}}
\DeclareOption{mongol}{\input{mongol.mld}} %v29
\DeclareOption{ngermanb}{\input{ngermanb.mld}} %v30
\DeclareOption{norsk}{\input{norsk.mld}}
\DeclareOption{nynorsk}{\input{nynorsk.mld}} %v25
\DeclareOption{polish}{\input{polish.mld}}
\DeclareOption{portuges}{\input{portuges.mld}}
\DeclareOption{romanian}{\input{romanian.mld}}
%%%%russian not supported \DeclareOption{russian}{\input{russian.mld}}
\DeclareOption{russianb}{\input{russianb.mld}} %v26
\DeclareOption{russianc}{\input{russianc.mld}} %v29
\DeclareOption{scottish}{\input{scottish.mld}} %v26
\DeclareOption{serbian}{\input{serbian.mld}} %v30
\DeclareOption{slovak}{\input{slovak.mld}}
\DeclareOption{slovene}{\input{slovene.mld}}
\DeclareOption{spanish}{\input{spanish.mld}}
\DeclareOption{swedish}{\input{swedish.mld}}
\DeclareOption{turkish}{\input{turkish.mld}}
\DeclareOption{ukraineb}{\input{ukraineb.mld}} %v30
\DeclareOption{usorbian}{\input{usorbian.mld}} %v26
\DeclareOption{vietnam}{\input{vietnam.mld}}   %v27
\DeclareOption{vietnamese}{\input{vietnam.mld}}   %v27
\DeclareOption{welsh}{\input{welsh.mld}}   %v30
%%%%%%%%%
\DeclareOption{shortext}{\@longextensionsfalse %v28
\typeout{*** You have forced the use of short extensions ***}}
%%%%%%%%%
\ExecuteOptions{english} %v27 % default
\ProcessOptions*
%%\languagespecific{russian.dtx}
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\endinput
%%
%% End of file `minitoc.sty'.
