diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoc/etoc.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/etoc/etoc.sty | 172 |
1 files changed, 116 insertions, 56 deletions
diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index be65156cf68..92f87fb28f4 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -23,10 +23,10 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{etoc} - [2015/04/09 v1.08d Completely customisable TOCs (jfB)] + [2015/04/17 v1.08e Completely customisable TOCs (jfB)] %% %% Package: etoc -%% Version: 1.08d (2015/04/09) +%% Version: 1.08e (2015/04/17) %% License: LPPL 1.3c or later (see etoc.dtx) %% Copyright (C) 2012-2015 Jean-Francois Burnol %% <jfbu at free dot fr> @@ -65,6 +65,11 @@ \newif\ifEtoc@stoptoc \newif\ifEtoc@notactive \newif\ifEtoc@mustclosegroup +\newif\ifEtoc@emptytoc % 1.08e +\newif\ifEtoc@checksemptiness % 1.08e. Default is 'no checks'. +\newcommand*\etocchecksemptiness {\Etoc@checksemptinesstrue } +\newif\ifEtoc@notocifnotoc % 1.08e +\newcommand*\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue } \def\etoc@{\etoc@} \newcounter{etoc@tocid} \newcounter{etoc@tocdepth}% 1.07g @@ -78,7 +83,7 @@ \chardef\Etoc@@four@@ 4 \chardef\Etoc@@five@@ 5 \chardef\Etoc@@six@@ 6 -\let\Etoc@localtop\Etoc@@minustwo@@ +%%\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} @@ -496,16 +501,15 @@ \fi} \def\etoc@@startlocaltoc#1#2{% \ifEtoc@localtoc - \ifEtoc@notactive \ifnum #1=#2\relax - \ifEtoc@jj \Etoc@global\let\Etoc@localtop\Etoc@@minusone@@ \fi - \ifEtoc@j \Etoc@global\let\Etoc@localtop\Etoc@@zero@@ \fi - \ifEtoc@ \Etoc@global\let\Etoc@localtop\Etoc@@one@@ \fi - \ifEtoc@i \Etoc@global\let\Etoc@localtop\Etoc@@two@@ \fi - \ifEtoc@ii \Etoc@global\let\Etoc@localtop\Etoc@@three@@ \fi - \ifEtoc@iii \Etoc@global\let\Etoc@localtop\Etoc@@four@@ \fi - \ifEtoc@iv \Etoc@global\let\Etoc@localtop\Etoc@@five@@ \fi - \ifEtoc@v \Etoc@global\let\Etoc@localtop\Etoc@@six@@ \fi + \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 @@ -516,28 +520,80 @@ \global\Etoc@jfalse \global\Etoc@jjfalse \fi - \fi \fi } \let\etoc@startlocaltoc\@gobble -\def\Etoc@localtableofcontents#1{% - \edef\Etoc@tmp{#1}% - \ifnum\Etoc@tmp<\@ne - \PackageWarning{etoc}% - {Unknown toc id: run LaTeX to get references right}% - \let\Etoc@next\@gobble +\def\Etoc@setemptytocbool {% + \global\Etoc@stoptocfalse + \global\Etoc@emptytoctrue + \global\let\Etoc@level\Etoc@minf + \begingroup + \def\etoc@startlocaltoc##1{% + \ifnum##1=\Etoc@tocid\relax + \global\let\Etoc@localtop\Etoc@level + \global\Etoc@notactivefalse + \fi }% + \let\contentsline\Etoc@testingcontentsline + \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@testingcontentsline #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 - \let\Etoc@next\@firstofone + \ifnum\Etoc@level>\c@tocdepth + \else + \global\Etoc@stoptoctrue + \ifnum\Etoc@level>\Etoc@localtop\global\Etoc@emptytocfalse\fi + \fi\fi + \fi\fi + \Etoc@gobblesixorfive\relax\relax\relax +} +\def\Etoc@localtableofcontents#1{% + \edef\Etoc@tocid{#1}% + \global\Etoc@emptytocfalse + \ifnum\Etoc@tocid<\@ne + \PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}% + % versions < 1.08e did not do any printing, 1.08e prints the toc heading. + \global\Etoc@notactivetrue + \global\Etoc@stoptoctrue % do only heading + \Etoc@localtoctrue % needed for stoptoc obedience + \Etoc@tableofcontents + \expandafter\Etoc@gobbletoetoc@ % skip all the rest \fi - \Etoc@next - {% 1.08b removes a space token from unprotected line ending - \edef\etoc@startlocaltoc##1{\noexpand\etoc@@startlocaltoc{##1}{#1}}% + \global\Etoc@notactivetrue + \ifEtoc@checksemptiness \Etoc@setemptytocbool \fi + \ifEtoc@emptytoc + \ifEtoc@notactive + \PackageWarning{etoc}{Unknown toc ID \number\Etoc@tocid. Run LaTeX again}% + % emptiness undecided. Declare it non empty. + \global\Etoc@emptytocfalse + \global\Etoc@stoptoctrue % do only heading + \Etoc@localtoctrue + \Etoc@tableofcontents + \expandafter\expandafter\expandafter\Etoc@gobbletoetoc@ + \else + %% \PackageWarning{etoc}{This toc is apparently empty}% + \fi + \else \Etoc@localtoctrue - \let\Etoc@localtop\Etoc@@minustwo@@ \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@aftertochook % 1.07h \etocaftertochook % 1.07g @@ -548,29 +604,43 @@ \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 - \def\Etoc@next{\expandafter\Etoc@label\@gobble}% - \else - \ifx\Etoc@nexttoken\@sptoken - \let\Etoc@next\Etoc@again - \else - \ifEtoc@tocwithid - \def\Etoc@next{\Etoc@localtableofcontents{\c@etoc@tocid}}% - \else + \ifx\Etoc@nexttoken\label + \Etoc@dothis{\expandafter\Etoc@label\@gobble}% + \fi + \ifx\Etoc@nexttoken\@sptoken + \Etoc@dothis{\Etoc@again}% + \fi \ifx\Etoc@nexttoken\ref - \def\Etoc@next{\expandafter\Etoc@ref\@gobble}% + \Etoc@dothis{\Etoc@tocwithidfalse\expandafter\Etoc@ref\@gobble}% + \fi + \ifEtoc@tocwithid + \Etoc@dothis{\Etoc@localtableofcontents{\c@etoc@tocid}}% + \fi + \global\Etoc@notactivefalse + \global\Etoc@emptytocfalse + \ifEtoc@checksemptiness + \let\Etoc@tocid\z@ + \global\let\Etoc@localtop\Etoc@minf + \Etoc@setemptytocbool + \fi + \ifEtoc@emptytoc + \ifEtoc@notocifnotoc\else + \Etoc@localtocfalse + \global\Etoc@stoptocfalse + \Etoc@tableofcontents + \fi \else - \def\Etoc@next{\Etoc@localtocfalse - \global\Etoc@notactivefalse - \Etoc@tableofcontents - \endgroup - \ifEtoc@mustclosegroup\endgroup\fi - \Etoc@aftertochook % 1.07h - \etocaftertochook % 1.07g - }% + \Etoc@localtocfalse + \global\Etoc@stoptocfalse + \Etoc@tableofcontents \fi - \fi\fi\fi\Etoc@next} + \endgroup\ifEtoc@mustclosegroup\endgroup\fi + \Etoc@aftertochook % 1.07h + \etocaftertochook % 1.07g + \@gobble\etoc@ + } \def\Etoc@table@fcontents{% \refstepcounter{etoc@tocid}% \Etoc@tocwithidfalse @@ -584,7 +654,6 @@ \let\etocaftercontentshook \@empty \def\etoctableofcontents{% \Etoc@openouttoc - \Etoc@par \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents \let\tof@begingroup\@empty \let\tof@endgroup \@empty @@ -595,7 +664,6 @@ \let\tableofcontents\etoctableofcontents \newcommand*\localtableofcontents{% \Etoc@openouttoc - \Etoc@par \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents \let\tof@begingroup\@empty \let\tof@endgroup \@empty @@ -610,6 +678,7 @@ \else\expandafter \Etoc@gobbletoetoc@ % skip all \fi + \Etoc@par % moved here 1.08e for matters of emptiness test \etocbeforetitlehook % 1.07m \Etoc@storetocdepth % 1.07g \let\Etoc@savedcontentsline\contentsline % moved up here 1.08 @@ -626,15 +695,6 @@ \ifEtoc@parskip\parskip\z@skip\fi %1.07d \Etoc@aftertitlehook \Etoc@toctoc - \ifEtoc@tocwithid\else - \ifEtoc@localtoc - \ifEtoc@notactive - \Etoc@localtocfalse - \global\Etoc@notactivefalse - \Etoc@toctoc - \fi - \fi - \fi \etocaftercontentshook #2\@nobreakfalse % 1.07d: \@nobreakfalse moved here \Etoc@resettocdepth % 1.07g. moved here from before #2 by 1.08 @@ -1265,7 +1325,7 @@ {Unknown sectioning unit #1, \protect\etocsetnextocdepth\space ignored}} {\edef\Etoc@aftertochook {\global\c@tocdepth\the\c@tocdepth\space \let\noexpand\Etoc@aftertochook\noexpand\@empty }% - \global\c@tocdepth\csname Etoc@#1@@\endcsname}% + \global\c@tocdepth\csname Etoc@#1@@\endcsname}% }% \addtocontents {toc}{\protect\@ifundefined{etoctocstyle}% {\let\protect\etoc@startlocaltoc\protect\@gobble |