summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/etoc/etoc.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-09-29 20:34:36 +0000
committerKarl Berry <karl@freefriends.org>2016-09-29 20:34:36 +0000
commit6786e1175d7ca2cad33e03d7bdf74cfb5cc87e13 (patch)
treedd011815bb34cedadaea700c77236b2787d7f626 /Master/texmf-dist/source/latex/etoc/etoc.dtx
parent9e0420d6944dc5399e597a557bf532aa77cdc7d3 (diff)
overlays (29sep16)
git-svn-id: svn://tug.org/texlive/trunk@42182 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/etoc/etoc.dtx')
-rw-r--r--Master/texmf-dist/source/latex/etoc/etoc.dtx416
1 files changed, 293 insertions, 123 deletions
diff --git a/Master/texmf-dist/source/latex/etoc/etoc.dtx b/Master/texmf-dist/source/latex/etoc/etoc.dtx
index 38d77969347..c5f7051eac6 100644
--- a/Master/texmf-dist/source/latex/etoc/etoc.dtx
+++ b/Master/texmf-dist/source/latex/etoc/etoc.dtx
@@ -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: <25-09-2016 at 19:33:27 CEST>}%
+\def\etocdtxtimestamp {Time-stamp: <29-09-2016 at 11:13:23 CEST>}%
%</none>
%<*!readme>
%%
%% Package: etoc
-%% Version: 1.08h-2016/09/25
+%% Version: 1.08i-2016/09/29
%% License: LPPL 1.3c
%% Copyright (C) 2012-2016 Jean-Francois Burnol
%% <jfbu at free dot fr>
@@ -17,14 +17,14 @@
%%
%</!readme>
%<*insfile>
-\def\etocpkgdate {2016/09/25}
-\def\etocdocdate {2016/09/25}
-\def\etocpkgversion {v1.08h}
+\def\etocpkgdate {2016/09/29}
+\def\etocdocdate {2016/09/29}
+\def\etocpkgversion {v1.08i}
\def\etocpkgdescription {Completely customisable TOCs (JFB)}
%</insfile>
%<*none>
-\def\etocDEpkgdate {25.09.2016}
-\def\etocDEdocdate {25.09.2016}
+\def\etocDEpkgdate {29.09.2016}
+\def\etocDEdocdate {29.09.2016}
\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.08h-2016/09/25
+% Version: 1.08i-2016/09/29
% License: LPPL 1.3c
% Copyright (C) 2012-2016 Jean-Francois Burnol <jfbu at free dot fr>
% Copyright (C) 2014-2016 Christine Roemer <Christine_Roemer at t-online dot de>
@@ -69,7 +69,7 @@
%<*readme>
<!-- -->
- Source: etoc.dtx (v1.08h-2016/09/25)
+ Source: etoc.dtx (v1.08i-2016/09/29)
Author: Jean-Francois Burnol
Author: Christine Roemer et al. (German tranlation)
Info: Completely customisable TOCs
@@ -140,8 +140,8 @@ Options can be set in etoc.tex:
- with or without source code,
- with dvipdfmx or with latex+dvips or pdflatex.
-Release 1.08h sets pdflatex as default in etoc.tex (prior it was
-latex+dvipdfmx as it produces smaller PDFs) in order to allow
+Since release 1.08h pdflatex is the default in etoc.tex (prior it
+was latex+dvipdfmx as it produces smaller PDFs) in order to allow
inclusion via the use of package `attachfile` of about 25 code
samples as file attachment annotations.
@@ -185,13 +185,39 @@ etoc.pdf, etoc-DE.pdf, etoc.dvi, etoc-DE.dvi.
RECENT CHANGES
==============
+v1.08i \[2016/09/29\]
+---------------------
+
+This fixes an issue dating back to `1.08e-2015/04/17`: under
+`\etocchecksemptiness` regime, some circumstances (such as adding to
+an already compiled document a `\localtableofcontents` before the
+main `\tableofcontents`) created an "`Undefined control sequence`
+`\Etoc@localtop`" error. Thanks to Denis Bitouzé for reporting the
+problem.
+
+On this occasion, `\etocdoesnotcheckemptiness` has been
+added to unset the flag.
+
+A rather more exotic issue was fixed: the emptiness check for
+local tocs could get confused if the `tocdepth` counter was varying
+in some specific ways from inside the `toc` file.
+
+After adding to a document a `\localtableofcontents`, two LaTeX
+passes are needed for etoc to get a chance to print the
+correct local contents. Formerly, etoc issued a Warning on
+the first pass; it now also induces LaTeX into
+announcing "There were undefined references", as this is nearer
+to the end of the log file and console output.
+
+
v1.08h \[2016/09/25\]
---------------------
New functioning of `\etocsetnexttocdepth`: the tocdepth counter is
-modified only at the time of the table of contents, not before.
-This fixes an issue which arose when `\etocsetnexttocdepth` was used
-multiple times with no intervening table of contents.
+modified only at the time of the table of contents, not before. This
+fixes an issue which arose when `\etocsetnexttocdepth` was used
+multiple times with no intervening table of contents. Thanks to
+Denis Bitouzé for reporting the problem.
The PDF documentation includes about 25 LaTeX code snippets also
as file attachment annotations, additionally to their verbatim
@@ -299,8 +325,8 @@ Thanks to Christine Römer!
%% - with or without source code,
%% - with dvipdfmx or with latex/pdflatex.
%%
-%% Release 1.08h sets pdflatex as default in etoc.tex (prior it was
-%% latex+dvipdfmx as it produces smaller PDFs) in order to allow
+%% Since release 1.08h pdflatex is the default in etoc.tex (prior it
+%% was latex+dvipdfmx as it produces smaller PDFs) in order to allow
%% inclusion via the use of package `attachfile` of about 25 code
%% samples as file attachment annotations.
%%
@@ -2013,7 +2039,7 @@ The simplest course is thus to have after |\begin{document}| and before the
typeset, this could break the correct restoring of the |tocdepth| counter
after the TOC. Starting with |1.08h|, the |tocdepth| counter is modified
only at the time the TOC is typeset, not earlier, thus fixing that
- issue.\footnote{Thanks to D.B. for signaling the problem.}
+ issue.\footnote{Thanks to Denis \textsc{Bitouzé} for signaling the problem.}
%
\subsection{The hyperref option \emph{bookmarksdepth}}
@@ -2043,7 +2069,7 @@ systematically and there was no need for |bookmarksdepth=3| anymore.
\label{etocsettocdepth.toc}
This command \csb{etocsettocdepth.toc} implements some functionality of
-|tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. I thank D.B. for drawing
+|tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. I thank Denis \textsc{Bitouzé} for drawing
my attention to the incompatibility of this package with \etoc.}, a package
which however was incompatible with \etoc (it can still be used for its
|secnumdepth|-related commands, but its |toc|-related activities will get
@@ -2186,6 +2212,12 @@ the scope of the local table of contents --- empty line styles by themselves do
not make the TOC empty. \etoc always executes the \csb{etocaftertochook}
command; and the test for emptiness itself executes everything else found in
the |.toc| file. See \autoref{sec:addingtotoc} in this context.
+\begin{enumerate}
+\item the \csb{etocifwasempty} command discussed below can be used from inside
+\csb{etocaftertochook}.
+\item there is no \csa{etocdoesnotcheckemptiness} but if there was one
+it would do |\makeatletter\Etoc@checksemptinessfalse\makeatother|.
+\end{enumerate}
The suppression of the heading (more precisely of the toc display style
elements) may be effective only for the final \LaTeX{} runs. For example in
@@ -2334,15 +2366,19 @@ the \etoc compatibility mode does respect the customizing done via the
class commands.} The original was invisibly defined with a label at the
beginning of \autoref{part:globalcmds}.
\begin{verbatim}
+\begingroup % to keep in particular toc=left with local effect
\KOMAoptions{toc=left}
\etocstandarddisplaystyle % necessary for the display to obey toc=left
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
+\endgroup
\end{verbatim}
+\begingroup
\KOMAoptions{toc=left}
\etocstandarddisplaystyle
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
+\endgroup
\section{Another compatibility mode}\label{sec:anothercompat}
@@ -4133,7 +4169,7 @@ Notes:
\label{etocpage}
Let us explain how \etoc was used to produce the table of
-contents displayed at the beginning of this second part.
+contents displayed at the beginning of this \autoref{part:linestyles}.
This
is a local table of contents, and we used the command \localtoc.
@@ -6722,7 +6758,7 @@ Der einfachste Weg ist also, eine einfache Instanz des
typeset, this could break the correct restoring of the |tocdepth| counter
after the TOC. Starting with |1.08h|, the |tocdepth| counter is modified
only at the time the TOC is typeset, not earlier, thus fixing that
- issue.\footnote{Thanks to D.B. for signaling the problem.}
+ issue.\footnote{Thanks to Denis \textsc{Bitouzé} for signaling the problem.}
\end{otherlanguage}
\subsection{Die hyperref"=Option \emph{bookmarksdepth}}
@@ -6752,7 +6788,7 @@ jetzt zu dem Paket hinzugefügt wurde, ist keine Verwendung mehr für
\label{etocsettocdepth.toc}
Dieser Befehl \csb{etocsettocdepth.toc} implementiert einige Funktionalitäten
-von Paket |tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. Ich danke D.B.
+von Paket |tocvsec2|\footnote{\url{http://ctan.org/pkg/tocvsec2}. Ich danke Denis \textsc{Bitouzé}
meine Aufmerksamkeit auf die Inkompatibilität dieses Pakets mit \etoc
gerichtet zu haben.}. Dieses Paket war inkompatibel mit \etoc. Es kann nun
noch für seine mit |secnumdepth| in Verbindung stehenden Befehle genutzt werden,
@@ -6904,6 +6940,12 @@ the scope of the local table of contents --- empty line styles by themselves do
not make the TOC empty. \etoc always executes the \csb{etocaftertochook}
command; and the test for emptiness itself executes everything else found in
the |.toc| file. See \autoref{sec:addingtotoc} in this context.
+\begin{enumerate}
+\item the \csb{etocifwasempty} command discussed below can be used from inside
+\csb{etocaftertochook}.
+\item there is no \csa{etocdoesnotcheckemptiness} but if there was one
+it would do |\makeatletter\Etoc@checksemptinessfalse\makeatother|.
+\end{enumerate}
The suppression of the heading (more precisely of the toc display style
elements) may be effective only for the final \LaTeX{} runs. For example in
@@ -7049,15 +7091,19 @@ Klassenbefehle umsetzt.} Das ursprüngliche Inhaltsverzeichnis ist
unsichtbar und wurde am Anfang von \autoref{part:globalcmds} definiert,
wobei es mit einem Label versehen wurde.
\begin{verbatim}
+\begingroup % to keep in particular toc=left with local effect
\KOMAoptions{toc=left}
\etocstandarddisplaystyle % wird benötigt, damit toc=left gilt
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
+\endgroup
\end{verbatim}
+\begingroup
\KOMAoptions{toc=left}
\etocstandarddisplaystyle
\etocstandardlines
\tableofcontents \ref{toc:globalcmds}
+\endgroup
\section{Ein weiterer Kompatibilitätsmodus}\label{sec:anothercompat}
@@ -8809,9 +8855,9 @@ Notes:
\label{etocpage}
Hier soll erläutert werden, wie \etoc\ dazu verwendet wurde, das
-Inhaltsverzeichnis am Beginn des zweiten Teils zu erstellen. Es handelt sich
-dabei um ein lokales Inhaltsverzeichnis, weshalb der Befehl \localtoc\ verwendet
-wurde.
+Inhaltsverzeichnis am Beginn dieses \autoref{part:linestyles}s zu erstellen.
+Es handelt sich dabei um ein lokales Inhaltsverzeichnis, weshalb der Befehl
+\localtoc\ verwendet wurde.
Wir müssen hierbei unterscheiden zwischen den Linienstilen (\emph{line styles})
und dem Ausgabestil (\emph{toc display style}). Die \emph{line styles} erhält
@@ -10625,12 +10671,37 @@ Dokumentation erzeugt von der Quelldatei mit dem Stempel
\begin{multicols}{2}
\begin{jfverbatim}
-v1.08h [2016/09/25]^
+v1.08i [2016/09/29]^
+
+ This fixes an issue dating back to 1.08e-2015/04/17: under
+ \etocchecksemptiness regime, some circumstances (such as
+ adding to an already compiled document a \localtableofcontents
+ before the main \tableofcontents) created an "Undefined
+ control sequence \Etoc@localtop" error. Thanks to Denis Bitouzé
+ for reporting the problem.
+
+ On this occasion, \etocdoesnotcheckemptiness
+ has been added to unset the flag.
+
+ A rather more exotic issue was fixed: the emptiness check for
+ local tocs could get confused if the tocdepth counter was varying
+ in some specific ways from inside the toc file.
+
+ After adding to a document a \localtableofcontents, two LaTeX
+ passes are needed for etoc to get a chance to print the
+ correct local contents. Formerly, etoc issued a Warning on
+ the first pass; it now also induces LaTeX into
+ announcing "There were undefined references", as this is nearer
+ to the end of the log file and console output.
+
+
+~v1.08h [2016/09/25]^
New functioning of \etocsetnexttocdepth: the tocdepth counter is
modified only at the time of the table of contents, not before.
- This fixes an issue which arose when \etocsetnexttocdepth was used
- multiple times with no intervening table of contents.
+ This fixes an issue which arose when \etocsetnexttocdepth was
+ used multiple times with no intervening table of contents.
+ Thanks to Denis Bitouzé for reporting the problem.
The PDF documentation includes about 25 LaTeX code snippets also
as file attachment annotations, additionally to their verbatim
@@ -11104,9 +11175,10 @@ v1.08h [2016/09/25]^
\newif\ifEtoc@mustclosegroup
\newif\ifEtoc@emptytoc % 1.08e
\newif\ifEtoc@checksemptiness % 1.08e. Default is 'no checks'.
-\newcommand*\etocchecksemptiness {\Etoc@checksemptinesstrue }
+\def\etocchecksemptiness {\Etoc@checksemptinesstrue }
+\def\etocdoesnotcheckemptiness {\Etoc@checksemptinessfalse }% 1.08i
\newif\ifEtoc@notocifnotoc % 1.08e
-\newcommand*\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue }
+\def\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue }
\def\etoc@{\etoc@}
% \end{macrocode}
% |1.07g| uses a second counter; this could be avoided, but ok, let's not be
@@ -11214,14 +11286,16 @@ v1.08h [2016/09/25]^
% The first two parameters of |\Etoc@et@hop| are exchanged in |1.08|
% compared to earlier versions; this is in relation to changes done in
% |\Etoc@etoccontentsline|.
+%
+% |1.08i| as a |fourorthree| rather than as formerly a |sixorfive|.
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{parskip}{\Etoc@parskiptrue}{}%
\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue
\def\Etoc@et@hop#1#2#3#4#5{#2{#3}{#4}{#5}#1}%
- \long\def\Etoc@gobblesixorfive#1#2#3#4#5#6{}}
+ \long\def\Etoc@gobblefourorthree#1#2#3#4{}}
{\def\Etoc@et@hop#1#2#3#4{#2{#3}{#4}#1}%
- \long\def\Etoc@gobblesixorfive#1#2#3#4#5{}}%
+ \long\def\Etoc@gobblefourorthree#1#2#3{}}%
}
% \end{macrocode}
% |2015/03/08| One has to be careful about the |Etoc@end@<level>| user
@@ -11369,55 +11443,77 @@ v1.08h [2016/09/25]^
% sets it for example to be |\Etoc@section@@| which has been let by
% |\etocsetlevel| to |\@ne|, thus is always self-terminating in
% |\ifnum..\fi| contexts.
+%
+% |1.08i-2016/09/29| makes some changes in the organization of the
+% conditionals. It could happen in certain special circumstances (created by
+% that part in |\Etoc@localtableofcontents| which is executed after the test
+% of emptiness) that |\Etoc@localtop| was still undefined. Earlier version of
+% the code was a bit lazy and did not avoid some unneeded |\ifnum| with
+% |\Etoc@localtop| in context where the flag |\ifEtoc@stoptoc| was |\iftrue|;
+% this was not an issue when code was first written, |\Etoc@localtop| was
+% always initialized back then. But the code in |\Etoc@localtableofcontents|
+% handling local TOCs with unrecognized ids would call execution of the |.toc|
+% file under some special context with flag |\ifEtoc@stoptoc| artificially set
+% to true. If |\Etoc@localtop| had not been initialized an undefined control
+% sequence error would occur. Furthermore as |\ifEtoc@notactive| was also set
+% to true, the case of no error lead then to unneededly expand|\Etoc@setflags|
+% code slowing down compilation.
+%
+% Also |1.08i| splits the macro into two, with accompanying slight
+% refactoring. I had such problems with the behaviour of TeX booleans in
+% 2011/12 that I got excessively cautious then, and was using an |\Etoc@next|
+% for the |\Etoc@setflags| rather than leaving it like here deep inside
+% conditional branches.
% \begin{macrocode}
\def\Etoc@etoccontentsline #1{%
\global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname
\Etoc@skipthisonefalse
- \ifnum\Etoc@level=\Etoc@@six@@
- \Etoc@skipthisonetrue
+ \ifnum\Etoc@level=\Etoc@@six@@\Etoc@skipthisonetrue
\else
- \ifEtoc@localtoc
- \let\Etoc@next\relax
- \ifEtoc@stoptoc
- \Etoc@skipthisonetrue
- \fi
- \ifnum\Etoc@level<\Etoc@localtop
- \def\Etoc@next{\global\Etoc@stoptoctrue}%
- \Etoc@skipthisonetrue
- \fi
- \ifEtoc@notactive
- \def\Etoc@next{\Etoc@setflags}%
- \Etoc@skipthisonetrue
+ \ifEtoc@localtoc
+ \ifEtoc@stoptoc\Etoc@skipthisonetrue
+ \else
+ \ifEtoc@notactive\Etoc@setflags\Etoc@skipthisonetrue
+ \else
+ \ifnum\Etoc@level<\Etoc@localtop\Etoc@skipthisonetrue
+ \global\Etoc@stoptoctrue
\fi
- \Etoc@next
+ \fi
\fi
+ \fi
\fi
- \let\Etoc@next\Etoc@gobblesixorfive
- \ifnum\c@tocdepth<\Etoc@level
- \else
- \ifEtoc@skipthisone
- \else
+ \let\Etoc@next\Etoc@gobblefourorthree
+ \ifEtoc@skipthisone\else
+ \ifnum\c@tocdepth<\Etoc@level\else
+ \ifEtoc@standard
+ \let\Etoc@next\Etoc@savedcontentsline
+ \else
+ \let\Etoc@next\Etoc@etoccontentsline@
+ \fi
+ \fi
+ \fi
+ \Etoc@next {#1}%
+}
% \end{macrocode}
% |1.08| New way to handle the compatibility mode. One has to worry
% only for the local tables of contents (in inactive state, which still
% must be parsed for global level flags) but in this case
% |\Etoc@setflags| was done above already. Earlier method proceeded with
% dummy empty line styles.
-% \begin{macrocode}
- \ifEtoc@standard\let\Etoc@next\@thirdofthree
- \else
-% \end{macrocode}
+%
% |2015/03/08| Ever since the first release of \etoc, the code has
% to be careful that the |\Etoc@end@<level>| user defined macros may
% close groups. This is the reason why some assignments have to be done
% globally. The |\let\Etoc@next\Etoc@gobblesixorfive| above could be
% local, because it is used only in case the stuff below is skipped,
-% inclusive of |\Etoc@doends| which may close groups.
+% inclusive of |\Etoc@doends| which may close groups. (code has changed since,
+% slightly).
%
% Versions |1.08| extracts to a separate macro |\Etoc@doends|. Earlier code
% did |\global\let\Etoc@next\relax| but we can now give a default |\relax|
% value to |\Etoc@next| with no need of a |\global| prefix.
% \begin{macrocode}
+\def\Etoc@etoccontentsline@ #1{%
\Etoc@doends
% \end{macrocode}
% |1.08| the |\Etoc@next| will (possibly) execute the |begin| code,
@@ -11455,7 +11551,6 @@ v1.08h [2016/09/25]^
\fi
\Etoc@setflags
\Etoc@next
- \let\Etoc@next\@empty
% \end{macrocode}
% |1.08|:
% \begin{enumerate}
@@ -11474,14 +11569,14 @@ v1.08h [2016/09/25]^
%
% \item adds the |\Etoc@global| prefix.
% \end{enumerate}
+% |1.08i| uses an |\edef| rather than |\def| with a chain of |\expandafter|.
% \begin{macrocode}
- \Etoc@global\expandafter\def\expandafter\Etoc@prefix\expandafter
- {\csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }%
- \Etoc@global\expandafter\def\expandafter\Etoc@contents\expandafter
- {\csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname }%
+ \Etoc@global\edef\Etoc@prefix {\expandafter\noexpand
+ \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }%
+ \Etoc@global\edef\Etoc@contents{\expandafter\noexpand
+ \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname }%
\ifEtoc@skipprefix \Etoc@global\let\Etoc@prefix\@empty\fi
\global\Etoc@skipprefixfalse
- \fi\fi\fi
% \end{macrocode}
% |1.08| modifies the ending to not use the |\Etoc@swa| and |\Etoc@swb|
% things. With this version, the |\Etoc@next| here is only to gobble
@@ -11500,8 +11595,7 @@ v1.08h [2016/09/25]^
% put into doing only expandable things after expansion of the
% \meta{prefix} and \meta{contents} parts of a sectioning unit style.
% \begin{macrocode}
- \Etoc@next
- \Etoc@et@hop{\Etoc@prefix\Etoc@contents}{\Etoc@savedcontentsline{#1}}%
+ \Etoc@et@hop{\Etoc@prefix\Etoc@contents}{\Etoc@savedcontentsline{#1}}%
}
% \end{macrocode}
% |2013/03/07|: up to |1.06| \etoc defined only \csa{etocname}, \csa{etocnumber} and
@@ -11811,7 +11905,9 @@ v1.08h [2016/09/25]^
% could be faster than an |\ifnum|, it adds to it as long as the local toc id
% is not yet found.
%
-% I replace (|1.08e|) the |\Etoc@global|'s for |\Etoc@localtop| by |\global|'s.
+% I replace (|1.08e|) the |\Etoc@global|'s for |\Etoc@localtop| by
+% |\global|'s. The |\relax| is needed because |#2| may sometimes be a count,
+% sometimes tokens.
% \begin{macrocode}
\def\etoc@@startlocaltoc#1#2{%
\ifEtoc@localtoc
@@ -11863,20 +11959,41 @@ v1.08h [2016/09/25]^
% possibility should not be supported anymore. This allowed to remove a few
% tokens from \csa{Etoc@tableofcontents} as well. And it also allowed
% improvements to \csa{Etoc@localtableofcontents}.
+%
+% Note: (|1.08i 2016/09/29|) the code has to handle both local and total toc.
+% Hence the flag |\ifEtoc@notactive| has to be set prior to it. For a global
+% toc, the |\Etoc@tocid| was set to |\z@|, and the |\ifnum| in
+% |\etoc@startlocaltoc| did always fail, but I now prefer to simply nullify
+% the |\etoc@startlocaltoc|. As its default fallback is |\@gobble| I simply
+% test here for the |localtoc| flag. The |\Etoc@tocid| will be undefined for a
+% global toc but it is not tested anymore.
+%
+% Note: the mechanism for recognizing the level when a local toc is
+% encountered is different from the one in |\etoc@@startlocaltoc| which uses
+% the level flags. Here we just record in |\Etoc@level| where we last stood.
+% The initialization |\global\let\Etoc@level\Etoc@minf| is thus needed in case
+% the |.toc| file contains an |\etoc@startlocaltoc| before any
+% |\contentsline|.
+%
+% |1.08i| has two |testingcontentsline| macros, one for local, one for global.
% \begin{macrocode}
\def\Etoc@setemptytocbool {%
- \global\Etoc@stoptocfalse
\global\Etoc@emptytoctrue
+ \global\Etoc@stoptocfalse
\global\let\Etoc@level\Etoc@minf
\begingroup
- \def\etoc@startlocaltoc##1{%
+ \ifEtoc@localtoc
+ \def\etoc@startlocaltoc##1{%
\ifnum##1=\Etoc@tocid\relax
\global\let\Etoc@localtop\Etoc@level
\global\Etoc@notactivefalse
\fi }%
- \let\contentsline\Etoc@testingcontentsline
+ \let\contentsline\Etoc@testingcontentslinelocal
+ \else
+ \let\contentsline\Etoc@testingcontentsline
+ \fi
\Etoc@storetocdepth
- \the\Etoc@toctoks
+ \the\Etoc@toctoks
\Etoc@resettocdepth
\endgroup
}
@@ -11884,21 +12001,37 @@ v1.08h [2016/09/25]^
{\ifEtoc@emptytoc\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi }
\expandafter
\let\expandafter\etocxifwasempty\csname etocifwasempty \endcsname
-\def\Etoc@testingcontentsline #1{%
- \ifEtoc@stoptoc
- \else
- \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@
- \else
+\def\Etoc@testingcontentslinelocal #1{%
+ \ifEtoc@stoptoc\else\ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
\global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname
- \ifEtoc@notactive
- \else
- \ifnum\Etoc@level>\c@tocdepth
- \else
+% \end{macrocode}
+% |\ifEtoc@notactive| set to False by |\etoc@startlocaltoc| with right id. It
+% that happened, check level of hit against unit. Will decide if empty or not.
+% Set |stoptoc| flag afterwards in all cases. |\Etoc@localtop| will have been
+% initialized by |\etoc@@startlocaltoc| as |\ifEtoc@notactive| flag can be
+% false only then.
+% \begin{macrocode}
+ \ifEtoc@notactive\else
+ \ifnum\Etoc@level>\Etoc@localtop
+ \ifnum\Etoc@level>\c@tocdepth\else
+ \global\Etoc@emptytocfalse
+ \global\Etoc@stoptoctrue
+ \fi
+ \else
\global\Etoc@stoptoctrue
- \ifnum\Etoc@level>\Etoc@localtop\global\Etoc@emptytocfalse\fi
- \fi\fi
+ \fi
+ \fi
\fi\fi
- \Etoc@gobblesixorfive\relax\relax\relax
+ \Etoc@gobblefourorthree\relax
+}
+\def\Etoc@testingcontentsline #1{%
+ \ifEtoc@stoptoc\else
+ \ifnum\csname Etoc@#1@@\endcsname=\Etoc@@six@@\else
+ \ifnum\csname Etoc@#1@@\endcsname>\c@tocdepth\else
+ \global\Etoc@emptytocfalse
+ \global\Etoc@stoptoctrue
+ \fi\fi\fi
+ \Etoc@gobblefourorthree\relax
}
% \end{macrocode}
% |1.07g| suppresses the printing of |--unknown etoc ref: run latex again--| as
@@ -11934,7 +12067,8 @@ v1.08h [2016/09/25]^
% \toc|\ref{foo}|; the latter could so far possibly refer to a local or also to
% a global table of contents but release |1.08e| has deprecated the latter use
% as it complicated the code, for something truly silly. Thus |\ref{foo}| must
-% now be with |foo| a label of a local TOC.
+% now be with |foo| a label of a local TOC. As a result |\Etoc@tocwithid| is
+% less used now.
%
% In the case of a |\ref|ed-to toc whose label was just added hence is not yet
% in the |.aux| file, |\Etoc@tocid| is |0|. \etoc used to issue a warning to
@@ -11955,35 +12089,61 @@ v1.08h [2016/09/25]^
% not found in the |.toc| file we can assume it definitely has to be a local
% TOC needing more compilations. The emptiness status is undecided, the code
% declares the TOC non empty.
+%
+% |1.08i-2016/09/29| now does |\Etoc@localtoctrue| right at the start (the
+% earlier code could have to handle table of contents which were actually
+% global, via the |\label/\ref| mechanism.) It does not rely on the |\ifnum|
+% automatically false in |\etoc@@startlocaltoc| due to the special values |0|
+% or |\z@| for |\Etoc@tocid|, but simply leaves |\etoc@startlocaltoc| to its
+% default |\@gobble|. The |\Etoc@emptytocfalse| flag is upfront in case some
+% code using |\etocifwasempty| is in user hooks. The default is to assume the
+% TOC non-empty as its contents are actually still unknown. Under the
+% |stoptoc| flag, the |\Etoc@etoccontentsline| is more efficient now.
+%
+% The |\Etoc@notactive| flag needs to be set before calling
+% |\Etoc@setemptytocbool|.
+%
+% I hesitated with |1.08i| to write something to aux file in order to let
+% \LaTeX\ prompt the user for extra pass, after insertion of some new
+% |\localtableofcontents|, but finally I prefer to only trick \LaTeX\ into
+% telling about undefined references. The first solution has the advantage
+% that at least in Emacs/AUCTeX the |C-cC-c| will propose |LaTeX|, not |View|.
+% But perhaps some automated scripts checking |aux| file will not like the
+% extra line which is then removed in next pass, and could possibly do one
+% extra unneeded compilation to check |aux| file remains identical. Hence the
+% second approach. Earlier I did only a |\PackageWarning| but this does not
+% output a message near the end of the log file or console output.
% \begin{macrocode}
\def\Etoc@localtableofcontents#1{%
- \edef\Etoc@tocid{#1}%
+ \Etoc@localtoctrue
\global\Etoc@emptytocfalse
+ \edef\Etoc@tocid{#1}%
\ifnum\Etoc@tocid<\@ne
- \PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}%
- % versions < 1.08e did not do any printing, 1.08e prints the toc heading.
- \global\Etoc@notactivetrue
+ %\PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}%
+ \setbox0\hbox{\ref{etoc-ref \@secondoftwo#1: run LaTeX again!}}%
+ %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
\global\Etoc@stoptoctrue % do only heading
- \Etoc@localtoctrue % needed for stoptoc obedience
\Etoc@tableofcontents
\expandafter\Etoc@gobbletoetoc@ % skip all the rest
\fi
\global\Etoc@notactivetrue
+% \end{macrocode}
+% |1.08i|'s |\Etoc@setemptytocbool| now checks |localtoc| flag.
+% \begin{macrocode}
\ifEtoc@checksemptiness \Etoc@setemptytocbool \fi
\ifEtoc@emptytoc
\ifEtoc@notactive
- \PackageWarning{etoc}{Unknown toc ID \number\Etoc@tocid. Run LaTeX again}%
- % emptiness undecided. Declare it non empty.
- \global\Etoc@emptytocfalse
- \global\Etoc@stoptoctrue % do only heading
- \Etoc@localtoctrue
+ %\PackageWarning{etoc}{Unknown toc ID \number\Etoc@tocid. Run LaTeX again}%
+ \setbox0\hbox{\ref{etoc-id \number\Etoc@tocid: run LaTeX again!}}%
+ %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi
+ \global\Etoc@emptytocfalse % assume real one will be non-empty
+ \global\Etoc@stoptoctrue % and print only heading for this pass
\Etoc@tableofcontents
\expandafter\expandafter\expandafter\Etoc@gobbletoetoc@
\else
%% \PackageWarning{etoc}{This toc is apparently empty}%
\fi
\else
- \Etoc@localtoctrue
\global\Etoc@stoptocfalse
\global\Etoc@notactivetrue
\global\let\Etoc@localtop\Etoc@@minustwo@@
@@ -12021,34 +12181,33 @@ v1.08h [2016/09/25]^
% \begin{macrocode}
\def\Etoc@dothis #1#2\etoc@ {\fi #1}
\def\Etoc@t@bleofcontents{%
- \ifx\Etoc@nexttoken\label
- \Etoc@dothis{\expandafter\Etoc@label\@gobble}%
- \fi
- \ifx\Etoc@nexttoken\@sptoken
- \Etoc@dothis{\Etoc@again}%
- \fi
- \ifx\Etoc@nexttoken\ref
- \Etoc@dothis{\Etoc@tocwithidfalse\expandafter\Etoc@ref\@gobble}%
- \fi
- \ifEtoc@tocwithid
- \Etoc@dothis{\Etoc@localtableofcontents{\c@etoc@tocid}}%
- \fi
- \global\Etoc@notactivefalse
- \global\Etoc@emptytocfalse
- \ifEtoc@checksemptiness
- \let\Etoc@tocid\z@
- \global\let\Etoc@localtop\Etoc@minf
- \Etoc@setemptytocbool
- \fi
- \ifEtoc@emptytoc
- \ifEtoc@notocifnotoc\else
- \Etoc@localtocfalse
- \Etoc@tableofcontents
- \fi
- \else
- \Etoc@localtocfalse
- \Etoc@tableofcontents
- \fi
+ \ifx\Etoc@nexttoken\label\Etoc@dothis{\expandafter\Etoc@label\@gobble}\fi
+ \ifx\Etoc@nexttoken\@sptoken\Etoc@dothis{\Etoc@again}\fi
+% \end{macrocode}
+% |\Etoc@ref| will hand over directly to |\Etoc@localtableofcontents|.
+% Argument will be (or rather expand to) zero if the reference is non-existent
+% yet. There was an |\Etoc@tocwithidfalse| flag which |1.08i| suppresses as it
+% is not used afterwards (since |1.08e| I think.)
+% \begin{macrocode}
+ \ifx\Etoc@nexttoken\ref\Etoc@dothis{\expandafter\Etoc@ref\@gobble}\fi
+% \end{macrocode}
+% Flag to check if we were called from a |\localtableofcontents|.
+% \begin{macrocode}
+ \ifEtoc@tocwithid\Etoc@dothis{\Etoc@localtableofcontents{\c@etoc@tocid}}\fi
+% \end{macrocode}
+% From now on we are handling a global TOC. Earlier, I used the trick of
+% setting |\Etoc@tocid| to |\z@| for compatibility with expansion of
+% |\etoc@startlocaltoc|. But since |1.08i| |\etoc@startlocaltoc| is left to be
+% |\@gobble|, and |\Etoc@tocid| is never tested. We don't need to set the
+% |notactive| flag as now |\Etoc@testingcontentsline| tests first the
+% |localtoc| flag (was already the case of |\Etoc@etoccontentsline|). I change
+% a bit the style of conditionals here for clarity of code.
+% \begin{macrocode}
+ \global\Etoc@emptytocfalse\ifEtoc@checksemptiness\Etoc@setemptytocbool\fi
+ \ifEtoc@emptytoc\ifEtoc@notocifnotoc
+ \expandafter\expandafter\expandafter\@gobble
+ \fi\fi
+ \Etoc@tableofcontents
\endgroup\ifEtoc@mustclosegroup\endgroup\fi
\Etoc@tocdepthreset % 1.07h, renamed 1.08h
\etocaftertochook % 1.07g
@@ -12062,6 +12221,10 @@ v1.08h [2016/09/25]^
% polyglossia or babel), one can not rely on |\arabic| having its default
% definition. As the number written here will be used later in an \csa{ifnum}, I
% should not have used it in the first place (done |2015/03/30|).
+%
+% |1.08i| moves elsewhere definition of |\etoc@startlocaltoc|. In
+% |\Etoc@table@fcontents| case it remains to be seen if a |\ref| follows which
+% could turn the TOC into a local one. Handled by |\Etoc@t@bleofcontents|.
% \begin{macrocode}
\def\Etoc@table@fcontents{%
\refstepcounter{etoc@tocid}%
@@ -12081,6 +12244,10 @@ v1.08h [2016/09/25]^
% \begin{macrocode}
\let\etocaftertitlehook \@empty
\let\etocaftercontentshook \@empty
+% \end{macrocode}
+% Attention that there could be a |\ref| following, thus we don't yet know
+% whether this is a local or global table of contents.
+% \begin{macrocode}
\def\etoctableofcontents{%
\Etoc@openouttoc
\Etoc@tocdepthset % new with 1.08h
@@ -12094,7 +12261,10 @@ v1.08h [2016/09/25]^
% \begin{macrocode}
\let\tof@begingroup\@empty
\let\tof@endgroup \@empty
- \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}%
+% \end{macrocode}
+% |1.08i| removes definition of |\etoc@startlocaltoc| from here. It is done
+% in |\Etoc@localtableofcontents| or uses its default of |\@gobble|.
+% \begin{macrocode}
\@ifstar
{\def\Etoc@aftertitlehook{}\Etoc@table@fcontents}
{\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@table@fcontents}}
@@ -13018,7 +13188,7 @@ v1.08h [2016/09/25]^
Grave accent \` Left brace \{ Vertical bar \|
Right brace \} Tilde \~}
-\CheckSum{3169}
+\CheckSum{3200}% 2^7 times 5^2 not bad.
\csname check@checksum\endcsname
\Finale