texlive[45429] Master/texmf-dist: bxjscls (28sep17)

commits+karl at tug.org commits+karl at tug.org
Fri Sep 29 22:37:58 CEST 2017


Revision: 45429
          http://tug.org/svn/texlive?view=revision&revision=45429
Author:   karl
Date:     2017-09-29 22:37:58 +0200 (Fri, 29 Sep 2017)
Log Message:
-----------
bxjscls (28sep17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/etoc/README.md
    trunk/Master/texmf-dist/doc/latex/etoc/etoc-DE.pdf
    trunk/Master/texmf-dist/doc/latex/etoc/etoc.pdf
    trunk/Master/texmf-dist/source/latex/etoc/etoc.dtx
    trunk/Master/texmf-dist/source/latex/etoc/etoc.ins
    trunk/Master/texmf-dist/tex/latex/etoc/etoc.sty

Modified: trunk/Master/texmf-dist/doc/latex/etoc/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/etoc/README.md	2017-09-29 10:47:32 UTC (rev 45428)
+++ trunk/Master/texmf-dist/doc/latex/etoc/README.md	2017-09-29 20:37:58 UTC (rev 45429)
@@ -1,6 +1,6 @@
 <!-- -->
 
-    Source:  etoc.dtx (v1.08j-2017/09/21)
+    Source:  etoc.dtx (v1.08k-2017/09/28)
     Author:  Jean-Francois Burnol
     Author:  Christine Roemer et al. (German tranlation)
     Info:    Completely customisable TOCs
@@ -116,6 +116,25 @@
 RECENT CHANGES
 ==============
 
+v1.08k \[2017/09/28\]
+---------------------
+
+Adds `\etocsetlocaltop.toc`. See corresponding manual section for
+details.
+
+Adds `\etocsavedparttocline`, `\etocsavedchaptertocline`,
+`\etocsavedsectiontocline`, ... They can be used in the context of
+the technique explained in section "Another compatibility mode".
+
+Formerly, etoc redefined for the duration of the TOC the memoir
+macro `\chapternumberline` and its likes to have same meaning as
+`\numberline` (of course, not when executed in compatibility mode),
+for the sake of extraction of `\etocnumber`.
+
+New method detects presence of any `\<foo>numberline` macro without
+any change to originals; they can thus be used as is when applying
+the approach of "Another compatibility mode" section from manual.
+
 v1.08j \[2017/09/21\]
 ---------------------
 

Modified: trunk/Master/texmf-dist/doc/latex/etoc/etoc-DE.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/etoc/etoc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/etoc/etoc.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/etoc/etoc.dtx	2017-09-29 10:47:32 UTC (rev 45428)
+++ trunk/Master/texmf-dist/source/latex/etoc/etoc.dtx	2017-09-29 20:37:58 UTC (rev 45429)
@@ -2,12 +2,12 @@
 % N.B.: this dtx file is NOT for use with \DocInput. The latex source of the
 % user manual is not prefixed with percent signs.
 %<*none>
-\def\etocdtxtimestamp {Time-stamp: <21-09-2017 at 19:38:23 CEST>}%
+\def\etocdtxtimestamp {Time-stamp: <28-09-2017 at 16:19:24 CEST>}%
 %</none>
 %<*!readme>
 %%
 %% Package: etoc
-%% Version: 1.08j-2017/09/21
+%% Version: 1.08k-2017/09/28
 %% License: LPPL 1.3c
 %% Copyright (C) 2012-2017 Jean-Francois Burnol
 %%                         <jfbu at free dot fr>
@@ -17,14 +17,14 @@
 %%
 %</!readme>
 %<*insfile>
-\def\etocpkgdate        {2017/09/21}
-\def\etocdocdate        {2017/09/21}
-\def\etocpkgversion     {v1.08j}
+\def\etocpkgdate        {2017/09/28}
+\def\etocdocdate        {2017/09/28}
+\def\etocpkgversion     {v1.08k}
 \def\etocpkgdescription {Completely customisable TOCs (JFB)}
 %</insfile>
 %<*none>
-\def\etocDEpkgdate      {21.09.2017}
-\def\etocDEdocdate      {21.09.2017}
+\def\etocDEpkgdate      {28.09.2017}% METTRE À JOUR À CHAQUE BUMP!
+\def\etocDEdocdate      {28.09.2017}
 \def\etocDEDEdocdate    {09.04.2015}%
 \def\etocDEDEpkgversion {v1.08d}%
 % Definition of \etocLicense
@@ -35,7 +35,7 @@
     \catcode32=13\catcode`\\=12^^Brelax^^A
 ^^Bfirstofone{^^Bendgroup^^Bdef^^BetocLicense^^A
 {% Package: etoc
-% Version: 1.08j-2017/09/21
+% Version: 1.08k-2017/09/28
 % License: LPPL 1.3c
 % Copyright (C) 2012-2017 Jean-Francois Burnol <jfbu at free dot fr>
 % Copyright (C) 2014-2017 Christine Roemer <Christine_Roemer at t-online dot de>
@@ -64,12 +64,12 @@
 % etoc.ins, etoc.tex, etoc-DE.tex, and README.md. See README.md for
 % further instructions.
 }}%
-\iffalse
+\bgroup\catcode2 0 \catcode`\\ 12 ^^Biffalse
 %</none>
 %<*readme>
 <!-- -->
 
-    Source:  etoc.dtx (v1.08j-2017/09/21)
+    Source:  etoc.dtx (v1.08k-2017/09/28)
     Author:  Jean-Francois Burnol
     Author:  Christine Roemer et al. (German tranlation)
     Info:    Completely customisable TOCs
@@ -185,6 +185,26 @@
 RECENT CHANGES
 ==============
 
+v1.08k \[2017/09/28\]
+---------------------
+
+Adds `\etocsetlocaltop.toc`. See corresponding manual section for
+details.
+
+Adds `\etocsavedparttocline`, `\etocsavedchaptertocline`,
+`\etocsavedsectiontocline`, ... They can be used in the context of
+the technique explained in section "Another compatibility mode".
+
+Formerly, etoc redefined for the duration of the TOC the memoir
+macro `\chapternumberline` and its likes to have same meaning as
+`\numberline` (of course, not when executed in compatibility mode),
+for the sake of extraction of `\etocnumber`.
+
+New method detects presence of any `\<foo>numberline` macro without
+any change to originals; they can thus be used as is when applying
+the approach of "Another compatibility mode" section from manual.
+
+
 v1.08j \[2017/09/21\]
 ---------------------
 
@@ -358,7 +378,7 @@
 \endbatchfile
 %</insfile>---------------------------------------------------------------------
 %<*none>------------------------------------------------------------------------
-\fi
+^^Bfi^^Begroup
 %
 \chardef\noetex 0
 \ifx\numexpr\undefined\chardef\noetex 1 \fi
@@ -786,11 +806,10 @@
 % et maintenant =4 pour version de la doc du 28 avril 2014... faudra vraiment qu
 % je mette un mécanisme plus robuste pour cette TOC.
 % ATTENTION AUSSI AUX CODES VERBATIM
+% màj pour 1.08k: \etocsavedsectiontocline etc...
 \makeatletter
 \newcommand*{\MyQuasiStandardTOC}[1]{%
   \begingroup
-  \let\savedsectionline\l at section
-  \let\savedsubsectionline\l at subsection 
   \etocsetstyle{section}{}
     {\ifnum\etocthenumber=4 % <- check this if new sections added to user manual
       \etocsetstyle{subsection}
@@ -805,9 +824,9 @@
         {.\par\endgroup}%
      \else
         \etocsetstyle{subsection}{}{}
-        {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+        {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
      \fi} 
-    {\savedsectionline
+    {\etocsavedsectiontocline
       {\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
     {}%
   \etocstandarddisplaystyle
@@ -948,29 +967,8 @@
         \pgftransformxshift{\the\tikzleveldistance}%
     \fi
     \ifnum\tikztreelevel=2
-% modifications le Vendredi 09 septembre 2016 à 11:23:42
-        % \pgfmathsetmacro\tikzoffsetofcurrentchild{(\tikzsiblingdistance)*(\tikznumberofcurrentgrandchild)}%
-        % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelwidth pt
-        %     \pgftransformxshift{\tikzlevelwidth/2-\tikzoffsetofcurrentchild}
-        %     \pgftransformyshift{\tikzlevelheight/2}
-        % \else
-        % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelwidth}%
-        % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt
-        %     \pgftransformxshift{-\tikzlevelwidth/2}
-        %     \pgftransformyshift{\tikzlevelheight/2-\tikzoffsetofcurrentchild}
-        % \else
-        % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelheight}%
-        % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelwidth pt
-        %     \pgftransformxshift{-\tikzlevelwidth/2+\tikzoffsetofcurrentchild}
-        %     \pgftransformyshift{-\tikzlevelheight/2}
-        % \else
-        % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelwidth}%
-        % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt
-        %     \pgftransformxshift{\tikzlevelwidth/2}
-        %     \pgftransformyshift{-\tikzlevelheight/2+\tikzoffsetofcurrentchild}
-        % \fi\fi\fi\fi
-        % \global\advance\tikznumberofcurrentgrandchild by1
-        \pgfmathsetmacro\tikzoffsetofcurrentchild{(\tikzsiblingdistance)*(\tikznumberofcurrentgrandchild)}%
+% modif Mercredi 27 septembre 2017 à 17:16:44
+        \pgfmathsetmacro\tikzoffsetofcurrentchild{(\tikzsiblingdistance)*(6+\tikznumberofcurrentgrandchild)}%
         \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt
             \pgftransformxshift{\tikzlevelwidth/2}
             \pgftransformyshift{-\tikzlevelheight/2+\tikzoffsetofcurrentchild}
@@ -1227,8 +1225,10 @@
   {% define the section node
    \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                         \unexpanded\expandafter{\etocthelinkedname}}}}%
-   \ifnum\value{partco}<9 % pour 1.08h
-   \appendtotok\parttok\childnode \fi}
+   %\ifnum\value{partco}<9 % pour 1.08h
+   \appendtotok\parttok\childnode 
+   %\fi
+   }
   {}
 
 \etocsetnexttocdepth{section}
@@ -1241,6 +1241,18 @@
     version:\par \etocpkgversion{} (\etocpkgdate )\par}}}}
   {\global\appendtotok\treetok{ ;}}
 
+\etocsettagdepth {preamble}{part}
+\etocsettagdepth {overview}{part}
+\etocsettagdepth {arbitrarily}{all}
+\etocsettagdepth {examples}{all}
+\etocsettagdepth {surprising}{all}
+\etocsettagdepth {linestyles}{part}
+\etocsettagdepth {globalcmds}{part}
+\etocsettagdepth {custom}{part}
+\etocsettagdepth {tips}{all}
+\etocsettagdepth {etocandworld}{all}
+\etocsettagdepth {code}{all}
+
 \etocinline\tableofcontents\label{toc:mindmaptitlepage}
 
 % \immediate\openout\TOCasTree=\jobname.toctree
@@ -1278,7 +1290,7 @@
 % 39 hard coded mais je pourrais aussi le calculer
 % pour version rectangulaire, par tâtonnements:
         level 2/.append style={level width=21cm,level height=30cm, sibling
-          distance=2.31cm},% je passe à 2.29cm par tatons après ajout section 1.09j
+          distance=3cm},% modif Mercredi 27 septembre 2017 à 17:17:20
                    ]
 \the\treetok
 \end{tikzpicture}}\endgroup }
@@ -1410,6 +1422,8 @@
 % Starting with release |1.07k| it is possible to
 % use \etoc concurrently with  package |tocloft|.
 
+\clearpage
+
 \section{License}
 
 \begingroup\ttfamily\small\hyphenchar\font -1
@@ -1417,9 +1431,8 @@
            \obeyspaces\obeylines %
 \etocLicense\endgroup
 
+\clearpage
 
-% \clearpage
-
 \etocsettocdepth {subsection}
 
 \etocdepthtag.toc{overview}
@@ -1622,6 +1635,8 @@
 compatibility mode at the ``toc display style'' level. It will be
 re-activated if use if made of \csb{etocstandarddisplaystyle}.
 
+See further \autoref{sec:anothercompat}.
+
 \section{A first example}
 \label{sec:firstexample}
 
@@ -2384,32 +2399,31 @@
 \item do either of the above only for some portions of the table of contents.
 \end{enumerate}
 
-Here is how to proceed. One puts in the preamble:
+Here is how to proceed.
+
+This has become easier since release |1.08k| as now \etoc preserves
+automatically in \csb{etocsavedsectiontocline}, \csb{etocsavedchaptertocline}
+etc... the meaning of the \LaTeX\ |\l at section|, |\l at chapter|, etc... macros as
+they were at the time the TOC is typeset.
+
 \begin{filecontentshere}{etocsnippet-\the\value{section}-A.tex}
 \makeatletter
 \newcommand{\MyStandardTOC}{%
   \begingroup
-  \let\savedpartline\l at part
-  \let\savedchapterline\l at chapter  %% remove if article/scrartcl class
-  \let\savedsectionline\l at section
-  \let\savedsubsectionline\l at subsection 
-  % and so on if \subsubsection, etc... is used
-  % 
   % for the book or article classes:
-  \etocsetstyle{part}{}{}
-    {\savedpartline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
+  %\etocsetstyle{part}{}{}
+  %  {\etocsavedparttocline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
   % for the scrbook or scrartcl classes:
   \etocsetstyle{part}{}{}
-    {\savedpartline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
-  % identical in book/article/scrbook/scrartcl classes:
+    {\etocsavedparttocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+  % following is identical in book/article/scrbook/scrartcl classes:
   \etocsetstyle{chapter}{}{}   %%% only for book and scrbook
-    {\savedchapterline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedchaptertocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   \etocsetstyle{section}{}{} 
-    {\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   \etocsetstyle{subsection}{}{}
-    {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   % etc... if further sectioning units are used
-  % (see the text for what to do with the memoir class)
   \etocstandarddisplaystyle % this is for the title, page-marks, etc...
   \tableofcontents     
   \endgroup}
@@ -2416,7 +2430,11 @@
 \makeatother
 \end{filecontentshere}
 \attachfile{etocsnippet-\the\value{section}-A.tex}
-Of course if the document has only one table of contents then there is no need
+
+One can add to the above arbitrary text formatting commands, for example
+replace |\etocpage| by |\textcolor{blue}{\etocpage}|.
+
+If the document has only one table of contents then there is no need
 to put the commands inside a macro, or even inside a group.\footnote{and if
 moreover one just wants to keep the same layout as in the default, one may
 question why using \etoc... there is \emph{one} good reason: numbers and names
@@ -2424,16 +2442,11 @@
 holding both the number and the name corresponding to one toc entry.} With these
 commands 
 \etoc will construct a TOC completely identical to what would have been done by
-one of the document class: |article|, |book|, |scrartcl|, |scrbook|. \footnote{For the
-|memoir| class, one needs a bit more: each of the command \csa{booknumberline},
-\csa{partnumberline} and \csa{chapternumberline} will have to be saved with a
-\csa{let}, and, one then specifies:
-\centeredline{%
-\csa{etocsetstyle\{chapter\}\{\}\{\}\{\string\savedchapterline\{%
-\string\savedchapternumberline}}
-\hbox to \linewidth{\hfil\hfil \ttfamily 
-        \{\csa{etocnumber}\}\csa{etocname}\}\{\csa{etocpage}\}\}\{\}\hfil} 
-(and analogously for |part|, respectively |book|).}
+one of the document class: |article|, |book|, |scrartcl|, |scrbook|.\footnote{For the
+|memoir| class, one needed prior to \etoc |1.08k| a bit more: each of the command \csa{booknumberline},
+\csa{partnumberline} and \csa{chapternumberline} had to be saved. They can now
+be used directly in the line styles, because their meanings are not modified
+anymore by \etoc during its TOC typesetting.}
 The number and the name of each entry are each separately an |hyperref| link, as
 is always the case with \etoc, when not in compatibility mode. Replacing
 \csa{etocnumber} with \csa{etocthenumber} will give a TOC where the numbers are
@@ -2466,10 +2479,10 @@
     \else
       \etocsetstyle{subsection}
        {}{}
-       {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}
+       {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}
        {}%
     \fi} 
-  {\savedsectionline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
+  {\etocsavedsectiontocline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
   {}%
 \end{filecontentshere}
 \attachfile{etocsnippet-\the\value{section}-B.tex}
@@ -4141,10 +4154,8 @@
 
 \localtableofcontents \label{toc:a}
 
-\section{The \csbhyp{etocsetstyle} command}
+\section{The \csbhyp{etocsetstyle}, \csbhyp{etocname} and \csbhyp{etocpage} commands}\label{sec:etocsetstyle}
 \label{etocsetstyle}
-
-\subsection{The \csbhyp{etocname} and \csbhyp{etocpage} commands}
 \label{etocname}
 \label{etocpage}
 
@@ -4231,7 +4242,7 @@
 \csa{etocpage} (this last one will have a link only if |hyperref| was passed
 option \emph{linktoc=all}.)
 
-\subsection{The \csbhyp{etocskipfirstprefix} and \csbhyp{etociffirst} commands}
+\section{The \csbhyp{etocskipfirstprefix} and \csbhyp{etociffirst} commands}
 \label{etocskipfirstprefix}
 \label{etociffirst}
 \label{etocxiffirst}
@@ -4252,7 +4263,7 @@
 The variant \csb{etocxiffirst} does the same, but is expandable.
 
 
-\subsection{The \csbhyp{etocnumber} command}
+\section{The \csbhyp{etocnumber} command}
 \label{etocnumber}
 
 So far, our specifications would use the numbering generated
@@ -4274,7 +4285,7 @@
 without needing an added |\protect|.
 
 
-\subsection{The \csbhyp{etocifnumbered} switch}
+\section{The \csbhyp{etocifnumbered} switch}
 \label{etocifnumbered}
 \label{etocxifnumbered}
 
@@ -4315,7 +4326,7 @@
 (new with |1.08|) has the same effect but is expandable.
 
 
-\subsection{The \csbhyp{etocthename}, \csbhyp{etocthenumber}, and
+\section{The \csbhyp{etocthename}, \csbhyp{etocthenumber}, and
 \csbhyp{etocthepage} commands}
 \label{etocthename}
 \label{etocthenumber}
@@ -4332,7 +4343,7 @@
 contexts (for example in a label specification) they should be
 preceded by |\protect|.
 
-\subsection{The \csbhyp{etoclink} command}
+\section{The \csbhyp{etoclink} command}
 \label{etoclink}
 
 The command \csb{etoclink}\marg{linkname} can be used in the line style
@@ -4353,7 +4364,7 @@
 destination in an already expanded form, so for example can be used even after
 a |&| in a tabular construction, if \csb{etocglobaldefs} was issued.
 
-\subsection{The \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
+\section{The \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
 \csbhyp{etocthelinkedpage} and \csbhyp{etocthelink} commands}
 \label{etocthelinkedname}
 \label{etocthelinkednumber}
@@ -4442,6 +4453,18 @@
     \etocinline\tableofcontents \ref{toc:globalcmds}
 \endgroup
 
+\section{The \csbhyp{etocsavedsectiontocline}, etc... commands.}
+\label{etocsavedsectiontocline}
+\label{etocsavedchaptertocline}
+
+Since |1.08k| \etoc preserves
+automatically in \csb{etocsavedsectiontocline}, \csb{etocsavedchaptertocline}
+etc... the meaning of the \LaTeX\ |\l at section|, |\l at chapter|, etc... in force
+at the time each \csb{tableofcontents} or \csb{localtableofcontents}
+macro is executed.
+
+See \autoref{sec:anothercompat} for usage.
+
 \section{The \csbhyp{etocsetlevel} command}
 \label{etocsetlevel}
 
@@ -5078,6 +5101,7 @@
 \newcommand*\etocfontminusone{\normalfont \large \bfseries}
 \newcommand*\etocfontzero{\normalfont \large \bfseries}
 \newcommand*\etocfontone{\normalfont \normalsize \bfseries}
+% (in classes with chapter, \etocfontone does not do \bfseries)
 \newcommand*\etocfonttwo{\normalfont \normalsize}
 \newcommand*\etocfontthree{\normalfont \footnotesize}
 
@@ -5322,22 +5346,91 @@
 
 %\section{... and tricks}
 
-\section{A known issue with \csbhyp{localtableofcontents}}
+\section{The \csbhyp{etocsetlocaltop.toc} command}
+\label{etocsetlocaltop.toc}
 
-The macro \csa{localtableofcontents} will be dysfunctional after a sectioning
-unit which \emph{does not make its way to the \texttt{.toc} file}: typically
-after a non-numbered section for example. The non-numbered section must be
-added to the \texttt{.toc} file via an \csa{addcontentsline}. Else, \etoc will
-construct a local TOC according to the last sectioning unit added to the
-\texttt{.toc} file. For example if this is a sub-section, then \etoc will think
-it must create a local TOC corresponding to a sub-section.
+It is important to understand that \csb{localtableofcontents} works entirely
+from data \emph{in the |.toc| file}. If the document, say with |article|
+class, contains starred sectioning commands, which are not accompanied
+by suitable \csa{addcontentsline}, then these units are completely
+transparent to \csb{localtableofcontents}:
+\begin{itemize}
+\item If it is issued before |\section*{Foo}|, say locally to a |\section|,
+  then the local TOC will include not only the |subsection|s between the
+  |\section| and the |\section*{Foo}| but also those following, and be stopped
+  uniquely by a later |\section| or |\part| from the document's body.
+\item If the command is issued right after |\section*{Foo}| and the later was
+  itself subsequent to a (numbered) |\subsection|, then \etoc will think it
+  must display a TOC local to that \emph{subsection} level.
+\end{itemize}
+Before concluding that \etoc is buggy, imagine how the global TOC of the
+document would look like in such circumstances: the \csb{localtableofcontents}
+does exactly the job of extracting from that global TOC various local TOCs; it
+works only from material in that (virtual) global TOC.
 
-This may be qualified a bug, perhaps a future version will fix
-this. If no one complains it might stay that way.
+Since relase |1.08k|, \etoc provides the one-argument command
+\csb{etocsetlocaltop.toc} to insert into the |.toc| file a kind
+of ``ghost'' of a given sectioning unit. Here is an example:
 
-\section{Hacking  framed parboxes}
+\begin{verbatim}
+\part*{Extra unnumbered part}
+\etocsetlocaltop.toc{part}
+\localtableofcontents
+\end{verbatim}
 
+Then in this example, \csb{localtableofcontents} will be stopped
+by the next |\part| (naturally a numbered one or a |\part*| followed by
+suitable |\addcontentsline|) or also by a later |\etocsetlocaltop.toc{part}|.
 
+This is all fine but keep in mind again that \csb{localtableofcontents} can
+only display units which have been pushed to the |.toc| file, so that |\part*|
+must be followed by numbered sections or |\section*/\addcontentsline| pairs if
+\csb{localtableofcontents} is to display anything useful. One can not use
+\etoc to typeset data not actually there in the |.toc| file!
+
+Thus, in the situation above, one may wonder why the document does not use
+|\addcontentsline| after the |\part*| as it must do so for sub-sectioning
+units if they are to appear in the local TOC.
+
+One may imagine some document where all |Part|s are non-numbered but
+nevertheless the user wants its \csb{localtableofcontents} for each one: then
+indeed \csb{etocsetlocaltop.toc} will help in that case.
+
+There are at least two more methods to handle this situation:
+\begin{itemize}
+\item the first one is simply to use the |\addcontentsline{toc}{part}{..}|
+  commands, and to set the |part| style to do nothing, so that the main TOC
+  will not display them,
+\item the second one does not add the |\addcontentsline{toc}{part}{...}| but
+  uses ``depth tags'' (\autoref{ssec:tocwithdepthtags}) and multiple
+  \csb{tableofcontents} (not \csb{localtableofcontents}), one for each desired
+  local TOC.
+\end{itemize}
+
+There is a variant of the first method which would set the level of |part|
+temporarily to |6| for the typesetting of the main TOC. But then the |chapter|
+toc line style will execute inside the main TOC only once its \emph{start} and
+\emph{finish} parts (see \autoref{sec:etocsetstyle}). This is actually also a
+problem of the second method.
+
+But not of the first method which uses
+\centeredline{\csb{etocsetstyle}|{part}{}{}{}{}|} nor of the approach with
+\csb{etocsetlocaltop.toc}: the \emph{start} and \emph{finish} portions of the
+|chapter| toc line style will get executed at the appropriate times in the
+main, global, TOC.
+
+Be aware however that this use of \csb{etocsetlocaltop.toc}|{part}| will also
+cause the main global TOC to execute (once) the \emph{start} and \emph{finish}
+portions of the |part| toc line style (assuming here again it is not typeset in
+compatibility mode).
+
+Final remark: usage of \csb{etocsetlocaltop.toc} interferes with
+\csb{etocchecksemptiness} only to the extent that it modifies (as explained in
+this section) the selection made by \csb{localtableofcontents}, hence the
+decision whether the local TOC is empty or not.
+
+\section{Hacking framed parboxes}
+
 \begin{verbatim}
 \etocdefaultlines
 \renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
@@ -5907,6 +6000,8 @@
 
 \part{The code}
 
+\localtableofcontents
+
 \section{Timestamp}
 
 This is the documentation as of \texttt{\etocdocdate}, printed from the
@@ -5962,7 +6057,10 @@
   {% define the section node
    \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber} 
                         \unexpanded\expandafter{\etocthelinkedname}}}}%
-   \ifnum\value{partco}<9 \appendtotok\parttok\childnode \fi}
+   %\ifnum\value{partco}<9 
+   \appendtotok\parttok\childnode 
+   %\fi
+   }
   {}
 
 \etocsetnexttocdepth{section}
@@ -5974,6 +6072,18 @@
   {\normalsize Paketversion:\par \etocpkgversion{} (\etocDEpkgdate )\par}}}}
   {\global\appendtotok\treetok{ ;}}
 
+\etocsettagdepth {preamble}{part}
+\etocsettagdepth {overview}{part}
+\etocsettagdepth {arbitrarily}{all}
+\etocsettagdepth {examples}{all}
+\etocsettagdepth {surprising}{all}
+\etocsettagdepth {linestyles}{part}
+\etocsettagdepth {globalcmds}{part}
+\etocsettagdepth {custom}{part}
+\etocsettagdepth {tips}{all}
+\etocsettagdepth {etocandworld}{all}
+\etocsettagdepth {code}{all}
+
 \etocinline\tableofcontents\label{toc:mindmaptitlepage}
 
 \tikzset {branch color/.style={concept color=#1!white,
@@ -5998,7 +6108,7 @@
   level 1 concept/.append style={font=\Large, text width = 3cm},
 % geändert 2015/11/12 20cm->21cm
   level 2/.append style={level width=21cm,level height=30cm, sibling
-          distance=2.31cm},%
+          distance=3cm},%
                    ]
 \the\treetok
 \end{tikzpicture}}\endgroup }
@@ -6035,7 +6145,7 @@
   Daniel Büttner, Claudia Dahl, Christian Otto und Christine Römer (FSU
   Jena). Die letzte Aktualisierung der Übersetzung is vom
   \texttt{\etocDEDEdocdate} (Paketversion \texttt{\etocDEDEpkgversion}).
-  Neuere Abschnitte bleiben in englischer Sprache. Hinweise zur
+  Neuere Abschnitte bleiben auf English. Hinweise zur
   Übersetzung an Christine\_Roemer at t-online dot de.
 
 \medskip
@@ -6134,6 +6244,8 @@
 kompatibel zu  sein. Seit der Version |1.07k| ist es möglich \etoc 
 gleichzeitig mit |tocloft| zu benutzen.
 
+\clearpage
+
 \section{Lizenz}
 
 \begingroup\ttfamily\small\hyphenchar\font -1
@@ -6142,7 +6254,7 @@
 \etocLicense\endgroup
 
 
-%\clearpage % ATTENTION retiré 28 mars 2015
+\clearpage
 
 \etocsettocdepth {subsection}
 
@@ -7113,32 +7225,34 @@
   ändern Sie es nur für Teilbereiche;
 \end{enumerate}
 
-Hier ist beschrieben, wie Sie vorgehen müssen. Man nimmt in die Präambel:
+Hier ist beschrieben, wie Sie vorgehen müssen.
+
+\begin{otherlanguage}{english}
+  This has become easier since release |1.08k| as now \etoc preserves
+automatically in \csb{etocsavedsectiontocline}, \csb{etocsavedchaptertocline}
+etc... the meaning of the \LaTeX\ |\l at section|, |\l at chapter|, etc... macros as
+they were at the time the TOC is typeset.
+\end{otherlanguage}
+
+Man nimmt in die Präambel:
 \begin{filecontentshere}{etocsnippet-\the\value{section}-A.tex}
 \makeatletter
 \newcommand{\MyStandardTOC}{%
   \begingroup
-  \let\savedpartline\l at part
-  \let\savedchapterline\l at chapter  %% remove if article/scrartcl class
-  \let\savedsectionline\l at section
-  \let\savedsubsectionline\l at subsection 
-  % and so on if \subsubsection, etc... is used
-  % 
   % for the book or article classes:
-  \etocsetstyle{part}{}{}
-    {\savedpartline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
+  %\etocsetstyle{part}{}{}
+  %  {\etocsavedparttocline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}%
   % for the scrbook or scrartcl classes:
   \etocsetstyle{part}{}{}
-    {\savedpartline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
-  % identical in book/article/scrbook/scrartcl classes:
+    {\etocsavedparttocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+  % following is identical in book/article/scrbook/scrartcl classes:
   \etocsetstyle{chapter}{}{}   %%% only for book and scrbook
-    {\savedchapterline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedchaptertocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   \etocsetstyle{section}{}{} 
-    {\savedsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   \etocsetstyle{subsection}{}{}
-    {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
+    {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}%
   % etc... if further sectioning units are used
-  % (see the text for what to do with the memoir class)
   \etocstandarddisplaystyle % this is for the title, page-marks, etc...
   \tableofcontents     
   \endgroup}
@@ -7145,7 +7259,12 @@
 \makeatother
 \end{filecontentshere}
 \attachfile{etocsnippet-\the\value{section}-A.tex}
-Natürlich ist es so, wenn das Dokument nur ein Inhaltsverzeichnis hat, dann gibt
+
+
+One can add to the above arbitrary text formatting commands, for example
+replace |\etocpage| by |\textcolor{blue}{\etocpage}|.
+
+Wenn das Dokument nur ein Inhaltsverzeichnis hat, dann gibt
 es keine Notwendigkeit, die Befehle in ein Makro zu setzen oder sogar in eine
 Gruppe. \footnote{Und wenn darüber hinaus, um das gleiche Layout wie im Standard
 zu halten, kann man sich die Frage stellen, warum man \etoc benutzt \ldots\ Es
@@ -7153,17 +7272,11 @@
 \texttt{hyperref}-Links, nach der Regel gibt es nur eine Verbindung, die sowohl
 die Nummer und den Namen auf einem toc"=Eintrag entsprechen.} Mit dem Befehl
 \etoc ist ein Inhaltsverzeichnis völlig identisch zu einem von der
-Dokumentenklasse: |article|, |book|, |scrartcl|, |scrbook|. \footnote{Für die
-|memoir|-Klasse braucht man ein bisschen mehr: Jeder der Befehle
-\csa{booknumberline}, 
-\csa{partnumberline} und \csa{chapternumberline} müssen in ein
-\csa{let} gebettet werden und sie ergeben dann ein:
-\centeredline{%
-\csa{etocsetstyle\{chapter\}\{\}\{\}\{\string\savedchapterline\{%
-\string\savedchapternumberline}}
-\hbox to \linewidth{\hfil\hfil \ttfamily 
-        \{\csa{etocnumber}\}\csa{etocname}\}\{\csa{etocpage}\}\}\{\}\hfil} 
-(und analog für |part| und |book|).}
+Dokumentenklasse: |article|, |book|, |scrartcl|, |scrbook|. \footnote{For the
+|memoir| class, one needed prior to \etoc |1.08k| a bit more: each of the command \csa{booknumberline},
+\csa{partnumberline} and \csa{chapternumberline} had to be saved. They can now
+be used directly in the line styles, because their meanings are not modified
+anymore by \etoc during its TOC typesetting.}
 Die Anzahl und die Namen der einzelnen Einträge sind jeweils separat in einem
 |hyperref|-Link, wie es immer der Fall bei \etoc ist, wenn man nicht im
 Kompatibilitätsmodus ist. Ersetzt man \csa{etocnumber} mit \csa{etocthenumber},
@@ -7197,10 +7310,10 @@
     \else
       \etocsetstyle{subsection}
        {}{}
-       {\savedsubsectionline{\numberline{\etocnumber}\etocname}{\etocpage}}
+       {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}
        {}%
     \fi} 
-  {\savedsectionline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
+  {\etocsavedsectiontocline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}
   {}%
 \end{filecontentshere}
 \attachfile{etocsnippet-\the\value{section}-B.tex}
@@ -8831,10 +8944,8 @@
 
 \localtableofcontents \label{toc:a}
 
-\section{Der \csbhyp{etocsetstyle}"=Befehl}
+\section{Die \csbhyp{etocsetstyle}-, \csbhyp{etocname}- und \csbhyp{etocpage}"=Befehle}\label{sec:etocsetstyle}
 \label{etocsetstyle}
-
-\subsection{Die \csbhyp{etocname}- und \csbhyp{etocpage}"=Befehle}
 \label{etocname}
 \label{etocpage}
 
@@ -8921,7 +9032,7 @@
 
 
 
-\subsection{Die \csbhyp{etocskipfirstprefix} und \csbhyp{etociffirst} Befehle}
+\section{Die \csbhyp{etocskipfirstprefix} und \csbhyp{etociffirst} Befehle}
 \label{etocskipfirstprefix}
 \label{etociffirst}
 \label{etocxiffirst}
@@ -8945,7 +9056,7 @@
 erweiterbar.
 
 
-\subsection{Der \csbhyp{etocnumber}"=Befehl}
+\section{Der \csbhyp{etocnumber}"=Befehl}
 \label{etocnumber}
 
 Bis hierhin würde unsere Spezifikation die Nummerierung verwenden, die von der 
@@ -8966,7 +9077,7 @@
 was erklärt, warum er in der Label"=Spezifikation benutzt werden kann, ohne
 |\protect| hinzuzufügen.
 
-\subsection{Der \csbhyp{etocifnumbered}-Schalter}
+\section{Der \csbhyp{etocifnumbered}-Schalter}
 \label{etocifnumbered}
 \label{etocxifnumbered}
 
@@ -9004,7 +9115,7 @@
 Der Befehl \csb{etocifnumbered} ist robust;  \csb{etocxifnumbered}
 (neu für |1.08|) hat den gleiche Effekt, aber er ist expandierbar.
 
-\subsection{Die Befehle \csbhyp{etocthename}, \csbhyp{etocthenumber} sowie
+\section{Die Befehle \csbhyp{etocthename}, \csbhyp{etocthenumber} sowie
 \csbhyp{etocthepage}}
 \label{etocthename}
 \label{etocthenumber}
@@ -9022,7 +9133,7 @@
 verwendet werden.
 
 
-\subsection{Der \csbhyp{etoclink}"=Befehl}
+\section{Der \csbhyp{etoclink}"=Befehl}
 \label{etoclink}
 
 Der Befehl \csb{etoclink}\marg{linkname} kann in Linienstil"=Beschreibungen
@@ -9044,7 +9155,7 @@
   if \csb{etocglobaldefs} was issued.
 \end{otherlanguage}
 
-\subsection{Die Befehle \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
+\section{Die Befehle \csbhyp{etocthelinkedname}, \csbhyp{etocthelinkednumber},
 \csbhyp{etocthelinkedpage} und \csbhyp{etocthelink}}
 \label{etocthelinkedname}
 \label{etocthelinkednumber}
@@ -9149,6 +9260,18 @@
     \etocinline\tableofcontents \ref{toc:globalcmds}
 \endgroup
 
+\section{Die \csbhyp{etocsavedsectiontocline}, usw... Befehle.}
+\label{etocsavedsectiontocline}
+\label{etocsavedchaptertocline}
+
+\begin{otherlanguage}{english}
+  Since |1.08k| \etoc preserves automatically in
+  \csb{etocsavedsectiontocline}, \csb{etocsavedchaptertocline} etc... the
+  meaning of the \LaTeX\ |\l at section|, |\l at chapter|, etc... in force at the
+  time each \csb{tableofcontents} or \csb{localtableofcontents} macro is
+  executed.
+\end{otherlanguage}
+
 \section{Der \csbhyp{etocsetlevel}"=Befehl}
 \label{etocsetlevel}
 
@@ -9770,6 +9893,7 @@
 \newcommand*\etocfontminusone{\normalfont \large \bfseries}
 \newcommand*\etocfontzero{\normalfont \large \bfseries}
 \newcommand*\etocfontone{\normalfont \normalsize \bfseries}
+% (in classes with chapter, \etocfontone does not do \bfseries)
 \newcommand*\etocfonttwo{\normalfont \normalsize}
 \newcommand*\etocfontthree{\normalfont \footnotesize}
 
@@ -10011,26 +10135,96 @@
 
 %\section{\ldots\ und Tricks}
 
-\section{A known issue with \csbhyp{localtableofcontents}}
-
 \begin{otherlanguage}{english}
-  The macro \csa{localtableofcontents} will be dysfunctional after a
-  sectioning unit which \emph{does not make its way to the \texttt{.toc}
-    file}: typically after a non-numbered section for example. The
-  non-numbered section must be added to the \texttt{.toc} file via an
-  \csa{addcontentsline}. Else, \etoc will construct a local TOC according to
-  the last sectioning unit added to the \texttt{.toc} file. For example if
-  this is a sub-section, then \etoc will think it must create a local TOC
-  corresponding to a sub-section.
+\section{The \csbhyp{etocsetlocaltop.toc} command}
+\label{etocsetlocaltop.toc}
 
-  This may be qualified a bug, perhaps a future version will fix this. If
-  no one complains it might stay that way.
+It is important to understand that \csb{localtableofcontents} works entirely
+from data \emph{in the |.toc| file}. If the document, say with |article|
+class, contains starred sectioning commands, which are not accompanied
+by suitable \csa{addcontentsline}, then these units are completely
+transparent to \csb{localtableofcontents}:
+\begin{itemize}
+\item If it is issued before |\section*{Foo}|, say locally to a |\section|,
+  then the local TOC will include not only the |subsection|s between the
+  |\section| and the |\section*{Foo}| but also those following, and be stopped
+  uniquely by a later |\section| or |\part| from the document's body.
+\item If the command is issued right after |\section*{Foo}| and the later was
+  itself subsequent to a (numbered) |\subsection|, then \etoc will think it
+  must display a TOC local to that \emph{subsection} level.
+\end{itemize}
+Before concluding that \etoc is buggy, imagine how the global TOC of the
+document would look like in such circumstances: the \csb{localtableofcontents}
+does exactly the job of extracting from that global TOC various local TOCs; it
+works only from material in that (virtual) global TOC.
+
+Since relase |1.08k|, \etoc provides the one-argument command
+\csb{etocsetlocaltop.toc} to insert into the |.toc| file a kind
+of ``ghost'' of a given sectioning unit. Here is an example:
+
+\begin{verbatim}
+\part*{Extra unnumbered part}
+\etocsetlocaltop.toc{part}
+\localtableofcontents
+\end{verbatim}
+
+Then in this example, \csb{localtableofcontents} will know be stopped
+by the next |\part| (naturally a numbered one or a |\part*| followed by
+suitable |\addcontentsline|) or also by a later |\etocsetlocaltop.toc{part}|.
+
+This is all fine but keep in mind again that \csb{localtableofcontents} can
+only display units which have been pushed to the |.toc| file, so that |\part*|
+must be followed by numbered sections or |\section*/\addcontentsline| pairs if
+\csb{localtableofcontents} is to display anything useful. One can not use
+\etoc to typeset data not actually there in the |.toc| file!
+
+Thus, in the situation above, one may wonder why the document does not use
+|\addcontentsline| after the |\part*| as it must do so for sub-sectioning
+units if they are to appear in the local TOC.
+
+One may imagine some document where all |Part|s are non-numbered (and are not
+pushed to the |.toc| file) but nevertheless the user wants its
+\csb{localtableofcontents} for each one: then indeed \csb{etocsetlocaltop.toc}
+will help in that case.
+
+There are at least two more methods to handle this situation:
+\begin{itemize}
+\item the first one is simply to use the |\addcontentsline{toc}{part}{..}|
+  commands, and to set the |part| style to do nothing, so that the main TOC
+  will not display them,
+\item the second one does not add the |\addcontentsline{toc}{part}{...}| but
+  uses ``depth tags'' (\autoref{ssec:tocwithdepthtags}) and multiple
+  \csb{tableofcontents} (not \csb{localtableofcontents}), one for each desired
+  local TOC.
+\end{itemize}
+
+There is a variant of the first method which would set the level of |part|
+temporarily to |6| for the typesetting of the main TOC. But then the |chapter|
+toc line style will execute inside the main TOC only once its \emph{start} and
+\emph{finish} parts (see \autoref{sec:etocsetstyle}). This is actually also a
+problem of the second method.
+
+But not of the first method which uses
+\centeredline{\csb{etocsetstyle}|{part}{}{}{}{}|} nor of the approach with
+\csb{etocsetlocaltop.toc}: the \emph{start} and \emph{finish} portions of the
+|chapter| toc line style will get executed at the appropriate times in the
+main, global, TOC.
+
+Be aware however that this use of \csb{etocsetlocaltop.toc}|{part}| will also
+cause the main global TOC to execute (once) the \emph{start} and \emph{finish}
+portions of the |part| toc line style (assuming here again it is not typeset in
+compatibility mode).
+
+Final remark: usage of \csb{etocsetlocaltop.toc} interferes with
+\csb{etocchecksemptiness} only to the extent that it modifies (as explained in
+this section) the selection made by \csb{localtableofcontents}, hence the
+decision whether the local TOC is empty or not.
+
 \end{otherlanguage}
 
 \section{Hacken "`framed parboxes"'}
 
-
-\begin{filecontentsdef}{etocsnippet-\the\value{section}.tex}{\foo}
+\begin{verbatim}
 \etocdefaultlines
 \renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
 \etocruled{\color{green}\fboxrule2pt\fboxsep1ex
@@ -10039,13 +10233,19 @@
                        {\normalfont Dieser Text ist vertikal  perfekt zentriert
                unter Berücksichtigung der \emph{surrounding horizontal rules.}}}}}
 \ref{toc:globalcmds}
-\end{filecontentsdef}
+\end{verbatim}
 
-\filecontentsexec\foo
+\etocdefaultlines
 
-\filecontentsprint\foo
-\attachfile{etocsnippet-\the\value{section}.tex}
+\renewcommand\etoctoprule{\hrule height 2pt depth 2pt}
 
+\etocruled{\color{green}\fboxrule2pt\fboxsep1ex
+               \fbox{\raisebox{-\fontdimen22\textfont2}
+                    {\color{blue}\parbox{.5\linewidth}
+                       {\normalfont Dieser Text ist vertikal  perfekt zentriert
+               unter Berücksichtigung der \emph{surrounding horizontal rules.}}}}}
+\ref{toc:globalcmds}
+
 \section{Umstellen der Ebenen}
 \label{subsec:interverting}
 
@@ -10400,7 +10600,7 @@
 % je retire le \clearpage car il y a une page quasi-vide à l'exception de
 % l'icône Paperclip.
 
-% \clearpage
+\clearpage
 \etocdepthtag.toc {etocandworld}
 
 \part{\etoc und die Außenwelt}
@@ -10609,12 +10809,14 @@
 
 \part{Der Code}
 
+\localtableofcontents
+
 \section{Zeitstempel}
 
 Die deutsche Übersetzung wurden zum letzten Mal am
 \texttt{\etocDEDEdocdate} (Paketversion \texttt{\etocDEDEpkgversion}) geändert
 (abgesehen von den organisatorischen Veränderungen).
-Einige neuere Abschnitte bleiben in englischer Sprache.
+Einige neuere Abschnitte bleiben auf Englisch.
 
 Dokumentation erzeugt von der Quelldatei mit dem Stempel
 \texttt{\etocdtxtimestamp}. Die dokumentierte Paketversion ist
@@ -10689,8 +10891,26 @@
 
 \begin{multicols}{2}
 \begin{jfverbatim}
-v1.08j [2017/09/21]^
+v1.08k [2017/09/28]^
 
+   Adds \etocsetlocaltop.toc. See corresponding manual section for
+   details.
+
+   Adds \etocsavedparttocline, \etocsavedchaptertocline,
+   \etocsavedsectiontocline, ... They can be used in the context of
+   the technique explained in section "Another compatibility mode".
+
+   Formerly, etoc redefined for the duration of the TOC the memoir
+   macro \chapternumberline and its likes to have same meaning as
+   \numberline (of course, not when executed in compatibility mode),
+   for the sake of extraction of \etocnumber.
+
+   New method detects presence of any \<foo>numberline macro without
+   any change to originals; they can thus be used as is when applying
+   the approach of "Another compatibility mode" section from manual.
+
+~v1.08j [2017/09/21]^
+
    Since 1.08a-2015/03/13 \etocname, \etocnumber, \etocpage
    contain, if hyperref is present and configured for using
    hyperlinks in the TOC, the link destination in already expanded
@@ -11192,7 +11412,7 @@
 \def\etocglobaldefs{\let\Etoc at global\global\let\tof at global\global}
 \def\etoclocaldefs {\let\Etoc at global\@empty\let\tof at global\@empty}
 \newif\ifEtoc at jj  % book
-\newif\ifEtoc at j   % part  
+\newif\ifEtoc at j   % part
 \newif\ifEtoc@    % chapter
 \newif\ifEtoc at i   % section
 \newif\ifEtoc at ii  % subsection
@@ -11220,7 +11440,7 @@
 \def\etoc@{\etoc@}
 %    \end{macrocode}
 % |1.07g| uses a second counter; this could be avoided, but ok, let's not be
-% that strict. 
+% that strict.
 %    \begin{macrocode}
 \newcounter{etoc at tocid}
 \newcounter{etoc at tocdepth}% 1.07g
@@ -11265,7 +11485,7 @@
 \expandafter\let\csname Etoc at 5@@\endcsname  \Etoc@@five@@
 \expandafter\let\csname Etoc at 6@@\endcsname  \Etoc@@six@@
 \let\Etoc at all@@   \Etoc@@five@@
-\let\Etoc at none@@  \Etoc at minf   
+\let\Etoc at none@@  \Etoc at minf
 %    \end{macrocode}
 % Versions earlier than |1.08| did |\Etoc at newlevel| in a quite
 % embarrassing way with an |\edef|.
@@ -11275,10 +11495,10 @@
 %    \begin{macrocode}
 \let\Etoc at levellist\@empty
 \def\Etoc at newlevel #1{\expandafter\def\expandafter\Etoc at levellist\expandafter
-        {\Etoc at levellist\Etoc at levellist@elt #1}}
+        {\Etoc at levellist\Etoc at levellist@elt{#1}}}
 \def\etocsetlevel#1#2{%
- \@ifundefined{Etoc@#1@@}{\expandafter\Etoc at newlevel\csname l@#1\endcsname}{}%
- \ifcase#2\relax
+   \@ifundefined{Etoc@#1@@}{\Etoc at newlevel{#1}}{}%
+   \ifcase#2\relax
       \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
       \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@
    \or
@@ -11299,19 +11519,22 @@
    \or
       \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@
    \else
-   \ifnum#2=\m at ne
-      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@
-      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@
-   \else
-   \ifnum#2=-\tw@
+    \ifnum#2=\m at 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}
+     \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}
+      \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@
+     \fi
+    \fi
+   \fi
+}
 \etocsetlevel{book}{-2}
 \etocsetlevel{part}{-1}
 \etocsetlevel{chapter}{0}
@@ -11324,7 +11547,7 @@
 % The first two parameters of |\Etoc at et@hop| are exchanged in |1.08|
 % compared to earlier versions; this is in relation to changes done in
 % |\Etoc at etoccontentsline|.
-% 
+%
 % |1.08i| as a |fourorthree| rather than as formerly a |sixorfive|.
 %    \begin{macrocode}
 \AtBeginDocument{%
@@ -11343,52 +11566,52 @@
 % |1.08| uses |\Etoc at level| rather than a |#1| which used to be anyhow always
 % the |\Etoc at tmp|. Now |\Etoc at level| is what was called formerly |\Etoc at tmp|
 % in |\Etoc at etoccontentsline|.
+%
+% Attention that |\Etoc at setflags| must not modify |\Etoc at next|!
 %    \begin{macrocode}
 \def\Etoc at setflags {%
-  \ifcase \Etoc at level
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iifalse
-      \global\Etoc at ifalse
-      \global\Etoc at true
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iifalse
-      \global\Etoc at itrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iitrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiitrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivtrue
-  \or
-      \global\Etoc at vtrue
-  \else
-%    \end{macrocode}
-% |2015/03/08| I move up the common assignments.
-%    \begin{macrocode}
-    \global\Etoc at vfalse
-    \global\Etoc at ivfalse
-    \global\Etoc at iiifalse
-    \global\Etoc at iifalse
-    \global\Etoc at ifalse
-    \global\Etoc at false
-    \ifnum\Etoc at level=\m at ne
-      \global\Etoc at jtrue
+    \ifcase \Etoc at level
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at ifalse
+        \global\Etoc at true
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at itrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iitrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiitrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivtrue
+    \or
+        \global\Etoc at vtrue
     \else
-      \global\Etoc at jfalse
-      \global\Etoc at jjtrue
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at ifalse
+        \global\Etoc at false
+        \ifnum\Etoc at level=\m at ne
+            \global\Etoc at jtrue
+        \else
+            \global\Etoc at jfalse
+            \global\Etoc at jjtrue
+        \fi
     \fi
-  \fi}
+}
 %    \end{macrocode}
 % |1.08| This was originally in |\Etoc at etoccontentsline|, intermixed
 % with the definitions of |\Etoc at contents| and |\Etoc at prefix|. Separated
@@ -11398,44 +11621,110 @@
 % |\ifcase| assumes none of the |\Etoc at end@..| routines modify it,
 % naturally.
 %    \begin{macrocode}
-\def\Etoc at doends {%  
+\def\Etoc at doends {%
     \ifcase \Etoc at level
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
-        \ifEtoc at ii \Etoc at end@two\fi
-        \ifEtoc at i  \Etoc at end@one\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
+        \ifEtoc at i  \Etoc at end@one  \fi
     \or
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
-        \ifEtoc at ii \Etoc at end@two\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
     \or
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
     \or
-        \ifEtoc at v \Etoc at end@five\fi
-        \ifEtoc at iv\Etoc at end@four\fi
-    \or 
-        \ifEtoc at v \Etoc at end@five\fi 
-    \or 
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
+    \or
+        \ifEtoc at v  \Etoc at end@five \fi
+    \or
     \else
-      \ifEtoc at v  \Etoc at end@five \fi
-      \ifEtoc at iv \Etoc at end@four \fi
-      \ifEtoc at iii\Etoc at end@three\fi
-      \ifEtoc at ii \Etoc at end@two  \fi
-      \ifEtoc at i  \Etoc at end@one  \fi
-      \ifEtoc@   \Etoc at end@zero \fi
-      \ifnum \Etoc at level =-\tw@
-        \ifEtoc at j \Etoc at end@minusone\fi
-      \fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
+        \ifEtoc at iii\Etoc at end@three\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
+        \ifEtoc at i  \Etoc at end@one  \fi
+        \ifEtoc@   \Etoc at end@zero \fi
+        \ifnum \Etoc at level =-\tw@
+            \ifEtoc at j \Etoc at end@minusone\fi
+        \fi
     \fi
 }
 %    \end{macrocode}
+% |1.08| the |\Etoc at next| will (possibly) execute the |begin| code,
+% \emph{before} |\Etoc at contents| and |\Etoc at prefix| get defined,
+% contrarily to what I did in earlier versions. I still reset the flags
+% before execution of the |begin| codes (although the flags are not
+% supposed to be used therein anyhow).
+%
+% Also the \meta{begin} code does |\Etoc at isfirsttrue|.
+%
+% |1.08k| This was originally in |\Etoc at etoccontentsline|. Extracted for
+% re-use by |\etocsetlocaltop.toc|. Calls |\Etoc at setflags| which must not
+% modify |\Etoc at next|.
+%    \begin{macrocode}
+\def\Etoc at dobegins{%
+    \let\Etoc at next\@empty
+    \Etoc at global\Etoc at isfirstfalse
+%    \end{macrocode}
+% |2015/03/08| If my naming scheme had not been so baroque, I could easily do
+% things in a more concise way here...
+%    \begin{macrocode}
+    \ifcase\Etoc at level
+        \ifEtoc@
+        \else
+            \def\Etoc at next{\Etoc at begin@zero}%
+        \fi
+    \or
+        \ifEtoc at i
+        \else
+            \def\Etoc at next{\Etoc at begin@one}%
+        \fi
+    \or
+        \ifEtoc at ii
+        \else
+            \def\Etoc at next{\Etoc at begin@two}%
+        \fi
+    \or
+        \ifEtoc at iii
+        \else
+            \def\Etoc at next{\Etoc at begin@three}%
+        \fi
+    \or
+        \ifEtoc at iv
+        \else
+            \def\Etoc at next{\Etoc at begin@four}%
+        \fi
+    \or
+        \ifEtoc at v
+        \else
+            \def\Etoc at next{\Etoc at begin@five}%
+        \fi
+    \else
+        \ifnum\Etoc at level=\m at ne
+            \ifEtoc at j
+            \else
+                \def\Etoc at next{\Etoc at begin@minusone}%
+            \fi
+        \else
+            \ifEtoc at jj
+            \else
+                \def\Etoc at next{\Etoc at begin@minustwo}%
+            \fi
+        \fi
+    \fi
+    \Etoc at setflags
+    \Etoc at next
+}
+%    \end{macrocode}
 % Heart of \etoc hack into execution of |.toc| file. The |.toc|
 % file must contain (at least indirectly via expansion)
-% |\contentsline {<unit>}...| instructions, with 
+% |\contentsline {<unit>}...| instructions, with
 % the standard meaning of executing |\l at unit| (the hyperref
 % modifications are taken into account). It is the various |\l at unit|'s
 % which are (locally) |\let| to |\Etoc at lxyz| and it is |\Etoc at lxyz|
@@ -11511,10 +11800,12 @@
    \ifEtoc at localtoc
     \ifEtoc at stoptoc\Etoc at skipthisonetrue
     \else
-     \ifEtoc at notactive\Etoc at setflags\Etoc at skipthisonetrue
+     \ifEtoc at notactive\Etoc at setflags
+       \Etoc at skipthisonetrue
      \else
-      \ifnum\Etoc at level<\Etoc at localtop\Etoc at skipthisonetrue
-       \global\Etoc at stoptoctrue
+      \ifnum\Etoc at level<\Etoc at localtop
+        \Etoc at skipthisonetrue
+        \global\Etoc at stoptoctrue
       \fi
      \fi
     \fi
@@ -11521,8 +11812,10 @@
    \fi
   \fi
   \let\Etoc at next\Etoc at gobblefourorthree
-  \ifEtoc at skipthisone\else
-   \ifnum\c at tocdepth<\Etoc at level\else
+  \ifEtoc at skipthisone
+  \else
+   \ifnum\c at tocdepth<\Etoc at level
+   \else
     \ifEtoc at standard
       \let\Etoc at next\Etoc at savedcontentsline
     \else
@@ -11530,7 +11823,7 @@
     \fi
    \fi
   \fi
-  \Etoc at next {#1}%
+  \Etoc at next{#1}%
 }
 %    \end{macrocode}
 % |1.08| New way to handle the compatibility mode. One has to worry
@@ -11547,49 +11840,16 @@
 % inclusive of |\Etoc at doends| which may close groups. (code has changed since,
 % slightly).
 %
-% Versions |1.08| extracts to a separate macro |\Etoc at doends|. Earlier code
+% |1.08| extracts to a separate macro |\Etoc at doends|. Earlier code
 % did |\global\let\Etoc at next\relax| but we can now give a default |\relax|
 % value to |\Etoc at next| with no need of a |\global| prefix.
+%
+% |1.08k| extracts |\Etoc at dobegins|.
 %    \begin{macrocode}
 \def\Etoc at etoccontentsline@ #1{%
-    \Etoc at doends
+    \Etoc at doends   % separated since 1.08
+    \Etoc at dobegins % separated since 1.08k. Does \Etoc at setflags.
 %    \end{macrocode}
-% |1.08| the |\Etoc at next| will (possibly) execute the |begin| code,
-% \emph{before} |\Etoc at contents| and |\Etoc at prefix| get defined,
-% contrarily to what I did in earlier versions. I still reset the flags
-% before execution of the |begin| codes (although the flags are not
-% supposed to be used therein anyhow).
-%
-% Also the \meta{begin} code does |\Etoc at isfirsttrue|.
-%    \begin{macrocode}
-    \let\Etoc at next\@empty
-    \Etoc at global\Etoc at isfirstfalse
-%    \end{macrocode}
-% |2015/03/08| If my naming scheme had not been so baroque, I could easily do
-% things in a more concise way here...
-%    \begin{macrocode}
-    \ifcase\Etoc at level
-        \ifEtoc@\else    \def\Etoc at next{\Etoc at begin@zero}\fi
-    \or
-        \ifEtoc at i\else   \def\Etoc at next{\Etoc at begin@one}\fi
-    \or
-        \ifEtoc at ii\else  \def\Etoc at next{\Etoc at begin@two}\fi
-    \or
-        \ifEtoc at iii\else \def\Etoc at next{\Etoc at begin@three}\fi
-    \or 
-        \ifEtoc at iv\else  \def\Etoc at next{\Etoc at begin@four}\fi
-    \or 
-        \ifEtoc at v\else   \def\Etoc at next{\Etoc at begin@five}\fi
-    \else
-      \ifnum\Etoc at level=\m at ne
-        \ifEtoc at j\else   \def\Etoc at next{\Etoc at begin@minusone}\fi
-      \else
-        \ifEtoc at jj\else  \def\Etoc at next{\Etoc at begin@minustwo}\fi
-      \fi
-    \fi
-    \Etoc at setflags
-    \Etoc at next
-%    \end{macrocode}
 % |1.08|:
 % \begin{enumerate}
 % \item  separates the definition of |\Etoc at prefix| and
@@ -11604,7 +11864,7 @@
 % \item has |\Etoc at level| rather than |\Etoc at tmp| and thus we can dispense
 % with the |\ifEtoc at part| switch as we will be able to test the equality
 % |\Etoc at level=-1| inside of |\Etoc at lxyz|.
-% 
+%
 % \item adds the |\Etoc at global| prefix.
 % \end{enumerate}
 % |1.08i| uses an |\edef| rather than |\def| with a chain of |\expandafter|.
@@ -11622,8 +11882,8 @@
 % compatibility mode).
 %
 % For the record we don't do |\csname l@#1\endcsname| mainly because
-% hyperref patches |\contentsline|. 
-% 
+% hyperref patches |\contentsline|.
+%
 % The location where |\Etoc at savedcontentsline| is |\let| to
 % |\contentsline| has been moved with release |1.08| to before the
 % title as set by |\etocsettoctyle|, thus it is now possible to open a
@@ -11637,7 +11897,7 @@
 }
 %    \end{macrocode}
 % START OF MAINLY OBSOLETE COMMENTS
-% 
+%
 % |2013/03/07|: up to |1.06| \etoc defined only \csa{etocname}, \csa{etocnumber} and
 % \csa{etocpage}. The |hyperref| added data is recycled in the simplest
 % manner, prefixing it with \csa{leavevmode}. The included
@@ -11673,7 +11933,7 @@
 %
 % |1.08a| drops the original constructions of |\etocname| etc... The obvious
 % decision to convert \csa{etocname}, etc ... to be the robust versions of
-% \csa{etocthelinkedname}, etc ... was delayed two years 
+% \csa{etocthelinkedname}, etc ... was delayed two years
 % (from |1.07f 2013/03/07| to |1.08a 2015/03/13|) for sentimental reason. But
 % the original
 % versions contained the hyperref destination only in unexpanded form, this
@@ -11688,13 +11948,13 @@
 % closed for example by a |&| from the sectioning style, even if having used
 % |\etocglobaldefs|.
 %    \begin{macrocode}
-\def\Etoc at lxyz #1#2{% 
+\def\Etoc at lxyz #1#2{%
     \Etoc at global\let\etocthelink\@firstofone % fall-back, was let \@empty up to 1.08i (inc.)
     \Etoc at global\def\etocthename       {#1}%  (if linked, will be removed later)
     \Etoc at global\def\etocthelinkedname {#1}%  (probably redefined later)
     \Etoc at getthepage #2\etoc@ % defines \etocthelinkedpage
     \Etoc at getnb #1\relax\relax\etoc@  % sets number, name, and \etocthelink
-    \ifEtoc at number\else               
+    \ifEtoc at number\else
       \ifnum\Etoc at level=\m at ne
         \Etoc at getit #1\hspace\relax\etoc@   % additional job for parts
       \fi
@@ -11721,7 +11981,7 @@
     \Etoc at global\def\etocthelinkedpage {#1}%
 }
 %    \end{macrocode}
-% |1.07k| corrects a bug here with an extra space before |##1| in 
+% |1.07k| corrects a bug here with an extra space before |##1| in
 % |\@namedef{etoclink } ##1|. In 99.99\% of use cases however, the
 % macro gets redefined at a later stage, thus the bug did not show.
 %
@@ -11766,13 +12026,23 @@
 % |1.08| adds the |\Etoc at global|'s.
 %
 % |1.08j| corrects an old |\ifx#1\numberline| into |\ifx\numberline#1|.
+%
+% |1.08k| uses a delimited macro to identify \csa{numberline},
+% \csa{chapternumberline} etc... in one go, avoiding
+% the |\let\chapternumberline\numberline| etc... which were done formerly
+% in \csa{Etoc at tableofcontents}. Currently \etoc does not yet use \eTeX.
 %    \begin{macrocode}
+\begingroup\@tfor\x:=NUMBZRLINZ\do{\catcode\expandafter`\x=12 }\lccode`Z `e
+\lowercase{\endgroup
+\long\def\Etoc at oneifnumberline #1NUMBZRLINZ#2#3\Etoc at next{%
+   \ifx\etoc@#20\else1\fi
+}%
 \def\Etoc at getnb@nohyp #1#2#3\etoc@ {%
     \def\Etoc at getname ##1\relax\relax\etoc@ {%
       \Etoc at global\def\etocthename       {##1}%
       \Etoc at global\def\etocthelinkedname {##1}%
      }%
-  \ifx\numberline#1%
+  \if1\expandafter\Etoc at oneifnumberline\string#1NUMBZRLINZ\etoc@\Etoc at next
     \Etoc at global\def\etocthenumber       {#2}%
     \Etoc at global\def\etocthelinkednumber {#2}%
     \Etoc at global\Etoc at numbertrue
@@ -11782,12 +12052,15 @@
     \Etoc at global\let\etocthelinkednumber \@empty
     \Etoc at global\Etoc at numberfalse
   \fi
-}
+}%
 %    \end{macrocode}
 % |1.07n| replaces use of |\toks@| by macro |\Etoc at tmp|. |1.08| adds
 % the |\Etoc at global|'s.
 %
 % |1.08j| corrects the old |\ifx#1\numberline| into |\ifx\numberline#1|.
+%
+% |1.08k| uses a delimited macro to identify \csa{numberline},
+% \csa{chapternumberline} etc... in one go, avoiding
 %    \begin{macrocode}
 \def\Etoc at getnb@hyp #1#2#3#4#5#6\etoc@ {%
          \def\Etoc at getname ##1\relax\relax\etoc@ {%
@@ -11797,7 +12070,7 @@
                               {\expandafter\hyperlink \Etoc at tmp{##1}}%
          }%
          \def\Etoc at getnbr ##1##2##3\etoc@ {%
-          \ifx\numberline##1%
+          \if1\expandafter\Etoc at oneifnumberline\string##1NUMBZRLINZ\etoc@\Etoc at next
             \Etoc at global\def\etocthenumber {##2}%
             \edef\Etoc at tmp   {{#3}}%
             \Etoc at global\expandafter\def\expandafter\etocthelinkednumber
@@ -11816,7 +12089,7 @@
          }%
   \Etoc at global\edef\etocthelink ##1{\noexpand\hyperlink {#3}{##1}}%
   \Etoc at getnbr #4\relax\relax\etoc@
-}
+}}
 %    \end{macrocode}
 % |1.08| adds the |\Etoc at global|'s.
 %    \begin{macrocode}
@@ -11825,7 +12098,8 @@
        \Etoc at global\def\etocthename       {##1}%
        \Etoc at global\def\etocthelinkedname {##1}%
     }%
-  \ifx\relax#2\else 
+  \ifx\relax#2%
+  \else
         \Etoc at global\def\etocthenumber       {#1}%
         \Etoc at global\def\etocthelinkednumber {#1}%
         \Etoc at global\Etoc at numbertrue
@@ -11851,7 +12125,8 @@
                    \expandafter{\expandafter\hyperlink \Etoc at tmp{##1}}%
     }%
     \def\Etoc at getnbr ##1\hspace##2##3\etoc@ {%
-       \ifx\relax##2\else
+       \ifx\relax##2%
+       \else
          \Etoc at global\def\etocthenumber {##1}%
          \Etoc at global\expandafter\def\expandafter\etocthelinkednumber
                      \expandafter{\expandafter\hyperlink \Etoc at tmp{##1}}%
@@ -11917,10 +12192,10 @@
 % 1.07d: parskip and |\@nobreakfalse| stuff moved to |\Etoc at tableofcontents|
 %    \begin{macrocode}
 \def\Etoc at openouttoc{%
-  \ifEtoc at hyperref 
+  \ifEtoc at hyperref
     \ifx\hyper at last\@undefined
     \IfFileExists{\jobname .toc}
-      {\Hy at WarningNoLine 
+      {\Hy at WarningNoLine
          {old toc file detected, not used; run LaTeX again (cheers from etoc)}%
        \global\Etoc at toctoks={}%
       }
@@ -11927,10 +12202,10 @@
       {}%
     \fi
   \fi
-  \if at filesw 
-   \newwrite \tf at toc 
-   \immediate \openout \tf at toc \jobname .toc\relax 
-  \fi 
+  \if at filesw
+   \newwrite \tf at toc
+   \immediate \openout \tf at toc \jobname .toc\relax
+  \fi
   \global\let\Etoc at openouttoc\empty
 }
 %    \end{macrocode}
@@ -11944,25 +12219,27 @@
 % easier to typeset TOC as tables with \etoc!
 %    \begin{macrocode}
 \def\Etoc at toctoc{%
-   \global\Etoc at vfalse
-   \global\Etoc at ivfalse
-   \global\Etoc at iiifalse
-   \global\Etoc at iifalse
-   \global\Etoc at ifalse
-   \global\Etoc at false
-   \global\Etoc at jfalse
-   \global\Etoc at jjfalse
-\the\Etoc at toctoks
-\ifEtoc at notactive\else 
-  \ifEtoc at v   \Etoc at end@five\fi
-  \ifEtoc at iv  \Etoc at end@four\fi
-  \ifEtoc at iii \Etoc at end@three\fi
-  \ifEtoc at ii  \Etoc at end@two\fi
-  \ifEtoc at i   \Etoc at end@one\fi
-  \ifEtoc@    \Etoc at end@zero\fi
-  \ifEtoc at j   \Etoc at end@minusone\fi
-  \ifEtoc at jj  \Etoc at end@minustwo\fi
-\fi}
+  \global\Etoc at vfalse
+  \global\Etoc at ivfalse
+  \global\Etoc at iiifalse
+  \global\Etoc at iifalse
+  \global\Etoc at ifalse
+  \global\Etoc at false
+  \global\Etoc at jfalse
+  \global\Etoc at jjfalse
+  \the\Etoc at toctoks
+  \ifEtoc at notactive
+  \else
+   \ifEtoc at v   \Etoc at end@five\fi
+   \ifEtoc at iv  \Etoc at end@four\fi
+   \ifEtoc at iii \Etoc at end@three\fi
+   \ifEtoc at ii  \Etoc at end@two\fi
+   \ifEtoc at i   \Etoc at end@one\fi
+   \ifEtoc@    \Etoc at end@zero\fi
+   \ifEtoc at j   \Etoc at end@minusone\fi
+   \ifEtoc at jj  \Etoc at end@minustwo\fi
+  \fi
+}
 %    \end{macrocode}
 % Slightly better coded in |1.08b|. Had some bad experiences with TeX
 % conditionals back in 2011/2012 when I started LaTeX programming, and the
@@ -11979,7 +12256,7 @@
 % sometimes tokens.
 %    \begin{macrocode}
 \def\etoc@@startlocaltoc#1#2{%
-    \ifEtoc at localtoc 
+    \ifEtoc at localtoc
         \ifnum #1=#2\relax
           \ifEtoc at jj  \global\let\Etoc at localtop\Etoc@@minusone@@ \fi
           \ifEtoc at j   \global\let\Etoc at localtop\Etoc@@zero@@  \fi
@@ -12071,7 +12348,10 @@
 \expandafter
 \let\expandafter\etocxifwasempty\csname etocifwasempty \endcsname
 \def\Etoc at testingcontentslinelocal #1{%
-  \ifEtoc at stoptoc\else\ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
+  \ifEtoc at stoptoc
+  \else
+   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
+   \else
     \global\expandafter\let\expandafter\Etoc at level\csname Etoc@#1@@\endcsname
 %    \end{macrocode}
 % |\ifEtoc at notactive| set to False by |\etoc at startlocaltoc| with right id. It
@@ -12080,26 +12360,34 @@
 % initialized by |\etoc@@startlocaltoc| as |\ifEtoc at notactive| flag can be
 % false only then.
 %    \begin{macrocode}
-    \ifEtoc at notactive\else
+    \ifEtoc at notactive
+    \else
      \ifnum\Etoc at level>\Etoc at localtop
-      \ifnum\Etoc at level>\c at tocdepth\else
-        \global\Etoc at emptytocfalse
-        \global\Etoc at stoptoctrue
+      \ifnum\Etoc at level>\c at tocdepth
+      \else
+       \global\Etoc at emptytocfalse
+       \global\Etoc at stoptoctrue
       \fi
      \else
       \global\Etoc at stoptoctrue
      \fi
     \fi
-  \fi\fi
+   \fi
+  \fi
   \Etoc at gobblefourorthree\relax
 }
 \def\Etoc at testingcontentsline #1{%
-  \ifEtoc at stoptoc\else
-   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
-    \ifnum\csname Etoc@#1@@\endcsname>\c at tocdepth\else
-       \global\Etoc at emptytocfalse
-       \global\Etoc at stoptoctrue
-  \fi\fi\fi
+  \ifEtoc at stoptoc
+  \else
+   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
+   \else
+    \ifnum\csname Etoc@#1@@\endcsname>\c at tocdepth
+    \else
+     \global\Etoc at emptytocfalse
+     \global\Etoc at stoptoctrue
+    \fi
+   \fi
+  \fi
   \Etoc at gobblefourorthree\relax
 }
 %    \end{macrocode}
@@ -12106,7 +12394,7 @@
 % |1.07g| suppresses the printing of |--unknown etoc ref: run latex again--| as
 % sometimes one uses \csa{localtableofcontents} to prepare something else, and one
 % does not want any text output even in intermediate runs.
-% 
+%
 % Also |1.07g| adds \csa{etocaftertochook} to help with
 % \csa{invisiblelocaltableofcontents} (and then I did \csa{etocsetnexttocdepth}).
 % |1.07h| makes the hook used by \csa{etocsetnexttocdepth} private.
@@ -12188,7 +12476,7 @@
     \global\Etoc at emptytocfalse
     \edef\Etoc at tocid{#1}%
     \ifnum\Etoc at tocid<\@ne
-      %\PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}% 
+      %\PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}%
       \setbox0\hbox{\ref{etoc-ref \@secondoftwo#1: run LaTeX again!}}%
       %\if at filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
       \global\Etoc at stoptoctrue % do only heading
@@ -12202,7 +12490,7 @@
     \ifEtoc at checksemptiness \Etoc at setemptytocbool \fi
     \ifEtoc at emptytoc
        \ifEtoc at notactive
-         %\PackageWarning{etoc}{Unknown toc ID \number\Etoc at tocid. Run LaTeX again}% 
+         %\PackageWarning{etoc}{Unknown toc ID \number\Etoc at tocid. Run LaTeX again}%
          \setbox0\hbox{\ref{etoc-id \number\Etoc at tocid: run LaTeX again!}}%
          %\if at filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
          \global\Etoc at emptytocfalse % assume real one will be non-empty
@@ -12210,7 +12498,7 @@
          \Etoc at tableofcontents
          \expandafter\expandafter\expandafter\Etoc at gobbletoetoc@
        \else
-       %%  \PackageWarning{etoc}{This toc is apparently empty}% 
+       %%  \PackageWarning{etoc}{This toc is apparently empty}%
        \fi
     \else
        \global\Etoc at stoptocfalse
@@ -12226,7 +12514,7 @@
 }
 %    \end{macrocode}
 % |2013/03/07|: I discover a \csa{@namedef} trick to construct the
-% \csa{Etoc at again} space delimited macro:\\ 
+% \csa{Etoc at again} space delimited macro:\\
 % |    \@namedef {Etoc at again} {...stuff...}|\\
 %  Original version was (copied from analogous stuff in |source2e|):\\
 % |    {\def\1{\Etoc at again}\expandafter\gdef\1 {...stuff...}}|\\
@@ -12279,7 +12567,7 @@
     \Etoc at tableofcontents
     \endgroup\ifEtoc at mustclosegroup\endgroup\fi
     \Etoc at tocdepthreset % 1.07h, renamed 1.08h
-    \etocaftertochook   % 1.07g 
+    \etocaftertochook   % 1.07g
     \@gobble\etoc@
     }
 %    \end{macrocode}
@@ -12296,7 +12584,7 @@
 % could turn the TOC into a local one. Handled by |\Etoc at t@bleofcontents|.
 %    \begin{macrocode}
 \def\Etoc at table@fcontents{%
-    \refstepcounter{etoc at tocid}% 
+    \refstepcounter{etoc at tocid}%
     \Etoc at tocwithidfalse
     \futurelet\Etoc at nexttoken\Etoc at t@bleofcontents}
 \def\Etoc at localtable@fcontents{%
@@ -12309,7 +12597,7 @@
 % brutal doings of some packages with |\tableofcontents|.
 %
 % |1.08| patches |tableof|'s influence. Version |1.4a| or later of |tableof|
-% is needed. 
+% is needed.
 %    \begin{macrocode}
 \let\etocaftertitlehook    \@empty
 \let\etocaftercontentshook \@empty
@@ -12388,14 +12676,17 @@
     \etocbeforetitlehook % 1.07m
     \Etoc at storetocdepth % 1.07g
     \let\Etoc at savedcontentsline\contentsline % moved up here 1.08
-    \let\contentsline\Etoc at etoccontentsline 
+    \let\contentsline\Etoc at etoccontentsline
     \ifEtoc at standard
     \else % moved here from \Etoc at toctoc (1.08)
-        \def\Etoc at levellist@elt####1{\let####1\Etoc at lxyz}%
+        \def\Etoc at levellist@elt####1{%
+            \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname
+                            \csname l@####1\endcsname
+            \expandafter\let\csname l@####1\endcsname\Etoc at lxyz}%
         \Etoc at levellist
-        \let\booknumberline\numberline
-        \let\partnumberline\numberline
-        \let\chapternumberline\numberline
+%    \end{macrocode}
+% |1.08k| removes |\let\chapternumberline\numberline| etc... done formerly here
+%    \begin{macrocode}
     \fi
     #1%
     \ifEtoc at parskip\parskip\z at skip\fi %1.07d
@@ -12412,7 +12703,7 @@
     \ifx\Etoc at global\global\ifx\tof at finish\@empty\else
         \global\let\contentsline\Etoc at savedcontentsline
     \fi\fi
-    \@gobble\etoc@ 
+    \@gobble\etoc@
 }% end of \Etoc at tableofcontents definition by \etocsettocstyle
 }
 %    \end{macrocode}
@@ -12468,7 +12759,7 @@
 \def\etocminustworightmargin {1.5em plus -0.5fil}
 \def\etocminusoneleftmargin  {1em}
 \def\etocminusonerightmargin {1em}
-\def\etoctoclineleaders 
+\def\etoctoclineleaders
         {\hbox{\normalfont\normalsize\hb at xt@2ex {\hss.\hss}}}
 \def\etocabbrevpagename {p.~}
 %    \end{macrocode}
@@ -12497,15 +12788,15 @@
 % package. Actually I am not fully satisfied with these line styles.
 %
 %    \begin{macrocode}
-\def\etocdefaultlines{\Etoc at standardfalse % 
+\def\etocdefaultlines{\Etoc at standardfalse %
 %% `book':
 \etoc at setstyle{@minustwo}
   {\addpenalty\@M\etocskipfirstprefix}
   {\addpenalty\@secpenalty}
-  {\begingroup 
+  {\begingroup
    \etocfontminustwo
    \addvspace{\etocsepminustwo}%
-   \parindent \z@ 
+   \parindent \z@
    \leftskip  \etocminustwoleftmargin
    \rightskip \etocminustworightmargin
    \parfillskip \@flushglue
@@ -12519,10 +12810,10 @@
 \etoc at setstyle{@minusone}
   {\addpenalty\@M\etocskipfirstprefix}
   {\addpenalty\@secpenalty}
-  {\begingroup 
+  {\begingroup
    \etocfontminusone
    \addvspace{\etocsepminusone}%
-   \parindent \z@ 
+   \parindent \z@
    \leftskip  \etocminusoneleftmargin
    \rightskip \etocminusonerightmargin
    \parfillskip \@flushglue
@@ -12536,10 +12827,10 @@
 \etoc at setstyle{@zero}
   {\addpenalty\@M\etocskipfirstprefix}
   {\addpenalty\@itempenalty}
-  {\begingroup 
+  {\begingroup
    \etocfontzero
    \addvspace{\etocsepzero}%
-   \parindent \z@ \parfillskip \@flushglue 
+   \parindent \z@ \parfillskip \@flushglue
    \vbox{\etocifnumbered{\etocnumber.\enspace}{}\etocname
          \baselineskip\etocbaselinespreadzero\baselineskip
          \par}%
@@ -12552,7 +12843,7 @@
   {\begingroup
    \etocfontone
    \addvspace{\etocsepone}%
-   \parindent \z@ \parfillskip \z@ 
+   \parindent \z@ \parfillskip \z@
    \setbox\z@\vbox{\parfillskip\@flushglue
                    \etocname\par
                    \setbox\tw@\lastbox
@@ -12571,16 +12862,16 @@
              \par}% 1.08b adds the % here
    \else
        \vbox{\etocname~%
-             \leaders\copy\z@\hfil\break 
+             \leaders\copy\z@\hfil\break
              \hbox{}\leaders\box\z@\hfil\box\tw@
              \baselineskip\etocbaselinespreadone\baselineskip
-             \par}% 
+             \par}%
    \fi
    \endgroup}
   {\addpenalty\@secpenalty\addvspace{\etocsepzero}}%
 %% `subsection':
 \etoc at setstyle{@two}
-  {\addpenalty\@medpenalty\etocskipfirstprefix} 
+  {\addpenalty\@medpenalty\etocskipfirstprefix}
   {\addpenalty\@itempenalty}
   {\begingroup
    \etocfonttwo
@@ -12603,7 +12894,7 @@
              \par}%
    \else
        \vbox{\etocname~%
-             \leaders\copy\z@\hfil\break 
+             \leaders\copy\z@\hfil\break
              \hbox{}\leaders\box\z@\hfil\box\tw@
              \baselineskip\etocbaselinespreadtwo\baselineskip
              \par}%
@@ -12636,7 +12927,7 @@
 % and |\etocabovetocskip|, I guess, but if I am remember correctly I chose them
 % to mimick the standard TOC spacings in |article| class.
 %    \begin{macrocode}
-\def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} 
+\def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex}
 \def\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex}
 \def\etoccolumnsep{2em}
 \def\etocmulticolsep{0ex}
@@ -12717,7 +13008,7 @@
         \begin{multicols}{#1}[\etoc at ruledheading{#2}]}
        {\etoc at ruledheading{#2}%
          \pretolerance\etocmulticolpretolerance
-         \tolerance\etocmulticoltolerance}} 
+         \tolerance\etocmulticoltolerance}}
    {\ifnum #1>\@ne\expandafter\@firstofone
          \else \expandafter\@gobble
     \fi
@@ -12746,8 +13037,8 @@
     \dimen\z@\dp\z@
         \ifdim\wd\z@<\linewidth \dp\z@\z@ \else \dimen\z@\z@ \fi
     \setbox\etoc at framed@titlebox=\hb at xt@\linewidth{\color at begingroup
-        \hss 
-        \ifx\etocbkgcolorcmd\Etoc at relax\else 
+        \hss
+        \ifx\etocbkgcolorcmd\Etoc at relax\else
             \sbox\tw@{\color{white}%
             \vrule\@width\wd\z@\@height\ht\z@\@depth\dimen\z@}%
             \ifdim\wd\z@<\linewidth \dp\tw@\z@\fi
@@ -12778,7 +13069,7 @@
         \multicoltolerance\etocmulticoltolerance
         \setlength{\columnsep}{\etoccolumnsep}%
         \setlength{\multicolsep}{\etocmulticolsep}%
-        \begin{multicols}{#1}}  
+        \begin{multicols}{#1}}
         {\pretolerance\etocmulticolpretolerance
          \tolerance\etocmulticoltolerance}}
     {\ifnum #1>\@ne\expandafter\@firstofone
@@ -12796,9 +13087,9 @@
             \hb at xt@\linewidth{\color at begingroup
             \etocleftrulecolorcmd\etocleftrule
             \etocbkgcolorcmd
-            \leaders\vrule 
-                   \@height\ht\etoc at framed@contentsbox 
-                   \@depth\dp\etoc at framed@contentsbox 
+            \leaders\vrule
+                   \@height\ht\etoc at framed@contentsbox
+                   \@depth\dp\etoc at framed@contentsbox
             \hss
             \etocrightrulecolorcmd\etocrightrule
             \color at endgroup}\nointerlineskip
@@ -12901,7 +13192,7 @@
 %    \begin{macrocode}
 \def\etocarticlestyle{%
     \etocsettocstyle
-    {\section *{\contentsname 
+    {\section *{\contentsname
                 \@mkboth {\MakeUppercase \contentsname}
                          {\MakeUppercase \contentsname}}}
     {}}
@@ -12914,14 +13205,14 @@
 %    \begin{macrocode}
 \def\etocbookstyle{%
     \etocsettocstyle
-    {\if at twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi 
-     \chapter *{\contentsname 
+    {\if at twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
+     \chapter *{\contentsname
                 \@mkboth {\MakeUppercase \contentsname}
                          {\MakeUppercase \contentsname}}}
     {\if at restonecol \twocolumn \fi}}
 \def\etocbookstylenomarks{%
     \etocsettocstyle
-    {\if at twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi 
+    {\if at twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi
      \chapter *{\contentsname}}
     {\if at restonecol \twocolumn \fi}}
 \let\etocreportstyle\etocbookstyle
@@ -12950,16 +13241,16 @@
               {\if at twocolumn \aftergroup \twocolumn \onecolumn \fi }}
              {}%
 %    \end{macrocode}
-% |1.07k|: next line to do as within current |scrartcl 2013/12/19 v3.12| 
+% |1.07k|: next line to do as within current |scrartcl 2013/12/19 v3.12|
 % KOMA-Script article class.
 %    \begin{macrocode}
          \iftocfeature {toc}{numberline}{\def \nonumberline {\numberline {}}}{}%
          \tocbasic at listhead {\listoftocname}%
-         \begingroup \expandafter \expandafter \expandafter 
-         \endgroup \expandafter 
-         \ifx 
-             \csname microtypesetup\endcsname \relax 
-         \else 
+         \begingroup \expandafter \expandafter \expandafter
+         \endgroup \expandafter
+         \ifx
+             \csname microtypesetup\endcsname \relax
+         \else
              \iftocfeature {toc}{noprotrusion}{}
                  {\microtypesetup {protrusion=false}%
                   \PackageInfo {tocbasic}%
@@ -12967,10 +13258,10 @@
          \fi
          \setlength {\parskip }{\z@ }%
          \setlength {\parindent }{\z@ }%
-         \setlength {\parfillskip }{\z@ \@plus 1fil}% 
+         \setlength {\parfillskip }{\z@ \@plus 1fil}%
          \csname tocbasic@@before at hook\endcsname
          \csname tb at toc@before at hook\endcsname}
-        {\csname tb at toc@after at hook\endcsname 
+        {\csname tb at toc@after at hook\endcsname
          \csname tocbasic@@after at hook\endcsname}}
 \let\etocscrbookstyle\etocscrartclstyle
 \let\etocscrreprtstyle\etocscrartclstyle
@@ -13037,7 +13328,7 @@
 %have the |\if at cftnctoc| boolean.
 %    \begin{macrocode}
 \def\etoctocloftstyle {%
-    \etocsettocstyle 
+    \etocsettocstyle
     {\@cfttocstart\par\begingroup
       \parindent\z@ \parskip\cftparskip \@cftmaketoctitle
       \if at cfttocbibind\@cftdobibtoc\fi }%
@@ -13053,7 +13344,7 @@
       {\@ifpackageloaded{tocloft}
        {\if at cftnctoc\else
          \PackageWarning {etoc}
-         {Package `tocloft' was loaded after `etoc'!^^J% 
+         {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'}%
@@ -13069,11 +13360,11 @@
 %    \begin{macrocode}
 \def\Etoc at addtocontents #1#2%
     {\ifEtoc at hyperref
-       \addtocontents {toc}{\protect\contentsline 
+       \addtocontents {toc}{\protect\contentsline
                 {#1}{#2}%
                 {\thepage }{\@currentHref }}%
      \else
-       \addtocontents {toc}{\protect\contentsline 
+       \addtocontents {toc}{\protect\contentsline
           {#1}{#2}{\thepage }}%
      \fi}
 \def\Etoc at addcontentsline@ #1#2#3%
@@ -13084,12 +13375,12 @@
 %    \end{macrocode}
 % All the following added for version |1.07g [2013/10/13]|. Motivated by
 % a demand about  |tovsec2|. But it is impossible to make |tocvsec2|
-% compatible, if not re-doing all `toc' macros in |tocvsec2| 
+% compatible, if not re-doing all `toc' macros in |tocvsec2|
 % (|v1.3, 2011/08/07|). I do not retain the stack idea, which does not convince
 % me as useful. The empty line in the |.toc| file is put there by
-% |tocvsec2| (see its code line 143). 
-% 
-% I take this opportunity to add to the start of the toc file 
+% |tocvsec2| (see its code line 143).
+%
+% I take this opportunity to add to the start of the toc file
 % |\let\etoc at startlocaltoc\@gobble| in case |etoc| is not detected, I should
 % possibly have done that long ago (like I did in |tableof|).
 %
@@ -13110,11 +13401,11 @@
 %    \begin{macrocode}
 \def\Etoc at storetocdepth {\global\c at etoc@tocdepth\c at tocdepth }
 \def\Etoc at resettocdepth {\global\c at tocdepth\c at etoc@tocdepth }
-\def\etocobeytoctocdepth {\def\etoc at settocdepth 
+\def\etocobeytoctocdepth {\def\etoc at settocdepth
         {\afterassignment\Etoc@@nottoodeep \global\c at tocdepth}}
 \def\Etoc@@nottoodeep {\ifnum\c at tocdepth>\c at etoc@tocdepth
                           \global\c at tocdepth\c at etoc@tocdepth\fi }
-\def\etocignoretoctocdepth {\let\etoc at settocdepth\@gobble } 
+\def\etocignoretoctocdepth {\let\etoc at settocdepth\@gobble }
 \def\etocsettocdepth   {\futurelet\Etoc at nexttoken\Etoc at set@tocdepth }
 \def\Etoc at set@tocdepth {\ifx\Etoc at nexttoken\bgroup
                             \expandafter\Etoc at set@tocdepth@
@@ -13130,15 +13421,15 @@
   \@ifundefined{Etoc@#1@@}%
    {\PackageWarning{etoc}
         {Unknown sectioning depth #1, \protect\etocsettocdepth.toc ignored}}%
-   {\addtocontents {toc}      
-   {\protect\etoc at settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}% 
+   {\addtocontents {toc}
+   {\protect\etoc at settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}%
 }
 %    \end{macrocode}
 % |1.07h| adds the depth tags, and an even more general mechanism could be added
 % at some point: we could insert `action' tags and have the user map them to
-% arbitrary commands. For the time being we just provide 
+% arbitrary commands. For the time being we just provide
 % |\etocdepthtag.toc {name}| and |\etocsettagdepth {tag_name}{level}| where
-% level is numeric or 
+% level is numeric or
 % alphabetical. The numeric
 % level |-3| is now again not accepted by |\etocsetlevel|, it can be used with
 % |\etocsettagdepth| (which accepts equivalently |none|).
@@ -13165,7 +13456,7 @@
 % downgrades it from warning to info).
 %    \begin{macrocode}
 \def\Etoc at tocvsec@err #1{\PackageError {etoc}
-        {the command \protect#1\space is incompatible with etoc} 
+        {the command \protect#1\space is incompatible with etoc}
         {use \protect\etocsettocdepth.toc as replacement (see etoc manual)}%
 }%
 \AtBeginDocument {%
@@ -13174,7 +13465,7 @@
      {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\etocsettocdepth\space and
      \protect\etocsetnexttocdepth^^J should replace
      use of memoir's \protect\maxtocdepth\space command.}}
     {\@ifpackageloaded {tocvsec2}
@@ -13185,12 +13476,12 @@
                           }%
       \def\save at tocdepth #1#2#3{}%    % if etoc is added to file previously
       \let\reset at tocdepth\relax       % using tocvsec2
-      \let\remax at tocdepth\relax   
+      \let\remax at 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 
+       \protect\etocsettocdepth.toc as a replacement^^J
        for the tocvsec2 toc-related commands}}{}%
    }%
 }%
@@ -13203,7 +13494,7 @@
 % the actual TOC typesetting.
 %    \begin{macrocode}
 \def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }%
-\def\invisiblelocaltableofcontents 
+\def\invisiblelocaltableofcontents
                          {\etocsetnexttocdepth {-3}\localtableofcontents }%
 \def\etocsetnexttocdepth #1{%
     \@ifundefined{Etoc@#1@@}
@@ -13217,13 +13508,61 @@
            \global\let\Etoc at tocdepthset\@empty}}%
 }%
 %    \end{macrocode}
+% |1.08k|. Serves to make local TOCs even after headings which were not added
+% to the |.toc| file; but of course the local TOCs can only display
+% sub-headings which made their way into the |.toc| file...
+%    \begin{macrocode}
+\def\etocsetlocaltop #1#{\Etoc at set@localtop}%
+\def\Etoc at set@localtop #1{%
+  \@ifundefined{Etoc@#1@@}%
+   {\PackageWarning{etoc}
+        {Unknown sectioning depth #1, \protect\etocsetlocaltop.toc ignored}}%
+   {\addtocontents {toc}
+   {\protect\etoc at setlocaltop\expandafter\protect\csname Etoc@#1@@\endcsname}}%
+}%
+\def\etoc at setlocaltop #1{%
+  \global\let\Etoc at level #1%
+  \Etoc at skipthisonefalse
+  \ifnum\Etoc at level=\Etoc@@six@@
+   \Etoc at skipthisonetrue
+  \else
+   \ifEtoc at localtoc
+    \ifEtoc at stoptoc\Etoc at skipthisonetrue
+    \else
+     \ifEtoc at notactive
+      \Etoc at setflags
+      \Etoc at skipthisonetrue
+     \else
+      \ifnum\Etoc at level<\Etoc at localtop
+       \Etoc at skipthisonetrue
+       \global\Etoc at stoptoctrue
+      \fi
+     \fi
+    \fi
+   \fi
+  \fi
+  \let\Etoc at next\@gobble
+  \ifEtoc at skipthisone
+  \else
+   \ifnum\c at tocdepth<\Etoc at level
+   \else
+    \ifEtoc at standard
+    \else
+     \let\Etoc at next\@firstofone
+    \fi
+   \fi
+  \fi
+  \Etoc at next{\Etoc at doends\Etoc at dobegins}%
+}%
+%    \end{macrocode}
 % |1.07h|. In order for the |.toc| file to be usable without error even
 % without etoc. In |1.07i| use of |\@gobble| for |\etoc at settocdepth|.
 %    \begin{macrocode}
 \addtocontents {toc}{\protect\@ifundefined{etoctocstyle}%
-           {\let\protect\etoc at startlocaltoc\protect\@gobble 
+           {\let\protect\etoc at startlocaltoc\protect\@gobble
             \let\protect\etoc at settocdepth\protect\@gobble
-            \let\protect\etoc at depthtag\protect\@gobble }{}}%
+            \let\protect\etoc at depthtag\protect\@gobble
+            \let\protect\etoc at setlocaltop\protect\@gobble}{}}%
 %    \end{macrocode}
 % Initializations.
 %    \begin{macrocode}
@@ -13230,9 +13569,9 @@
 \def\etocstandardlines {\Etoc at standardtrue}
 \def\etoctoclines      {\Etoc at standardfalse}
 \etocdefaultlines
-\etocstandardlines 
+\etocstandardlines
 \etocstandarddisplaystyle
-\etocobeytoctocdepth 
+\etocobeytoctocdepth
 \etocobeydepthtags
 \let\Etoc at tocdepthreset\@empty % new 1.08h functioning of \etocsetnexttocdepth
 \let\Etoc at tocdepthset  \@empty %
@@ -13257,7 +13596,7 @@
   Grave accent  \`     Left brace    \{     Vertical bar  \|
   Right brace   \}     Tilde         \~}
 
-\CheckSum{3210}%
+\CheckSum{3309}%
 
 \csname check at checksum\endcsname
 \Finale

Modified: trunk/Master/texmf-dist/source/latex/etoc/etoc.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/etoc/etoc.ins	2017-09-29 10:47:32 UTC (rev 45428)
+++ trunk/Master/texmf-dist/source/latex/etoc/etoc.ins	2017-09-29 20:37:58 UTC (rev 45429)
@@ -1,6 +1,6 @@
 %%
 %% Package: etoc
-%% Version: 1.08j-2017/09/21
+%% Version: 1.08k-2017/09/28
 %% License: LPPL 1.3c
 %% Copyright (C) 2012-2017 Jean-Francois Burnol
 %%                         <jfbu at free dot fr>
@@ -8,9 +8,9 @@
 %%                         <Christine_Roemer at t-online dot de>
 %% and collaborators for the translation into German of the documentation
 %%
-\def\etocpkgdate        {2017/09/21}
-\def\etocdocdate        {2017/09/21}
-\def\etocpkgversion     {v1.08j}
+\def\etocpkgdate        {2017/09/28}
+\def\etocdocdate        {2017/09/28}
+\def\etocpkgversion     {v1.08k}
 \def\etocpkgdescription {Completely customisable TOCs (JFB)}
 %% Run etex on this file to extract from etoc.dtx:
 %%        etoc.sty, etoc.tex, etoc-DE.tex and README.md

Modified: trunk/Master/texmf-dist/tex/latex/etoc/etoc.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/etoc/etoc.sty	2017-09-29 10:47:32 UTC (rev 45428)
+++ trunk/Master/texmf-dist/tex/latex/etoc/etoc.sty	2017-09-29 20:37:58 UTC (rev 45429)
@@ -23,10 +23,10 @@
 %%
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{etoc}
- [2017/09/21 v1.08j Completely customisable TOCs (JFB)]
+ [2017/09/28 v1.08k Completely customisable TOCs (JFB)]
 %%
 %% Package: etoc
-%% Version: 1.08j-2017/09/21
+%% Version: 1.08k-2017/09/28
 %% License: LPPL 1.3c
 %% Copyright (C) 2012-2017 Jean-Francois Burnol
 %%                         <jfbu at free dot fr>
@@ -107,10 +107,10 @@
 \let\Etoc at none@@  \Etoc at minf
 \let\Etoc at levellist\@empty
 \def\Etoc at newlevel #1{\expandafter\def\expandafter\Etoc at levellist\expandafter
-        {\Etoc at levellist\Etoc at levellist@elt #1}}
+        {\Etoc at levellist\Etoc at levellist@elt{#1}}}
 \def\etocsetlevel#1#2{%
- \@ifundefined{Etoc@#1@@}{\expandafter\Etoc at newlevel\csname l@#1\endcsname}{}%
- \ifcase#2\relax
+   \@ifundefined{Etoc@#1@@}{\Etoc at newlevel{#1}}{}%
+   \ifcase#2\relax
       \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
       \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@
    \or
@@ -131,19 +131,22 @@
    \or
       \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@
    \else
-   \ifnum#2=\m at ne
-      \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@
-      \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@
-   \else
-   \ifnum#2=-\tw@
+    \ifnum#2=\m at 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}
+     \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}
+      \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@
+     \fi
+    \fi
+   \fi
+}
 \etocsetlevel{book}{-2}
 \etocsetlevel{part}{-1}
 \etocsetlevel{chapter}{0}
@@ -161,81 +164,131 @@
                             \long\def\Etoc at gobblefourorthree#1#2#3{}}%
 }
 \def\Etoc at setflags {%
-  \ifcase \Etoc at level
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iifalse
-      \global\Etoc at ifalse
-      \global\Etoc at true
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iifalse
-      \global\Etoc at itrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiifalse
-      \global\Etoc at iitrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivfalse
-      \global\Etoc at iiitrue
-  \or
-      \global\Etoc at vfalse
-      \global\Etoc at ivtrue
-  \or
-      \global\Etoc at vtrue
-  \else
-    \global\Etoc at vfalse
-    \global\Etoc at ivfalse
-    \global\Etoc at iiifalse
-    \global\Etoc at iifalse
-    \global\Etoc at ifalse
-    \global\Etoc at false
-    \ifnum\Etoc at level=\m at ne
-      \global\Etoc at jtrue
+    \ifcase \Etoc at level
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at ifalse
+        \global\Etoc at true
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at itrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iitrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiitrue
+    \or
+        \global\Etoc at vfalse
+        \global\Etoc at ivtrue
+    \or
+        \global\Etoc at vtrue
     \else
-      \global\Etoc at jfalse
-      \global\Etoc at jjtrue
+        \global\Etoc at vfalse
+        \global\Etoc at ivfalse
+        \global\Etoc at iiifalse
+        \global\Etoc at iifalse
+        \global\Etoc at ifalse
+        \global\Etoc at false
+        \ifnum\Etoc at level=\m at ne
+            \global\Etoc at jtrue
+        \else
+            \global\Etoc at jfalse
+            \global\Etoc at jjtrue
+        \fi
     \fi
-  \fi}
+}
 \def\Etoc at doends {%
     \ifcase \Etoc at level
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
-        \ifEtoc at ii \Etoc at end@two\fi
-        \ifEtoc at i  \Etoc at end@one\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
+        \ifEtoc at i  \Etoc at end@one  \fi
     \or
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
-        \ifEtoc at ii \Etoc at end@two\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
     \or
-        \ifEtoc at v  \Etoc at end@five\fi
-        \ifEtoc at iv \Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
         \ifEtoc at iii\Etoc at end@three\fi
     \or
-        \ifEtoc at v \Etoc at end@five\fi
-        \ifEtoc at iv\Etoc at end@four\fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
     \or
-        \ifEtoc at v \Etoc at end@five\fi
+        \ifEtoc at v  \Etoc at end@five \fi
     \or
     \else
-      \ifEtoc at v  \Etoc at end@five \fi
-      \ifEtoc at iv \Etoc at end@four \fi
-      \ifEtoc at iii\Etoc at end@three\fi
-      \ifEtoc at ii \Etoc at end@two  \fi
-      \ifEtoc at i  \Etoc at end@one  \fi
-      \ifEtoc@   \Etoc at end@zero \fi
-      \ifnum \Etoc at level =-\tw@
-        \ifEtoc at j \Etoc at end@minusone\fi
-      \fi
+        \ifEtoc at v  \Etoc at end@five \fi
+        \ifEtoc at iv \Etoc at end@four \fi
+        \ifEtoc at iii\Etoc at end@three\fi
+        \ifEtoc at ii \Etoc at end@two  \fi
+        \ifEtoc at i  \Etoc at end@one  \fi
+        \ifEtoc@   \Etoc at end@zero \fi
+        \ifnum \Etoc at level =-\tw@
+            \ifEtoc at j \Etoc at end@minusone\fi
+        \fi
     \fi
 }
+\def\Etoc at dobegins{%
+    \let\Etoc at next\@empty
+    \Etoc at global\Etoc at isfirstfalse
+    \ifcase\Etoc at level
+        \ifEtoc@
+        \else
+            \def\Etoc at next{\Etoc at begin@zero}%
+        \fi
+    \or
+        \ifEtoc at i
+        \else
+            \def\Etoc at next{\Etoc at begin@one}%
+        \fi
+    \or
+        \ifEtoc at ii
+        \else
+            \def\Etoc at next{\Etoc at begin@two}%
+        \fi
+    \or
+        \ifEtoc at iii
+        \else
+            \def\Etoc at next{\Etoc at begin@three}%
+        \fi
+    \or
+        \ifEtoc at iv
+        \else
+            \def\Etoc at next{\Etoc at begin@four}%
+        \fi
+    \or
+        \ifEtoc at v
+        \else
+            \def\Etoc at next{\Etoc at begin@five}%
+        \fi
+    \else
+        \ifnum\Etoc at level=\m at ne
+            \ifEtoc at j
+            \else
+                \def\Etoc at next{\Etoc at begin@minusone}%
+            \fi
+        \else
+            \ifEtoc at jj
+            \else
+                \def\Etoc at next{\Etoc at begin@minustwo}%
+            \fi
+        \fi
+    \fi
+    \Etoc at setflags
+    \Etoc at next
+}
 \def\etocskipfirstprefix {\global\Etoc at skipprefixtrue }
 \def\Etoc at etoccontentsline #1{%
   \global\expandafter\let\expandafter\Etoc at level\csname Etoc@#1@@\endcsname
@@ -245,10 +298,12 @@
    \ifEtoc at localtoc
     \ifEtoc at stoptoc\Etoc at skipthisonetrue
     \else
-     \ifEtoc at notactive\Etoc at setflags\Etoc at skipthisonetrue
+     \ifEtoc at notactive\Etoc at setflags
+       \Etoc at skipthisonetrue
      \else
-      \ifnum\Etoc at level<\Etoc at localtop\Etoc at skipthisonetrue
-       \global\Etoc at stoptoctrue
+      \ifnum\Etoc at level<\Etoc at localtop
+        \Etoc at skipthisonetrue
+        \global\Etoc at stoptoctrue
       \fi
      \fi
     \fi
@@ -255,8 +310,10 @@
    \fi
   \fi
   \let\Etoc at next\Etoc at gobblefourorthree
-  \ifEtoc at skipthisone\else
-   \ifnum\c at tocdepth<\Etoc at level\else
+  \ifEtoc at skipthisone
+  \else
+   \ifnum\c at tocdepth<\Etoc at level
+   \else
     \ifEtoc at standard
       \let\Etoc at next\Etoc at savedcontentsline
     \else
@@ -264,33 +321,11 @@
     \fi
    \fi
   \fi
-  \Etoc at next {#1}%
+  \Etoc at next{#1}%
 }
 \def\Etoc at etoccontentsline@ #1{%
-    \Etoc at doends
-    \let\Etoc at next\@empty
-    \Etoc at global\Etoc at isfirstfalse
-    \ifcase\Etoc at level
-        \ifEtoc@\else    \def\Etoc at next{\Etoc at begin@zero}\fi
-    \or
-        \ifEtoc at i\else   \def\Etoc at next{\Etoc at begin@one}\fi
-    \or
-        \ifEtoc at ii\else  \def\Etoc at next{\Etoc at begin@two}\fi
-    \or
-        \ifEtoc at iii\else \def\Etoc at next{\Etoc at begin@three}\fi
-    \or
-        \ifEtoc at iv\else  \def\Etoc at next{\Etoc at begin@four}\fi
-    \or
-        \ifEtoc at v\else   \def\Etoc at next{\Etoc at begin@five}\fi
-    \else
-      \ifnum\Etoc at level=\m at ne
-        \ifEtoc at j\else   \def\Etoc at next{\Etoc at begin@minusone}\fi
-      \else
-        \ifEtoc at jj\else  \def\Etoc at next{\Etoc at begin@minustwo}\fi
-      \fi
-    \fi
-    \Etoc at setflags
-    \Etoc at next
+    \Etoc at doends   % separated since 1.08
+    \Etoc at dobegins % separated since 1.08k. Does \Etoc at setflags.
     \Etoc at global\edef\Etoc at prefix  {\expandafter\noexpand
          \csname Etoc at prefix@\csname Etoc@#1@\endcsname\endcsname }%
     \Etoc at global\edef\Etoc at contents{\expandafter\noexpand
@@ -347,12 +382,17 @@
   \fi\fi
   \Etoc at next #1%
 }
+\begingroup\@tfor\x:=NUMBZRLINZ\do{\catcode\expandafter`\x=12 }\lccode`Z `e
+\lowercase{\endgroup
+\long\def\Etoc at oneifnumberline #1NUMBZRLINZ#2#3\Etoc at next{%
+   \ifx\etoc@#20\else1\fi
+}%
 \def\Etoc at getnb@nohyp #1#2#3\etoc@ {%
     \def\Etoc at getname ##1\relax\relax\etoc@ {%
       \Etoc at global\def\etocthename       {##1}%
       \Etoc at global\def\etocthelinkedname {##1}%
      }%
-  \ifx\numberline#1%
+  \if1\expandafter\Etoc at oneifnumberline\string#1NUMBZRLINZ\etoc@\Etoc at next
     \Etoc at global\def\etocthenumber       {#2}%
     \Etoc at global\def\etocthelinkednumber {#2}%
     \Etoc at global\Etoc at numbertrue
@@ -362,7 +402,7 @@
     \Etoc at global\let\etocthelinkednumber \@empty
     \Etoc at global\Etoc at numberfalse
   \fi
-}
+}%
 \def\Etoc at getnb@hyp #1#2#3#4#5#6\etoc@ {%
          \def\Etoc at getname ##1\relax\relax\etoc@ {%
          \Etoc at global\def\etocthename {##1}%
@@ -371,7 +411,7 @@
                               {\expandafter\hyperlink \Etoc at tmp{##1}}%
          }%
          \def\Etoc at getnbr ##1##2##3\etoc@ {%
-          \ifx\numberline##1%
+          \if1\expandafter\Etoc at oneifnumberline\string##1NUMBZRLINZ\etoc@\Etoc at next
             \Etoc at global\def\etocthenumber {##2}%
             \edef\Etoc at tmp   {{#3}}%
             \Etoc at global\expandafter\def\expandafter\etocthelinkednumber
@@ -390,13 +430,14 @@
          }%
   \Etoc at global\edef\etocthelink ##1{\noexpand\hyperlink {#3}{##1}}%
   \Etoc at getnbr #4\relax\relax\etoc@
-}
+}}
 \def\Etoc at getit@nohyp #1\hspace#2#3\etoc@ {%
     \def\Etoc at getname ##1\hspace\relax\etoc@ {%
        \Etoc at global\def\etocthename       {##1}%
        \Etoc at global\def\etocthelinkedname {##1}%
     }%
-  \ifx\relax#2\else
+  \ifx\relax#2%
+  \else
         \Etoc at global\def\etocthenumber       {#1}%
         \Etoc at global\def\etocthelinkednumber {#1}%
         \Etoc at global\Etoc at numbertrue
@@ -410,7 +451,8 @@
                    \expandafter{\expandafter\hyperlink \Etoc at tmp{##1}}%
     }%
     \def\Etoc at getnbr ##1\hspace##2##3\etoc@ {%
-       \ifx\relax##2\else
+       \ifx\relax##2%
+       \else
          \Etoc at global\def\etocthenumber {##1}%
          \Etoc at global\expandafter\def\expandafter\etocthelinkednumber
                      \expandafter{\expandafter\hyperlink \Etoc at tmp{##1}}%
@@ -476,25 +518,27 @@
   \global\let\Etoc at openouttoc\empty
 }
 \def\Etoc at toctoc{%
-   \global\Etoc at vfalse
-   \global\Etoc at ivfalse
-   \global\Etoc at iiifalse
-   \global\Etoc at iifalse
-   \global\Etoc at ifalse
-   \global\Etoc at false
-   \global\Etoc at jfalse
-   \global\Etoc at jjfalse
-\the\Etoc at toctoks
-\ifEtoc at notactive\else
-  \ifEtoc at v   \Etoc at end@five\fi
-  \ifEtoc at iv  \Etoc at end@four\fi
-  \ifEtoc at iii \Etoc at end@three\fi
-  \ifEtoc at ii  \Etoc at end@two\fi
-  \ifEtoc at i   \Etoc at end@one\fi
-  \ifEtoc@    \Etoc at end@zero\fi
-  \ifEtoc at j   \Etoc at end@minusone\fi
-  \ifEtoc at jj  \Etoc at end@minustwo\fi
-\fi}
+  \global\Etoc at vfalse
+  \global\Etoc at ivfalse
+  \global\Etoc at iiifalse
+  \global\Etoc at iifalse
+  \global\Etoc at ifalse
+  \global\Etoc at false
+  \global\Etoc at jfalse
+  \global\Etoc at jjfalse
+  \the\Etoc at toctoks
+  \ifEtoc at notactive
+  \else
+   \ifEtoc at v   \Etoc at end@five\fi
+   \ifEtoc at iv  \Etoc at end@four\fi
+   \ifEtoc at iii \Etoc at end@three\fi
+   \ifEtoc at ii  \Etoc at end@two\fi
+   \ifEtoc at i   \Etoc at end@one\fi
+   \ifEtoc@    \Etoc at end@zero\fi
+   \ifEtoc at j   \Etoc at end@minusone\fi
+   \ifEtoc at jj  \Etoc at end@minustwo\fi
+  \fi
+}
 \def\etoc@@startlocaltoc#1#2{%
     \ifEtoc at localtoc
         \ifnum #1=#2\relax
@@ -544,28 +588,39 @@
 \expandafter
 \let\expandafter\etocxifwasempty\csname etocifwasempty \endcsname
 \def\Etoc at testingcontentslinelocal #1{%
-  \ifEtoc at stoptoc\else\ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
+  \ifEtoc at stoptoc
+  \else
+   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
+   \else
     \global\expandafter\let\expandafter\Etoc at level\csname Etoc@#1@@\endcsname
-    \ifEtoc at notactive\else
+    \ifEtoc at notactive
+    \else
      \ifnum\Etoc at level>\Etoc at localtop
-      \ifnum\Etoc at level>\c at tocdepth\else
-        \global\Etoc at emptytocfalse
-        \global\Etoc at stoptoctrue
+      \ifnum\Etoc at level>\c at tocdepth
+      \else
+       \global\Etoc at emptytocfalse
+       \global\Etoc at stoptoctrue
       \fi
      \else
       \global\Etoc at stoptoctrue
      \fi
     \fi
-  \fi\fi
+   \fi
+  \fi
   \Etoc at gobblefourorthree\relax
 }
 \def\Etoc at testingcontentsline #1{%
-  \ifEtoc at stoptoc\else
-   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
-    \ifnum\csname Etoc@#1@@\endcsname>\c at tocdepth\else
-       \global\Etoc at emptytocfalse
-       \global\Etoc at stoptoctrue
-  \fi\fi\fi
+  \ifEtoc at stoptoc
+  \else
+   \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
+   \else
+    \ifnum\csname Etoc@#1@@\endcsname>\c at tocdepth
+    \else
+     \global\Etoc at emptytocfalse
+     \global\Etoc at stoptoctrue
+    \fi
+   \fi
+  \fi
   \Etoc at gobblefourorthree\relax
 }
 \def\Etoc at localtableofcontents#1{%
@@ -673,11 +728,11 @@
     \let\contentsline\Etoc at etoccontentsline
     \ifEtoc at standard
     \else % moved here from \Etoc at toctoc (1.08)
-        \def\Etoc at levellist@elt####1{\let####1\Etoc at lxyz}%
+        \def\Etoc at levellist@elt####1{%
+            \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname
+                            \csname l@####1\endcsname
+            \expandafter\let\csname l@####1\endcsname\Etoc at lxyz}%
         \Etoc at levellist
-        \let\booknumberline\numberline
-        \let\partnumberline\numberline
-        \let\chapternumberline\numberline
     \fi
     #1%
     \ifEtoc at parskip\parskip\z at skip\fi %1.07d
@@ -1317,10 +1372,53 @@
            \global\c at tocdepth\csname Etoc@#1@@\endcsname
            \global\let\Etoc at tocdepthset\@empty}}%
 }%
+\def\etocsetlocaltop #1#{\Etoc at set@localtop}%
+\def\Etoc at set@localtop #1{%
+  \@ifundefined{Etoc@#1@@}%
+   {\PackageWarning{etoc}
+        {Unknown sectioning depth #1, \protect\etocsetlocaltop.toc ignored}}%
+   {\addtocontents {toc}
+   {\protect\etoc at setlocaltop\expandafter\protect\csname Etoc@#1@@\endcsname}}%
+}%
+\def\etoc at setlocaltop #1{%
+  \global\let\Etoc at level #1%
+  \Etoc at skipthisonefalse
+  \ifnum\Etoc at level=\Etoc@@six@@
+   \Etoc at skipthisonetrue
+  \else
+   \ifEtoc at localtoc
+    \ifEtoc at stoptoc\Etoc at skipthisonetrue
+    \else
+     \ifEtoc at notactive
+      \Etoc at setflags
+      \Etoc at skipthisonetrue
+     \else
+      \ifnum\Etoc at level<\Etoc at localtop
+       \Etoc at skipthisonetrue
+       \global\Etoc at stoptoctrue
+      \fi
+     \fi
+    \fi
+   \fi
+  \fi
+  \let\Etoc at next\@gobble
+  \ifEtoc at skipthisone
+  \else
+   \ifnum\c at tocdepth<\Etoc at level
+   \else
+    \ifEtoc at standard
+    \else
+     \let\Etoc at next\@firstofone
+    \fi
+   \fi
+  \fi
+  \Etoc at next{\Etoc at doends\Etoc at dobegins}%
+}%
 \addtocontents {toc}{\protect\@ifundefined{etoctocstyle}%
            {\let\protect\etoc at startlocaltoc\protect\@gobble
             \let\protect\etoc at settocdepth\protect\@gobble
-            \let\protect\etoc at depthtag\protect\@gobble }{}}%
+            \let\protect\etoc at depthtag\protect\@gobble
+            \let\protect\etoc at setlocaltop\protect\@gobble}{}}%
 \def\etocstandardlines {\Etoc at standardtrue}
 \def\etoctoclines      {\Etoc at standardfalse}
 \etocdefaultlines



More information about the tex-live-commits mailing list