diff options
author | Karl Berry <karl@freefriends.org> | 2023-03-02 21:01:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-03-02 21:01:34 +0000 |
commit | b8da298343979094f22cce0307bba6a106426d42 (patch) | |
tree | 7d1a220754f3312493a9768642aea9e2f44e090e /Master/texmf-dist/tex/latex/etoc | |
parent | ef4b3553f6f32608d2dbd42af151d5adbd5fb54d (diff) |
etoc (2mar23)
git-svn-id: svn://tug.org/texlive/trunk@66299 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoc')
-rw-r--r-- | Master/texmf-dist/tex/latex/etoc/etoc.sty | 1387 |
1 files changed, 936 insertions, 451 deletions
diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index 1268084daca..070a3fe4ae7 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -22,16 +22,66 @@ %% in the same archive or directory.) %% %% Package: etoc -%% Version: 1.1c +%% Version: 1.2 %% License: LPPL 1.3c %% Copyright (C) 2012-2023 Jean-Francois Burnol %% <jfbu at free dot fr> \NeedsTeXFormat{LaTeX2e}[2020/10/01] \ProvidesPackage{etoc} -[2023/01/20 v1.1c Completely customisable TOCs (JFB)] +[2023/03/01 v1.2 Completely customisable TOCs (JFB)] +\RequirePackage{kvoptions} +\SetupKeyvalOptions{prefix=Etoc@} +\newif\ifEtoc@lof +\DeclareVoidOption{lof}{\Etoc@loftrue + \PackageInfo{etoc}{Experimental support for \string\locallistoffigures.\MessageBreak + Barely tested, use at own risk}% +} +\newif\ifEtoc@lot +\DeclareVoidOption{lot}{\Etoc@lottrue + \PackageInfo{etoc}{Experimental support for \string\locallistoftables.\MessageBreak + Barely tested, use at own risk}% +} +\@ifclassloaded{memoir}{ +\PackageInfo{etoc} + {As this is with memoir class, all `...totoc' options\MessageBreak + are set true by default. Reported} +\DeclareBoolOption[true]{maintoctotoc} +\DeclareBoolOption[true]{localtoctotoc} +\DeclareBoolOption[true]{localloftotoc} +\DeclareBoolOption[true]{locallottotoc} +}{ +\DeclareBoolOption[false]{maintoctotoc} +\DeclareBoolOption[false]{localtoctotoc} +\DeclareBoolOption[false]{localloftotoc} +\DeclareBoolOption[false]{locallottotoc} +} +\DeclareBoolOption[true]{ouroboros} +\DeclareDefaultOption{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} +\ProcessKeyvalOptions* +\DisableKeyvalOption[action=error,package=etoc]{etoc}{lof} +\DisableKeyvalOption[action=error,package=etoc]{etoc}{lot} +\def\etocsetup#1{\setkeys{etoc}{#1}} +\def\etocifmaintoctotoc{\ifEtoc@maintoctotoc + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\def\etociflocaltoctotoc{\ifEtoc@localtoctotoc + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\def\etociflocalloftotoc{\ifEtoc@localloftotoc + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\def\etociflocallottotoc{\ifEtoc@locallottotoc + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} \RequirePackage{multicol} -\DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} -\ProcessOptions\relax \def\etoc@{\etoc@} \long\def\Etoc@gobtoetoc@ #1\etoc@{} \newtoks\Etoc@toctoks @@ -42,19 +92,14 @@ \let\Etoc@global\@empty \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@numbered \newif\ifEtoc@hyperref \newif\ifEtoc@parskip \newif\ifEtoc@tocwithid -\newif\ifEtoc@standard +\newif\ifEtoc@standardlines +\newif\ifEtoc@etocstyle +\newif\ifEtoc@classstyle +\newif\ifEtoc@keeporiginaltoc \newif\ifEtoc@skipprefix \newif\ifEtoc@isfirst \newif\ifEtoc@localtoc @@ -62,88 +107,88 @@ \newif\ifEtoc@stoptoc \newif\ifEtoc@notactive \newif\ifEtoc@mustclosegroup -\newif\ifEtoc@emptytoc +\newif\ifEtoc@isemptytoc \newif\ifEtoc@checksemptiness \def\etocchecksemptiness {\Etoc@checksemptinesstrue } \def\etocdoesnotcheckemptiness {\Etoc@checksemptinessfalse } \newif\ifEtoc@notocifnotoc \def\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue } \newcounter{etoc@tocid} -\newcounter{etoc@tocdepth} -\@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 -\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} +\def\Etoc@tocext{toc} +\def\Etoc@lofext{lof} +\def\Etoc@lotext{lot} +\let\Etoc@currext\Etoc@tocext +\def\etocifislocal{\ifEtoc@localtoc\expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi + } +\def\etocifislocaltoc{\etocifislocal{\ifx\Etoc@currext\Etoc@tocext + \expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi}% + {\@secondoftwo}% + } +\def\etocifislocallof{\etocifislocal{\ifx\Etoc@currext\Etoc@lofext + \expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi}% + {\@secondoftwo}% + } +\def\etocifislocallot{\etocifislocal{\ifx\Etoc@currext\Etoc@lotext + \expandafter\@firstoftwo\else + \expandafter\@secondoftwo\fi}% + {\@secondoftwo}% + } \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@@ +\expandafter\def\csname Etoc@-2@@\endcsname {-\tw@} +\expandafter\let\csname Etoc@-1@@\endcsname \m@ne +\expandafter\let\csname Etoc@0@@\endcsname \z@ +\expandafter\let\csname Etoc@1@@\endcsname \@ne +\expandafter\let\csname Etoc@2@@\endcsname \tw@ +\expandafter\let\csname Etoc@3@@\endcsname \thr@@ +\expandafter\chardef\csname Etoc@4@@\endcsname 4 +\expandafter\chardef\csname Etoc@5@@\endcsname 5 +\expandafter\chardef\csname Etoc@6@@\endcsname 6 +\expandafter\let\expandafter\Etoc@@six@@\csname Etoc@6@@\endcsname +\@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}} \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@@ +\expandafter\let\expandafter\Etoc@all@@ \csname Etoc@5@@\endcsname +\let\Etoc@dolevels\@empty +\def\Etoc@newlevel #1{\expandafter\def\expandafter\Etoc@dolevels\expandafter + {\Etoc@dolevels\Etoc@do{#1}}} +\def\etocsetlevel#1#2{\expanded{\noexpand\etoc@setlevel{#1}{#2}}}% +\def\etoc@setlevel#1#2{% + \edef\Etoc@tmp{\the\numexpr#2}% + \if1\ifnum\Etoc@tmp>\Etoc@@six@@0\fi\ifnum\Etoc@tmp<-\tw@0\fi1% + \in@{.#1,}{.none,.all,.figure,.table,.-3,.-2,.-1,.0,.1,.2,.3,.4,.5,.6,}% + \ifin@\else\if\@car#1\@nil @\in@true\fi\fi + \ifin@ + \PackageWarning{etoc} + {Sorry, but `#1' is forbidden as level name.\MessageBreak + \if\@car#1\@nil @% + (because of the @, especially as first character)\MessageBreak\fi + Reported}% + \else + \etocifunknownlevelTF{#1}{\Etoc@newlevel{#1}}{}% + \expandafter\let\csname Etoc@#1@@\expandafter\endcsname + \csname Etoc@\Etoc@tmp @@\endcsname + \expandafter\edef\csname Etoc@@#1@@\endcsname + {\expandafter\noexpand\csname Etoc@#1@@\endcsname}% + \expandafter\edef\csname toclevel@@#1\endcsname + {\expandafter\noexpand\csname toclevel@#1\endcsname}% + \fi \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.\MessageBreak - It must be one of -2,-1, 0, 1, 2, 3, 4, 5, or 6 and\MessageBreak - will be set to 6: the \string\contentsline\space entries of type\MessageBreak - `#1' will be ignored by `etoc'.\MessageBreak Reported}% + {Argument `\detokenize{#2}' of \string\etocsetlevel\space should + represent\MessageBreak + -2, -1, 0, 1, 2, 3, 4, 5, or 6 but evaluates to \Etoc@tmp.\MessageBreak + The level of `#1' will be set to 6.\MessageBreak + Tables of contents will ignore `#1' as long\MessageBreak + as its level is 6.\MessageBreak + Reported}% + \etocifunknownlevelTF{#1}{\Etoc@newlevel{#1}}{}% \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@ - \fi - \fi \fi } +\def\etoclevel#1{\csname Etoc@#1@@\endcsname} +\def\etocifunknownlevelTF#1{\@ifundefined{Etoc@#1@@}} \etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} @@ -152,148 +197,53 @@ \etocsetlevel{subsubsection}{3} \etocsetlevel{paragraph}{4} \etocsetlevel{subparagraph}{5} +\ifdefined\c@chapter + \etocsetlevel{appendix}{0} +\else + \etocsetlevel{appendix}{1} +\fi +\def\Etoc@do#1{\@namedef{l@@#1}{\csname l@#1\endcsname}} +\Etoc@dolevels +\let\Etoc@figure@@\Etoc@@six@@ +\let\Etoc@table@@\Etoc@@six@@ \AtBeginDocument{% \@ifpackageloaded{parskip}{\Etoc@parskiptrue}{}% \@ifpackageloaded{hyperref}{\Etoc@hyperreftrue}{}% } -\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\etocskipfirstprefix {\global\Etoc@skipprefixtrue } +\def\Etoc@updatestackofends#1\etoc@{\gdef\Etoc@stackofends{#1}} +\def\Etoc@stackofends{{-3}{}} +\def\Etoc@doendsandbegin{% + \expandafter\Etoc@traversestackofends\Etoc@stackofends\etoc@ } -\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\Etoc@traversestackofends#1{% + \ifnum#1>\Etoc@level\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + {\csname Etoc@end@#1\endcsname + \Etoc@traversestackofends + }% + {\ifnum#1<\Etoc@level + \csname Etoc@begin@\the\numexpr\Etoc@level\endcsname + \Etoc@global\Etoc@isfirsttrue + \edef\Etoc@tmp{{\the\numexpr\Etoc@level}}% + \else + \Etoc@global\Etoc@isfirstfalse + \let\Etoc@tmp\@empty + \fi + \expandafter\Etoc@updatestackofends\Etoc@tmp{#1}% + }% } -\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 + \let\Etoc@next\@gobblefour + \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@ \else + \Etoc@skipthisonefalse + \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname + \if @\@car#1\@nil\else\global\let\Etoc@virtualtop\Etoc@level\fi \ifEtoc@localtoc \ifEtoc@stoptoc \Etoc@skipthisonetrue \else - \ifEtoc@notactive\Etoc@setflags + \ifEtoc@notactive \Etoc@skipthisonetrue \else \unless\ifnum\Etoc@level>\etoclocaltop @@ -303,31 +253,30 @@ \fi \fi \fi - \fi - \let\Etoc@next\@gobblefour - \ifEtoc@skipthisone - \else - \unless\ifnum\c@tocdepth<\Etoc@level - \ifEtoc@standard - \let\Etoc@next\Etoc@savedcontentsline - \else - \let\Etoc@next\Etoc@etoccontentsline@ + \ifEtoc@skipthisone + \else + \unless\ifnum\Etoc@level>\c@tocdepth + \ifEtoc@standardlines + \let\Etoc@next\Etoc@savedcontentsline + \else + \let\Etoc@next\Etoc@etoccontentsline@ + \fi \fi \fi \fi \Etoc@next{#1}% } \def\Etoc@etoccontentsline@ #1#2#3#4{% - \Etoc@doends - \Etoc@dobegins + \Etoc@doendsandbegin \Etoc@global\edef\Etoc@prefix {\expandafter\noexpand - \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }% + \csname Etoc@prefix@\the\numexpr\Etoc@level\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 + \csname Etoc@contents@\the\numexpr\Etoc@level\endcsname }% + \ifEtoc@skipprefix \Etoc@global\def\Etoc@prefix{\@empty}\fi \global\Etoc@skipprefixfalse \Etoc@lxyz{#2}{#3}{#4}% - \Etoc@prefix\Etoc@contents + \Etoc@prefix + \Etoc@contents } \def\Etoc@lxyz #1#2#3{% \ifEtoc@hyperref @@ -350,7 +299,7 @@ \ifEtoc@hyperref \def\Etoc@tmp##1##2{\Etoc@global\def##2{\hyperlink{#3}{##1}}}% \expandafter\Etoc@tmp\expandafter{\etocthename}\etocthelinkedname - \ifEtoc@number + \ifEtoc@numbered \expandafter\Etoc@tmp\expandafter{\etocthenumber}\etocthelinkednumber \else \Etoc@global\let\etocthelinkednumber\@empty @@ -405,7 +354,7 @@ \Etoc@next #1% } \def\Etoc@getnb@nmbrd #1#2{% - \Etoc@global\Etoc@numbertrue + \Etoc@global\Etoc@numberedtrue \Etoc@global\def\etocthenumber {#2}% \Etoc@getnb@nmbrd@getname\@empty }% @@ -413,20 +362,20 @@ \Etoc@global\expandafter\def\expandafter\etocthename\expandafter{#1}% } \def\Etoc@getnb@nonbr #1\etoc@ {% - \Etoc@global\Etoc@numberfalse + \Etoc@global\Etoc@numberedfalse \Etoc@global\let\etocthenumber \@empty } \def\Etoc@getnb@nonumberline #1\hspace\etoc@ {% - \Etoc@global\Etoc@numberfalse + \Etoc@global\Etoc@numberedfalse \Etoc@global\let\etocthenumber \@empty \Etoc@global\expandafter\def\expandafter\etocthename\expandafter{\@gobble#1}% } \def\Etoc@@getit #1\hspace#2{% \ifx\etoc@#2% - \Etoc@global\Etoc@numberfalse + \Etoc@global\Etoc@numberedfalse \Etoc@global\let\etocthenumber \@empty \else - \Etoc@global\Etoc@numbertrue + \Etoc@global\Etoc@numberedtrue \Etoc@global\def\etocthenumber {#1}% \expandafter\Etoc@getit@getname \expandafter\@empty \fi @@ -446,7 +395,7 @@ \DeclareRobustCommand*{\etocpage} {} \DeclareRobustCommand*{\etoclink} {\@firstofone} \DeclareRobustCommand*{\etocifnumbered} - {\ifEtoc@number\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} + {\ifEtoc@numbered\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} \expandafter\let\expandafter\etocxifnumbered\csname etocifnumbered \endcsname \DeclareRobustCommand*{\etociffirst} {\ifEtoc@isfirst\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} @@ -488,88 +437,250 @@ \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 + \gdef\Etoc@stackofends{{-3}{}}% + \global\let\Etoc@level\Etoc@minf + \global\let\Etoc@virtualtop\Etoc@minf \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 + \gdef\Etoc@level{-\thr@@}% + \Etoc@doendsandbegin \fi } -\def\etoc@@startlocaltoc#1#2{% +\def\Etoc@@startlocaltoc#1#2{% \ifEtoc@localtoc \ifnum #1=#2\relax - \ifEtoc@jj \global\let\etoclocaltop\Etoc@@minustwo@@\fi - \ifEtoc@j \global\let\etoclocaltop\Etoc@@minusone@@\fi - \ifEtoc@ \global\let\etoclocaltop\Etoc@@zero@@ \fi - \ifEtoc@i \global\let\etoclocaltop\Etoc@@one@@ \fi - \ifEtoc@ii \global\let\etoclocaltop\Etoc@@two@@ \fi - \ifEtoc@iii \global\let\etoclocaltop\Etoc@@three@@ \fi - \ifEtoc@iv \global\let\etoclocaltop\Etoc@@four@@ \fi - \ifEtoc@v \global\let\etoclocaltop\Etoc@@five@@ \fi - \global\c@tocdepth\Etoc@localtocdepth + \global\let\etoclocaltop\Etoc@virtualtop + \Etoc@@startlocaltochook + \etoclocaltableofcontentshook + \ifEtoc@etocstyle + \etocetoclocaltocmaketitle + \fi + \ifx\Etoc@aftertitlehook\@empty + \else + \ifEtoc@localtoctotoc + \ifEtoc@ouroboros + \else + \let\Etoc@tmp\contentsline + \def\contentsline{\let\contentsline\Etoc@tmp\@gobblefour}% + \fi + \fi + \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 +\let\Etoc@@startlocaltoc@toc\Etoc@@startlocaltoc +\let\Etoc@@startlocaltochook\@empty +\def\etocdivisionnameatlevel#1{% + \ifcase\numexpr#1\relax + \ifdefined\c@chapter chapter\else section\fi% + \or section% + \or subsection% + \or subsubsection% + \or paragraph% + \or subparagraph% + \or empty% + \else\ifnum\numexpr#1<\m@ne + book% + \else + part% + \fi + \fi +} +\def\etoclocalheadtotoc#1#2{\addcontentsline{toc}{@#1}{#2}} +\def\etocglobalheadtotoc{\addcontentsline{toc}} +\providecommand*\UseName{\@nameuse} +\def\etocetoclocaltocmaketitle{% + \UseName{\etocdivisionnameatlevel{\etoclocaltop+1}}*{\localcontentsname}% + \ifnum\etoclocaltop>\tw@\mbox{}\par\fi + \etociflocaltoctotoc + {\etocifisstarred + {}% star variant, do not add to toc + {\etoclocalheadtotoc + {\etocdivisionnameatlevel{\etoclocaltop+1}}% + {\localcontentsname}% + }% + }% + {}% +}% +\def\localcontentsname {\contentsname}% +\let\etoclocaltableofcontentshook\@empty +\if1\ifEtoc@lof0\fi\ifEtoc@lot0\fi1% +\else +\AtBeginDocument{% + \let\Etoc@originaladdcontentsline\addcontentsline + \def\addcontentsline{\Etoc@hackedaddcontentsline}% +}% +\fi +\def\Etoc@hackedaddcontentsline#1{% + \expanded{\noexpand\in@{.#1,}{\ifEtoc@lof.lof,\fi\ifEtoc@lot.lot,\fi}}% + \ifin@\expandafter\Etoc@hackedaddcontentsline@i + \else\expandafter\Etoc@originaladdcontentsline + \fi + {#1}% +} + +\def\Etoc@hackedaddcontentsline@i#1#2#3{% + \expanded{\noexpand\in@{.#1;#2,}}{.lof;figure,.lot;table,}% + \ifin@ + \addtocontents {toc}{% + \protect\contentsline{#2}{#3}{\thepage}{\ifEtoc@hyperref\@currentHref\fi}% + \ifdefined\protected@file@percent\protected@file@percent\fi + }% + \fi + \Etoc@originaladdcontentsline{#1}{#2}{#3}% +} +\def\Etoc@@startlocallistof#1#2#3{% + \ifEtoc@localtoc + \ifnum #2=#3\relax + \global\let\etoclocaltop\Etoc@virtualtop + \global\Etoc@notactivefalse + \Etoc@@startlocaltochook + \csname etoclocallistof#1shook\endcsname + \ifEtoc@etocstyle + \csname etocetoclistof#1smaketitle\endcsname + \fi + \fi + \fi +} +\def\Etoc@@startlocallistof@setlevels#1{% + \ifnum\etoclocaltop<\z@ + \expandafter\let\csname Etoc@#1@@\endcsname\@ne + \else + \expandafter\let\csname Etoc@#1@@\expandafter\endcsname + \csname Etoc@\the\numexpr\etoclocaltop+\@ne @@\endcsname + \fi + \def\Etoc@do##1{% + \ifnum\etoclevel{##1}>\etoclocaltop + \expandafter\let\csname Etoc@##1@@\endcsname\Etoc@@six@@ + \fi}% + \Etoc@dolevels +} +\def\etoclocallistoffigureshook{\etocstandardlines} +\def\etoclocallistoftableshook {\etocstandardlines} +\def\locallistfigurename{\listfigurename} +\def\locallisttablename {\listtablename} +\def\etocetoclistoffiguresmaketitle{% + \UseName{\etocdivisionnameatlevel{\etoclocaltop+1}}*{\locallistfigurename}% + \ifnum\etoclocaltop>\tw@\mbox{}\par\fi + \etociflocalloftotoc + {\etocifisstarred + {}% star variant, do not add to toc + {\etoclocalheadtotoc + {\etocdivisionnameatlevel{\etoclocaltop+1}}% + {\locallistfigurename}% + }% + }% + {}% +}% +\def\etocetoclistoftablesmaketitle{% + \UseName{\etocdivisionnameatlevel{\etoclocaltop+1}}*{\locallisttablename}% + \ifnum\etoclocaltop>\tw@\mbox{}\par\fi + \etociflocallottotoc + {\etocifisstarred + {}% star variant, do not add to toc + {\etoclocalheadtotoc + {\etocdivisionnameatlevel{\etoclocaltop+1}}% + {\locallisttablename}% + }% + }% + {}% +}% +\let\Etoc@listofreset\@empty +\def\locallistoffigures{% + \ifEtoc@lof + \def\Etoc@listofreset{% + \let\Etoc@currext\Etoc@tocext + \let\Etoc@@startlocaltoc\Etoc@@startlocaltoc@toc + \let\Etoc@@startlocaltochook\@empty + \let\Etoc@listofreset\@empty + \let\Etoc@listofhook\@empty + }% + \let\Etoc@currext\Etoc@lofext + \def\Etoc@@startlocaltoc{\Etoc@@startlocallistof{figure}}% + \def\Etoc@@startlocaltochook{\Etoc@@startlocallistof@setlevels{figure}}% + \def\Etoc@listofhook{% + \def\Etoc@do####1{% + \expandafter\let\csname Etoc@@####1@@\endcsname\Etoc@@six@@ + }% + \Etoc@dolevels + }% + \expandafter\localtableofcontents + \else + \PackageError{etoc}{% + \string\locallistoffigures \on@line\space but\MessageBreak + package was loaded without `lof' option}% + {Try again with \string\usepackage[lof]{etoc}}% + \fi +} +\def\locallistoftables{% + \ifEtoc@lot + \def\Etoc@listofreset{% + \let\Etoc@currext\Etoc@tocext + \let\Etoc@@startlocaltoc\Etoc@@startlocaltoc@toc + \let\Etoc@@startlocaltochook\@empty + \let\Etoc@listofreset\@empty + \let\Etoc@listofhook\@empty + }% + \let\Etoc@currext\Etoc@lotext + \def\Etoc@@startlocaltoc{\Etoc@@startlocallistof{table}}% + \def\Etoc@@startlocaltochook{\Etoc@@startlocallistof@setlevels{table}}% + \def\Etoc@listofhook{% + \def\Etoc@do####1{% + \expandafter\let\csname Etoc@@####1@@\endcsname\Etoc@@six@@ + }% + \Etoc@dolevels + }% + \expandafter\localtableofcontents + \else + \PackageError{etoc}{% + \string\locallistoftable \on@line\space but\MessageBreak + package was loaded without `lot' option}% + {Try again with \string\usepackage[lot]{etoc}}% + \fi +} +\def\Etoc@checkifempty {% + \global\Etoc@isemptytoctrue \global\Etoc@stoptocfalse \global\let\Etoc@level\Etoc@minf + \global\let\Etoc@virtualtop\Etoc@minf + \gdef\Etoc@stackofends{{-3}{}}% \begingroup \ifEtoc@localtoc \def\etoc@startlocaltoc##1{% \ifnum##1=\Etoc@tocid\relax - \global\let\etoclocaltop\Etoc@level + \global\let\etoclocaltop\Etoc@virtualtop + \Etoc@@startlocaltochook \global\Etoc@notactivefalse - \fi }% + \fi + }% \let\contentsline\Etoc@testingcontentslinelocal \else \let\contentsline\Etoc@testingcontentsline \fi \Etoc@storetocdepth - \let\Etoc@setlocaltop@doends@dobegins\@empty + \let\Etoc@setlocaltop@doendsandbegin\@empty \the\Etoc@toctoks \Etoc@restoretocdepth \endgroup } \DeclareRobustCommand*\etocifwasempty - {\ifEtoc@emptytoc\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi } -\expandafter -\let\expandafter\etocxifwasempty\csname etocifwasempty \endcsname + {\ifEtoc@isemptytoc\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 + \if @\@car#1\@nil\else\global\let\Etoc@virtualtop\Etoc@level\fi \ifEtoc@notactive \else \ifnum\Etoc@level>\etoclocaltop - \unless\ifnum\Etoc@level>\Etoc@localtocdepth - \global\Etoc@emptytocfalse + \unless\ifnum\Etoc@level>\c@tocdepth + \global\Etoc@isemptytocfalse \global\Etoc@stoptoctrue \fi \else @@ -578,7 +689,7 @@ \fi \fi \fi - \@gobblefour\relax + \@gobblethree } \def\Etoc@testingcontentsline #1{% \ifEtoc@stoptoc @@ -586,17 +697,17 @@ \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@ \else \unless\ifnum\csname Etoc@#1@@\endcsname>\c@tocdepth - \global\Etoc@emptytocfalse + \global\Etoc@isemptytocfalse \global\Etoc@stoptoctrue \fi \fi \fi - \@gobblefour\relax + \@gobblethree } \def\Etoc@localtableofcontents#1{% \gdef\etoclocaltop{-\@m}% \Etoc@localtoctrue - \global\Etoc@emptytocfalse + \global\Etoc@isemptytocfalse \edef\Etoc@tocid{#1}% \ifnum\Etoc@tocid<\@ne \setbox0\hbox{\ref{Unknown toc ref \@secondoftwo#1. \space Rerun LaTeX}}% @@ -607,12 +718,12 @@ \fi \global\Etoc@notactivetrue \ifEtoc@checksemptiness - \Etoc@setemptytocbool + \Etoc@checkifempty \fi - \ifEtoc@emptytoc + \ifEtoc@isemptytoc \ifEtoc@notactive \setbox0\hbox{\ref{Unknown toc ID \number\Etoc@tocid. \space Rerun LaTeX}}% - \global\Etoc@emptytocfalse + \global\Etoc@isemptytocfalse \global\Etoc@stoptoctrue \gdef\etoclocaltop{-\thr@@}% \Etoc@tableofcontents @@ -622,18 +733,24 @@ \global\Etoc@stoptocfalse \global\Etoc@notactivetrue \edef\etoc@startlocaltoc##1% - {\noexpand\etoc@@startlocaltoc{##1}{\Etoc@tocid}}% + {\noexpand\Etoc@@startlocaltoc{##1}{\Etoc@tocid}}% \Etoc@tableofcontents \fi \@gobble\etoc@ \endgroup\ifEtoc@mustclosegroup\endgroup\fi \Etoc@tocdepthreset + \Etoc@listofreset \etocaftertochook - \let\Etoc@localtocdepth\c@tocdepth }% \Etoc@localtableofcontents -\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@getref #1{% + \@ifundefined{r@#1} + {0} + {\expandafter\Etoc@getref@i\romannumeral-`0% + \expandafter\expandafter\expandafter + \@car\csname r@#1\endcsname0\@nil\@etoc + }% +} +\def\Etoc@getref@i#1#2\@etoc{\ifnum9<1\string#1 #1#2\else 0\fi} \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} @@ -644,29 +761,32 @@ \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 + \global\Etoc@isemptytocfalse + \ifEtoc@checksemptiness\Etoc@checkifempty\fi + \ifEtoc@isemptytoc \ifEtoc@notocifnotoc \expandafter\expandafter\expandafter\@gobble \fi \fi \Etoc@tableofcontents - \endgroup\ifEtoc@mustclosegroup\endgroup\fi + \endgroup + \ifEtoc@mustclosegroup\endgroup\fi \Etoc@tocdepthreset + \Etoc@listofreset \etocaftertochook \@gobble\etoc@ }% \Etoc@t@bleofcontents \def\Etoc@table@fcontents{% \refstepcounter{etoc@tocid}% \Etoc@tocwithidfalse - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} + \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 + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents +} \def\etoctableofcontents{% \Etoc@openouttoc \Etoc@tocdepthset @@ -675,59 +795,98 @@ {\let\Etoc@aftertitlehook\@empty\Etoc@table@fcontents} {\def\Etoc@aftertitlehook{\etocaftertitlehook}\Etoc@table@fcontents}% }% \etoctableofcontents +\def\etocifisstarred{\ifx\Etoc@aftertitlehook\@empty + \expandafter\@firstoftwo\else + \expandafter\@secondoftwo + \fi} \let\etocoriginaltableofcontents\tableofcontents \let\tableofcontents\etoctableofcontents +\let\Etoc@listofhook\@empty \newcommand*\localtableofcontents{% \Etoc@openouttoc \Etoc@tocdepthset \begingroup + \Etoc@listofhook \@ifstar {\let\Etoc@aftertitlehook\@empty\Etoc@localtable@fcontents} {\def\Etoc@aftertitlehook{\etocaftertitlehook}\Etoc@localtable@fcontents}% }% \localtableofcontents \newcommand*\localtableofcontentswithrelativedepth[1]{% - \edef\Etoc@localtocdepth - {\numexpr\noexpand\etoclocaltop+\the\numexpr#1\relax\relax}% + \def\Etoc@@startlocaltochook{% + \global\c@tocdepth\numexpr\etoclocaltop+#1\relax + }% + \def\Etoc@listofreset{\let\Etoc@@startlocaltochook\@empty + \let\Etoc@listofreset\@empty}% \localtableofcontents }% \localtableofcontentswithrelativedepth -\let\Etoc@localtocdepth\c@tocdepth \newcommand\etocsettocstyle[2]{% -\def\Etoc@tableofcontents -{% + \Etoc@etocstylefalse + \Etoc@classstylefalse + \def\Etoc@tableofcontents@user@before{#1}% + \def\Etoc@tableofcontents@user@after {#2}% +}% +\def\etocstoretocstyleinto#1{% +%% \@ifdefinable#1{% + \edef#1{\noexpand\Etoc@etocstylefalse\noexpand\Etoc@classstylefalse + \def\noexpand\Etoc@tableofcontents@user@before{% + \unexpanded\expandafter{\Etoc@tableofcontents@user@before}% + }% + \def\noexpand\Etoc@tableofcontents@user@after{% + \unexpanded\expandafter{\Etoc@tableofcontents@user@after}% + }% + }% +%% }% +}% +\def\Etoc@tableofcontents {% + \Etoc@tableofcontents@etoc@before + \ifEtoc@localtoc\ifEtoc@etocstyle\expandafter\expandafter\expandafter\@gobble\fi\fi + \Etoc@tableofcontents@user@before + \Etoc@tableofcontents@contents + \ifEtoc@localtoc\ifEtoc@etocstyle\expandafter\expandafter\expandafter\@gobble\fi\fi + \Etoc@tableofcontents@user@after + \Etoc@tableofcontents@etoc@after + \@gobble\etoc@ +} +\def\Etoc@tableofcontents@etoc@before{% \ifnum\c@tocdepth>\Etoc@minf \else \expandafter\Etoc@gobtoetoc@ \fi \Etoc@par + \Etoc@beforetitlehook \etocbeforetitlehook \Etoc@storetocdepth \let\Etoc@savedcontentsline\contentsline \let\contentsline\Etoc@etoccontentsline - \ifEtoc@standard + \ifEtoc@standardlines \else - \def\Etoc@levellist@elt####1{% - \expandafter\def\csname etocsaved####1tocline\endcsname - {\PackageWarning{etoc}{% - \expandafter\string\csname etocsaved####1tocline\endcsname\space - has been deprecated at 1.1a.\MessageBreak - It will be removed from `etoc' in near feature. \space Use\MessageBreak - \expandafter\string\csname l@####1\endcsname\space directly. \space - Reported}% - \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname - \csname l@####1\endcsname - \csname l@####1\endcsname - }% + \def\Etoc@do##1{% + \expandafter\def\csname etocsaved##1tocline\endcsname + {\PackageError{etoc}{% + \expandafter\string\csname etocsaved##1tocline\endcsname\space + has been deprecated\MessageBreak + at 1.1a and is removed at 1.2.\MessageBreak + Use \expandafter\string\csname l@##1\endcsname\space directly.\MessageBreak + Reported \on@line}% + {I will use \expandafter\string + \csname l@##1\endcsname\space myself for this time.% + }% + \csname l@##1\endcsname + }% }% - \Etoc@levellist + \Etoc@dolevels \fi - #1% +}% +\def\Etoc@tableofcontents@contents{% \Etoc@tocdepthset \ifEtoc@parskip\parskip\z@skip\fi \Etoc@aftertitlehook \gdef\etoclocaltop{-\thr@@}% \Etoc@toctoc \etocaftercontentshook - #2\@nobreakfalse +}% +\def\Etoc@tableofcontents@etoc@after{% + \@nobreakfalse \Etoc@restoretocdepth \ifx\Etoc@global\global \@ifundefined{tof@finish} @@ -738,21 +897,60 @@ \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\etocsetstyle#1{\ifcsname Etoc@#1@@\endcsname + \expandafter\Etoc@setstyle@a + \else + \expandafter\Etoc@setstyle@error + \fi {#1}% +} +\def\Etoc@setstyle@error #1{% + \PackageWarning{etoc}{`#1' is unknown to etoc. \space Did you\MessageBreak + forget some \string\etocsetlevel{#1}{<level>}?\MessageBreak + Reported}% + \@gobblefour +} +\def\Etoc@setstyle@a #1{% + \edef\Etoc@tmp{\the\numexpr\csname Etoc@#1@@\endcsname}% + \if1\unless\ifnum\Etoc@tmp<\Etoc@@six@@ 0\fi\unless\ifnum\Etoc@tmp>\Etoc@minf 0\fi1% + \Etoc@standardlinesfalse + \expandafter\Etoc@setstyle@b\expandafter\Etoc@tmp + \else + \PackageWarning{etoc}{Sorry, but you can not set the style of `#1',\MessageBreak + as its level \Etoc@tmp\space is either \number\Etoc@minf\space + or 6.\MessageBreak + Consider using \string\etocsetlevel\space first, but note + that `all',\MessageBreak + `none', `figure' and `table' are forbidden there. \space + Check\MessageBreak + the documentation about how to proceed for customizing\MessageBreak + figure and table entries in \string\listoffigures/tables.\MessageBreak + Reported}% + \expandafter\@gobblefour + \fi +} +\long\def\Etoc@setstyle@b#1#2#3#4#5{% + \expandafter\def\csname Etoc@begin@#1\endcsname {#2}% + \expandafter\def\csname Etoc@prefix@#1\endcsname {#3}% + \expandafter\def\csname Etoc@contents@#1\endcsname {#4}% + \expandafter\def\csname Etoc@end@#1\endcsname {#5}% +} +\def\Etoc@storelines@a#1{% + \noexpand\Etoc@setstyle@b{#1}% + {\expandafter\Etoc@expandonce\csname Etoc@begin@#1\endcsname}% + {\expandafter\Etoc@expandonce\csname Etoc@prefix@#1\endcsname}% + {\expandafter\Etoc@expandonce\csname Etoc@contents@#1\endcsname}% + {\expandafter\Etoc@expandonce\csname Etoc@end@#1\endcsname}% +} +\def\Etoc@expandonce#1{\unexpanded\expandafter{#1}} +\def\etocstorelinestylesinto#1{% + \edef#1{\Etoc@storelines@a{-2}\Etoc@storelines@a{-1}\Etoc@storelines@a{0}% + \Etoc@storelines@a {1}\Etoc@storelines@a {2}\Etoc@storelines@a{3}% + \Etoc@storelines@a {4}\Etoc@storelines@a {5}}% +} +\def\etocstorethislinestyleinto#1#2{% + \edef#2{\expandafter\Etoc@storelines@a\expandafter{\number\etoclevel{#1}}}% +}% \def\etocfontminustwo {\normalfont \LARGE \bfseries} \def\etocfontminusone {\normalfont \large \bfseries} \def\etocfontzero {\normalfont \large \bfseries} @@ -780,9 +978,10 @@ \def\etocabbrevpagename {p.~} \def\etocpartname {Part} \def\etocbookname {Book} -\def\etocdefaultlines{\Etoc@standardfalse +\def\etocdefaultlines{\Etoc@standardlinesfalse %% `book': -\etoc@setstyle{@minustwo} +\Etoc@setstyle@b + {-2}% {\addpenalty\@M\etocskipfirstprefix} {\addpenalty\@secpenalty} {\begingroup @@ -800,7 +999,8 @@ \endgroup} {}% %% `part': -\etoc@setstyle{@minusone} +\Etoc@setstyle@b + {-1}% {\addpenalty\@M\etocskipfirstprefix} {\addpenalty\@secpenalty} {\begingroup @@ -818,7 +1018,8 @@ \endgroup} {}% %% `chapter': -\etoc@setstyle{@zero} +\Etoc@setstyle@b + {0}% {\addpenalty\@M\etocskipfirstprefix} {\addpenalty\@itempenalty} {\begingroup @@ -831,7 +1032,8 @@ \endgroup} {\addpenalty{-\@highpenalty}\addvspace{\etocsepminusone}}% %% `section': -\etoc@setstyle{@one} +\Etoc@setstyle@b + {1}% {\addpenalty\@M\etocskipfirstprefix} {\addpenalty\@itempenalty} {\begingroup @@ -864,7 +1066,8 @@ \endgroup} {\addpenalty\@secpenalty\addvspace{\etocsepzero}}% %% `subsection': -\etoc@setstyle{@two} +\Etoc@setstyle@b + {2}% {\addpenalty\@medpenalty\etocskipfirstprefix} {\addpenalty\@itempenalty} {\begingroup @@ -896,7 +1099,8 @@ \endgroup} {\addpenalty\@secpenalty\addvspace{\etocsepone}}% %% `subsubsection': -\etoc@setstyle{@three} +\Etoc@setstyle@b + {3}% {\addpenalty\@M \etocfontthree \vspace{\etocsepthree}% @@ -910,9 +1114,9 @@ \par \endgroup \addpenalty{-\@highpenalty}}% -\etoc@setstyle{@four}{}{}{}{}% -\etoc@setstyle{@five}{}{}{}{}% -} +\Etoc@setstyle@b{4}{}{}{}{}% +\Etoc@setstyle@b{5}{}{}{}{}% +}% end of \etocdefaultlines definition \def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} \def\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} \def\etoccolumnsep{2em} @@ -1139,33 +1343,106 @@ \@ifstar {\etoc@local@framedtoci} {\etoc@local@framedtoc}} +\def\etocmemoirtoctotocfmt #1#2{% + \PackageWarning{etoc} + {\string\etocmemoirtoctotocfmt\space is deprecated.\MessageBreak + Use in its place \string\etocsettoclineforclasstoc,\MessageBreak + and \string\etocsettoclineforclasslistof{toc} (or {lof}, {lot}). + I will do this now.\MessageBreak + Reported}% + \etocsettoclineforclasstoc{#1}{#2}% + \etocsettoclineforclasslistof{toc}{#1}{#2}% +} +\def\etocsettoclineforclasstoc #1#2{% + \def\etocclassmaintocaddtotoc{\etocglobalheadtotoc{#1}{#2}}% +} +\def\etocsettoclineforclasslistof #1#2#3{% + \@namedef{etocclasslocal#1addtotoc}{\etoclocalheadtotoc{#2}{#3}}% +} +\let\etocclasslocaltocaddtotoc\@empty +\let\etocclasslocallofaddtotoc\@empty +\let\etocclasslocallotaddtotoc\@empty +\ifdefined\c@chapter + \def\etocclasslocaltocmaketitle{\section*{\localcontentsname}} + \def\etocclasslocallofmaketitle{\section*{\locallistfigurename}} + \def\etocclasslocallotmaketitle{\section*{\locallisttablename}} + \etocsettoclineforclasstoc {chapter}{\contentsname} + \etocsettoclineforclasslistof{toc}{section}{\localcontentsname} + \etocsettoclineforclasslistof{lof}{section}{\locallistfigurename} + \etocsettoclineforclasslistof{lot}{section}{\locallisttablename} +\else + \def\etocclasslocaltocmaketitle{\subsection*{\localcontentsname}}% + \def\etocclasslocallofmaketitle{\subsection*{\locallistfigurename}}% + \def\etocclasslocallotmaketitle{\subsection*{\locallisttablename}}% + \etocsettoclineforclasstoc {section}{\contentsname} + \etocsettoclineforclasslistof{toc}{subsection}{\localcontentsname} + \etocsettoclineforclasslistof{lof}{subsection}{\locallistfigurename} + \etocsettoclineforclasslistof{lot}{subsection}{\locallisttablename} +\fi +\def\etocclasslocalperhapsaddtotoc #1{% + \etocifisstarred + {} + {\csname ifEtoc@local#1totoc\endcsname + \csname etocclasslocal#1addtotoc\endcsname + \fi + }% +} \def\etocarticlestyle{% \etocsettocstyle - {\section *{\contentsname - \@mkboth {\MakeUppercase \contentsname} - {\MakeUppercase \contentsname}}} - {}} + {\ifEtoc@localtoc + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \section *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}% + \etocifisstarred{}{\etocifmaintoctotoc{\etocclassmaintocaddtotoc}{}}% + \fi + } + {}% +} \def\etocarticlestylenomarks{% \etocsettocstyle - {\section *{\contentsname}} - {}} + {\ifEtoc@localtoc + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \section *{\contentsname}% + \etocifisstarred{}{\etocifmaintoctotoc{\etocclassmaintocaddtotoc}{}}% + \fi + } + {}% +} \def\etocbookstyle{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi - \chapter *{\contentsname - \@mkboth {\MakeUppercase \contentsname} - {\MakeUppercase \contentsname}}} - {\if@restonecol \twocolumn \fi}} + \ifEtoc@localtoc + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \chapter *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}% + \etocifisstarred{}{\etocifmaintoctotoc{\etocclassmaintocaddtotoc}{}}% + \fi + }% + {\if@restonecol \twocolumn \fi}% +} \def\etocbookstylenomarks{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi - \chapter *{\contentsname}} - {\if@restonecol \twocolumn \fi}} + \ifEtoc@localtoc + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \chapter *{\contentsname}% + \etocifisstarred{}{\etocifmaintoctotoc{\etocclassmaintocaddtotoc}{}}% + \fi + }% + {\if@restonecol \twocolumn \fi}% +} \let\etocreportstyle\etocbookstyle \let\etocreportstylenomarks\etocbookstylenomarks -\def\etocmemoirtoctotocfmt #1#2{% - \def\Etoc@addsuitablecontentsline{\addcontentsline {toc}{#1}{#2}}% -} \def\etocmemoirstyle{% \etocsettocstyle {\ensureonecol \par \begingroup \phantomsection @@ -1173,16 +1450,59 @@ \else \ifmem@em@starred@listof \else - \Etoc@addsuitablecontentsline + \ifEtoc@localtoc + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \ifEtoc@maintoctotoc + \etocclassmaintocaddtotoc + \fi + \fi \fi \fi - \@nameuse {@tocmaketitle} %<< space token here from memoir code + \ifEtoc@localtoc + % trying to mimick a section title but there is no \sectionheadstart + % there is no \printsectiontitle etc... Oh well I will be more + % radical then + \@namedef{@\Etoc@currext maketitle}{% + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + }% + \fi + \@nameuse {@\Etoc@currext maketitle} %<< space token here from memoir code \ifx\Etoc@aftertitlehook\@empty \else \Etoc@aftertitlehook \let \Etoc@aftertitlehook \relax \fi - \parskip \cftparskip \@nameuse {cfttocbeforelisthook}} - {\@nameuse {cfttocafterlisthook}\endgroup\restorefromonecol}} + \parskip \cftparskip \@nameuse {cft\Etoc@currext beforelisthook}% + }% + {\@nameuse {cft\Etoc@currext afterlisthook}% + \endgroup\restorefromonecol + }% +} +\let\Etoc@beforetitlehook\@empty +\if1\@ifclassloaded{scrartcl}0{\@ifclassloaded{scrbook}0{\@ifclassloaded{scrreprt}01}}% +\expandafter\@gobble +\else + \ifdefined\setuptoc + \def\Etoc@beforetitlehook{% + \ifEtoc@localtoc + \etocclasslocalperhapsaddtotoc\Etoc@currext + \setuptoc{\Etoc@currext}{leveldown}% + \else + \etocifisstarred{}{\etocifmaintoctotoc{\setuptoc{toc}{totoc}}}% + \fi + }% + \fi +\expandafter\@firstofone +\fi +{\def\etocclasslocalperhapsaddtotoc #1{% + \etocifisstarred + {}% + {\csname ifEtoc@local#1totoc\endcsname + \setuptoc{\Etoc@currext}{totoc}% + \fi + }% + }% +} \ifdefined\Iftocfeature \def\etoc@Iftocfeature{\Iftocfeature}% \else @@ -1190,44 +1510,55 @@ \fi \def\etocscrartclstyle{% \etocsettocstyle - {\let\if@dynlist\if@tocleft - \def\@currext{toc}% - \@ifundefined{listoftocname}% - {\def\list@fname{\listofname~toc}}% - {\expandafter\let\expandafter\list@fname\csname listoftocname\endcsname}% - \etoc@Iftocfeature {toc}{onecolumn} - {\etoc@Iftocfeature {toc}{leveldown} + {\ifx\Etoc@currext\Etoc@tocext + \expandafter\@firstofone + \else + \expandafter\@gobble + \fi + {\let\if@dynlist\if@tocleft}% + \edef\@currext{\Etoc@currext}% + \@ifundefined{listof\@currext name}% + {\def\list@fname{\listofname~\@currext}}% + {\expandafter\let\expandafter\list@fname + \csname listof\@currext name\endcsname}% + \etoc@Iftocfeature {\@currext}{onecolumn} + {\etoc@Iftocfeature {\@currext}{leveldown} {} {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }} {}% - \etoc@Iftocfeature {toc}{numberline}{\def \nonumberline {\numberline {}}}{}% + \etoc@Iftocfeature {\@currext}{numberline}% + {\def \nonumberline {\numberline {}}}{}% \expandafter\tocbasic@listhead\expandafter {\list@fname}% \begingroup \expandafter \expandafter \expandafter \endgroup \expandafter \ifx \csname microtypesetup\endcsname \relax \else - \etoc@Iftocfeature {toc}{noprotrusion}{} + \etoc@Iftocfeature {\@currext}{noprotrusion}{} {\microtypesetup {protrusion=false}% \PackageInfo {tocbasic}% - {character protrusion at toc deactivated}}% + {character protrusion at \@currext\space deactivated}}% \fi - \etoc@Iftocfeature{toc}{noparskipfake}{}{% + \etoc@Iftocfeature{\@currext}{noparskipfake}{}{% \ifvmode \@tempskipa\lastskip \vskip-\lastskip \addtolength{\@tempskipa}{\parskip}\vskip\@tempskipa\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@\@currext @before@hook\endcsname + }% end of before_toc + {% start of after_toc \providecommand\tocbasic@end@toc@file{}\tocbasic@end@toc@file - \csname tb@toc@after@hook\endcsname - \csname tocbasic@@after@hook\endcsname}} + \edef\@currext{\Etoc@currext}% + \csname tb@\@currext @after@hook\endcsname + \csname tocbasic@@after@hook\endcsname + }% end of after_toc +} \let\etocscrbookstyle\etocscrartclstyle \let\etocscrreprtstyle\etocscrartclstyle -\def\etocstandarddisplaystyle{\etocarticlestyle} +\def\etocclasstocstyle{\etocarticlestyle} \newcommand*\etocmarkboth[1]{% \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} \newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} @@ -1237,51 +1568,110 @@ {\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}}}} +\def\Etoc@redefetocstylesforchapters{% + \renewcommand\etoctocstylewithmarks[4][chapter]{% + \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3\etocmarkboth{##4}}}% + } + \renewcommand\etoctocstylewithmarksnouc[4][chapter]{% + \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3\etocmarkbothnouc{##4}}}% + } + \renewcommand\etoctocstyle[3][chapter]{% + \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}} + } +} \@ifclassloaded{scrartcl} - {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{} + {\renewcommand*\etocclasstocstyle{\etocscrartclstyle}}{} \@ifclassloaded{book} {\renewcommand*\etocfontone{\normalfont\normalsize} - \renewcommand*\etocstandarddisplaystyle{\etocbookstyle} - \Etoc@redefetocstyle{chapter}}{} + \renewcommand*\etocclasstocstyle{\etocbookstyle} + \Etoc@redefetocstylesforchapters}{} \@ifclassloaded{report} {\renewcommand*\etocfontone{\normalfont\normalsize} - \renewcommand*\etocstandarddisplaystyle{\etocreportstyle} - \Etoc@redefetocstyle{chapter}}{} + \renewcommand*\etocclasstocstyle{\etocreportstyle} + \Etoc@redefetocstylesforchapters}{} \@ifclassloaded{scrbook} {\renewcommand*\etocfontone{\normalfont\normalsize} - \renewcommand*\etocstandarddisplaystyle{\etocscrbookstyle} - \Etoc@redefetocstyle{chapter}}{} + \renewcommand*\etocclasstocstyle{\etocscrbookstyle} + \Etoc@redefetocstylesforchapters}{} \@ifclassloaded{scrreprt} {\renewcommand*\etocfontone{\normalfont\normalsize} - \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle} - \Etoc@redefetocstyle{chapter}}{} + \renewcommand*\etocclasstocstyle{\etocscrreprtstyle} + \Etoc@redefetocstylesforchapters}{} \@ifclassloaded{memoir} - {\etocsetlevel{appendix}{0}% - \renewcommand*\etocfontone{\normalfont\normalsize} - \etocmemoirtoctotocfmt{chapter}{\contentsname}% - \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle} - \Etoc@redefetocstyle{chapter}}{} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocclasstocstyle{\etocmemoirstyle} + \Etoc@redefetocstylesforchapters}{} \def\etoctocloftstyle {% - \etocsettocstyle - {\@cfttocstart\par\begingroup - \parindent\z@ \parskip\cftparskip \@cftmaketoctitle - \if@cfttocbibind\@cftdobibtoc\fi }% - {\endgroup\@cfttocfinish }% + \etocsettocstyle{% + \@cfttocstart + \par + \begingroup + \parindent\z@ \parskip\cftparskip + \@nameuse{@cftmake\Etoc@currext title}% + \ifEtoc@localtoc + \etoctocloftlocalperhapsaddtotoc\Etoc@currext + \else + \etocifisstarred {}{\ifEtoc@maintoctotoc\@cftdobibtoc\fi}% + \fi + }% + {% + \endgroup + \@cfttocfinish + }% +} +\def\etoctocloftlocalperhapsaddtotoc#1{% + \etocifisstarred + {}% + {\csname ifEtoc@local#1totoc\endcsname + \ifdefined\c@chapter\def\@tocextra{@section}\else\def\@tocextra{@subsection}\fi + \csname @cftdobib#1\endcsname + \fi + }% +} +\def\etoctocbibindstyle {% + \etocsettocstyle {% + \toc@start + \ifEtoc@localtoc + \@nameuse{etocclasslocal\Etoc@currext maketitle}% + \etocclasslocalperhapsaddtotoc\Etoc@currext + \else + \etoc@tocbibind@dotoctitle + \fi + }% + {\toc@finish}% } -\@ifclassloaded{memoir}{} -{\@ifpackageloaded{tocloft} +\def\etoc@tocbibind@dotoctitle {% + \if@bibchapter + \etocifisstarred + {\chapter*{\contentsname}\prw@mkboth{\contentsname} % id. + }% + {\ifEtoc@maintoctotoc + \toc@chapter{\contentsname} %<-space from original + \else + \chapter*{\contentsname}\prw@mkboth{\contentsname} % id. + \fi + }% + \else + \etocifisstarred + {\@nameuse{\@tocextra}*{\contentsname\prw@mkboth{\contentsname}} %<-space + } + {\ifEtoc@maintoctotoc + \toc@section{\@tocextra}{\contentsname} %<-space from original + \else + \@nameuse{\@tocextra}*{\contentsname\prw@mkboth{\contentsname}} % id. + \fi + }% + \fi +}% +\@ifclassloaded{memoir} +{} +{% memoir not loaded + \@ifpackageloaded{tocloft} {\if@cftnctoc\else - \renewcommand*\etocstandarddisplaystyle{\etoctocloftstyle} - \AtBeginDocument{\let\tableofcontents\etoctableofcontents} + \ifEtoc@keeporiginaltoc + \else + \let\tableofcontents\etoctableofcontents + \fi \fi } {\AtBeginDocument {\@ifpackageloaded{tocloft} @@ -1290,7 +1680,10 @@ {Package `tocloft' was loaded after `etoc'.\MessageBreak To prevent it from overwriting \protect\tableofcontents, it will\MessageBreak be tricked into believing to have been loaded with its\MessageBreak - option `titles'. \space Please load `tocloft' before `etoc'}% + option `titles'. \space But this will cause the `tocloft'\MessageBreak + customization of the titles of the main list of figures\MessageBreak + and list of tables to not apply either.\MessageBreak + You should load `tocloft' before `etoc'.}% \AtEndDocument{\PackageWarning{etoc} {Please load `tocloft' before `etoc'!\@gobbletwo}}% \fi @@ -1299,19 +1692,93 @@ }% }% } -\def\Etoc@addtocontents #1#2% - {\ifEtoc@hyperref - \addtocontents {toc}{\protect\contentsline - {#1}{#2}% - {\thepage }{\@currentHref }% - \ifdefined\protected@file@percent\protected@file@percent\fi - }% +\@ifclassloaded{memoir} +{} +{% memoir not loaded + \AtBeginDocument{% + \@ifpackageloaded{tocloft} + {% + \def\etocclasstocstyle{% + \etoctocloftstyle + \Etoc@classstyletrue + }% + \ifEtoc@etocstyle + \ifEtoc@classstyle + \etocclasstocstyle + \Etoc@etocstyletrue + \fi \else - \addtocontents {toc}{\protect\contentsline - {#1}{#2}{\thepage }{}% - \ifdefined\protected@file@percent\protected@file@percent\fi - }% - \fi} + \ifEtoc@classstyle + \etocclasstocstyle + \fi + \fi + }% + {% no tocloft + \@ifpackageloaded {tocbibind} + {\if@dotoctoc + \def\etocclasstocstyle{% + \etoctocbibindstyle + \Etoc@classstyletrue + }% + \ifEtoc@etocstyle + \ifEtoc@classstyle + \etocclasstocstyle + \Etoc@etocstyletrue + \fi + \else + \ifEtoc@classstyle + \etocclasstocstyle + \fi + \fi + \ifEtoc@keeporiginaltoc + \else + \let\tableofcontents\etoctableofcontents + \fi + }% + {}% + }% + \@ifpackageloaded{tocbibind} + {% tocbibind, perhaps with tocloft + \if@dotoctoc + \ifEtoc@keeporiginaltoc + \else + \let\tableofcontents\etoctableofcontents + \fi + \etocsetup{maintoctotoc,localtoctotoc}% + \PackageInfo{etoc}{% + Setting (or re-setting) the options `maintoctotoc' and\MessageBreak + `localtoctotoc' to true as tocbibind was detected and\MessageBreak + found to be configured for `TOC to toc'.\MessageBreak + Reported at begin document}% + \fi + \if@dotoclof + \ifEtoc@lof + \etocsetup{localloftotoc}% + \PackageInfo{etoc}{% + Setting (or re-setting) `localloftotoc=true' as the\MessageBreak + package tocbibind was detected and is configured for\MessageBreak + `LOF to toc'. Reported at begin document}% + \fi + \fi + \if@dotoclot + \ifEtoc@lot + \etocsetup{locallottotoc}% + \PackageInfo{etoc}{% + Setting (or re-setting) `locallottotoc=true' as the\MessageBreak + package tocbibind was detected and is configured for\MessageBreak + `LOT to toc'. Reported at begin document}% + \fi + \fi + }% end of tocbibind branch + {}% + }% end of at begin document +}% end of not with memoir branch +\def\Etoc@addtocontents #1#2{% + \addtocontents {toc}{% + \protect\contentsline{#1}{#2}{\thepage}{\ifEtoc@hyperref\@currentHref\fi}% + \ifdefined\protected@file@percent\protected@file@percent\fi + }% +} \def\Etoc@addcontentsline@ #1#2#3{% \@namedef{toclevel@#1}{#3}\addcontentsline {toc}{#1}{#2}% } @@ -1333,12 +1800,12 @@ } \DeclareRobustCommand*{\etocimmediatetoccontentsline} {\@ifstar{\Etoc@addcontentsline@@immediately}{\Etoc@addtocontents@immediately}} -\def\Etoc@storetocdepth {\global\c@etoc@tocdepth\c@tocdepth } -\def\Etoc@restoretocdepth {\global\c@tocdepth\c@etoc@tocdepth } +\def\Etoc@storetocdepth {\xdef\Etoc@savedtocdepth{\number\c@tocdepth}} +\def\Etoc@restoretocdepth {\global\c@tocdepth\Etoc@savedtocdepth\relax} \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 } + {\afterassignment\Etoc@@nottoodeep \global\c@tocdepth}} +\def\Etoc@@nottoodeep {\ifnum\Etoc@savedtocdepth<\c@tocdepth + \global\c@tocdepth\Etoc@savedtocdepth\relax\fi } \def\etocignoretoctocdepth {\let\etoc@settocdepth\@gobble } \def\etocsettocdepth {\futurelet\Etoc@nexttoken\Etoc@set@tocdepth } \def\Etoc@set@tocdepth {\ifx\Etoc@nexttoken\bgroup @@ -1399,7 +1866,7 @@ {Use \protect\etocsettocdepth.toc as replacement}% }% \AtBeginDocument {% - \@ifclassloaded{memoir} + \@ifclassloaded{memoir} {\PackageInfo {etoc} {Regarding `memoir' class command \protect\settocdepth, consider\MessageBreak \protect\etocsettocdepth.toc as a drop-in replacement with more\MessageBreak @@ -1408,8 +1875,8 @@ and \protect\etocsetnexttocdepth\space should be used in place of\MessageBreak `memoir' command \protect\maxtocdepth\@gobble}% }% - {\@ifpackageloaded {tocvsec2} - {\def\maxtocdepth #1{\Etoc@tocvsec@err \maxtocdepth }% + {\@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 }% @@ -1422,9 +1889,10 @@ {Package `tocvsec2' detected and its modification of\MessageBreak \protect\tableofcontents\space reverted. \space Use \protect\etocsettocdepth.toc\MessageBreak as a replacement - for `tocvsec2' toc-related commands}}% tocvsec2 loaded - {}% not loaded - }% + for `tocvsec2' toc-related commands}% + }% tocvsec2 loaded + {}% tocvsec2 not loaded + }% }% \def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }% \def\invisiblelocaltableofcontents @@ -1471,16 +1939,17 @@ }% }% \def\etoc@setlocaltop #1{% - \global\let\Etoc@level #1% - \Etoc@skipthisonefalse - \ifnum\Etoc@level=\Etoc@@six@@ + \ifnum#1=\Etoc@@six@@ \Etoc@skipthisonetrue \else + \Etoc@skipthisonefalse + \global\let\Etoc@level #1% + \global\let\Etoc@virtualtop #1% \ifEtoc@localtoc - \ifEtoc@stoptoc\Etoc@skipthisonetrue + \ifEtoc@stoptoc + \Etoc@skipthisonetrue \else \ifEtoc@notactive - \Etoc@setflags \Etoc@skipthisonetrue \else \unless\ifnum\Etoc@level>\etoclocaltop @@ -1494,34 +1963,50 @@ \let\Etoc@next\@empty \ifEtoc@skipthisone \else - \ifnum\c@tocdepth<\Etoc@level + \ifnum\Etoc@level>\c@tocdepth \else - \ifEtoc@standard + \ifEtoc@standardlines \else - \let\Etoc@next\Etoc@setlocaltop@doends@dobegins + \let\Etoc@next\Etoc@setlocaltop@doendsandbegin \fi \fi \fi \Etoc@next }% -\def\Etoc@setlocaltop@doends@dobegins - {\Etoc@doends\Etoc@dobegins\global\Etoc@skipprefixfalse}% +\def\Etoc@setlocaltop@doendsandbegin{% + \Etoc@doendsandbegin + \global\Etoc@skipprefixfalse +} \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} +\def\etocstandardlines {\Etoc@standardlinestrue} +\def\etoctoclines {\Etoc@standardlinesfalse} \etocdefaultlines \etocstandardlines -\etocstandarddisplaystyle +\def\etocstandarddisplaystyle{% + \PackageWarningNoLine{etoc}{% + \string\etocstandarddisplaystyle \on@line\MessageBreak + is deprecated. \space Please use \string\etocclasstocstyle}% +} +\expandafter\def\expandafter\etocclasstocstyle\expandafter{% + \etocclasstocstyle + \Etoc@classstyletrue +} +\def\etocetoclocaltocstyle{\Etoc@etocstyletrue} +\def\etocusertocstyle{\Etoc@etocstylefalse} +\etocclasstocstyle +\etocetoclocaltocstyle \etocobeytoctocdepth \etocobeydepthtags -\let\etocaftertochook \@empty -\let\etocbeforetitlehook \@empty +\let\etocbeforetitlehook \@empty +\let\etocaftertitlehook \@empty +\let\etocaftercontentshook \@empty +\let\etocaftertochook \@empty \def\etockeeporiginaltableofcontents - {\let\tableofcontents\etocoriginaltableofcontents}% + {\Etoc@keeporiginaltoctrue\let\tableofcontents\etocoriginaltableofcontents}% \endinput %% %% End of file `etoc.sty'. |