%%
%% This is file `etoc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% etoc.dtx  (with options: `package')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from etoc.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file etoc.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{etoc}
 [2018/02/23 v1.08n Completely customisable TOCs (JFB)]
%%
%% Package: etoc
%% Version: 1.08n-2018/02/23
%% License: LPPL 1.3c
%% Copyright (C) 2012-2018 Jean-Francois Burnol
%%                         <jfbu at free dot fr>
%% Copyright (C) 2014-2018 Christine Roemer
%%                         <Christine_Roemer at t-online dot de>
%% and collaborators for the translation into German of the documentation
%%
\RequirePackage{multicol}
\DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}}
\ProcessOptions\relax
\newtoks\Etoc@toctoks
\def\Etoc@par{\par}
\def\etocinline{\def\Etoc@par{}}
\let\etocnopar\etocinline
\def\etocdisplay{\def\Etoc@par{\par}}% 1.07m 2015/01/23
\let\Etoc@global\@empty              % 1.08 2015/03/10
\def\etocglobaldefs{\let\Etoc@global\global\let\tof@global\global}
\def\etoclocaldefs {\let\Etoc@global\@empty\let\tof@global\@empty}
\newif\ifEtoc@jj  % book
\newif\ifEtoc@j   % part
\newif\ifEtoc@    % chapter
\newif\ifEtoc@i   % section
\newif\ifEtoc@ii  % subsection
\newif\ifEtoc@iii % subsubsection
\newif\ifEtoc@iv  % paragraph
\newif\ifEtoc@v   % subparagraph
\newif\ifEtoc@number
\newif\ifEtoc@hyperref
\newif\ifEtoc@parskip   % 1.07d
\newif\ifEtoc@tocwithid
\newif\ifEtoc@standard
\newif\ifEtoc@skipprefix % 1.08
\newif\ifEtoc@isfirst    % 1.08
\newif\ifEtoc@localtoc
\newif\ifEtoc@skipthisone
\newif\ifEtoc@stoptoc
\newif\ifEtoc@notactive
\newif\ifEtoc@mustclosegroup
\newif\ifEtoc@emptytoc     % 1.08e
\newif\ifEtoc@checksemptiness % 1.08e. Default is 'no checks'.
\def\etocchecksemptiness       {\Etoc@checksemptinesstrue }
\def\etocdoesnotcheckemptiness {\Etoc@checksemptinessfalse }% 1.08i
\newif\ifEtoc@notocifnotoc % 1.08e
\def\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue }
\def\etoc@{\etoc@}
\newcounter{etoc@tocid}
\newcounter{etoc@tocdepth}% 1.07g
\@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}}
\def\Etoc@@minustwo@@{-\tw@}
\let\Etoc@@minusone@@\m@ne
\let\Etoc@@zero@@    \z@
\let\Etoc@@one@@     \@ne
\let\Etoc@@two@@     \tw@
\let\Etoc@@three@@   \thr@@
\chardef\Etoc@@four@@ 4
\chardef\Etoc@@five@@ 5
\chardef\Etoc@@six@@  6
%%\let\Etoc@localtop\Etoc@@minustwo@@ % 1.08e does it at each local TOC.
\def\Etoc@@minustwo@{minustwo}
\def\Etoc@@minusone@{minusone}
\def\Etoc@@zero@    {zero}
\def\Etoc@@one@     {one}
\def\Etoc@@two@     {two}
\def\Etoc@@three@   {three}
\def\Etoc@@four@    {four}
\def\Etoc@@five@    {five}
\expandafter\def\csname Etoc@-3@@\endcsname {-\thr@@}
\expandafter\let\csname Etoc@-2@@\endcsname \Etoc@@minustwo@@
\expandafter\let\csname Etoc@-1@@\endcsname \Etoc@@minusone@@
\expandafter\let\csname Etoc@0@@\endcsname  \Etoc@@zero@@
\expandafter\let\csname Etoc@1@@\endcsname  \Etoc@@one@@
\expandafter\let\csname Etoc@2@@\endcsname  \Etoc@@two@@
\expandafter\let\csname Etoc@3@@\endcsname  \Etoc@@three@@
\expandafter\let\csname Etoc@4@@\endcsname  \Etoc@@four@@
\expandafter\let\csname Etoc@5@@\endcsname  \Etoc@@five@@
\expandafter\let\csname Etoc@6@@\endcsname  \Etoc@@six@@
\let\Etoc@all@@   \Etoc@@five@@
\let\Etoc@none@@  \Etoc@minf
\let\Etoc@levellist\@empty
\def\Etoc@newlevel #1{\expandafter\def\expandafter\Etoc@levellist\expandafter
        {\Etoc@levellist\Etoc@levellist@elt{#1}}}
\def\etocsetlevel#1#2{%
   \@ifundefined{Etoc@#1@@}{\Etoc@newlevel{#1}}{}%
   \ifcase#2\relax
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@one@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@one@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@two@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@two@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@three@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@three@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@four@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@four@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@five@
   \or
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@
   \else
    \ifnum#2=\m@ne
     \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@
     \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@
    \else
     \ifnum#2=-\tw@
      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minustwo@@
      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minustwo@
     \else
      \PackageWarning{etoc}
         {unexpected value `#2' in \string\etocsetlevel.^^J%
          Should be -2,-1, 0, 1, 2, 3, 4, 5, or 6. Set to 6 (=ignored)}%
      \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@
     \fi
    \fi
   \fi
}
\etocsetlevel{book}{-2}
\etocsetlevel{part}{-1}
\etocsetlevel{chapter}{0}
\etocsetlevel{section}{1}
\etocsetlevel{subsection}{2}
\etocsetlevel{subsubsection}{3}
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
\AtBeginDocument{%
\@ifpackageloaded{parskip}{\Etoc@parskiptrue}{}%
\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue
                            \def\Etoc@et@hop#1#2#3#4#5{#2{#3}{#4}{#5}#1}%
                            \long\def\Etoc@gobblefourorthree#1#2#3#4{}}
                           {\def\Etoc@et@hop#1#2#3#4{#2{#3}{#4}#1}%
                            \long\def\Etoc@gobblefourorthree#1#2#3{}}%
}
\def\Etoc@setflags {%
    \ifcase \Etoc@level
        \global\Etoc@vfalse
        \global\Etoc@ivfalse
        \global\Etoc@iiifalse
        \global\Etoc@iifalse
        \global\Etoc@ifalse
        \global\Etoc@true
    \or
        \global\Etoc@vfalse
        \global\Etoc@ivfalse
        \global\Etoc@iiifalse
        \global\Etoc@iifalse
        \global\Etoc@itrue
    \or
        \global\Etoc@vfalse
        \global\Etoc@ivfalse
        \global\Etoc@iiifalse
        \global\Etoc@iitrue
    \or
        \global\Etoc@vfalse
        \global\Etoc@ivfalse
        \global\Etoc@iiitrue
    \or
        \global\Etoc@vfalse
        \global\Etoc@ivtrue
    \or
        \global\Etoc@vtrue
    \else
        \global\Etoc@vfalse
        \global\Etoc@ivfalse
        \global\Etoc@iiifalse
        \global\Etoc@iifalse
        \global\Etoc@ifalse
        \global\Etoc@false
        \ifnum\Etoc@level=\m@ne
            \global\Etoc@jtrue
        \else
            \global\Etoc@jfalse
            \global\Etoc@jjtrue
        \fi
    \fi
}
\def\Etoc@doends {%
    \ifcase \Etoc@level
        \ifEtoc@v  \Etoc@end@five \fi
        \ifEtoc@iv \Etoc@end@four \fi
        \ifEtoc@iii\Etoc@end@three\fi
        \ifEtoc@ii \Etoc@end@two  \fi
        \ifEtoc@i  \Etoc@end@one  \fi
    \or
        \ifEtoc@v  \Etoc@end@five \fi
        \ifEtoc@iv \Etoc@end@four \fi
        \ifEtoc@iii\Etoc@end@three\fi
        \ifEtoc@ii \Etoc@end@two  \fi
    \or
        \ifEtoc@v  \Etoc@end@five \fi
        \ifEtoc@iv \Etoc@end@four \fi
        \ifEtoc@iii\Etoc@end@three\fi
    \or
        \ifEtoc@v  \Etoc@end@five \fi
        \ifEtoc@iv \Etoc@end@four \fi
    \or
        \ifEtoc@v  \Etoc@end@five \fi
    \or
    \else
        \ifEtoc@v  \Etoc@end@five \fi
        \ifEtoc@iv \Etoc@end@four \fi
        \ifEtoc@iii\Etoc@end@three\fi
        \ifEtoc@ii \Etoc@end@two  \fi
        \ifEtoc@i  \Etoc@end@one  \fi
        \ifEtoc@   \Etoc@end@zero \fi
        \ifnum \Etoc@level =-\tw@
            \ifEtoc@j \Etoc@end@minusone\fi
        \fi
    \fi
}
\def\Etoc@dobegins{%
    \let\Etoc@next\@empty
    \Etoc@global\Etoc@isfirstfalse
    \ifcase\Etoc@level
        \ifEtoc@
        \else
            \def\Etoc@next{\Etoc@begin@zero}%
        \fi
    \or
        \ifEtoc@i
        \else
            \def\Etoc@next{\Etoc@begin@one}%
        \fi
    \or
        \ifEtoc@ii
        \else
            \def\Etoc@next{\Etoc@begin@two}%
        \fi
    \or
        \ifEtoc@iii
        \else
            \def\Etoc@next{\Etoc@begin@three}%
        \fi
    \or
        \ifEtoc@iv
        \else
            \def\Etoc@next{\Etoc@begin@four}%
        \fi
    \or
        \ifEtoc@v
        \else
            \def\Etoc@next{\Etoc@begin@five}%
        \fi
    \else
        \ifnum\Etoc@level=\m@ne
            \ifEtoc@j
            \else
                \def\Etoc@next{\Etoc@begin@minusone}%
            \fi
        \else
            \ifEtoc@jj
            \else
                \def\Etoc@next{\Etoc@begin@minustwo}%
            \fi
        \fi
    \fi
    \Etoc@setflags
    \Etoc@next
}
\def\etocskipfirstprefix {\global\Etoc@skipprefixtrue }
\def\Etoc@etoccontentsline #1{%
  \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname
  \Etoc@skipthisonefalse
  \ifnum\Etoc@level=\Etoc@@six@@
    \Etoc@skipthisonetrue
  \else
   \ifEtoc@localtoc
    \ifEtoc@stoptoc
      \Etoc@skipthisonetrue
    \else
     \ifEtoc@notactive\Etoc@setflags
       \Etoc@skipthisonetrue
     \else
      \ifnum\Etoc@level<\Etoc@localtop
        \Etoc@skipthisonetrue
        \global\Etoc@stoptoctrue
      \fi
     \fi
    \fi
   \fi
  \fi
  \let\Etoc@next\Etoc@gobblefourorthree
  \ifEtoc@skipthisone
  \else
   \ifnum\c@tocdepth<\Etoc@level
   \else
    \ifEtoc@standard
      \let\Etoc@next\Etoc@savedcontentsline
    \else
      \let\Etoc@next\Etoc@etoccontentsline@
    \fi
   \fi
  \fi
  \Etoc@next{#1}%
}
\def\Etoc@etoccontentsline@ #1{%
    \Etoc@doends   % separated since 1.08
    \Etoc@dobegins % separated since 1.08k. Does \Etoc@setflags.
    \Etoc@global\edef\Etoc@prefix  {\expandafter\noexpand
         \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }%
    \Etoc@global\edef\Etoc@contents{\expandafter\noexpand
         \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname }%
    \ifEtoc@skipprefix \Etoc@global\let\Etoc@prefix\@empty\fi
    \global\Etoc@skipprefixfalse
    \Etoc@et@hop{\Etoc@prefix\Etoc@contents}{\Etoc@savedcontentsline{#1}}%
}
\def\Etoc@lxyz #1#2{%
    \Etoc@global\let\etocthelink\@firstofone % fall-back, was let \@empty up to 1.08i (inc.)
    \Etoc@global\def\etocthename       {#1}%  (if linked, will be removed later)
    \Etoc@global\def\etocthelinkedname {#1}%  (probably redefined later)
    \futurelet\Etoc@getthepage@token
       \Etoc@getthepage #2\etoc@ % defines \etocthelinkedpage
    \futurelet\Etoc@getnb@token
       \Etoc@getnb #1\relax\relax\etoc@  % sets number, name, and \etocthelink
    \ifEtoc@number
    \else
     \ifnum\Etoc@level=\m@ne
       \futurelet\Etoc@getit@token
          \Etoc@getit #1\hspace\relax\etoc@   % additional job for parts
     \fi
    \fi
    \Etoc@global\expandafter\let\csname etoclink \endcsname\etocthelink
    \Etoc@global\expandafter\let\csname etocname \endcsname\etocthelinkedname
    \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthelinkednumber
    \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthelinkedpage
    }
\def\Etoc@getthepage {%
    \if1\ifEtoc@hyperref
        \ifx\hyper@linkstart\Etoc@getthepage@token1\else0\fi
        \else0\fi
       \expandafter\Etoc@getthepage@hyp
    \else
       \expandafter\Etoc@getthepage@nohyp
    \fi
}
\def\Etoc@getthepage@nohyp #1\etoc@ {%
    \Etoc@global\def\etocthepage       {#1}%
    \Etoc@global\def\etocthelinkedpage {#1}%
}
\def\Etoc@getthepage@hyp #1#2#3#4#5\etoc@ {%
    \Etoc@global\def\etocthepage {#4}%
    \edef\Etoc@tmp {{#3}}%
    \Etoc@global\expandafter\def\expandafter\etocthelinkedpage\expandafter
      {\expandafter\hyperlink \Etoc@tmp{#4}}%
    \Etoc@global\edef\etocthelink##1{\noexpand\hyperlink\Etoc@tmp{##1}}%
}
\def\Etoc@getnb {%
    \ifx\Etoc@getnb@token\bgroup
       \expandafter\Etoc@getnb@nohyp@nonbr
    \else
       \if1\ifEtoc@hyperref
            \ifx\hyper@linkstart\Etoc@getnb@token1\else0\fi
           \else0\fi
        \expandafter\expandafter\expandafter\Etoc@getnb@hyp
       \else
        \expandafter\expandafter\expandafter\Etoc@getnb@nohyp
       \fi
    \fi
}
\def\Etoc@getnb@nohyp #1{%
    \in@{#1}{\numberline\chapternumberline\partnumberline\booknumberline}%
    \ifin@
       \let\Etoc@next\Etoc@getnb@nohyp@nmbrd
    \else
       \let\Etoc@next\Etoc@getnb@nohyp@nonbr
       \in@{#1}{\nonumberline}%
       \ifin@
           \ifx\nonumberline\empty\else\let\Etoc@next\Etoc@getnb@nohyp@nmbrd\fi
           \expandafter\expandafter\expandafter\expandafter
       \fi
    \fi
    \Etoc@next #1%
}
\def\Etoc@getnb@nohyp@nmbrd #1#2#3\relax\relax\etoc@ {%
    \Etoc@global\Etoc@numbertrue
    \Etoc@global\def\etocthenumber       {#2}%
    \Etoc@global\def\etocthelinkednumber {#2}%
    \Etoc@global\def\etocthename         {#3}%
    \Etoc@global\def\etocthelinkedname   {#3}%
}
\def\Etoc@getnb@nohyp@nonbr #1\etoc@ {%
    % \etocthename and \etocthelinkedname already defined in \Etoc@lxyz
    \Etoc@global\Etoc@numberfalse
    \Etoc@global\let\etocthenumber       \@empty
    \Etoc@global\let\etocthelinkednumber \@empty
}
\def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@ {%
    \edef\Etoc@tmp {{#3}}%
    \Etoc@global\edef\etocthelink ##1{\noexpand\hyperlink {#3}{##1}}%
    \Etoc@global\def\etocthename {#4}% temporary definition
    \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                \expandafter {\expandafter\hyperlink \Etoc@tmp{#4}}%
    \futurelet\Etoc@hyp@getnb@token\Etoc@hyp@getnb #4\relax\relax\etoc@
}
\def\Etoc@hyp@getnb {%
    \ifx\Etoc@hyp@getnb@token\bgroup
       \expandafter\Etoc@hyp@getnb@nonbr
    \else
       \expandafter\Etoc@getnb@hyp@a
    \fi
}
\def\Etoc@getnb@hyp@a #1{%
    \in@{#1}{\numberline\chapternumberline\partnumberline\booknumberline}%
    \ifin@
       \let\Etoc@next\Etoc@getnb@hyp@nmbrd
    \else
       \let\Etoc@next\Etoc@getnb@hyp@nonbr
       \in@{#1}{\nonumberline}%
       \ifin@
           \ifx\nonumberline\empty\else\let\Etoc@next\Etoc@getnb@hyp@nmbrd\fi
           \expandafter\expandafter\expandafter\expandafter
       \fi
    \fi
    \Etoc@next #1%
}
\def\Etoc@getnb@hyp@nmbrd #1#2#3\relax\relax\etoc@ {%
    \Etoc@global\Etoc@numbertrue
    \Etoc@global\def\etocthenumber {#2}%
    \Etoc@global\expandafter\def\expandafter\etocthelinkednumber
                \expandafter{\expandafter\hyperlink \Etoc@tmp{#2}}%
    \Etoc@global\def\etocthename {#3}%
    \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                \expandafter{\expandafter\hyperlink \Etoc@tmp{#3}}%
}
\let\Etoc@getnb@hyp@nonbr\Etoc@getnb@nohyp@nonbr
\def\Etoc@getit {%
    \if1\ifEtoc@hyperref
        \ifx\hyper@linkstart\Etoc@getit@token1\else0\fi
        \else0\fi
       \expandafter\Etoc@getit@hyp
    \else
       \expandafter\Etoc@getit@nohyp
    \fi
}
\def\Etoc@getit@nohyp #1\hspace#2#3\etoc@ {%
    \ifx\relax#2%
    \else
      \Etoc@global\def\etocthenumber       {#1}%
      \Etoc@global\def\etocthelinkednumber {#1}%
      \Etoc@global\Etoc@numbertrue
      \Etoc@getit@nohyp@getname #3\etoc@
    \fi
}
\def\Etoc@getit@nohyp@getname #1\hspace\relax\etoc@ {%
    \Etoc@global\def\etocthename       {#1}%
    \Etoc@global\def\etocthelinkedname {#1}%
}
\def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@ {%
    \edef\Etoc@tmp {{#3}}%
    \Etoc@global\edef\etocthelink ##1{\noexpand\hyperlink \Etoc@tmp{##1}}%
    \Etoc@global\def\etocthename {#4}% temporary definition
    \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                \expandafter{\expandafter\hyperlink \Etoc@tmp{#4}}%
    \Etoc@hyp@getit #4\hspace\relax\etoc@
}
\def\Etoc@hyp@getit #1\hspace#2#3\etoc@ {%
    \ifx\relax#2% not extremely safe
    \else
      \Etoc@global\Etoc@numbertrue
      \Etoc@global\def\etocthenumber {#1}%
      \Etoc@global\expandafter\def\expandafter\etocthelinkednumber
                  \expandafter{\expandafter\hyperlink \Etoc@tmp{#1}}%
      \Etoc@getit@hyp@getname #3\etoc@
    \fi
}
\def\Etoc@getit@hyp@getname #1\hspace\relax\etoc@ {%
    \Etoc@global\def\etocthename {#1}%
    \Etoc@global\expandafter\def\expandafter\etocthelinkedname
                \expandafter{\expandafter\hyperlink \Etoc@tmp{#1}}%
}%
\let\etocthename   \@empty
\let\etocthenumber \@empty
\let\etocthepage   \@empty
\let\etocthelinkedname   \@empty
\let\etocthelinkednumber \@empty
\let\etocthelinkedpage   \@empty
\let\etocthelink   \@firstofone % prior to 1.08j its was \let to \@empty
\DeclareRobustCommand*{\etocname}  {}
\DeclareRobustCommand*{\etocnumber}{}
\DeclareRobustCommand*{\etocpage}  {}
\DeclareRobustCommand*{\etoclink}  {\@firstofone}
\DeclareRobustCommand*{\etocifnumbered}
   {\ifEtoc@number\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\expandafter\let\expandafter\etocxifnumbered\csname etocifnumbered \endcsname
\DeclareRobustCommand*{\etociffirst}
   {\ifEtoc@isfirst\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\expandafter\let\expandafter\etocxiffirst\csname etociffirst \endcsname
\def\Etoc@readtoc {%
  \ifeof \Etoc@tf
  \else
     \read \Etoc@tf to \Etoc@buffer
     \Etoc@toctoks=\expandafter\expandafter\expandafter
       {\expandafter\the\expandafter\Etoc@toctoks\Etoc@buffer}%
     \expandafter\Etoc@readtoc
  \fi
}
\Etoc@toctoks {}% (superfluous, but for clarity)
\AtBeginDocument{\IfFileExists{\jobname.toc}
    {{\endlinechar=\m@ne
      \makeatletter
      \newread\Etoc@tf
      \openin\Etoc@tf\@filef@und
      \Etoc@readtoc
      \global\Etoc@toctoks=\expandafter{\the\Etoc@toctoks}%
      \closein\Etoc@tf}}
    {\typeout{No file \jobname.toc.}}}
\def\Etoc@openouttoc{%
  \ifEtoc@hyperref
   \ifx\hyper@last\@undefined
    \IfFileExists{\jobname .toc}
      {\Hy@WarningNoLine
         {old toc file detected, not used; run LaTeX again (cheers from etoc)}%
       \global\Etoc@toctoks={}%
      }
      {}%
   \fi
  \fi
  \if@filesw
   \newwrite \tf@toc
   \immediate \openout \tf@toc \jobname .toc\relax
  \fi
  \global\let\Etoc@openouttoc\empty
}
\def\Etoc@toctoc{%
  \global\Etoc@vfalse
  \global\Etoc@ivfalse
  \global\Etoc@iiifalse
  \global\Etoc@iifalse
  \global\Etoc@ifalse
  \global\Etoc@false
  \global\Etoc@jfalse
  \global\Etoc@jjfalse
  \the\Etoc@toctoks
  \ifEtoc@notactive
  \else
   \ifEtoc@v   \Etoc@end@five\fi
   \ifEtoc@iv  \Etoc@end@four\fi
   \ifEtoc@iii \Etoc@end@three\fi
   \ifEtoc@ii  \Etoc@end@two\fi
   \ifEtoc@i   \Etoc@end@one\fi
   \ifEtoc@    \Etoc@end@zero\fi
   \ifEtoc@j   \Etoc@end@minusone\fi
   \ifEtoc@jj  \Etoc@end@minustwo\fi
  \fi
}
\def\etoc@@startlocaltoc#1#2{%
    \ifEtoc@localtoc
       \ifnum #1=#2\relax
          \ifEtoc@jj  \global\let\Etoc@localtop\Etoc@@minusone@@ \fi
          \ifEtoc@j   \global\let\Etoc@localtop\Etoc@@zero@@  \fi
          \ifEtoc@    \global\let\Etoc@localtop\Etoc@@one@@   \fi
          \ifEtoc@i   \global\let\Etoc@localtop\Etoc@@two@@   \fi
          \ifEtoc@ii  \global\let\Etoc@localtop\Etoc@@three@@ \fi
          \ifEtoc@iii \global\let\Etoc@localtop\Etoc@@four@@  \fi
          \ifEtoc@iv  \global\let\Etoc@localtop\Etoc@@five@@  \fi
          \ifEtoc@v   \global\let\Etoc@localtop\Etoc@@six@@   \fi
          \global\Etoc@notactivefalse
          \global\Etoc@vfalse
          \global\Etoc@ivfalse
          \global\Etoc@iiifalse
          \global\Etoc@iifalse
          \global\Etoc@ifalse
          \global\Etoc@false
          \global\Etoc@jfalse
          \global\Etoc@jjfalse
       \fi
    \fi
}
\let\etoc@startlocaltoc\@gobble
\def\Etoc@setemptytocbool {%
    \global\Etoc@emptytoctrue
    \global\Etoc@stoptocfalse
    \global\let\Etoc@level\Etoc@minf
    \begingroup
      \ifEtoc@localtoc
        \def\etoc@startlocaltoc##1{%
          \ifnum##1=\Etoc@tocid\relax
              \global\let\Etoc@localtop\Etoc@level
              \global\Etoc@notactivefalse
          \fi }%
        \let\contentsline\Etoc@testingcontentslinelocal
      \else
        \let\contentsline\Etoc@testingcontentsline
      \fi
      \Etoc@storetocdepth
        \the\Etoc@toctoks
      \Etoc@resettocdepth
    \endgroup
}
\DeclareRobustCommand*\etocifwasempty
  {\ifEtoc@emptytoc\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi }
\expandafter
\let\expandafter\etocxifwasempty\csname etocifwasempty \endcsname
\def\Etoc@testingcontentslinelocal #1{%
  \ifEtoc@stoptoc
  \else
   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
   \else
    \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname
    \ifEtoc@notactive
    \else
     \ifnum\Etoc@level>\Etoc@localtop
      \ifnum\Etoc@level>\c@tocdepth
      \else
       \global\Etoc@emptytocfalse
       \global\Etoc@stoptoctrue
      \fi
     \else
      \global\Etoc@stoptoctrue
     \fi
    \fi
   \fi
  \fi
  \Etoc@gobblefourorthree\relax
}
\def\Etoc@testingcontentsline #1{%
  \ifEtoc@stoptoc
  \else
   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
   \else
    \ifnum\csname Etoc@#1@@\endcsname>\c@tocdepth
    \else
     \global\Etoc@emptytocfalse
     \global\Etoc@stoptoctrue
    \fi
   \fi
  \fi
  \Etoc@gobblefourorthree\relax
}
\def\Etoc@localtableofcontents#1{%
    \Etoc@localtoctrue
    \global\Etoc@emptytocfalse
    \edef\Etoc@tocid{#1}%
    \ifnum\Etoc@tocid<\@ne
      %\PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}%
      \setbox0\hbox{\ref{Unknown toc ref \@secondoftwo#1. Rerun LaTeX}}%
      %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
      \global\Etoc@stoptoctrue % do only heading
      \Etoc@tableofcontents
      \expandafter\Etoc@gobbletoetoc@ % skip all the rest
    \fi
    \global\Etoc@notactivetrue
    \ifEtoc@checksemptiness \Etoc@setemptytocbool \fi
    \ifEtoc@emptytoc
       \ifEtoc@notactive
         %\PackageWarning{etoc}{Unknown toc ID \number\Etoc@tocid. Run LaTeX again}%
         \setbox0\hbox{\ref{Unknown toc ID \number\Etoc@tocid. Rerun LaTeX}}%
         %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
         \global\Etoc@emptytocfalse % assume real one will be non-empty
         \global\Etoc@stoptoctrue   % and print only heading for this pass
         \Etoc@tableofcontents
         \expandafter\expandafter\expandafter\Etoc@gobbletoetoc@
       \else
       %%  \PackageWarning{etoc}{This toc is apparently empty}%
       \fi
    \else
       \global\Etoc@stoptocfalse
       \global\Etoc@notactivetrue
       \global\let\Etoc@localtop\Etoc@@minustwo@@
       \edef\etoc@startlocaltoc##1{\noexpand\etoc@@startlocaltoc{##1}{\Etoc@tocid}}%
       \Etoc@tableofcontents
    \fi
    \@gobble\etoc@
    \endgroup\ifEtoc@mustclosegroup\endgroup\fi
    \Etoc@tocdepthreset % 1.07h, renamed 1.08h
    \etocaftertochook   % 1.07g
}
\def\Etoc@getrefno #1#2\etoc@ {#1}
\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter
          \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}}
\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}}
\def\Etoc@label#1{\label{#1}\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\@firstofone{\def\Etoc@again} {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\def\Etoc@dothis #1#2\etoc@ {\fi #1}
\def\Etoc@t@bleofcontents{%
    \ifx\Etoc@nexttoken\label\Etoc@dothis{\expandafter\Etoc@label\@gobble}\fi
    \ifx\Etoc@nexttoken\@sptoken\Etoc@dothis{\Etoc@again}\fi
    \ifx\Etoc@nexttoken\ref\Etoc@dothis{\expandafter\Etoc@ref\@gobble}\fi
    \ifEtoc@tocwithid\Etoc@dothis{\Etoc@localtableofcontents{\c@etoc@tocid}}\fi
    \global\Etoc@emptytocfalse\ifEtoc@checksemptiness\Etoc@setemptytocbool\fi
    \ifEtoc@emptytoc
     \ifEtoc@notocifnotoc
      \expandafter\expandafter\expandafter\@gobble
     \fi
    \fi
    \Etoc@tableofcontents
    \endgroup\ifEtoc@mustclosegroup\endgroup\fi
    \Etoc@tocdepthreset % 1.07h, renamed 1.08h
    \etocaftertochook   % 1.07g
    \@gobble\etoc@
    }
\def\Etoc@table@fcontents{%
    \refstepcounter{etoc@tocid}%
    \Etoc@tocwithidfalse
    \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\def\Etoc@localtable@fcontents{%
    \refstepcounter{etoc@tocid}%
    \addtocontents{toc}{\string\etoc@startlocaltoc{\the\c@etoc@tocid}}%
    \Etoc@tocwithidtrue
    \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
\let\etocaftertitlehook    \@empty
\let\etocaftercontentshook \@empty
\def\etoctableofcontents{%
   \Etoc@openouttoc
   \Etoc@tocdepthset % new with 1.08h
   \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents
      \let\tof@begingroup\@empty
      \let\tof@endgroup  \@empty
      \@ifstar
      {\def\Etoc@aftertitlehook{}\Etoc@table@fcontents}
      {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@table@fcontents}}
\let\tableofcontents\etoctableofcontents
\newcommand*\localtableofcontents{%
   \Etoc@openouttoc
   \Etoc@tocdepthset % new with 1.08h
   \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents
      \let\tof@begingroup\@empty
      \let\tof@endgroup  \@empty
      \@ifstar
      {\def\Etoc@aftertitlehook{}\Etoc@localtable@fcontents}
      {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@localtable@fcontents}}
\long\def\Etoc@gobbletoetoc@ #1\etoc@ {}
\newcommand\etocsettocstyle[2]{%
\def\Etoc@tableofcontents
{%
    \ifnum\c@tocdepth>\Etoc@minf
    \else
     \expandafter\Etoc@gobbletoetoc@
    \fi
    \Etoc@par
    \etocbeforetitlehook % 1.07m
    \Etoc@storetocdepth % 1.07g
    \let\Etoc@savedcontentsline\contentsline % moved up here 1.08
    \let\contentsline\Etoc@etoccontentsline
    \ifEtoc@standard
    \else % moved here from \Etoc@toctoc (1.08)
        \def\Etoc@levellist@elt####1{%
            \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname
                            \csname l@####1\endcsname
            \expandafter\let\csname l@####1\endcsname\Etoc@lxyz}%
        \Etoc@levellist
    \fi
    #1%
    \ifEtoc@parskip\parskip\z@skip\fi %1.07d
    \Etoc@aftertitlehook
    \Etoc@toctoc
    \etocaftercontentshook
    #2\@nobreakfalse % 1.07d: \@nobreakfalse moved here
    \Etoc@resettocdepth  % 1.07g. moved here from before #2 by 1.08
    \ifx\Etoc@global\global
     \ifx\tof@finish\@empty
     \else
       \global\let\contentsline\Etoc@savedcontentsline
     \fi
    \fi
    \@gobble\etoc@
}% end of \Etoc@tableofcontents definition by \etocsettocstyle
}
\def\etocsetstyle{\Etoc@standardfalse\etoc@setstyle}
\long\def\etoc@setstyle#1#2#3#4#5{%
     \expandafter\def
     \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname
                     {#2\Etoc@global\Etoc@isfirsttrue}%
     \expandafter\def
     \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname   {#3}%
     \expandafter\def
     \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}%
     \expandafter\def
     \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname      {#5}%
}
\def\etocfontminustwo {\normalfont \LARGE \bfseries}
\def\etocfontminusone {\normalfont \large \bfseries}
\def\etocfontzero     {\normalfont \large \bfseries}
\def\etocfontone      {\normalfont \normalsize \bfseries}
\def\etocfonttwo      {\normalfont \normalsize}
\def\etocfontthree    {\normalfont \footnotesize}
\def\etocsepminustwo  {4ex \@plus .5ex \@minus .5ex}
\def\etocsepminusone  {4ex \@plus .5ex \@minus .5ex}
\def\etocsepzero      {2.5ex \@plus .4ex \@minus .4ex}
\def\etocsepone       {1.5ex \@plus .3ex \@minus .3ex}
\def\etocseptwo       {.5ex \@plus .1ex \@minus .1ex}
\def\etocsepthree     {.25ex \@plus .05ex \@minus .05ex}
\def\etocbaselinespreadminustwo {1}
\def\etocbaselinespreadminusone {1}
\def\etocbaselinespreadzero     {1}
\def\etocbaselinespreadone      {1}
\def\etocbaselinespreadtwo      {1}
\def\etocbaselinespreadthree    {.9}
\def\etocminustwoleftmargin  {1.5em plus 0.5fil}
\def\etocminustworightmargin {1.5em plus -0.5fil}
\def\etocminusoneleftmargin  {1em}
\def\etocminusonerightmargin {1em}
\def\etoctoclineleaders
        {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}}
\def\etocabbrevpagename {p.~}
\def\etocpartname       {Part}% modified 1.08b
\def\etocbookname       {Book}
\def\etocdefaultlines{\Etoc@standardfalse %
%% `book':
\etoc@setstyle{@minustwo}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@secpenalty}
  {\begingroup
   \etocfontminustwo
   \addvspace{\etocsepminustwo}%
   \parindent \z@
   \leftskip  \etocminustwoleftmargin
   \rightskip \etocminustworightmargin
   \parfillskip \@flushglue
   \vbox{\etocifnumbered{\etocbookname\enspace\etocnumber:\quad}{}\etocname
        \baselineskip\etocbaselinespreadminustwo\baselineskip
        \par}%
   \addpenalty\@M\addvspace{\etocsepminusone}%
   \endgroup}
  {}%
%% `part':
\etoc@setstyle{@minusone}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@secpenalty}
  {\begingroup
   \etocfontminusone
   \addvspace{\etocsepminusone}%
   \parindent \z@
   \leftskip  \etocminusoneleftmargin
   \rightskip \etocminusonerightmargin
   \parfillskip \@flushglue
   \vbox{\etocifnumbered{\etocpartname\enspace\etocnumber.\quad}{}\etocname
         \baselineskip\etocbaselinespreadminusone\baselineskip
         \par}%
   \addpenalty\@M\addvspace{\etocsepzero}%
   \endgroup}
  {}%
%% `chapter':
\etoc@setstyle{@zero}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@itempenalty}
  {\begingroup
   \etocfontzero
   \addvspace{\etocsepzero}%
   \parindent \z@ \parfillskip \@flushglue
   \vbox{\etocifnumbered{\etocnumber.\enspace}{}\etocname
         \baselineskip\etocbaselinespreadzero\baselineskip
         \par}%
   \endgroup}
  {\addpenalty{-\@highpenalty}\addvspace{\etocsepminusone}}%
%% `section':
\etoc@setstyle{@one}
  {\addpenalty\@M\etocskipfirstprefix}
  {\addpenalty\@itempenalty}
  {\begingroup
   \etocfontone
   \addvspace{\etocsepone}%
   \parindent \z@ \parfillskip \z@
   \setbox\z@\vbox{\parfillskip\@flushglue
                   \etocname\par
                   \setbox\tw@\lastbox
                   \global\setbox\@ne\hbox{\unhbox\tw@\ }}%
   \dimen\z@=\wd\@ne
   \setbox\z@=\etoctoclineleaders
   \advance\dimen\z@\wd\z@
   \etocifnumbered
     {\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}}
     {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
   \advance\dimen\z@\wd\tw@
   \ifdim\dimen\z@ < \linewidth
       \vbox{\etocname~%
             \leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadone\baselineskip
             \par}% 1.08b adds the % here
   \else
       \vbox{\etocname~%
             \leaders\copy\z@\hfil\break
             \hbox{}\leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadone\baselineskip
             \par}%
   \fi
   \endgroup}
  {\addpenalty\@secpenalty\addvspace{\etocsepzero}}%
%% `subsection':
\etoc@setstyle{@two}
  {\addpenalty\@medpenalty\etocskipfirstprefix}
  {\addpenalty\@itempenalty}
  {\begingroup
   \etocfonttwo
   \addvspace{\etocseptwo}%
   \parindent \z@ \parfillskip \z@
   \setbox\z@\vbox{\parfillskip\@flushglue
                   \etocname\par\setbox\tw@\lastbox
                   \global\setbox\@ne\hbox{\unhbox\tw@}}%
   \dimen\z@=\wd\@ne
   \setbox\z@=\etoctoclineleaders
   \advance\dimen\z@\wd\z@
   \etocifnumbered
     {\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}}
     {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
   \advance\dimen\z@\wd\tw@
   \ifdim\dimen\z@ < \linewidth
       \vbox{\etocname~%
             \leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadtwo\baselineskip
             \par}%
   \else
       \vbox{\etocname~%
             \leaders\copy\z@\hfil\break
             \hbox{}\leaders\box\z@\hfil\box\tw@
             \baselineskip\etocbaselinespreadtwo\baselineskip
             \par}%
   \fi
   \endgroup}
  {\addpenalty\@secpenalty\addvspace{\etocsepone}}%
%% `subsubsection':
\etoc@setstyle{@three}
  {\addpenalty\@M
   \etocfontthree
   \vspace{\etocsepthree}%
   \noindent
   \etocskipfirstprefix}
  {\allowbreak\,--\,}
  {\etocname}
  {.\hfil
    \begingroup
     \baselineskip\etocbaselinespreadthree\baselineskip
     \par
    \endgroup
   \addpenalty{-\@highpenalty}}%
\etoc@setstyle{@four}{}{}{}{}%
\etoc@setstyle{@five}{}{}{}{}%
} % end of \etocdefaultlines!
\def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex}
\def\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex}
\def\etoccolumnsep{2em}
\def\etocmulticolsep{0ex}
\def\etocmulticolpretolerance{-1}
\def\etocmulticoltolerance{200}
\def\etocdefaultnbcol{2}
\def\etocinnertopsep{2ex}
\newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle
   {\let\etocoldpar\par
    \addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne
          \expandafter\@firstoftwo
    \else \expandafter\@secondoftwo
    \fi
    {\multicolpretolerance\etocmulticolpretolerance
    \multicoltolerance\etocmulticoltolerance
    \setlength{\columnsep}{\etoccolumnsep}%
    \setlength{\multicolsep}{\etocmulticolsep}%
    \begin{multicols}{#1}[#2\etocoldpar\addvspace{\etocinnertopsep}]}
    {#2\ifvmode\else\begingroup\interlinepenalty\@M\parskip\z@skip
                    \@@par\endgroup
       \fi
       \nobreak\addvspace{\etocinnertopsep}%
       \pretolerance\etocmulticolpretolerance
       \tolerance\etocmulticoltolerance}%
   }%
   {\ifnum #1>\@ne
          \expandafter\@firstofone
    \else \expandafter\@gobble
    \fi
    {\end{multicols}}%
    \addvspace{\etocbelowtocskip}}%
}
\def\etocinnerbottomsep{3.5ex}
\def\etocinnerleftsep{2em}
\def\etocinnerrightsep{2em}
\def\etoctoprule{\hrule}
\def\etocleftrule{\vrule}
\def\etocrightrule{\vrule}
\def\etocbottomrule{\hrule}
\def\etoctoprulecolorcmd{\relax}
\def\etocbottomrulecolorcmd{\relax}
\def\etocleftrulecolorcmd{\relax}
\def\etocrightrulecolorcmd{\relax}
\def\etoc@ruledheading #1{%
   \hb@xt@\linewidth{\color@begingroup
          \hss #1\hss\hskip-\linewidth
          \etoctoprulecolorcmd\leaders\etoctoprule\hss
          \phantom{#1}%
          \leaders\etoctoprule\hss\color@endgroup}%
          \nointerlineskip\nobreak\vskip\etocinnertopsep}
\newcommand*\etocruledstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle
   {\addvspace{\etocabovetocskip}%
    \ifnum #1>\@ne
          \expandafter\@firstoftwo
    \else \expandafter\@secondoftwo
    \fi
       {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}[\etoc@ruledheading{#2}]}
       {\etoc@ruledheading{#2}%
         \pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}}
   {\ifnum #1>\@ne\expandafter\@firstofone
         \else \expandafter\@gobble
    \fi
    {\end{multicols}}%
    \addvspace{\etocbelowtocskip}}}
\def\etocframedmphook{\relax}
\long\def\etocbkgcolorcmd{\relax}
\long\def\Etoc@relax{\relax}
\newbox\etoc@framed@titlebox
\newbox\etoc@framed@contentsbox
\newcommand*\etocframedstyle[2][\etocdefaultnbcol]{%
\etocsettocstyle{%
    \addvspace{\etocabovetocskip}%
    \sbox\z@{#2}%
    \dimen\z@\dp\z@
    \ifdim\wd\z@<\linewidth \dp\z@\z@ \else \dimen\z@\z@ \fi
    \setbox\etoc@framed@titlebox=\hb@xt@\linewidth{\color@begingroup
        \hss
        \ifx\etocbkgcolorcmd\Etoc@relax
        \else
            \sbox\tw@{\color{white}%
            \vrule\@width\wd\z@\@height\ht\z@\@depth\dimen\z@}%
            \ifdim\wd\z@<\linewidth \dp\tw@\z@\fi
            \box\tw@
            \hskip-\wd\z@
        \fi
        \copy\z@
        \hss
        \hskip-\linewidth
        \etoctoprulecolorcmd\leaders\etoctoprule\hss
        \hskip\wd\z@
        \etoctoprulecolorcmd\leaders\etoctoprule\hss\color@endgroup}%
    \setbox\z@\hbox{\etocleftrule\etocrightrule}%
    \dimen\tw@\linewidth\advance\dimen\tw@-\wd\z@
        \advance\dimen\tw@-\etocinnerleftsep
        \advance\dimen\tw@-\etocinnerrightsep
    \setbox\etoc@framed@contentsbox=\vbox\bgroup
        \hsize\dimen\tw@
        \kern\dimen\z@
        \vskip\etocinnertopsep
        \hbox\bgroup
        \begin{minipage}{\hsize}%
        \etocframedmphook
    \ifnum #1>\@ne
          \expandafter\@firstoftwo
    \else \expandafter\@secondoftwo
    \fi
        {\multicolpretolerance\etocmulticolpretolerance
        \multicoltolerance\etocmulticoltolerance
        \setlength{\columnsep}{\etoccolumnsep}%
        \setlength{\multicolsep}{\etocmulticolsep}%
        \begin{multicols}{#1}}
        {\pretolerance\etocmulticolpretolerance
         \tolerance\etocmulticoltolerance}}
    {\ifnum #1>\@ne\expandafter\@firstofone
         \else \expandafter\@gobble
     \fi
      {\end{multicols}\unskip }%
    \end{minipage}%
    \egroup
    \vskip\etocinnerbottomsep
    \egroup
    \vbox{\hsize\linewidth
        \ifx\etocbkgcolorcmd\Etoc@relax
        \else
            \kern\ht\etoc@framed@titlebox
            \kern\dp\etoc@framed@titlebox
            \hb@xt@\linewidth{\color@begingroup
            \etocleftrulecolorcmd\etocleftrule
            \etocbkgcolorcmd
            \leaders\vrule
                   \@height\ht\etoc@framed@contentsbox
                   \@depth\dp\etoc@framed@contentsbox
            \hss
            \etocrightrulecolorcmd\etocrightrule
            \color@endgroup}\nointerlineskip
            \vskip-\dp\etoc@framed@contentsbox
            \vskip-\ht\etoc@framed@contentsbox
            \vskip-\dp\etoc@framed@titlebox
            \vskip-\ht\etoc@framed@titlebox
        \fi
    \box\etoc@framed@titlebox\nointerlineskip
    \hb@xt@\linewidth{\color@begingroup
    {\etocleftrulecolorcmd\etocleftrule}%
    \hss\box\etoc@framed@contentsbox\hss
    \etocrightrulecolorcmd\etocrightrule\color@endgroup}
    \nointerlineskip
    \vskip\ht\etoc@framed@contentsbox
    \vskip\dp\etoc@framed@contentsbox
    \hb@xt@\linewidth{\color@begingroup\etocbottomrulecolorcmd
          \leaders\etocbottomrule\hss\color@endgroup}}
    \addvspace{\etocbelowtocskip}}}
\newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \tableofcontents}
\newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \tableofcontents*}
\newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \localtableofcontents}
\newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{%
    \etocmulticolstyle[#1]{#2}%
    \localtableofcontents*}
\newcommand*\etoc@ruledtoc[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \tableofcontents}
\newcommand*\etoc@ruledtoci[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \tableofcontents*}
\newcommand*\etoc@local@ruledtoc[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \localtableofcontents}
\newcommand*\etoc@local@ruledtoci[2][\etocdefaultnbcol]{%
    \etocruledstyle[#1]{#2}%
    \localtableofcontents*}
\newcommand*\etoc@framedtoc[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \tableofcontents}
\newcommand*\etoc@framedtoci[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \tableofcontents*}
\newcommand*\etoc@local@framedtoc[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \localtableofcontents}
\newcommand*\etoc@local@framedtoci[2][\etocdefaultnbcol]{%
    \etocframedstyle[#1]{#2}%
    \localtableofcontents*}
\def\etocmulticol{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@multicoltoci}
    {\etoc@multicoltoc}}
\def\etocruled{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@ruledtoci}
    {\etoc@ruledtoc}}
\def\etocframed{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@framedtoci}
    {\etoc@framedtoc}}
\def\etoclocalmulticol{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@multicoltoci}
    {\etoc@local@multicoltoc}}
\def\etoclocalruled{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@ruledtoci}
    {\etoc@local@ruledtoc}}
\def\etoclocalframed{\begingroup
    \Etoc@mustclosegrouptrue
    \@ifstar
    {\etoc@local@framedtoci}
    {\etoc@local@framedtoc}}
\def\etocarticlestyle{%
    \etocsettocstyle
    {\section *{\contentsname
                \@mkboth {\MakeUppercase \contentsname}
                         {\MakeUppercase \contentsname}}}
    {}}
\def\etocarticlestylenomarks{%
    \etocsettocstyle
    {\section *{\contentsname}}
    {}}
\def\etocbookstyle{%
    \etocsettocstyle
    {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
     \chapter *{\contentsname
                \@mkboth {\MakeUppercase \contentsname}
                         {\MakeUppercase \contentsname}}}
    {\if@restonecol \twocolumn \fi}}
\def\etocbookstylenomarks{%
    \etocsettocstyle
    {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
     \chapter *{\contentsname}}
    {\if@restonecol \twocolumn \fi}}
\let\etocreportstyle\etocbookstyle
\let\etocreportstylenomarks\etocbookstylenomarks
\def\etocmemoirtoctotocfmt #1#2{%
    \def\Etoc@addsuitablecontentsline{\addcontentsline {toc}{#1}{#2}}%
    \renewcommand*\etocaftertitlehook{%
      \ifmem@em@starred@listof
      \else
        \phantomsection
        \aftergroup\Etoc@addsuitablecontentsline
      \fi}%
}
\def\etocmemoirstyle{%
    \etocsettocstyle
        {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle}
         \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax
         \parskip \cftparskip \@nameuse {cfttocbeforelisthook}}
        {\@nameuse {cfttocafterlisthook}\endgroup\restorefromonecol}}
\def\etocscrartclstyle{%
    \etocsettocstyle
        {\let\if@dynlist\if@tocleft
         \def\@currext{toc}% added 1.07m 2015/01/23
         \iftocfeature {toc}{onecolumn}
             {\iftocfeature {toc}{leveldown}
              {}
              {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }}
             {}%
         \iftocfeature {toc}{numberline}{\def \nonumberline {\numberline {}}}{}%
         \tocbasic@listhead {\listoftocname}%
         \begingroup \expandafter \expandafter \expandafter
         \endgroup \expandafter
         \ifx
             \csname microtypesetup\endcsname \relax
         \else
             \iftocfeature {toc}{noprotrusion}{}
                 {\microtypesetup {protrusion=false}%
                  \PackageInfo {tocbasic}%
                  {character protrusion at toc deactivated}}%
         \fi
         \setlength {\parskip }{\z@ }%
         \setlength {\parindent }{\z@ }%
         \setlength {\parfillskip }{\z@ \@plus 1fil}%
         \csname tocbasic@@before@hook\endcsname
         \csname tb@toc@before@hook\endcsname}
        {\csname tb@toc@after@hook\endcsname
         \csname tocbasic@@after@hook\endcsname}}
\let\etocscrbookstyle\etocscrartclstyle
\let\etocscrreprtstyle\etocscrartclstyle
\def\etocstandarddisplaystyle{\etocarticlestyle}
\newcommand*\etocmarkboth[1]{%
    \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}}
\newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}}
\newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3}}}
\newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3\etocmarkboth{#4}}}}
\newcommand\etoctocstylewithmarksnouc[4][section]{\etocmulticolstyle[#2]%
    {\csname #1\endcsname *{#3\etocmarkbothnouc{#4}}}}
\def\Etoc@redefetocstyle#1{%
    \renewcommand\etoctocstylewithmarks[4][#1]
    {\etocmulticolstyle[##2]%
          {\csname ##1\endcsname *{##3\etocmarkboth{##4}}}}
    \renewcommand\etoctocstylewithmarksnouc[4][#1]
    {\etocmulticolstyle[##2]%
          {\csname ##1\endcsname *{##3\etocmarkbothnouc{##4}}}}
    \renewcommand\etoctocstyle[3][#1]{%
     \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}}
\@ifclassloaded{scrartcl}
    {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{}
\@ifclassloaded{book}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocbookstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{report}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocreportstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{scrbook}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocscrbookstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{scrreprt}
    {\renewcommand*\etocfontone{\normalfont\normalsize}
     \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle}
     \Etoc@redefetocstyle{chapter}}{}
\@ifclassloaded{memoir}
    {\etocsetlevel{appendix}{0}%
     \renewcommand*\etocfontone{\normalfont\normalsize}
     \etocmemoirtoctotocfmt{chapter}{\contentsname}%
     \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle}
     \Etoc@redefetocstyle{chapter}}{}
\def\etoctocloftstyle {%
    \etocsettocstyle
    {\@cfttocstart\par\begingroup
      \parindent\z@ \parskip\cftparskip \@cftmaketoctitle
      \if@cfttocbibind\@cftdobibtoc\fi }%
    {\endgroup\@cfttocfinish }%
}
\@ifclassloaded{memoir}{}
{\@ifpackageloaded{tocloft}
    {\if@cftnctoc\else
     \renewcommand*\etocstandarddisplaystyle{\etoctocloftstyle}
     \AtBeginDocument{\let\tableofcontents\etoctableofcontents}
     \fi }
    {\AtBeginDocument
      {\@ifpackageloaded{tocloft}
       {\if@cftnctoc\else
         \PackageWarning {etoc}
         {Package `tocloft' was loaded after `etoc'!^^J%
**** to prevent it from overwriting \protect\tableofcontents, it will be tricked^^J%
**** into believing to have been loaded with option `titles'. For better^^J%
**** compatibility, please load `tocloft' before `etoc'}%
        \AtEndDocument{\PackageWarning{etoc}
                       {Please load `tocloft' /before/ `etoc'!}}\fi
        \@cftnctoctrue }%
       {}%
      }%
     }%
}
\def\Etoc@addtocontents #1#2%
    {\ifEtoc@hyperref
       \addtocontents {toc}{\protect\contentsline
                {#1}{#2}%
                {\thepage }{\@currentHref }}%
     \else
       \addtocontents {toc}{\protect\contentsline
          {#1}{#2}{\thepage }}%
     \fi}
\def\Etoc@addcontentsline@ #1#2#3%
    {\@namedef{toclevel@#1}{#3}%
     \addcontentsline {toc}{#1}{#2}}
\DeclareRobustCommand*{\etoctoccontentsline}
    {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}}
\def\Etoc@storetocdepth {\global\c@etoc@tocdepth\c@tocdepth }
\def\Etoc@resettocdepth {\global\c@tocdepth\c@etoc@tocdepth }
\def\etocobeytoctocdepth {\def\etoc@settocdepth
        {\afterassignment\Etoc@@nottoodeep \global\c@tocdepth}}
\def\Etoc@@nottoodeep {\ifnum\c@tocdepth>\c@etoc@tocdepth
                          \global\c@tocdepth\c@etoc@tocdepth\fi }
\def\etocignoretoctocdepth {\let\etoc@settocdepth\@gobble }
\def\etocsettocdepth   {\futurelet\Etoc@nexttoken\Etoc@set@tocdepth }
\def\Etoc@set@tocdepth {\ifx\Etoc@nexttoken\bgroup
                            \expandafter\Etoc@set@tocdepth@
                       \else\expandafter\Etoc@set@toctocdepth
                       \fi }
\def\Etoc@set@tocdepth@ #1{\@ifundefined {Etoc@#1@@}
      {\PackageWarning{etoc}
          {Unknown sectioning unit #1, \protect\etocsettocdepth\space ignored}}
      {\global\c@tocdepth\csname Etoc@#1@@\endcsname}%
}
\def\Etoc@set@toctocdepth  #1#{\Etoc@set@toctocdepth@ }
\def\Etoc@set@toctocdepth@ #1{%
  \@ifundefined{Etoc@#1@@}%
   {\PackageWarning{etoc}
        {Unknown sectioning depth #1, \protect\etocsettocdepth.toc ignored}}%
   {\addtocontents {toc}
   {\protect\etoc@settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}%
}
\def\etocdepthtag   #1#{\Etoc@depthtag } % \etocdepthtag.toc {name}
\def\Etoc@depthtag  #1{\addtocontents {toc}{\protect\etoc@depthtag {#1}}}
\def\etocignoredepthtags {\let\etoc@depthtag \@gobble }
\def\etocobeydepthtags   {\let\etoc@depthtag \Etoc@depthtag@ }
\def\Etoc@depthtag@ #1{\@ifundefined{Etoc@depthof@#1}%
       {}% ignore in silence if tag has no associated depth
       {\afterassignment\Etoc@@nottoodeep
                 \global\c@tocdepth\csname Etoc@depthof@#1\endcsname}%
}
\def\etocsettagdepth #1#2{\@ifundefined{Etoc@#2@@}%
       {\PackageWarning{etoc}
         {Unknown sectioning depth #2, \protect\etocsettagdepth\space ignored}}%
       {\@namedef{Etoc@depthof@#1}{\@nameuse{Etoc@#2@@}}}%
}
\def\Etoc@tocvsec@err #1{\PackageError {etoc}
        {the command \protect#1\space is incompatible with etoc}
        {use \protect\etocsettocdepth.toc as replacement (see etoc manual)}%
}%
\AtBeginDocument {%
   \@ifclassloaded{memoir}
    {\PackageInfo {etoc}
     {Regarding memoir class command \protect\settocdepth, consider^^J
     \protect\etocsettocdepth.toc as a drop-in replacement with
     more capabilities^^J (see etoc manual). Similarly
     \protect\etocsettocdepth\space and
     \protect\etocsetnexttocdepth^^J should replace
     use of memoir's \protect\maxtocdepth\space command.}}
    {\@ifpackageloaded {tocvsec2}
     {\def\maxtocdepth  #1{\Etoc@tocvsec@err \maxtocdepth   }%
      \def\settocdepth  #1{\Etoc@tocvsec@err \settocdepth   }%
      \def\resettocdepth  {\@ifstar {\Etoc@tocvsec@err \resettocdepth }%
                                    {\Etoc@tocvsec@err \resettocdepth }%
                          }%
      \def\save@tocdepth #1#2#3{}%    % if etoc is added to file previously
      \let\reset@tocdepth\relax       % using tocvsec2
      \let\remax@tocdepth\relax
      \let\tableofcontents\etoctableofcontents
      \PackageWarning {etoc}
      {package tocvsec2 detected and its modification of^^J
       \protect\tableofcontents\space reverted. Use
       \protect\etocsettocdepth.toc as a replacement^^J
       for the tocvsec2 toc-related commands}}{}%
   }%
}%
\def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }%
\def\invisiblelocaltableofcontents
                         {\etocsetnexttocdepth {-3}\localtableofcontents }%
\def\etocsetnexttocdepth #1{%
    \@ifundefined{Etoc@#1@@}
     {\PackageWarning{etoc}
       {Unknown sectioning unit #1, \protect\etocsetnextocdepth\space ignored}}
     {\def\Etoc@tocdepthset
          {\edef\Etoc@tocdepthreset {%
                   \global\c@tocdepth\the\c@tocdepth\space
                   \global\let\noexpand\Etoc@tocdepthreset\noexpand\@empty }%
           \global\c@tocdepth\csname Etoc@#1@@\endcsname
           \global\let\Etoc@tocdepthset\@empty}}%
}%
\def\etocsetlocaltop #1#{\Etoc@set@localtop}%
\def\Etoc@set@localtop #1{%
  \@ifundefined{Etoc@#1@@}%
   {\PackageWarning{etoc}
        {Unknown sectioning depth #1, \protect\etocsetlocaltop.toc ignored}}%
   {\addtocontents {toc}
   {\protect\etoc@setlocaltop\expandafter\protect\csname Etoc@#1@@\endcsname}}%
}%
\def\etoc@setlocaltop #1{%
  \global\let\Etoc@level #1%
  \Etoc@skipthisonefalse
  \ifnum\Etoc@level=\Etoc@@six@@
   \Etoc@skipthisonetrue
  \else
   \ifEtoc@localtoc
    \ifEtoc@stoptoc\Etoc@skipthisonetrue
    \else
     \ifEtoc@notactive
      \Etoc@setflags
      \Etoc@skipthisonetrue
     \else
      \ifnum\Etoc@level<\Etoc@localtop
       \Etoc@skipthisonetrue
       \global\Etoc@stoptoctrue
      \fi
     \fi
    \fi
   \fi
  \fi
  \let\Etoc@next\@gobble
  \ifEtoc@skipthisone
  \else
   \ifnum\c@tocdepth<\Etoc@level
   \else
    \ifEtoc@standard
    \else
     \let\Etoc@next\@firstofone
    \fi
   \fi
  \fi
  \Etoc@next{\Etoc@doends\Etoc@dobegins}%
}%
\addtocontents {toc}{\protect\@ifundefined{etoctocstyle}%
           {\let\protect\etoc@startlocaltoc\protect\@gobble
            \let\protect\etoc@settocdepth\protect\@gobble
            \let\protect\etoc@depthtag\protect\@gobble
            \let\protect\etoc@setlocaltop\protect\@gobble}{}}%
\def\etocstandardlines {\Etoc@standardtrue}
\def\etoctoclines      {\Etoc@standardfalse}
\etocdefaultlines
\etocstandardlines
\etocstandarddisplaystyle
\etocobeytoctocdepth
\etocobeydepthtags
\let\Etoc@tocdepthreset\@empty % new 1.08h functioning of \etocsetnexttocdepth
\let\Etoc@tocdepthset  \@empty %
\let\etocaftertochook    \@empty % public for end user.
\let\etocbeforetitlehook \@empty % new with 1.07m
\endinput
%%
%% End of file `etoc.sty'.
