diff options
author | Norbert Preining <norbert@preining.info> | 2023-01-15 03:00:57 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-01-15 03:00:57 +0000 |
commit | b8345f39630408bb198e7636381ce4240154ca9b (patch) | |
tree | 52cdbf3a9b8e71f414f416b50106f1bc5f936459 /macros/latex/contrib/etoc | |
parent | 1d1c448a4f84ba2f5329218a68e7fcadf62999e6 (diff) |
CTAN sync 202301150300
Diffstat (limited to 'macros/latex/contrib/etoc')
-rw-r--r-- | macros/latex/contrib/etoc/README.md | 32 | ||||
-rw-r--r-- | macros/latex/contrib/etoc/etoc.dtx | 1699 | ||||
-rw-r--r-- | macros/latex/contrib/etoc/etoc.pdf | bin | 890715 -> 850065 bytes |
3 files changed, 628 insertions, 1103 deletions
diff --git a/macros/latex/contrib/etoc/README.md b/macros/latex/contrib/etoc/README.md index 96322539d8..e431588369 100644 --- a/macros/latex/contrib/etoc/README.md +++ b/macros/latex/contrib/etoc/README.md @@ -1,10 +1,10 @@ <!-- --> - Source: etoc.dtx (1.09i) + Source: etoc.dtx (1.1a) Author: Jean-Francois Burnol Info: Completely customisable TOCs License: LPPL 1.3c - Copyright (C) 2012-2022 Jean-Francois Burnol. + Copyright (C) 2012-2023 Jean-Francois Burnol. <jfbu at free dot fr> ABSTRACT @@ -97,6 +97,34 @@ etoc.sty, etoc.tex, etoc.pdf, etoc.dvi. RECENT CHANGES ============== +1.1a \[2023/01/14\] +---------------------- + +This version brings no new functionality, despite the number bump. +It implements a complete rewrite of old legacy core internals. +Formerly, etoc waited for +[hyperref](https://ctan.org/pkg/hyperref) +(if present) to have added hyperlinks via its patch to LaTeX's +`\contentsline`. etoc examined the arguments of `\l@section` and +other commands to extract hyperlinking information, if any. +With this release etoc decides earlier according to +[hyperref](https://ctan.org/pkg/hyperref) +linktoc status whether section names and page numbers +should be hyperlinked, and add links itself via `\hyperlink`. +etoc is thus now immune to the details of how hyperref patches +the `\contentsline` command, which is not executed anymore. +Overall, the code is greatly simplified. + +`\etoclink` now wraps its argument in an hyperlink even if +[hyperref](https://ctan.org/pkg/hyperref) is configured via +`linktoc=none`. Formerly no hyperlink was added then. + +Deprecation of `\etocsavedsectiontocline` and similarly named +commands. They are not needed as `\l@section` et al. are with this +release left unmodified during the table of contents typesetting. + +LaTeX kernel from `2020/10/01` or later is required. + 1.09i \[2022/11/21\] -------------------- diff --git a/macros/latex/contrib/etoc/etoc.dtx b/macros/latex/contrib/etoc/etoc.dtx index 5e19538d9f..89e7b3a109 100644 --- a/macros/latex/contrib/etoc/etoc.dtx +++ b/macros/latex/contrib/etoc/etoc.dtx @@ -2,20 +2,20 @@ % 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-11-2022 at 19:35:48 CET>}% +\def\etocdtxtimestamp {Time-stamp: <14-01-2023 at 21:26:57 CET>}% %</none> %<*!readme> %% %% Package: etoc -%% Version: 1.09i +%% Version: 1.1a %% License: LPPL 1.3c -%% Copyright (C) 2012-2022 Jean-Francois Burnol +%% Copyright (C) 2012-2023 Jean-Francois Burnol %% <jfbu at free dot fr> %</!readme> %<*none> -\def\etocpkgdate {2022/11/21} -\def\etocdocdate {2022/11/21} -\def\etocpkgversion {1.09i} +\def\etocpkgdate {2023/01/14} +\def\etocdocdate {2023/01/14} +\def\etocpkgversion {1.1a} \def\etocpkgdescription {Completely customisable TOCs (JFB)} %% German translation was last udpated on April 2015 and all new material %% was included since in English. During 2020/2021/2022 emerged a still @@ -33,9 +33,9 @@ \catcode32=13\catcode`\\=12^^Brelax^^A ^^Bfirstofone{^^Bendgroup^^Bdef^^BetocLicense^^A {% Package: etoc -% Version: 1.09i +% Version: 1.1a % License: LPPL 1.3c -% Copyright (C) 2012-2022 Jean-Francois Burnol <jfbu at free dot fr> +% Copyright (C) 2012-2023 Jean-Francois Burnol <jfbu at free dot fr> % % This Work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, in its @@ -60,11 +60,11 @@ %<*readme> <!-- --> - Source: etoc.dtx (1.09i) + Source: etoc.dtx (1.1a) Author: Jean-Francois Burnol Info: Completely customisable TOCs License: LPPL 1.3c - Copyright (C) 2012-2022 Jean-Francois Burnol. + Copyright (C) 2012-2023 Jean-Francois Burnol. <jfbu at free dot fr> ABSTRACT @@ -157,6 +157,34 @@ etoc.sty, etoc.tex, etoc.pdf, etoc.dvi. RECENT CHANGES ============== +1.1a \[2023/01/14\] +---------------------- + +This version brings no new functionality, despite the number bump. +It implements a complete rewrite of old legacy core internals. +Formerly, etoc waited for +[hyperref](https://ctan.org/pkg/hyperref) +(if present) to have added hyperlinks via its patch to LaTeX's +`\contentsline`. etoc examined the arguments of `\l@section` and +other commands to extract hyperlinking information, if any. +With this release etoc decides earlier according to +[hyperref](https://ctan.org/pkg/hyperref) +linktoc status whether section names and page numbers +should be hyperlinked, and add links itself via `\hyperlink`. +etoc is thus now immune to the details of how hyperref patches +the `\contentsline` command, which is not executed anymore. +Overall, the code is greatly simplified. + +`\etoclink` now wraps its argument in an hyperlink even if +[hyperref](https://ctan.org/pkg/hyperref) is configured via +`linktoc=none`. Formerly no hyperlink was added then. + +Deprecation of `\etocsavedsectiontocline` and similarly named +commands. They are not needed as `\l@section` et al. are with this +release left unmodified during the table of contents typesetting. + +LaTeX kernel from `2020/10/01` or later is required. + 1.09i \[2022/11/21\] -------------------- @@ -732,7 +760,8 @@ mechanism. \usepackage{hyperref}% I had used [pdfencoding=pdfdoc] until 1.09f \hypersetup{% -linktoc=all,% why is the important stuff +linktoc=all,% +%%linktoc=none,% STRESS TEST OF 1.1a %% bookmarksdepth=3,% (not needeed anymore now, 1.07g) breaklinks=true,% colorlinks,% @@ -794,10 +823,12 @@ pdfstartview=FitH,% % je mette un mécanisme plus robuste pour cette TOC. % ATTENTION AUSSI AUX CODES VERBATIM % màj pour 1.08k: \etocsavedsectiontocline etc... +% màj pour 1.1-deev: emploi de \l@section etc... \makeatletter \newcommand*{\MyQuasiStandardTOC}[1]{% \begingroup - \etocsetstyle{section}{} + \etocsetstyle{section} + {} {\ifnum\etocthenumber=4 % <- check this if new sections added to user manual \etocsetstyle{subsection} {\par\nopagebreak\begingroup @@ -810,16 +841,21 @@ pdfstartview=FitH,% {\etocname\ \textup{(\etocnumber)}} {.\par\endgroup}% \else - \etocsetstyle{subsection}{}{} - {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% - \fi} - {\etocsavedsectiontocline - {\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}} + \etocsetstyle{subsection} + {}% + {}% + {\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}% + {}% + \fi + }% prefix for section sets the style dynamically for subsections! + % direct usage of \l@subsection, \l@section allowed here since 1.1a + {\l@section{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}% {}% \etocstandarddisplaystyle \etocsetnexttocdepth {2}% \tableofcontents #1 - \endgroup} + \endgroup +} \makeatother %-------- % Statistics on sections and subsections in a part \thispartstats: @@ -2836,12 +2872,23 @@ the document class defaults: \item do either of the above only for some portions of the table of contents. \end{enumerate} -Here is how to proceed. +One only needs% +% +\marginpar{\normalfont\footnotesize\itshape Modified at \texttt{1.1a}} +% +to use the \LaTeX{} standard \csa{l@chapter}, \csa{l@section}, +etc... commands inside the TOC line style definitions via \csb{etocsetstyle}, +re-constituting their arguments using \csb{etocname}, \csb{etocnumber}, +\csb{etocpage} as one wishes. + +The aliases \csb{etocsavedsectiontocline}, \csb{etocsavedchaptertocline} +etc... are set to have the exact same meanings as the \LaTeX{} |\l@chapter|, +|\l@section|, etc... commands each time a TOC is typeset. They are +\fbox{DEPRECATED} as the latter \LaTeX\ commands are not modified (nor used) by +\etoc since release |1.1a|. -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@section|, |\l@chapter|, etc... macros as -they were at the time the TOC is typeset. +You should use directly |\l@chapter|, etc... within suitable +|\makeatletter/\makeatother|. Here is an example. \begin{filecontentshere}{etocsnippet-\snippetno.tex} \makeatletter @@ -2849,17 +2896,17 @@ they were at the time the TOC is typeset. \begingroup % for the book or article classes: %\etocsetstyle{part}{}{} - % {\etocsavedparttocline{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}% + % {\l@part{\etocnumber\hspace{1em}\etocname}{\etocpage}}{}% % for the scrbook or scrartcl classes: \etocsetstyle{part}{}{} - {\etocsavedparttocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% + {\l@part{\numberline{\etocnumber}\etocname}{\etocpage}}{}% % following is identical in book/article/scrbook/scrartcl classes: \etocsetstyle{chapter}{}{} %%% only for book and scrbook - {\etocsavedchaptertocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% + {\l@chapter{\numberline{\etocnumber}\etocname}{\etocpage}}{}% \etocsetstyle{section}{}{} - {\etocsavedsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% + {\l@section{\numberline{\etocnumber}\etocname}{\etocpage}}{}% \etocsetstyle{subsection}{}{} - {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}}{}% + {\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}{}% % etc... if further sectioning units are used \etocstandarddisplaystyle % this is for the title, page-marks, etc... \tableofcontents @@ -2897,39 +2944,51 @@ the subsections as in the default, \emph{except} for those of one specific section, for which the layout is completely modified: \MyQuasiStandardTOC{\ref{toc:overview}} \bigskip -This example only has sections and subsections, and the code used in \csa{MyStandardTOC} was: +This example only has sections and subsections (assumed to be numbered), and +the code used was: \begin{filecontentshere}{etocsnippet-\snippetno.tex} -\etocsetstyle{section}{} - {\ifnum\etocthenumber=4 +\makeatletter +\newcommand*{\MyQuasiStandardTOC}[1]{% + \begingroup + \etocsetstyle{section} + {} + {\ifnum\etocthenumber=4 \etocsetstyle{subsection} {\par\nopagebreak\begingroup - \leftskip1.5em \rightskip\@tocrmarg \parfillskip\@flushglue - \parindent 0pt \normalfont\normalsize\rmfamily\itshape - % \columnsep1em - % \begin{minipage}{\dimexpr\linewidth-\leftskip-\rightskip\relax}% - % \begin{multicols}{2}% + \leftskip1.5em \rightskip\@tocrmarg + \parfillskip \@flushglue + \parindent 0pt + \normalfont\normalsize\rmfamily\itshape \etocskipfirstprefix} {\allowbreak\,--\,} {\etocname\ \textup{(\etocnumber)}} {.\par\endgroup}% - % {.\par\end{multicols}\end{minipage}\par\endgroup}% - \else - \etocsetstyle{subsection} - {}{} - {\etocsavedsubsectiontocline{\numberline{\etocnumber}\etocname}{\etocpage}} - {}% - \fi} - {\etocsavedsectiontocline{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}} - {}% + \else + \etocsetstyle{subsection} + {}% + {}% + {\l@subsection{\numberline{\etocnumber}\etocname}{\etocpage}}% + {}% + \fi + }% prefix for section sets the style dynamically for subsections! + {\l@section{\numberline{{\color{cyan}\etocthenumber}}\etocname}{\etocpage}}% + {}% + \etocstandarddisplaystyle + \etocsetnexttocdepth {2}% + \tableofcontents #1 + \endgroup +} +\makeatother \end{filecontentshere} \marginattach{-B} -Notice the page head-mark added by this standard TOC. Sections and subsections -are printed exactly as in the default (except for the subsections of one -specific user-chosen section and except for the color of the section numbers), -with no need to specify explicitely any length, font or other formatting -instructions. But we had to examine the \ctanpkg{scrartcl} sources to determine what to -use for \csa{leftskip} and \csa{rightskip} for our customized section -entries. + +The page heading (on the page where this TOC appears) may have been modified +as is expected from usage of \csb{etocstandarddisplaystyle} in the code. +Sections and subsections are printed exactly as in the default, \emph{except} +for the subsections of one specific user-chosen section and except for the +color of the section numbers. We had to examine the \ctanpkg{scrartcl} sources +to determine what to use for \csa{leftskip} and \csa{rightskip} for our +customized section entry (the one wih number 4). \section{Emulating the book class}\label{sec:thirdexample} @@ -4429,11 +4488,14 @@ and page number of the corresponding toc entry. If package \ctanpkg{hyperref} is active in the document and has added hyperlinks to the TOC data, then these links are kept in the commands \csb{etocname}, \csb{etocnumber} and \csb{etocpage} (this last one will have a link only if \ctanpkg{hyperref} was passed -option \emph{linktoc=all}.)% +either option \emph{linktoc=all} or option \emph{linktoc=page}.)% % -\footnote{In case of \emph{linktoc=page}, only \csb{etocpage} is an hyperlink; -see the discussion of \csb{etoclink} on how to create (possibly also with the -\emph{name} or \emph{number}) hyperlinks with the same target.} +\footnote{As expected, in case of \emph{linktoc=page}, only \csb{etocpage} is +an hyperlink, not \csb{etocname} nor \csb{etocnumber}. See \csb{etoclink} on +how to create hyperlinks with the entry target.} +% +In accordance with the \ctanpkg{hyperref} native behavior, no +link gets incorporated into \csb{etocpage} if the page number is empty. \section{The \csbhyp{etocskipfirstprefix} and \csbhyp{etociffirst} commands} \label{etocskipfirstprefix} @@ -4541,26 +4603,27 @@ preceded by |\protect|. The command \csb{etoclink}\marg{text} can be used in the line style specifications in a manner analogous to \csb{etocname}, \csb{etocnumber} and -\csb{etocpage}. It creates a link (if such a link was added by \ctanpkg{hyperref} to -the |.toc| file entry) whose target is the corresponding document unit and +\csb{etocpage}. It creates a link (if \ctanpkg{hyperref} is present% +% +\footnote{Prior to \texttt{1.1a}, no such link was added if the \texttt{.toc} + file entry was encountered + with \ctanpkg{hyperref}'s option \texttt{linktoc} set to \texttt{none}.}) +% +whose target is the corresponding document unit and whose name is the given \meta{text} mandatory argument. Hence |\etoclink{\etocthename}| is under default conditions of \ctanpkg{hyperref} like -the original |\etocname|, because the latter is already hyperlinked. Under +the original \csb{etocname}, because the latter is already hyperlinked. Under \emph{linktoc=page} context |\etoclink{\etocthename}| adds the hyperlink which is missing from \csb{etocname}. Similarly under the default \ctanpkg{hyperref} -condition (\emph{linktoc=section}) \csb{etocpage} is not an hyperlink, but one +condition (i.e.\@ \emph{linktoc=section}) \csb{etocpage} is not an hyperlink, but one can use |\etoclink{\etocthepage}|. -If \csa{hypersetup} is used with \emph{linktoc=none} then no miracle happens, -\csb{etoclink} does nothing special and none of \csb{etocname}, -\csb{etocnumber} and \csb{etocpage} are links. - - +The command \csb{etoclink} is robust. -The command \csb{etoclink} is robust. Since |etoc 1.08j| it contains the link -destination in an already expanded form, so for example can be used even after -a |&| in a tabular construction, if \csb{etocglobaldefs} was issued. +% Since |etoc 1.08j| it contains the link +% destination in an already expanded form, so for example can be used even after +% a |&| in a tabular construction, if \csb{etocglobaldefs} was issued. % Sadly the [] syntax influences both the header and the entry in the TOC @@ -4592,25 +4655,43 @@ a |&| in a tabular construction, if \csb{etocglobaldefs} was issued. \makeatletter\scr@activate@xsection{0}\makeatother -These macros are fragile and contain the link destination in already expanded -form. So their meaning can be stored for delayed usage. For example this is -done here when doing the \hyperref[tocastree]{examples with trees}. +The meanings of these commands +can be stored for delayed usage. For example this is +done in the \hyperref[tocastree]{examples with trees}. + +Notice though the following facts: +\begin{itemize}[noitemsep] +\item \csb{etocthelinkednumber} and \csb{etocthelinkedname} are hyperlinks + only if \ctanpkg{hyperref} was configured via |linktoc=all| or + |linktoc=section| (the default), +\item \csb{etocthelinkedpage} is an hyperlink only if \ctanpkg{hyperref} was + configured via |linktoc=all| or |linktoc=page|. \emph{Furthermore}, the + page number must not be empty: if it is empty no hyperlink is added (this + matches the \ctanpkg{hyperref} behavior when \etoc is not loaded). +\end{itemize} -Notice though that \csb{etocthelinkednumber} and \csb{etocthelinkedname} are -hyperlinks only if \ctanpkg{hyperref} was configured to let the heading name be -linked (this is the default). So under \ctanpkg{hyperref} option \emph{linktoc=page}, -both \csb{etocthelinkednumber} and \csb{etocthelinkedname} are no different -from respectively \csb{etocthenumber} and \csb{etocthename}. +It may be a bit strange that the link is not sytematically added despite the +command names, but this is legacy behavior of the package. It is coherent +with the commands \csb{etocname}, \csb{etocnumber}, and \csb{etocpage} being +their robust variants. -For this reason, a further macro is provided: \csb{etocthelink} will fetch -the link destination if available be it from the name or from the page number. -Then |\etocthelink{foo}| hyperlinks an arbitrary text to the target destination -inside the produced PDF. -All these commands are fragile. The \csb{etocname}, \csb{etocnumber}, -\csb{etocpage} and \csb{etoclink} are simply their robust variants. They too -contain the hyperlink destination in already expanded form since |1.08a| for -the first three, since |1.08j| for \csb{etoclink}. +A further command is provided: \csb{etocthelink}, which wraps% +% +\footnote{Prior to \texttt{1.1a}, there was a link added only if \ctanpkg{hyperref} option \texttt{linktoc} was not \texttt{none}.} +% +an hyperlink around its argument: |\etocthelink|\marg{foo} hyperlinks an +arbitrary text \meta{foo} to the target sectioning unit in the document. +The command \csb{etoclink} is its robust variant. + +Thus, \csb{etocthelinkednumber} is essentially +\csb{etocthelink}|{|\csb{etocthenumber}|}| if |linktoc| is |all| or the +default |section|, else it is an alias to \csb{etocthenumber}. Similarly for +the other two. + +% They too +% contain the hyperlink destination in already expanded form since |1.08a| for +% the first three, since |1.08j| for \csb{etoclink}. Obsolete example of \begingroup \etocsetstyle {section} @@ -4676,17 +4757,25 @@ Example of \etocinline\tableofcontents \ref{toc:globalcmds} \endgroup -\section{The \csbhyp{etocsavedsectiontocline}, etc... commands.} +\section{DEPRECATED \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@section|, |\l@chapter|, etc... in force -at the time each \csb{tableofcontents} or \csb{localtableofcontents} -macro is executed. +Prior to |1.1a|, \etoc modified (locally) at each \csb{tableofcontents} or +\csb{localtableofcontents} encountered the meaning of the \LaTeX\ internal +commands |\l@part|, |\l@chapter|, |\l@section|, etc... It stored (since |1.08k|) +their original meanings (at the time of the encountered TOC), into +\csb{etocsavedchaptertocline}, \csb{etocsavedsectiontocline}, etc... commands, +which allowed to do some simple changes via \etoc of the rendering via the +technique explained in \autoref{sec:anothercompat}. -See \autoref{sec:anothercompat} for usage. +This is all obsolete at |1.1a| because \etoc does not modify anymore (even +locally) |\l@part|, |\l@chapter|, |\l@section|, etc... so they can be used +directly in the context of the techniques of \autoref{sec:anothercompat}. + +Thus \csb{etocsavedchaptertocline}, \csb{etocsavedsectiontocline}, +etc... raise some warning that they will be removed at some later release and +that you should stop using them. \section{The \csbhyp{etocsetlevel} command} \label{etocsetlevel} @@ -4700,7 +4789,7 @@ command with \csb{etocsetlevel}. For example: \etocsetlevel{atom}{2} \etocsetlevel{nucleus}{3} \end{verbatim} -In compatibility mode, it will be assumed that the macros |\l@cell|, +In compatibility mode, it will be assumed that the commands |\l@cell|, |\l@molecule|, ..., have been defined somewhere either by the user or a class: doing only |\etocsetlevel| is not enough for the corresponding level to work out-of-the-box in compatibility mode. @@ -6240,14 +6329,16 @@ updated since. \label{etocscrbookstyle} \label{etocscrreprtstyle} -Not really tested. But nominally supported, as the code contains this +Not really tested... well, tested by this document with its dozens of \etoc +TOCs and which uses \ctanpkg{scrartcl}! The package code contains \begin{verbatim} \@ifclassloaded{scrartcl} {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{} \end{verbatim} -and \cs{etocscrartclstyle} tries to emulate the global display style of the -\cs{tableofcontents} command with the class \ctanpkg{scrartcl}. It was last updated -at |1.09f|. +with \cs{etocscrartclstyle} trying to emulate the global display style of the +\cs{tableofcontents} within the class \ctanpkg{scrartcl}. Thus \etoc is ready +for basic usage in compatibility mode (last updated +at |1.09f|). \subsection{Compatibility with the \ctanpkg{memoir} class} \label{ssec:memoir} @@ -6411,17 +6502,25 @@ Unknown. (not tested a.t.t.o.w). \section{\TeX nical matters} The \csb{etocname}, \csb{etocnumber}, \csb{etocpage} commands are protected -against premature expansion. They contain suitable \ctanpkg{hyperref} links if package -\ctanpkg{hyperref} is loaded and active for the TOC. The commands \csb{etoclink} and -\csb{etocifnumbered} are also protected against premature expansion. Also -\csb{etociffirst} and \csb{etoctoccontentsline}. +against premature expansion. They are hyperlinks if package \ctanpkg{hyperref} +is loaded and depending on its option |linktoc| value; under the default +|linktoc=section|, only name and number are hyperlinked, not the page +number. On the other hand \csb{etocthename}, \csb{etocthenumber}, \csb{etocthepage} are \emph{not} protected against expansion. And neither are \csb{etocthelinkedname}, \csb{etocthelinkednumber}, \csb{etocthelinkedpage}. -The latter contain hyperlink data, if present in the |.toc| file. +The latter three are hyperlinks only if \ctanpkg{hyperref} |linktoc| option +has the suitable value: |section| (which is default) or |all| for name and +number to be hyperlinks, |page| or |all| for the page number (which must not +be empty). The commands \csb{etocname}, \csb{etocnumber}, and \csb{etocpage} +are their robust variants. + +The commands \csb{etoclink} and \csb{etocifnumbered} are also +protected against premature expansion. Also \csb{etociffirst} and +\csb{etoctoccontentsline}. -The commands such as \csb{etocsetstyle}, \csb{etocsetlevel}, +Commands such as \csb{etocsetstyle}, \csb{etocsetlevel}, \csb{etocsettocstyle}, \csb{etocmulticolstyle}, \csb{etocruledstyle}, \csb{etocframedstyle} obey \LaTeX{}'s groups. All TOCs are typeset inside groups. @@ -6545,6 +6644,8 @@ version is \texttt{\etocpkgversion}, of \texttt{\etocpkgdate}. \def\1{\vskip\baselineskip 1}% ajouté 2015/05/09; faudra trouver mieux. % 2022/08/26, stop using \frenchspacing % \frenchspacing +% 2023/01/14 + \def\2##1.{\ctanpkg{##1}}% % 2022/08/26. I realized that rendering was broken, and finally identified % the bad commit to be in LaTeX 2022/06/01 release. Its \obeyspaces not only % makes the ascii32 \active but it also redefines it! Solution could be to @@ -6576,7 +6677,32 @@ version is \texttt{\etocpkgversion}, of \texttt{\etocpkgdate}. \def {\ifvmode\advance\jfverbadim.5em\relax\else\expandafter\jfverbaspace\fi}}\x \makeatother \begin{jfverbatim} -1.09i [2022/11/21]^ +1.1a [2023/01/14]^ + + This version brings no new functionality, despite the number bump. + It implements a complete rewrite of old legacy core internals. + Formerly, etoc waited for ~2hyperref. (if present) to have added + hyperlinks via its patch to LaTeX's \contentsline. + etoc examined the arguments of \l@section and other commands to extract + hyperlinking information, if any. + With this release etoc decides earlier according to + ~2hyperref. linktoc status whether section names and page numbers + should be hyperlinked, and add links itself via \hyperlink. etoc + is thus now immune to the details of how ~2hyperref. patches the + \contentsline command, which is not executed anymore. + Overall, the code is greatly simplified. + + \etoclink now wraps its argument in an hyperlink even if + ~2hyperref. is configured via + linktoc=none. Formerly no hyperlink was added then. + + Deprecation of \etocsavedsectiontocline and similarly named + commands. They are not needed as \l@section et al. are with this + release left unmodified during the table of contents typesetting. + + ~LaTeX kernel from 2020/10/01 or later is required. + +~1.09i [2022/11/21]^ Fix bug showing when a document uses both \etocchecksemptiness and \etocsetlocaltop.toc: the start and finish parts of some levels were @@ -7423,54 +7549,74 @@ the syntax highlighting automatization. \fi }% } -Warning: the author's brain reboots frequently, and more and more often. -Hence most comments are not for the general reader, they are for the author -himself and they document more the history of the package than its actual -functioning, because the historical evolution is the way the author can -remember and understand the code. There are a few precious isolated -paragraphs which may prove vaguely useful to people who are not the author. +% Warning: the author's brain reboots frequently, and more and more often. +% Hence most comments are not for the general reader, they are for the author +% himself and they document more the history of the package than its actual +% functioning, because the historical evolution is the way the author can +% remember and understand the code. There are a few precious isolated +% paragraphs which may prove vaguely useful to people who are not the author. -\etoc,\normalmarginpar\marginpar{\footnotesize\rmfamily\itshape\RaggedRight +Apology: the code comments served mainly as a record for the author's benefit +of the historical evolution of the package and rarely as a description of what +the macros do. At |1.1a| I have removed almost all code comments which had +accumulated as in a palimpsest. As a result, very few comments actually +remain. + + +\etoc,% +% +\normalmarginpar\marginpar{\footnotesize\rmfamily\itshape\RaggedRight This paragraph and the next were added very late in the history of the - package, at 1.09h.\par} when not left in compatibility mode, hijacks the -\csa{contentsline} expansion so as to not execute \csa{l@chapter}, -\csa{l@section} etc..., but use \csbc{Etoc@lxyz}, which will parse the data and -extract from it the name, number and page number. Indeed, for legacy reasons -the \LaTeX{} |.toc| data is \emph{not structured}, but already to some extent -oriented towards typesetting tasks, in an already pre-decided orderly manner. -This part of \etoc maneuvers is fragile as 1) it requires the |.toc| file to -be built from \csa{contentsline} entries, and 2) and relies on -\csa{contentsline} to hand over the job to \csa{l@chapter}, \csa{l@section}, -etc... macros. Of course \etoc can be easily broken if changes happen to how -data is stored there, in particular to how the text (which in \etoc lingua is -called the \emph{name}) and the number (this one is called by us also -\emph{number}) are put together. Things would have been much easier for \etoc -in 2012 if the \csa{contentsline} arguments separated text (name) and number; -unfortunately some mix is prepared, which may depend on the document class -also, and typically handles \csa{part} levels very differently (and with more -hard-coded stuff). Anyway, fortunately upstream changes happen rarely. The -|7.00u| release of \ctanpkg{hyperref} was such an instance. + package, at 1.09h.\par} +% +when not left in compatibility mode, hijacks the \csa{contentsline} expansion +so as to not execute \csa{l@chapter}, \csa{l@section} etc..., but rather to +parse the date and extract from it the \emph{name}, \emph{number}, and +\emph{page number}. +% +The \LaTeX{} |.toc| data +is \emph{not structured}, but contains already typesetting mark-up. +The +\etoc maneuvers to disentangle \emph{name} and \emph{number} are somewhat +fragile as they expect the |.toc| file to contain the +\csa{contentsline} arguments to be arranged in a certain manner.% +% +\normalmarginpar\marginpar{\footnotesize\rmfamily\itshape\RaggedRight +Prior to \texttt{1.1a}, \etoc aliased \csa{l@chapter}, \csa{l@section}, +etc... (at the time of TOC typesetting only) to its own \csbc{Etoc@lxyz} in order to leave time to +\ctanpkg{hyperref} to add its marks-up. Thus the disentangling was +more complex than it is now. With \texttt{1.1a}, \etoc leaves +\csa{l@chapter} etc... unmodified and inserts itself hyperlinks via \csa{hyperlink}.} +% +Of course \etoc can be easily broken if changes happen to how data is stored +there. Things would have been much easier for \etoc in 2012 if the +\csa{contentsline} arguments had considered the section titles (aka +\emph{name} for \etoc) and their numbers (which are not numbers in the sense +of things with which \TeX\ can compute, in general) separately, each providing +an argument to \csa{contentsline}. But some mix is prepared, which may depend +on the document class also, and besides usually handles \csa{part} levels very +differently. Fortunately upstream changes happen rarely. The other core part of \etoc present from day one of the package is that it -creates (but only virtually, and dynamically, not statically) a tree-like -structure of the sectioning levels present in the |.toc| file. It could be -fun to actually implement officially such a tree (where the children of a -sectioning title are the sectioning levels at a greater depth such as -subsections versus a section). Let us recall that \LaTeX{} provides zero -means to know from a subsection for example, what is the title of the section -containing it, or chapter, or part. To do this one has to create a really -structured document which neither core \LaTeX{} nor the main document classes -do. This remark was given for document body, but it also applies to |.toc| -data. But \etoc adds at least some kind of follow-up to the successive -encountered sectioning titles, and is thus able, to ``on-the-fly'' add some -kind of structure and follow the succession of levels. Ultimately this is why -the \csbc{etocsetstyle} offers \marg{start} and \marg{finish} parts in -additions to \marg{contents} (which I divided into a \marg{prefix} and a -\marg{contents}). At some point one could imagine that a really -\emph{structured} document (in opposition to what core \LaTeX{} from thirty -years ago up to nowadays realizes) would store in the |.toc| data directly a -tree structure, where each node would have attributes name, number, page -number, completely separated from any typesetting. Once this exists then +creates a tree-like structure of the sectioning levels present in the |.toc| +file. But this is purely virtual, and handled via a notion of ``level'' and +\TeX\ conditionals. It could be fun to implement officially such a tree +(where the children of a sectioning title are the sectioning levels at a +greater depth such as subsections versus a section). Let us recall that +\LaTeX{} provides zero means to know from a subsection for example, what is +the title of the section containing it, or chapter, or part. To do this one +has to create a really structured document which neither core \LaTeX{} nor the +main document classes do. This remark was given for document body, but it +also applies to the |.toc| data. But \etoc adds at least some kind of +follow-up to the successive encountered sectioning titles, and is thus able, +to ``on-the-fly'' add some kind of structure and follow the chaining of +levels. Ultimately this is why the \csbc{etocsetstyle} offers \marg{start} +and \marg{finish} parts in additions to \marg{contents} (which I divided into +a \marg{prefix} and a \marg{contents}). At some point one could imagine that +a really \emph{structured} document (in opposition to what core \LaTeX{} from +thirty years ago up to nowadays realizes) would store in the |.toc| data +directly a tree structure, where each node would have attributes name, number, +page number, completely separated from any typesetting. Once this exists then basically \etoc disappears. In brief, once \etoc ideas will have permeated the society, it will disappear as its was born only to palliate the absence of real structure in the |.toc| file (which is sort of inherited from the absence @@ -7517,28 +7663,28 @@ of real structure in a \LaTeX{} document body). % %</none> %<*package> +% |1.1a| implements a radical change to all internals for compatibility +% with (attow future) \ctanpkg{hyperref}. In order to facilitate this +% overhaul, we require \LaTeX{} 2020/10/01 for the fourth argument to +% \cs{contentsline} lines in the |.toc| file to be always present. % \begin{macrocode} -\NeedsTeXFormat{LaTeX2e} +\NeedsTeXFormat{LaTeX2e}[2020/10/01] \ProvidesPackage{etoc} -[2022/11/21 v1.09i Completely customisable TOCs (JFB)] +[2023/01/14 v1.1a Completely customisable TOCs (JFB)] \RequirePackage{multicol} \DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} \ProcessOptions\relax -% \end{macrocode} -% |1.08| suppresses |\ifEtoc@part| and defines |\ifEtoc@skipprefix|. It -% also defines \csbc{etocglobaldefs}, \csbc{etoclocaldefs} and \csbc{Etoc@global}. -% \begin{macrocode} \newtoks\Etoc@toctoks \def\Etoc@par{\par} \def\etocinline{\def\Etoc@par{}} \let\etocnopar\etocinline -\def\etocdisplay{\def\Etoc@par{\par}}% 1.07m 2015/01/23 +\def\etocdisplay{\def\Etoc@par{\par}} % \end{macrocode} % \csbc{etocglobaldefs} should be used only for special things such as TOC as a % table; it should be put in a group to limit its scope. If used in the % preamble, it must come \emph{after} \ctanpkg{tableof} if the latter is loaded too. % \begin{macrocode} -\let\Etoc@global\@empty % 1.08 2015/03/10 +\let\Etoc@global\@empty \def\etocglobaldefs{\let\Etoc@global\global\let\tof@global\global} \def\etoclocaldefs {\let\Etoc@global\@empty\let\tof@global\@empty} \newif\ifEtoc@jj % book @@ -7551,38 +7697,26 @@ of real structure in a \LaTeX{} document body). \newif\ifEtoc@v % subparagraph \newif\ifEtoc@number \newif\ifEtoc@hyperref -\newif\ifEtoc@parskip % 1.07d +\newif\ifEtoc@parskip \newif\ifEtoc@tocwithid \newif\ifEtoc@standard -\newif\ifEtoc@skipprefix % 1.08 -\newif\ifEtoc@isfirst % 1.08 +\newif\ifEtoc@skipprefix +\newif\ifEtoc@isfirst \newif\ifEtoc@localtoc \newif\ifEtoc@skipthisone \newif\ifEtoc@stoptoc \newif\ifEtoc@notactive \newif\ifEtoc@mustclosegroup -\newif\ifEtoc@emptytoc % 1.08e -\newif\ifEtoc@checksemptiness % 1.08e. Default is 'no checks'. +\newif\ifEtoc@emptytoc +\newif\ifEtoc@checksemptiness \def\etocchecksemptiness {\Etoc@checksemptinesstrue } -\def\etocdoesnotcheckemptiness {\Etoc@checksemptinessfalse }% 1.08i -\newif\ifEtoc@notocifnotoc % 1.08e +\def\etocdoesnotcheckemptiness {\Etoc@checksemptinessfalse } +\newif\ifEtoc@notocifnotoc \def\etocnotocifnotoc {\Etoc@checksemptinesstrue\Etoc@notocifnotoctrue } \def\etoc@{\etoc@} -\newif\ifEtoc@bracedname % 1.08p -% \end{macrocode} -% |1.07g| uses a second counter; this could be avoided, but ok, let's not be -% that strict. -% \begin{macrocode} +\newif\ifEtoc@bracedname \newcounter{etoc@tocid} -\newcounter{etoc@tocdepth}% 1.07g -% \end{macrocode} -% |2015/03/08| Why do I use |jj| in the flags and |minustwo| here? and -% is there an entity full of forgiveness out there to save my soul even -% if taking into consideration my use of single and doubled |@|'s ? -% Although I desperately need to waste time I miraculously decided not -% to change everything today and thus the somewhat dispendious set-up -% below is maintained. -% \begin{macrocode} +\newcounter{etoc@tocdepth} \@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}} \def\Etoc@@minustwo@@{-\tw@} \let\Etoc@@minusone@@\m@ne @@ -7601,9 +7735,6 @@ of real structure in a \LaTeX{} document body). \def\Etoc@@three@ {three} \def\Etoc@@four@ {four} \def\Etoc@@five@ {five} -% \end{macrocode} -% |1.07g|. -% \begin{macrocode} \expandafter\def\csname Etoc@-3@@\endcsname {-\thr@@} \expandafter\let\csname Etoc@-2@@\endcsname \Etoc@@minustwo@@ \expandafter\let\csname Etoc@-1@@\endcsname \Etoc@@minusone@@ @@ -7617,17 +7748,9 @@ of real structure in a \LaTeX{} document body). \let\Etoc@all@@ \Etoc@@five@@ \let\Etoc@none@@ \Etoc@minf % \end{macrocode} -% Versions earlier than |1.08| did \csbc{Etoc@newlevel} in a quite -% embarrassing way with an |\edef|. -% -% |1.08f|'s \csbc{etocsetlevel} avoids multiple insertions of the same level -% in the \csbc{Etoc@levellist} list. -% -% |1.08k| modified \csbc{Etoc@newlevel}: formerly a token |\l@#1| was stored in -% place of braced name |{#1}|. This changed is to facilitate creation of the -% \csa{etocsavedsectiontocline} etc... type macros later on, at each TOC. But the -% stored |#1| is not expanded immediately, although it is in other parts of -% \csbc{etocsetlevel}, which may cause timing problems if |#1| is a macro. +% At |1.1a|, the \csa{etocsavedsectiontocline} and cousins are deprecated and +% when they will be removed, \csbc{Etoc@levelist} will be too as it now serves +% only for their definitions. % \begin{macrocode} \let\Etoc@levellist\@empty \def\Etoc@newlevel #1{\expandafter\def\expandafter\Etoc@levellist\expandafter @@ -7680,104 +7803,24 @@ of real structure in a \LaTeX{} document body). \etocsetlevel{paragraph}{4} \etocsetlevel{subparagraph}{5} % \end{macrocode} -% The first two parameters of \csbc{Etoc@et@hop} are exchanged in |1.08| -% compared to earlier versions; this is in relation to changes done in -% \csbc{Etoc@etoccontentsline}. -% -% |1.08i 2016/09/29| has a |fourorthree| rather than as formerly a |sixorfive|. -% -% \LaTeX\ of November 2021 will have its |\contentsline| always grab four -% arguments. So we must adjust \csbc{Etoc@et@hop} et al., else usage of \etoc -% without hyperref will be broken. Done at |1.09e 2021/09/23|. -% -%^^A Side note to myself: I see there is now a |\@gobblethree| in latex.ltx and -%^^A I wonder since when. No time to lose on checking that. -%^^A Answer: 2020-02-27 ltdefns.dtx 1.5g |\@gobblethree|: Macro added -% % |1.09g| adapts to \ctanpkg{hyperref} depending on % whether the latter is at |7.00u| or earlier. Indeed internal changes to % \ctanpkg{hyperref} at |7.00u| broke \etoc. Thanks to Denis~\textsc{Bitouzé} for % reporting the issue. +% +% But |1.1a| radically simplifies matters at \etoc core, and with it the +% breakage induced from \ctanpkg{hyperref} |7.00u| would not have happened. % \begin{macrocode} \AtBeginDocument{% \@ifpackageloaded{parskip}{\Etoc@parskiptrue}{}% -\@ifpackageloaded{hyperref}{% - \Etoc@hyperreftrue - \@ifpackagelater{hyperref}{2022/11/13}% - {% - \def\Etoc@getthepage {% - \ifx\Hy@toclinkstart\Etoc@getthepage@token - \expandafter\expandafter\expandafter\Etoc@getthepage@hyp - \else - \expandafter\Etoc@getthepage@nohyp - \fi}% - \def\Etoc@getnb@a {% - \ifx\Hy@toclinkstart\Etoc@getnb@token - \expandafter\expandafter\expandafter\Etoc@getnb@hyp - \else - \expandafter\Etoc@getnb@nohyp - \fi}% - \def\Etoc@getit {% - \ifx\Hy@toclinkstart\Etoc@getit@token - \expandafter\expandafter\expandafter\Etoc@getit@hyp - \else - \expandafter\Etoc@getit@nohyp - \fi}% - }% - {% - \def\Etoc@getthepage {% - \ifx\hyper@linkstart\Etoc@getthepage@token - \expandafter\Etoc@getthepage@hyp - \else - \expandafter\Etoc@getthepage@nohyp - \fi}% - \def\Etoc@getnb@a {% - \ifx\hyper@linkstart\Etoc@getnb@token - \expandafter\Etoc@getnb@hyp - \else - \expandafter\Etoc@getnb@nohyp - \fi}% - \def\Etoc@getit {% - \ifx\hyper@linkstart\Etoc@getit@token - \expandafter\Etoc@getit@hyp - \else - \expandafter\Etoc@getit@nohyp - \fi}% - }% - \def\Etoc@et@hop#1#2#3#4#5{#2{#3}{#4}{#5}#1}% - \let\Etoc@gobblefourorthree\@gobblefour - }% - {% - \let\Etoc@getthepage\Etoc@getthepage@nohyp - \let\Etoc@getnb@a\Etoc@getnb@nohyp - \let\Etoc@getit \Etoc@getit@nohyp - \def\Etoc@et@hop#1#2#3#4{#2{#3}{#4}#1}% - \long\def\Etoc@gobblefourorthree#1#2#3{}% - }% -% \end{macrocode} -% Until |1.09i| the date threshold was erroneously set to 2021/11/15. -% In practice this meant that for some version of \LaTeX{} \etoc was -% a bit sloppy and left some empty brace pairs |{}|, which however -% could possibly impact I think only TOCs executed in math mode... not -% very frequent! -% \begin{macrocode} -\@ifl@t@r\fmtversion{2020/10/01}% - {% - \def\Etoc@et@hop#1#2#3#4#5{#2{#3}{#4}{#5}#1}% - \let\Etoc@gobblefourorthree\@gobblefour - }% - {}% +\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue}{}% } % \end{macrocode} % |2015/03/08| One has to be careful about the |Etoc@end@<level>| user % defined macros which may close groups. This has always been the reason % for the |\global|'s here and elsewhere. % -% |1.08| uses \csbc{Etoc@level} rather than a |#1| which used to be anyhow always -% the |\Etoc@tmp|. Now \csbc{Etoc@level} is what was called formerly |\Etoc@tmp| -% in \csbc{Etoc@etoccontentsline}. -% -% Attention that \csbc{Etoc@setflags} must not modify |\Etoc@next|! +% Attention that \csbc{Etoc@setflags} must not modify \csa{Etoc@next}! % \begin{macrocode} \def\Etoc@setflags {% \ifcase \Etoc@level @@ -7823,12 +7866,10 @@ of real structure in a \LaTeX{} document body). \fi } % \end{macrocode} -% |1.08| This was originally in \csbc{Etoc@etoccontentsline}, intermixed -% with the definitions of \csbc{Etoc@contents} and \csbc{Etoc@prefix}. Separated -% here for clarity of code. One has to be careful that this may close +% One has to be careful that this may close % groups. The conditionals are all global. The \csbc{Etoc@level} has been % |\global\let| to a |\chardef| variable. The final |\else| of the -% |\ifcase| assumes none of the |\Etoc@end@..| routines modify it, +% |\ifcase| assumes none of the \csa{Etoc@end@..} routines modify it, % naturally. % \begin{macrocode} \def\Etoc@doends {% @@ -7866,25 +7907,11 @@ of real structure in a \LaTeX{} document body). \fi } % \end{macrocode} -% |1.08| the |\Etoc@next| will (possibly) execute the |begin| code, -% \emph{before} \csbc{Etoc@contents} and \csbc{Etoc@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 \csa{Etoc@isfirsttrue}. -% -% |1.08k| This was originally in \csbc{Etoc@etoccontentsline}. Extracted for -% re-use by \csbc{etocsetlocaltop.toc}. Calls \csbc{Etoc@setflags} which must not -% modify |\Etoc@next|. +% Calls \csbc{Etoc@setflags} which must not modify \csa{Etoc@next}. % \begin{macrocode} \def\Etoc@dobegins{% \let\Etoc@next\@empty \Etoc@global\Etoc@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@level \ifEtoc@ \else @@ -7931,79 +7958,9 @@ of real structure in a \LaTeX{} document body). \Etoc@setflags \Etoc@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 -% the standard meaning of executing |\l@unit| (the hyperref -% modifications are taken into account). It is the various |\l@unit|'s -% which are (locally) |\let| to \csbc{Etoc@lxyz} and it is \csbc{Etoc@lxyz} -% which does the parsing of the arguments in order to extract name, -% number and page number. Once they are obtained, via the execution of -% this indirectly hacked |\contentsline|, the code executes the -% \csbc{Etoc@prefix} and \csbc{Etoc@contents} corresponding to that unit level, -% according to the user \csbc{etocsetstyle} declarations. Before that the -% begin part is executed when \etoc first encounters that level -% coming from a higher one and the end part will be executed when -% hitting a more important level. -% -% \csbc{etocskipfirstprefix} was already part of the very first release of -% \etoc. Up to |1.07n| it was just an elegant |\@thirdofthree| possibly -% executed just before a |\@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}| -% line. But this made it impossible for me to execute things after the -% |begin| parts. -% -% Executing stuff before |begin| is now a potential problem because the user -% can close some group in the |begin| code (this was in fact impossible in -% versions |<1.08| because this would have erased the definitions of -% \csbc{Etoc@contents} and \csbc{Etoc@prefix}). Thus I am not so free now to define -% things before execution of begin, if I allow people to close a group -% therein, except if I make them global. -% -% The mechanism of \csbc{etocskipfirstprefix} made it impossible to add -% anything at the end of the |begin| codes. Thus I changed it in |1.08| -% to simply work with a (global) boolean flag. This gives user the -% freedom to use \csbc{etocskipfirstprefix} anywhere in the |begin| code and -% it made room for a delimited macro I called \csa{etoconlyonfirst}. But -% then I dropped it in favor of definition of the \csbc{etociffirst} -% conditional. -% -% Macros |\Etoc@swa| and |\Etoc@swb| which did the \csbc{Etoc@et@hop} thing have -% been suppressed, their effect is incorporated to the end of -% \csbc{Etoc@etoccontentsline}. -% \begin{macrocode} \def\etocskipfirstprefix {\global\Etoc@skipprefixtrue } % \end{macrocode} -% |2015/03/08| let's record that \csbc{Etoc@level} used to be called -% |\Etoc@tmp| in versions earlier than |1.08| (and |\Etoc@tmp| is used -% in the completely different ulterior \csbc{Etoc@lxyz} context). The code -% sets it for example to be \csa{Etoc@section@@} which has been let by -% \csbc{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 \csbc{Etoc@localtableofcontents} which is executed after the test -% of emptiness) that \csa{Etoc@localtop} was still undefined. Earlier version of -% the code was a bit lazy and did not avoid some unneeded |\ifnum| with -% \csa{Etoc@localtop} in context where the flag \csbc{ifEtoc@stoptoc} was |\iftrue|; -% this was not an issue when code was first written, \csa{Etoc@localtop} was -% always initialized back then. But the code in \csbc{Etoc@localtableofcontents} -% handling local TOCs with unrecognized ids would call execution of the |.toc| -% file under some special context with flag \csbc{ifEtoc@stoptoc} artificially set -% to true. If \csa{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 leads then to unneededly expand \csbc{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 \csbc{Etoc@setflags} rather than leaving it like here deep inside -% conditional branches. -% -% Attention! |1.09|'s \csbc{etoclocaltop} is the former \csa{Etoc@localtop} -% \emph{minus one}. Hence some slight change in conditional here. +% Heart of \etoc hack into execution of |.toc| file. % \begin{macrocode} \def\Etoc@etoccontentsline #1{% \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname @@ -8026,7 +7983,7 @@ of real structure in a \LaTeX{} document body). \fi \fi \fi - \let\Etoc@next\Etoc@gobblefourorthree + \let\Etoc@next\@gobblefour \ifEtoc@skipthisone \else \unless\ifnum\c@tocdepth<\Etoc@level @@ -8040,49 +7997,22 @@ of real structure in a \LaTeX{} document body). \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 -% \csbc{Etoc@setflags} was done above already. Earlier method proceeded with -% dummy empty line styles. -% % |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 \csbc{Etoc@doends} which may close groups. (code has changed since, -% slightly). -% -% |1.08| extracts to a separate macro \csbc{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. -% -% |1.08k| extracts \csbc{Etoc@dobegins}. -% \begin{macrocode} -\def\Etoc@etoccontentsline@ #1{% - \Etoc@doends % separated since 1.08 - \Etoc@dobegins % separated since 1.08k. Does \Etoc@setflags. -% \end{macrocode} -% |1.08|: -% \begin{enumerate} -% \item separates the definition of \csbc{Etoc@prefix} and -% \csbc{Etoc@contents} from the execution of the |end| parts. And it does -% the definition with some |\csname|'s. -% -% \item implements \csbc{etocskipfirstprefix} with a boolean, this is less slick -% but more flexible than the earlier method. -% -% \item defines the \csbc{etociffirst} conditional. -% -% \item has \csbc{Etoc@level} rather than |\Etoc@tmp| and thus we can dispense -% with the |\ifEtoc@part| switch as we will be able to test the equality -% |\Etoc@level=-1| inside of \csbc{Etoc@lxyz}. -% -% \item adds the \csbc{Etoc@global} prefix. -% \end{enumerate} -% |1.08i| uses an |\edef| rather than |\def| with a chain of |\expandafter|. +% globally +% +% |1.1a| implements a radical change to all internals for compatibility +% with (attow future) \ctanpkg{hyperref}. Formerly this macro fetched only +% the first argument. It now also fetches all four (the fourth argument of +% \csa{contentsline} is always present since \LaTeX{} |2020/10/01|). The +% \csbc{Etoc@lxyz} used to receive only two arguments like \csa{l@chapter}, +% \csa{l@section}, etc... which were formerly |\let| to it. It now also +% receives the fourth argument of \csa{contentsline}. % \begin{macrocode} +\def\Etoc@etoccontentsline@ #1#2#3#4{% + \Etoc@doends + \Etoc@dobegins \Etoc@global\edef\Etoc@prefix {\expandafter\noexpand \csname Etoc@prefix@\csname Etoc@#1@\endcsname\endcsname }% \Etoc@global\edef\Etoc@contents{\expandafter\noexpand @@ -8090,174 +8020,156 @@ of real structure in a \LaTeX{} document body). \ifEtoc@skipprefix \Etoc@global\let\Etoc@prefix\@empty\fi \global\Etoc@skipprefixfalse % \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 -% everything if it has to (or gobble only the \etoc things, when in -% compatibility mode). -% -% For the record we don't do |\csname l@#1\endcsname| mainly because -% hyperref patches |\contentsline|. -% -% The location where \csbc{Etoc@savedcontentsline} is |\let| to -% |\contentsline| has been moved with release |1.08| to before the -% title as set by \csbc{etocsettocstyle}, thus it is now possible to open a -% tabular in this part. And with the |\Etoc@global| prefix the user may -% opt for global definitions of \csbc{etocname} and the like, thus use -% freely |&| and other group closing things. Also, some care has been -% put into doing only expandable things after expansion of the -% \meta{prefix} and \meta{contents} parts of a sectioning unit -% style. -% -% |1.09e| prepares for LaTeX November 2021 upcoming release -% whose |\contentsline| will always grab four arguments whether or -% not hyperref is loaded. The \csbc{Etoc@et@hop} definition done at -% begin document must now swap the same number of arguments -% whether or not hyperref is loaded (else \etoc would be broken in -% absence of hyperref). +% |1.1a| made core rewrites for \ctanpkg{hyperref} compatibility, and +% simplified the logic. The code does not execute the original +% \csa{contentsline} in a custom wrapper, which needed to have aliased all +% \csa{l@section} etc... to \csbc{Etoc@lxyz}. Now the \etoc custom +% \csa{contentsline} passes over directly to \csbc{Etoc@lxyz} which will do +% itself the job of adding hyperlinking according to the status of +% \ctanpkg{hyperref}'s \csa{Hy@linktoc}. +% +% This is a breaking change if a user hacked \csa{contentsline} to do some +% specific pre-processing of the data, as this extra will now be ignored. The +% kind of hack one can think of is perhaps to pre-process the section title to +% turn it into uppercase, this kind of things, but why do such things when one +% is using \etoc which precisely provides a general interface for such +% customization? Besides as the \LaTeX{} legacy set-up already mixes up in +% various ways name and number in the second argument of \csa{contentsline}, +% doing such hacks in a non-breaking way was not easy, and could have broken +% \etoc easily anyhow. +% +% The major hacker was \ctanpkg{hyperref}... Indeed in 2012 when I started +% work on \etoc, it was not clear to me how \ctanpkg{hyperref} would end up +% using the fourth argument of \csa{contentsline} and I did not want to spend +% too much time tracing hyperref code. So I simply let \ctanpkg{hyperref} do +% its stuff, and added specific post-processing branches to unravel it. +% It looks quite dumb in retrospect (at this time the |.toc| file lines +% with \csa{contentsline} had either three or four arguments which contributed +% for the design decisions back then). +% +% All \ctanpkg{hyperref} specific branches are now gone, replaced by extra +% code added depending on the status of the \csbc{ifEtoc@hyperref} boolean. +% We also check the \csa{Hy@linktoc} \csa{chardef} status and (imitating +% \ctanpkg{hyperref} do not hyperlink the page number argument if it turns out +% empty. This maintains backwards-compatibility with earlier releases of +% \etoc. % \begin{macrocode} - \Etoc@et@hop{\Etoc@prefix\Etoc@contents}{\Etoc@savedcontentsline{#1}}% + \Etoc@lxyz{#2}{#3}{#4}% + \Etoc@prefix\Etoc@contents } % \end{macrocode} -% START OF MAINLY OBSOLETE COMMENTS -% -% |2013/03/07|: up to |1.06| \etoc defined only \csbc{etocname}, \csbc{etocnumber} and -% \csbc{etocpage}. The \ctanpkg{hyperref} added data is recycled in the simplest -% manner, prefixing it with \csa{leavevmode}. The included -% \csa{Hy@tocdestname} is (was, see below |1.07f| and |1.08a|) left -% unexpanded. We have to spend some time with delimited macros to dis-entangle -% the |.toc| data, and reconstruct the possible \ctanpkg{hyperref} data. If the page -% number is not hyperlinked, \csbc{etocpage} does \emph{not} add the link found -% possibly in the name. -% -% |1.07| adds \csbc{etocthename}, \csbc{etocthenumber}, \csbc{etocthepage} which -% are left fragile and do not have the links data, and -% \csbc{etoclink}\marg{linkname} which is robust and reconstructs an -% arbitrarily named link. -% -% A need (for things like building up a token list to be used in a -% |tikzpicture|) arose later to have some form of the link which could be -% saved by a simple command like one can do -% |\global\let\lastname\etocthename|, and avoid having to manipulate -% \csa{Hy@tocdestname}. So |1.07f| adds \csbc{etocthelinkedname}, -% \csbc{etocthelinkednumber}, \csbc{etocthelinkedpage}, \csbc{etocthelink}: they -% use \csa{hyperlink} with an expanded \csa{Hy@tocdestname}. -% -% |1.07f| also adds \csa{leavevmode} to \csbc{etoclink} which -% should have been done earlier, as it was included in \csbc{etocname} etc... -% attention, \csa{@namedef}|{A}{B}| and not \csa{@namedef}|{A} {B}| !! -% on the other hand this gives a simple way to insert a space as the first -% token in the paramaters. For \csbc{Etoc@again} (which appears later in the -% code), a \csa{@firstofone} construct is however the simplest of all. -% -% END OF MAINLY OBSOLETE COMMENTS -% -% |1.08| adds \csbc{Etoc@global} prefix (|2015/03/09|). -% -% |1.08a| drops the original constructions of \csbc{etocname} etc... The obvious -% decision to convert \csbc{etocname}, etc ... to be the robust versions of -% \csbc{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 -% forced to use \csbc{etocthelinkedname}, etc... in cases when the thing had to -% be stored for delayed use. Now the user can do this directly with -% \csbc{etocname}, \csbc{etocnumber}, \csbc{etocpage} (taking into account though -% that these are robust macros, thus perhaps using something like |\LetLtxMacro|.) -% -% |1.08j| turns \csbc{etoclink} into the robust version of \csbc{etocthelink}. Indeed -% so far only \csbc{etocthelink} contained |\Hy@tocdestname| expanded. But -% \csbc{etoclink} did not, and thus it could not be used after a group was -% closed for example by a |&| from the sectioning style, even if having used -% \csbc{etocglobaldefs}. -% -% |1.08n| adds |\futurelet|-based methods to avoid unbracing things. -% -% |1.08p| uses \csbc{Etoc@@getnb} (and \csbc{Etoc@@getit}) to intercept cases -% when |\numberline| is hidden behind braces -% (\url{https://github.com/ho-tex/hyperref/issues/65}). +% |1.1a| makes a core rewrite for compatibility with \ctanpkg{hyperref}. +% In particular \csbc{Etoc@lxyz} now has a third argument which was the +% fourth argument of \csa{contentsline}. All various ``|@hyp|'' code +% branches have been removed. We only check the \csbc{ifEtoc@hyperref} +% boolean here. +% +% A \textbf{breaking change} is made at |1.1a|: \csbc{etoclink} will always +% create an hyperlink, even in case of \ctanpkg{hyperref} being (possibly +% locally) configured to obey |linktoc=none|. Formerly, in such case, +% \csbc{etoclink} added no hyperlink because \etoc identified the hyperlink +% target from +% the \ctanpkg{hyperref} hacked arguments of \csa{l@section} et al, rather +% than picking it from the fourth argument of \csa{contentsline}. +% \begin{macrocode} +\def\Etoc@lxyz #1#2#3{% + \ifEtoc@hyperref + \Etoc@global\def\etocthelink##1{\hyperlink{#3}{##1}}% + \else + \Etoc@global\let\etocthelink\@firstofone + \fi + \Etoc@global\def\etocthepage {#2}% + \ifEtoc@hyperref + \ifx\etocthepage\ltx@empty + \Etoc@global\let\etocthelinkedpage\etocthepage + \else + \Etoc@global\def\etocthelinkedpage{\hyperlink {#3}{#2}}% + \fi + \else + \Etoc@global\let\etocthelinkedpage\etocthepage + \fi +% \end{macrocode} +% Define \cs{etocthename} and \cs{etocthelinkedname}, but this will +% perhaps be redone later if it is found out that the entry was numbered. +% \begin{macrocode} + \Etoc@global\def\etocthename{#1}% + \ifEtoc@hyperref + \Etoc@global\def\etocthelinkedname{\hyperlink{#3}{#1}}% + \else + \Etoc@global\let\etocthelinkedname\etocthename + \fi +% \end{macrocode} +% Now we check if the entry was numbered and then disentangle the number from the name. % \begin{macrocode} -\def\Etoc@lxyz #1#2{% - \Etoc@global\let\etocthelink\@firstofone % fall-back, was let \@empty up to 1.08i (inc.) - \Etoc@global\def\etocthename {#1}% (if linked, will be removed later) - \Etoc@global\def\etocthelinkedname {#1}% (probably redefined later) - \futurelet\Etoc@getthepage@token - \Etoc@getthepage #2\etoc@ % defines \etocthelinkedpage \futurelet\Etoc@getnb@token - \Etoc@@getnb #1\relax\relax\etoc@ % sets number, name, and \etocthelink + \Etoc@@getnb #1\relax\relax\etoc@ +% \end{macrocode} +% We may believe the entry was not numbered due it being a \cs{part} entry +% which has a specific format. So we need to do some additional job in +% such cases. +% \begin{macrocode} \ifEtoc@number \else \ifnum\Etoc@level=\m@ne \futurelet\Etoc@getit@token - \Etoc@@getit #1\hspace\relax\etoc@ % additional job for parts + \Etoc@@getit #1\hspace\relax\etoc@ \fi \fi - \Etoc@global\expandafter\let\csname etoclink \endcsname\etocthelink - \Etoc@global\expandafter\let\csname etocname \endcsname\etocthelinkedname - \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthelinkednumber - \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthelinkedpage - } % \end{macrocode} -% |1.08| adds the \csbc{Etoc@global}'s. -% -% |1.08j| fixes an old |\ifx #1\hyperlink@start| bug. -% -% Potential (but rather exotic) brace removal problems avoided at |1.08n|. -% -% |1.09g| delays definition of \csbc{Etoc@getthepage} to \csa{AtBeginDocument} to -% check if \ctanpkg{hyperref} is at version |7.00u 2022-11-13| or later, as that -% version replaced \csa{hyper@linkstart} with \csa{protected} macro -% \csa{Hy@toclinkstart} which furthermore requires one more expansion step. -% Formerly, the \csbc{ifEtoc@hyperref} test was executed via the expansion of -% \csbc{Etoc@getthepage} but now this test is tacitly done only once at begin -% document to define appropriately \csbc{Etoc@getthepage}. Falls back to -% \csbc{Etoc@getthepage@nohyp}. +% If there was a number the \csbc{etocthename} and \csbc{etocthenumber} got +% redefined. We know need to give proper definition to \csbc{etocthelinkedname} +% and \csbc{etocthelinkednumber}. % \begin{macrocode} -\def\Etoc@getthepage@nohyp #1\etoc@ {% - \Etoc@global\def\etocthepage {#1}% - \Etoc@global\def\etocthelinkedpage {#1}% + \ifEtoc@number + \ifEtoc@hyperref + \def\Etoc@tmp##1##2{\Etoc@global\def##2{\hyperlink{#3}{##1}}}% + \expandafter\Etoc@tmp\expandafter{\etocthename}\etocthelinkedname + \expandafter\Etoc@tmp\expandafter{\etocthenumber}\etocthelinkednumber + \else + \Etoc@global\let\etocthelinkedname\etocthename + \Etoc@global\let\etocthelinkednumber\etocthenumber + \fi + \else + \Etoc@global\let\etocthenumber\@empty + \Etoc@global\let\etocthelinkednumber\@empty + \fi + \Etoc@global\expandafter\let\csname etoclink \endcsname\etocthelink + \Etoc@global\expandafter\let\csname etocname \endcsname\etocthename + \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthenumber + \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthepage + \ifEtoc@hyperref + \Etoc@lxyz@hyper + \fi } % \end{macrocode} -% |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. -% -% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. Thus, the user has -% the (not so recommended) possibility to use |\toks@| in the styles, even to -% store information whose scope extends beyond the execution of each -% |\contentsline|. -% -% |1.08| adds the \csbc{Etoc@global}'s. +% In presence of \ctanpkg{hyperref}, \etoc |1.1a| adds the hyperlinks +% itself. For this it imitates the \ctanpkg{hyperref} own logic and tests +% \csa{Hy@linktoc} and if the page number is empty. This adds a dependency +% that \csa{Hy@linktoc} should exist and have the expected interpretation. % -% |1.08j| does not define \csa{etoclink<space>} anymore, only \csbc{etocthelink} -% which contains the |\Hy@tocdestname| already expanded. +% Matters of tagging will have to wait for \LaTeX\ itself to show me what it +% does in \csa{l@section} etc... so that I can imitate. % \begin{macrocode} -\def\Etoc@getthepage@hyp #1#2#3#4#5\etoc@ {% - \Etoc@global\def\etocthepage {#4}% - \edef\Etoc@tmp {{#3}}% - \Etoc@global\expandafter\def\expandafter\etocthelinkedpage\expandafter - {\expandafter\hyperlink \Etoc@tmp{#4}}% - \Etoc@global\edef\etocthelink##1{\noexpand\hyperlink\Etoc@tmp{##1}}% +\def\Etoc@lxyz@hyper{% + \ifcase\Hy@linktoc + % none: nothing to do + \or % section (aka name for etoc): link name and number + \Etoc@global\expandafter\let\csname etocname \endcsname\etocthelinkedname + \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthelinkednumber + \or % page. Do as hyperref: add a link only if page number isn't empty. + \ifx\etocthepage\ltx@empty + \else + \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthelinkedpage + \fi + \else % all + \Etoc@global\expandafter\let\csname etocname \endcsname\etocthelinkedname + \Etoc@global\expandafter\let\csname etocnumber \endcsname\etocthelinkednumber + \ifx\etocthepage\ltx@empty + \else + \Etoc@global\expandafter\let\csname etocpage \endcsname\etocthelinkedpage + \fi + \fi } -% \end{macrocode} -% |1.08j| fixes an old buggy |\ifx #1\hyper@linkstart|. This could show if -% hyperref was present with |linktoc=page| option for example, because in that -% case |#1| could be some tokens within braces. As this is rare case though, -% no bug was reported. -% -% Anyway I refactored the whole thing at |1.08n|. -% -% |1.08p| adds workaround for an extra brace pair inserted by hyperref -% in case of |linktoc=page| option -% \centeredline{\url{https://github.com/ho-tex/hyperref/issues/65}} -% -% |1.09f| examines also if next token in a space token; if it is we know -% that we are not with a hyperref-customized entry and that we do not have a -% numbered entry. We thus jump directly to \csbc{Etoc@getnb@nohyp@nonbr}, so -% \csbc{etocthename} is certainly not redefined and there is no risk of space -% gobbling and brace removal. This precaution is a bit academic though as -% code from previous release could derail (i.e. mis-interpret data) only in -% especially crafted circumstances. -% \begin{macrocode} \def\Etoc@@getnb {% \Etoc@bracednamefalse \let\Etoc@next\Etoc@getnb @@ -8280,43 +8192,23 @@ of real structure in a \LaTeX{} document body). \futurelet\Etoc@getnb@token\Etoc@getnb } % \end{macrocode} -% |1.09g| adds an \csa{Etoc@getnb@a} which -% gets defined only at begin document to adapt to \ctanpkg{hyperref} depending on -% whether the latter is at |7.00u| or earlier. In absence of \ctanpkg{hyperref} -% it is \csa{let} to \csbc{Etoc@getnb@nohyp}. +% The |@nohyp| in the macro names is a legacy of pre-|1.1a| code. % \begin{macrocode} \def\Etoc@getnb {% \ifx\Etoc@getnb@token\bgroup \expandafter\Etoc@getnb@nohyp@nonbr \else - \expandafter\Etoc@getnb@a + \expandafter\Etoc@getnb@nohyp \fi } % \end{macrocode} -% |1.08| adds the \csbc{Etoc@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 \csbc{Etoc@tableofcontents}. Currently \etoc does not yet use \eTeX. -% -% |1.08m| fixes incompatibility of |1.08k|'s delimited macro method with KOMA's -% \csa{nonumberline}. -% -% Both |1.08k| and -% |1.08m| actually would have needed some |\detokenize| for complete safety -% and so far \etoc does not use e-\TeX. So here at |1.08n| I refactored the -% whole thing. And I added a |\futurelet|-based brace detection in -% \csbc{Etoc@getnb} so here |#1| is guaranteed not braced now. -% -% |1.08n| tries to handle reasonably the |\nonumberline| of \ctanpkg{KOMA-script}. +% |1.08n| tries to handle reasonably the \csa{nonumberline} of \ctanpkg{KOMA-script}. % If it expands to |\numberline{}|, \etoc will thus consider the line % numbered with an empty number. % -% At |1.09f| complications to get rid of a \ctanpkg{KOMA-script} |\nonumberline| -% even though its meaning is |\empty| then, but for case of delayed use. +% At |1.09f| complications to get rid of a \ctanpkg{KOMA-script} \csa{nonumberline} +% even though its meaning is \csa{empty} then, but let's get rid of it in case +% the tokens are stored by the user section styles for delayed use. % \begin{macrocode} \def\Etoc@getnb@nohyp #1{% \in@{#1}{\numberline\chapternumberline\partnumberline\booknumberline}% @@ -8356,8 +8248,8 @@ of real structure in a \LaTeX{} document body). \Etoc@global\let\etocthelinkednumber \@empty } % \end{macrocode} -% Special KOMA branch: |#1| starts with |\nonumberline| which has here same -% meaning as |\empty|. It is in the current provisory definition of +% Special KOMA branch: |#1| starts with \csa{nonumberline} which has here same +% meaning as \csa{empty}. It is in the current provisory definition of % \csbc{etocthename}. We get rid of this token, in case usage is delayed, % to avoid improbable problems. % \begin{macrocode} @@ -8374,138 +8266,18 @@ of real structure in a \LaTeX{} document body). \Etoc@global\let\etocthelinkedname \etocthename } % \end{macrocode} -% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. |1.08| adds -% the \csbc{Etoc@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. -% -% But anyway this was completely refactored at |1.08n|. Unfortunately -% bad macro naming scheme caused a typo in a macro name, and it was -% left undefined. -% Fixed at |1.08o|. -% -% At |1.08p| which fixed an hyperref problem in case of |linktoc=page| -% we are lazy because the problem with extra braces should not happen -% in this branch (hyperref does not brace the hyperlink). So we ignore -% the |\ifEtoc@bracedname| setting. -% -% At |1.09f| complications to get rid of a \ctanpkg{KOMA-script} |\nonumberline| -% even though its meaning is |\empty| then, but for case of delayed use. -% -% At |1.09h| I converted the |#5#6| into |#5|, the |#5#6| had been kept -% around for ages here, perhaps a legacy of early versions, anyway -% here the macro really wants the |#4| anyhow only (and |#3|) and there -% can be only one \csa{etoc@}. -% -% The |7.00u| \ctanpkg{hyperref} has modified the mark-up, but \csa{Etoc@getnb@a} -% defined at begin document has caused the expansion of \csa{Hy@toclinkstart} -% so we are back to the |<7.00u| situation; and \csa{Hy@toclinkend} is anyhow -% gobbled as part of |#5| as was formerly \csa{hyper@linkend} so we don't have -% to worry about that \ctanpkg{hyperref} change. -% \begin{macrocode} -\def\Etoc@getnb@hyp #1#2#3#4#5\etoc@ {% - \edef\Etoc@tmp {{#3}}% - \Etoc@global\edef\etocthelink ##1{\noexpand\hyperlink {#3}{##1}}% - \Etoc@global\def\etocthename {#4}% temporary definition - \Etoc@global\expandafter\def\expandafter\etocthelinkedname - \expandafter {\expandafter\hyperlink \Etoc@tmp{#4}}% - \futurelet\Etoc@hyp@getnb@token\Etoc@getnb@hyp@a #4\relax\relax\etoc@ -} -% \end{macrocode} -% In case of an upfront brace, the sectioning heading is not numbered, so we -% can avoid potential brace removal problems by jumping now to the not -% numbered branch not hyperlinked branch; indeed \csbc{etocthelinkedname} has -% already been defined with the |\hyperlink| so we can bail out. -% \begin{macrocode} -\def\Etoc@getnb@hyp@a {% - \ifx\Etoc@hyp@getnb@token\bgroup - \expandafter\Etoc@getnb@nohyp@nonbr - \else - \expandafter\Etoc@getnb@hyp@b - \fi -} -\def\Etoc@getnb@hyp@b #1{% - \in@{#1}{\numberline\chapternumberline\partnumberline\booknumberline}% - \ifin@ - \let\Etoc@next\Etoc@getnb@hyp@nmbrd - \else -% \end{macrocode} -% If not numbered we can bail out to the "nohyp" branch, as -% \csbc{etocthelinkedname} has already been defined with the |\hyperlink|. -% \begin{macrocode} - \let\Etoc@next\Etoc@getnb@nohyp@nonbr - \in@{#1}{\nonumberline}% - \ifin@ -% \end{macrocode} -% In case of presence of KOMA \csa{nonumberline} we need to expand it -% once, and then execute the numbered branch which will redefine -% \csbc{etocthename} as well. But in case it is empty we will have to -% correct \csbc{etocthename}, just to be perfect. -% \begin{macrocode} - \ifx\nonumberline\empty - \let\Etoc@next\Etoc@getnb@hyp@nonumberline - \else - \def\Etoc@next{\expandafter\Etoc@getnb@hyp@nmbrd}% - \fi - \fi - \fi - \Etoc@next #1% -} -\def\Etoc@getnb@hyp@nmbrd #1#2#3\relax\relax\etoc@ {% - \Etoc@global\Etoc@numbertrue - \Etoc@global\def\etocthenumber {#2}% - \Etoc@global\expandafter\def\expandafter\etocthelinkednumber - \expandafter{\expandafter\hyperlink \Etoc@tmp{#2}}% - \Etoc@global\def\etocthename {#3}% - \Etoc@global\expandafter\def\expandafter\etocthelinkedname - \expandafter{\expandafter\hyperlink \Etoc@tmp{#3}}% -} -% \end{macrocode} -% Special KOMA branch: |#1| starts with |\nonumberline| which has here same -% meaning as |\empty|. We need to remove it. -% \begin{macrocode} -\def\Etoc@getnb@hyp@nonumberline #1\relax\relax\etoc@ {% - \Etoc@global\Etoc@numberfalse - \Etoc@global\let\etocthenumber \@empty - \Etoc@global\let\etocthelinkednumber \@empty - \ifEtoc@bracedname - \Etoc@global\expandafter\def\expandafter\etocthename - \expandafter{\expandafter{#1}}% - \else - \Etoc@global\expandafter\def\expandafter\etocthename\expandafter{#1}% - \fi - \Etoc@global\expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter\etocthelinkedname - \expandafter\expandafter\expandafter{% - \expandafter\expandafter\expandafter\hyperlink - \expandafter\Etoc@tmp\expandafter{\etocthename}}% -} -% \end{macrocode} -% |1.08| adds the \csbc{Etoc@global}'s. -% -% |1.08n| refactors this but it is still not extremely robust. -% -% |1.08p| completes the fix of |linktoc=page| problematic hyperref. If -% the name was found to be braced, keep the brace pair on extracted -% name. But not for extracted number... don't ask why, I did not want -% spending ages on working around hyperref's bug. +% |1.1a| maps directly to \csbc{Etoc@getit@nohyp}, and the |@nohyp| will +% perhaps be removed from its name at some later stage. % \begin{macrocode} \def\Etoc@@getit{% \ifEtoc@bracedname \expandafter\expandafter\expandafter\Etoc@getit@nameisbraced \expandafter\@firstofone \else - \expandafter\Etoc@getit + \expandafter\Etoc@getit@nohyp \fi } -\def\Etoc@getit@nameisbraced {\futurelet\Etoc@getit@token\Etoc@getit } -% \end{macrocode} -% |1.09g| delays defining \csbc{Etoc@getit} to at begin document to adapt to -% \ctanpkg{hyperref} depending on whether the latter is at |7.00u| or earlier. -% \begin{macrocode} +\def\Etoc@getit@nameisbraced {\futurelet\Etoc@getit@token\Etoc@getit@nohyp } \def\Etoc@getit@nohyp #1\hspace#2#3\etoc@ {% \ifx\relax#2% \else @@ -8524,51 +8296,6 @@ of real structure in a \LaTeX{} document body). \Etoc@global\let\etocthelinkedname\etocthename } % \end{macrocode} -% |1.07n| replaces use of |\toks@| by macro |\Etoc@tmp|. |1.08| adds -% the \csbc{Etoc@global}'s. -% -% |1.08j| adds \csbc{etocthelink} definition here which was missing. This bug -% showed in case hyperref was used with option |linktoc=page|, for |part| -% styles: the \csbc{etocthelink} would not create a link if used therein. But the -% |linktoc=page| condition could easily however trigger the more serious -% |\ifx| bug in \csbc{Etoc@getnb} also fixed at |1.08j|, and this would have -% overshadowed this one by a real compilation error rather than a missing link -% in the procuced PDF. -% -% |1.08n| refactors the whole thing. |1.08o| chooses better names for -% macros. -% -% For |1.08p| fix of hyperref's extra brace (see \csbc{Etoc@@getnb}, -% \csbc{Etoc@@getit}), this branch should not suffer the issue, hence I -% don't bother checking |\ifEtoc@bracedname| status. -% -% At |1.09h| the |#5#6| becomes |#5|, the |#5#6| was for some legacy reason -% I guess, but here the macro really wants the |#4| anyhow only (and |#3|). -% \begin{macrocode} -\def\Etoc@getit@hyp #1#2#3#4#5\etoc@ {% - \edef\Etoc@tmp {{#3}}% - \Etoc@global\edef\etocthelink ##1{\noexpand\hyperlink \Etoc@tmp{##1}}% - \Etoc@global\def\etocthename {#4}% temporary definition - \Etoc@global\expandafter\def\expandafter\etocthelinkedname - \expandafter{\expandafter\hyperlink \Etoc@tmp{#4}}% - \Etoc@getit@hyp@a #4\hspace\relax\etoc@ -} -\def\Etoc@getit@hyp@a #1\hspace#2#3\etoc@ {% - \ifx\relax#2% not extremely safe - \else - \Etoc@global\Etoc@numbertrue - \Etoc@global\def\etocthenumber {#1}% - \Etoc@global\expandafter\def\expandafter\etocthelinkednumber - \expandafter{\expandafter\hyperlink \Etoc@tmp{#1}}% - \Etoc@getit@hyp@getname #3\etoc@ - \fi -} -\def\Etoc@getit@hyp@getname #1\hspace\relax\etoc@ {% - \Etoc@global\def\etocthename {#1}% - \Etoc@global\expandafter\def\expandafter\etocthelinkedname - \expandafter{\expandafter\hyperlink \Etoc@tmp{#1}}% -}% -% \end{macrocode} % |1.08a| of |2015/03/12| does the long-postponed thing to let \csbc{etocname} % etc.. be simply the robust variant of \csbc{etocthelinkedname} etc... % \begin{macrocode} @@ -8578,7 +8305,7 @@ of real structure in a \LaTeX{} document body). \let\etocthelinkedname \@empty \let\etocthelinkednumber \@empty \let\etocthelinkedpage \@empty -\let\etocthelink \@firstofone % prior to 1.08j its was \let to \@empty +\let\etocthelink \@firstofone \DeclareRobustCommand*{\etocname} {} \DeclareRobustCommand*{\etocnumber}{} \DeclareRobustCommand*{\etocpage} {} @@ -8586,15 +8313,9 @@ of real structure in a \LaTeX{} document body). \DeclareRobustCommand*{\etocifnumbered} {\ifEtoc@number\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} \expandafter\let\expandafter\etocxifnumbered\csname etocifnumbered \endcsname -% \end{macrocode} -% |1.08| defines \csbc{etociffirst} -% \begin{macrocode} \DeclareRobustCommand*{\etociffirst} {\ifEtoc@isfirst\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} \expandafter\let\expandafter\etocxiffirst\csname etociffirst \endcsname -% \end{macrocode} -% |1.07j| modifies \csbc{Etoc@readtoc}. -% \begin{macrocode} \def\Etoc@readtoc {% \ifeof \Etoc@tf \else @@ -8618,9 +8339,6 @@ of real structure in a \LaTeX{} document body). \global\Etoc@toctoks=\expandafter{\the\Etoc@toctoks}% \closein\Etoc@tf}} {\typeout{No file \jobname.toc.}}} -% \end{macrocode} -% 1.07d: parskip and |\@nobreakfalse| stuff moved to \csbc{Etoc@tableofcontents} -% \begin{macrocode} \def\Etoc@openouttoc{% \ifEtoc@hyperref \ifx\hyper@last\@undefined @@ -8638,16 +8356,6 @@ of real structure in a \LaTeX{} document body). \fi \global\let\Etoc@openouttoc\empty } -% \end{macrocode} -% |1.08| has a new way to handle |\Etoc@standardtrue|. -% -% Also the expansion of \csbc{Etoc@levellist} is moved to inside -% \csbc{Etoc@tableofcontents} as set-up by \csbc{etocsettocstyle}. This opens up -% the possibility for the user to open a group in the title (for example -% start a tabular) which would be closed (by the first |&|) sometime -% later. In combination with \csbc{etocglobaldefs} it will be now much -% easier to typeset TOC as tables with \etoc! -% \begin{macrocode} \def\Etoc@toctoc{% \global\Etoc@vfalse \global\Etoc@ivfalse @@ -8671,27 +8379,12 @@ of real structure in a \LaTeX{} document body). \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 -% code was a remnant of extra cautious attitude. Also, now -% \csbc{etoc@@startlocaltoc} is expandable if it does nothing. -% -% |2015/04/16|: |1.08e| removes a \csbc{ifEtoc@notactive} test as |\ifnum| can -% be positive only once anyhow; although the \csbc{ifEtoc@notactive} boolean -% 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 \csbc{Etoc@global}'s for \csa{Etoc@localtop} by -% |\global|'s. The |\relax| is needed because |#2| may sometimes be a count, -% sometimes tokens. -% -% Attention! |1.09| defines a public \csbc{etoclocaltop} in replacement of old -% \csa{Etoc@localtop} \emph{minus one}. Memo: \csbc{etoclocaltop} has only +% Memo: \csbc{etoclocaltop} has only % meaningful meaning when the local toc has its "active" flag set. Except that % I used a "notactive" flag to torture myself, so: has the "notactive" flag % off. % -% Also attention |1.09| now sets the |\c@tocdepth| there in relation to +% Also attention |1.09| now sets the \csa{c@tocdepth} there in relation to % implementation of \localtocwrdp. This is needed for line styles in % compatibility mode as the code from standard classes checks the tocdepth % counter. @@ -8722,53 +8415,27 @@ of real structure in a \LaTeX{} document body). } \let\etoc@startlocaltoc\@gobble % \end{macrocode} -% |2015/03/16|: |1.08e| tests if a local table of contents turns out empty. -% The \csa{Etoc@localtop} there does not have the same meaning as when set-up -% by the regular \csbc{etoc@@startlocaltoc}. It is off by 1 (in general). THIS -% IS OBSOLETE since |1.09|: a \csbc{etoclocaltop} is used with same meaning in -% all code branches. -% -% After some hesitation I opted for making and obeying the test always (*) for -% local tables of contents, and do it also for global tables of contents but -% for the latter the user must issue \csbc{etocnotocifnotoc} for the emptiness -% test to be obeyed. The emptiness tests are to be trusted only when the -% compilations have stabilized. -% -% (*) finally the user must issue \csbc{etocchecksemptiness} once. -% % \csbc{Etoc@tocid} is the number of the toc (possibly gotten via a |\ref| % following a \csbc{tableofcontents}), or it is |\z@| if the emptiness test is % from a global toc. Until the compilations stabilize, some local TOCs can get % printed at wrong locations naturally and emptiness tests can not be trusted -% either. Releases earlier than |1.08e| authorized -% \csbc{tableofcontents}|\ref{foo}| with |foo| the label of a \emph{global} -% toc. But as it was impossible (without much complications) to discriminate, -% until auxiliary files have stabilized, between a |\ref| to a local toc whose -% id is not yet in the |.toc| file and a |\ref| to a global toc whose id will -% in the end definitely not be in the |.toc| file, I decided that this silly -% possibility should not be supported anymore. This allowed to remove a few -% tokens from \csbc{Etoc@tableofcontents} as well. And it also allowed -% improvements to \csbc{Etoc@localtableofcontents}. +% either. % % Note: (|1.08i 2016/09/29|) the code has to handle both local and total toc. -% Hence the flag \csbc{ifEtoc@notactive} has to be set prior to it. For a global -% toc, the \csbc{Etoc@tocid} was set to |\z@|, and the |\ifnum| in -% \csbc{etoc@startlocaltoc} did always fail, but I now prefer to simply nullify -% the \csbc{etoc@startlocaltoc}. As its default fallback is |\@gobble| I simply -% test here for the \csbc{ifEtoc@localtoc} flag. The \csbc{Etoc@tocid} will be undefined for a -% global toc but it is not tested anymore. +% Hence the flag \csbc{ifEtoc@notactive} has to be set prior to it. For a +% global toc, the \csbc{Etoc@tocid} was set to |\z@|, and the |\ifnum| in +% \csbc{etoc@startlocaltoc} did always fail, but I now prefer to simply +% nullify the \csbc{etoc@startlocaltoc}. As its default fallback is +% |\@gobble| I simply test here for the \csbc{ifEtoc@localtoc} flag. The +% \csbc{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 \csbc{etoc@@startlocaltoc} which uses % the level flags. Here we just record in \csbc{Etoc@level} where we last stood. % The initialization |\global\let\Etoc@level\Etoc@minf| is thus needed in case % the |.toc| file contains an \csbc{etoc@startlocaltoc} before any -% |\contentsline|. -% -% |1.08i| has two |testingcontentsline| macros, one for local, one for global. -% -% |1.09| renames the \csa{Etoc@localtop} which was used here to a public -% \csbc{etoclocaltop} to make it usable in \csbc{etocsettocstyle}. +% \csa{contentsline}. % \begin{macrocode} \def\Etoc@setemptytocbool {% \global\Etoc@emptytoctrue @@ -8805,14 +8472,11 @@ of real structure in a \LaTeX{} document body). \else \global\expandafter\let\expandafter\Etoc@level\csname Etoc@#1@@\endcsname % \end{macrocode} -% |\ifEtoc@notactive| set to False by \csbc{etoc@startlocaltoc} with right id. It +% \csbc{ifEtoc@notactive} set to False by \csbc{etoc@startlocaltoc} with right id. It % that happened, check level of hit against unit. Will decide if empty or not. % Set \csbc{ifEtoc@stoptoc} flag afterwards in all cases. \csa{Etoc@localtop} will have been % initialized by \csbc{etoc@@startlocaltoc} as \csbc{ifEtoc@notactive} flag can be % false only then. -% -% |1.09| renamed the \csa{Etoc@localtop} as formerly here to \csbc{etoclocaltop} -% and adds support for \localtocwrdp. % \begin{macrocode} \ifEtoc@notactive \else @@ -8827,7 +8491,7 @@ of real structure in a \LaTeX{} document body). \fi \fi \fi - \Etoc@gobblefourorthree\relax + \@gobblefour\relax } \def\Etoc@testingcontentsline #1{% \ifEtoc@stoptoc @@ -8840,22 +8504,9 @@ of real structure in a \LaTeX{} document body). \fi \fi \fi - \Etoc@gobblefourorthree\relax + \@gobblefour\relax } % \end{macrocode} -% |1.07g| suppresses the printing of |--unknown etoc ref: run latex again--| as -% sometimes one uses \csbc{localtableofcontents} to prepare something else, and one -% does not want any text output even in intermediate runs. -% -% Also |1.07g| adds \csbc{etocaftertochook} to help with -% \csbc{invisiblelocaltableofcontents} (and then I did \csbc{etocsetnexttocdepth}). -% |1.07h| makes the hook used by \csbc{etocsetnexttocdepth} private. -% -% |2015/03/14|: |1.08b| suppresses a space token from an unprotected end of -% line at the end after the replacement text of \csbc{etoc@startlocaltoc} (bug -% dating back to |1.03 2012/11/23|). I didn't see it due to the originally -% badly formatted source of |\Etoc@next|. -% % |2015/03/16|: |1.08e| lets \csbc{localtableofcontents} do a first scan of the % |.toc| file (as stored in \csbc{Etoc@toctoks}) to determine if the table of % contents will in fact end up empty. In that case, nothing is typeset. The @@ -8899,7 +8550,7 @@ of real structure in a \LaTeX{} document body). % 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 +% |1.08i-2016/09/29| now does \csa{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 \csbc{etoc@@startlocaltoc} due to the special values |0| @@ -8914,7 +8565,7 @@ of real structure in a \LaTeX{} document body). % % 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 +% \csa{localtableofcontents}, but finally I prefer to only trick \LaTeX\ into % telling about undefined references. % % The \csa{PackageWarning} approach has the advantage @@ -8925,7 +8576,7 @@ of real structure in a \LaTeX{} document body). % second approach. (edit |2017/10/23|: good thing I documented that! I had % completely forgotten that rationale, but I wonder if it is correct.) % -% Also the |\PackageWarning| does not trigger a visible message +% Also the \csa{PackageWarning} does not trigger a visible message % near the end of the log file or console output, contrarily to a % \centeredline{|LaTeX Warning: There were undefined references.|} % followed by a @@ -8940,43 +8591,35 @@ of real structure in a \LaTeX{} document body). \global\Etoc@emptytocfalse \edef\Etoc@tocid{#1}% \ifnum\Etoc@tocid<\@ne - %\PackageWarning{etoc}{Unknown toc reference \@secondoftwo#1. Run LaTeX again}% \setbox0\hbox{\ref{Unknown toc ref \@secondoftwo#1. Rerun LaTeX}}% - %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi - \global\Etoc@stoptoctrue % do only heading +% \end{macrocode} +% Do only heading, skip all the rest. +% \begin{macrocode} + \global\Etoc@stoptoctrue \gdef\etoclocaltop{-\thr@@}% \Etoc@tableofcontents - \expandafter\Etoc@gobbletoetoc@ % skip all the rest + \expandafter\Etoc@gobbletoetoc@ \fi \global\Etoc@notactivetrue -% \end{macrocode} -% |1.08i|'s \csbc{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}% \setbox0\hbox{\ref{Unknown toc ID \number\Etoc@tocid. Rerun LaTeX}}% - %\if@filesw\immediate\write\@mainaux{\noexpand\@tempswatrue}\fi - \global\Etoc@emptytocfalse % assume real one will be non-empty - \global\Etoc@stoptoctrue % and print only heading for this pass +% \end{macrocode} +% Assume real one will be non-empty and print only heading for this pass. +% \begin{macrocode} + \global\Etoc@emptytocfalse + \global\Etoc@stoptoctrue \gdef\etoclocaltop{-\thr@@}% \Etoc@tableofcontents \expandafter\expandafter\expandafter\Etoc@gobbletoetoc@ - \else - %% \PackageWarning{etoc}{This toc is apparently empty}% \fi \else \global\Etoc@stoptocfalse \global\Etoc@notactivetrue % \end{macrocode} -% Prior to |1.09| a \csa{Etoc@localtop} was reset here. This has now been -% moved to \csbc{Etoc@tableofcontents} and \csa{Etoc@localtop} replaced by a -% public \csbc{etoclocaltop} usable in line styles, and in \csbc{etocsettocstyle} -% (under checksemptinesstrue regime). -% % We can end up here either if the emptiness check was done and turned % negative (then \csbc{etoclocaltop} has the correct level for usage in first % argument of \csbc{etocsettocstyle}), or if the emptiness check was not done. @@ -8988,15 +8631,15 @@ of real structure in a \LaTeX{} document body). \fi \@gobble\etoc@ \endgroup\ifEtoc@mustclosegroup\endgroup\fi - \Etoc@tocdepthreset % 1.07h, renamed 1.08h - \etocaftertochook % 1.07g + \Etoc@tocdepthreset + \etocaftertochook % \end{macrocode} % |1.09| hesitates about putting this before of after the % \csbc{etocaftertochook}. The information of the used tocdepth is lost if % puuting it first. The usage of \csbc{etocaftertochook} may be broken if % unexpected tokens follows. % \begin{macrocode} - \let\Etoc@localtocdepth\c@tocdepth % 1.09 + \let\Etoc@localtocdepth\c@tocdepth }% \Etoc@localtableofcontents % \end{macrocode} % |2013/03/07|: I discover a \csa{@namedef} trick to construct the @@ -9004,7 +8647,7 @@ of real structure in a \LaTeX{} document body). % | \@namedef {Etoc@again} {...stuff...}|\\ % Original version was (copied from analogous stuff in |source2e|):\\ % | {\def\1{\Etoc@again}\expandafter\gdef\1 {...stuff...}}|\\ -% and in the end (now that I think about it) I simply use |\@firstofone|.\par +% and in the end (now that I think about it) I simply use \csa{@firstofone}.\par % \begin{macrocode} \def\Etoc@getrefno #1#2\etoc@ {#1} \def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter @@ -9013,14 +8656,9 @@ of real structure in a \LaTeX{} document body). \def\Etoc@label#1{\label{#1}\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} \@firstofone{\def\Etoc@again} {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} % \end{macrocode} -% |1.08e| adds test for emptiness. And uses another coding style for -% conditional branching. Easier to read. Not tested for efficiency. -% -% Also, |\ref{foo}| expects |foo| to be a label to a \emph{local} TOC. Earlier -% versions accepted a reference to a global TOC, I have removed the support -% from \csbc{Etoc@tableofcontents}. +% |\ref{foo}| expects |foo| to be a label to a \emph{local} TOC. % -% The syntax \csbc{localtableofcontents}|\ref{foo}| is now accepted. +% The syntax \csbc{localtableofcontents}|\ref{foo}| is supported. % \begin{macrocode} \def\Etoc@dothis #1#2\etoc@ {\fi #1} \def\Etoc@t@bleofcontents{% @@ -9030,8 +8668,7 @@ of real structure in a \LaTeX{} document body). % \end{macrocode} % \csbc{Etoc@ref} will hand over directly to \csbc{Etoc@localtableofcontents}. % Argument will be (or rather expand to) zero if the reference is non-existent -% yet. There was an \csa{Etoc@tocwithidfalse} flag which |1.08i| suppresses as it -% is not used afterwards (since |1.08e| I think.) +% yet. % \begin{macrocode} \ifx\Etoc@nexttoken\ref\Etoc@dothis{\expandafter\Etoc@ref\@gobble}\fi % \end{macrocode} @@ -9055,22 +8692,16 @@ of real structure in a \LaTeX{} document body). \fi \Etoc@tableofcontents \endgroup\ifEtoc@mustclosegroup\endgroup\fi - \Etoc@tocdepthreset % 1.07h, renamed 1.08h - \etocaftertochook % 1.07g + \Etoc@tocdepthreset + \etocaftertochook \@gobble\etoc@ }% \Etoc@t@bleofcontents % \end{macrocode} -% |1.07g| for consistency Etoc@ prefix added. -% -% |1.08c| does not use |\arabic| in the |\addtocontents| since I have seen +% |1.08c| does not use |\arabic| in the \csa{addtocontents} since I have seen % that in some circumstances (for some right to left languages with % 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 \csbc{etoc@startlocaltoc}. In -% \csbc{Etoc@table@fcontents} case it remains to be seen if a |\ref| follows which -% could turn the TOC into a local one. Handled by \csbc{Etoc@t@bleofcontents}. % \begin{macrocode} \def\Etoc@table@fcontents{% \refstepcounter{etoc@tocid}% @@ -9081,13 +8712,6 @@ of real structure in a \LaTeX{} document body). \addtocontents{toc}{\string\etoc@startlocaltoc{\the\c@etoc@tocid}}% \Etoc@tocwithidtrue \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -% \end{macrocode} -% |1.07g| defines \csbc{etoctableofcontents} to be able to undo the evil and -% brutal doings of some packages with |\tableofcontents|. -% -% |1.08| patches \ctanpkg{tableof}'s influence. Version |1.4a| or later of \ctanpkg{tableof} -% is needed. -% \begin{macrocode} \let\etocaftertitlehook \@empty \let\etocaftercontentshook \@empty % \end{macrocode} @@ -9098,18 +8722,18 @@ of real structure in a \LaTeX{} document body). % \begin{macrocode} \def\etoctableofcontents{% \Etoc@openouttoc - \Etoc@tocdepthset % new with 1.08h (\etocsetnexttocdepth) - \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents + \Etoc@tocdepthset + \begingroup % \end{macrocode} -% Prior to its release |1.4c|, \ctanpkg{tableof} added a group pair via |\tof@begin| -% and |\tof@finish|. This was removed at |1.4c|. So no need to do anything now -% here about silencing |\tof@begingroup| and |\tof@endgroup|: they are +% This group will be closed in \csbc{Etoc@t@bleofcontents} or +% \csbc{Etoc@localtableofcontents}. +% +% Prior to its release |1.4c|, \ctanpkg{tableof} added a group pair via \csa{tof@begin} +% and \csa{tof@finish}. This was removed at |1.4c|. So no need to do anything now +% here about silencing \csa{tof@begingroup} and \csa{tof@endgroup}: they are % inserted only in the \ctanpkg{tableof} private copy of the |.toc| file which is % used by its own table of contents typesetting command. % -% |1.08i| removes definition of \csbc{etoc@startlocaltoc} from here. It is done -% in \csbc{Etoc@localtableofcontents} or uses its default of |\@gobble|. -% % |1.09b| uses a |\def| in non-starred variant for allowing tricks to % recognize later on if we are in a starred or non-starred case, whatever the % user definition of \csbc{etocaftertitlehook} may be. @@ -9126,9 +8750,10 @@ of real structure in a \LaTeX{} document body). \let\tableofcontents\etoctableofcontents \newcommand*\localtableofcontents{% \Etoc@openouttoc - \Etoc@tocdepthset % new with 1.08h (\etocsetnexttocdepth) - \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents + \Etoc@tocdepthset + \begingroup % \end{macrocode} +% This group closed in \csbc{Etoc@t@bleofcontents} or \csbc{Etoc@localtableofcontents}. % Same comment relative to \ctanpkg{tableof}. No need to do anything here. % \begin{macrocode} \@ifstar @@ -9152,33 +8777,9 @@ of real structure in a \LaTeX{} document body). }% \localtableofcontentswithrelativedepth \let\Etoc@localtocdepth\c@tocdepth % \end{macrocode} -% |1.08| moves earlier the definitions of \csbc{Etoc@savedcontentsline} as -% well as \csbc{Etoc@levellist}. It will thus not be operative to do -% \csbc{etocsetlevel} from inside the title now. But perhaps it will be -% easier to deal with tables. -% -% Also I remove a big |\@firstofone|, and use rather -% \csbc{Etoc@gobbletoetoc@} for the gobbling case. -% -% Also, |1.08| modifies the code to do only expandable things after +% The code does only expandable things after % \csbc{Etoc@toctoc}, in order to allow opening of an alignment in the first -% argument and closing in the second. Earlier versions had an -% |\Etoc@@next| initially set to relax after the first \csbc{Etoc@toctoc}. I -% was in 2012/2013 quite uneasy with the TeX conditionals hence wanted -% for safety to move the things for the second invocation of -% \csbc{Etoc@toctoc} after the |\fi\fi\fi|. I could define an |\afterfififi| -% macro, but it should be ok as it is done here. -% -% |1.08e| moved the \csbc{Etoc@par} to \csbc{Etoc@tableofcontents}. This was needed -% for the implementation of the emptiness test. It might have some impact in -% fringe cases as the \csa{refstepcounter} is now done before the |\par| is -% issued. -% -% |1.08e| suppresses the possibility to do a \csbc{tableofcontents}|\ref{foo}| -% with |foo| the label of a global TOC: issueing \csbc{tableofcontents} alone -% suffices. Allowed to simplify some code. -% -% |1.08g| moves \csbc{Etoc@par} to before \csbc{etocbeforetitlehook}, not after. +% argument and closing in the second. % \begin{macrocode} \long\def\Etoc@gobbletoetoc@ #1\etoc@ {} \newcommand\etocsettocstyle[2]{% @@ -9189,27 +8790,30 @@ of real structure in a \LaTeX{} document body). \expandafter\Etoc@gobbletoetoc@ \fi \Etoc@par - \etocbeforetitlehook % 1.07m - \Etoc@storetocdepth % 1.07g - \let\Etoc@savedcontentsline\contentsline % moved up here 1.08 + \etocbeforetitlehook + \Etoc@storetocdepth + \let\Etoc@savedcontentsline\contentsline \let\contentsline\Etoc@etoccontentsline \ifEtoc@standard - \else % moved here from \Etoc@toctoc (1.08) + \else % \end{macrocode} -% Prior to |1.08|, this was done in \csbc{Etoc@toctoc} -% -% |1.08k| defines here |\etocsavedchaptertocline|, |\etocsavedsectiontocline|, -% and so on for all declared level names, again at each TOC and for the -% duration of it. +% |1.1a|'s \csbc{Etoc@lxyz} now fetches 3 not 2 arguments and the +% \csa{l@section} etc... are not |\let| to it anymore, as they used to be here +% formerly. For backwards compatibility the \csa{etocsavedchaptertocline} +% etc... are still defined, but raise a deprecation warning. % \begin{macrocode} \def\Etoc@levellist@elt####1{% - \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname - \csname l@####1\endcsname - \expandafter\let\csname l@####1\endcsname\Etoc@lxyz}% + \expandafter\def\csname etocsaved####1tocline\endcsname + {\PackageWarning{etoc}{\expandafter\string\csname + etocsaved####1tocline\endcsname\space is deprecated + and to be\MessageBreak soon removed from etoc. + Use directly \expandafter\string\csname l@####1\endcsname\MessageBreak }% + \expandafter\let\csname etocsaved####1tocline\expandafter\endcsname + \csname l@####1\endcsname + \csname l@####1\endcsname + }% + }% \Etoc@levellist -% \end{macrocode} -% |1.08k| removes |\let\chapternumberline\numberline| etc... done formerly here -% \begin{macrocode} \fi % \end{macrocode} % |1.09| makes \csbc{etocsetnexttocdepth} usable in |#1| (but this is not 100\% @@ -9220,7 +8824,7 @@ of real structure in a \LaTeX{} document body). % \begin{macrocode} #1% \Etoc@tocdepthset - \ifEtoc@parskip\parskip\z@skip\fi %1.07d + \ifEtoc@parskip\parskip\z@skip\fi \Etoc@aftertitlehook % \end{macrocode} % |1.09| has replaced former \csa{Etoc@localtop} (\emph{minus one}) by @@ -9232,28 +8836,24 @@ of real structure in a \LaTeX{} document body). \gdef\etoclocaltop{-\thr@@}% \Etoc@toctoc \etocaftercontentshook - #2\@nobreakfalse % 1.07d: \@nobreakfalse moved here - \Etoc@restoretocdepth % 1.07g. moved here from before #2 by 1.08 + #2\@nobreakfalse + \Etoc@restoretocdepth % \end{macrocode} -% |\contentsline| was set to \csbc{Etoc@etoccontentsline} by a non-global |\let|, +% \csa{contentsline} was set to \csbc{Etoc@etoccontentsline} by a non-global |\let|, % and it will recover its normal value from exiting a scope limiting group. -% But \ctanpkg{tableof} (since |1.4a|) under |\etocglobaldefstrue| does a global -% redefinition of |\contentsline|. Its |\tof@finish| then does a global -% restore of |\contentsline|, but it will be to the \etoc set -% value. |\tof@finish| is active only if either the table of contents was -% typeset using |\tableof|, |\tablenotof|, |\tableoftaggedcontents|, or -% |\nextocwithtags| was used. If not active it is either undefined (no +% But \ctanpkg{tableof} (since |1.4a|) under \csa{etocglobaldefstrue} does a global +% redefinition of \csa{contentsline}. Its \csa{tof@finish} then does a global +% restore of \csa{contentsline}, but it will be to the \etoc set +% value. \csa{tof@finish} is active only if either the table of contents was +% typeset using \csa{tableof}, \csa{tablenotof}, \csa{tableoftaggedcontents}, or +% \csa{nextocwithtags} was used. If not active it is either undefined (no % package \ctanpkg{tableof}) or |\@empty|. Prior to \ctanpkg{tableof} |1.4c|, the -% |\tof@finish| closed a group and could be undefined as well, but not if -% |\etocglobaldefstrue|. -% -% \etoc |1.09c| tested here only equality to |\@empty| to decide if it is -% needed to globally restore |\contentsline| but this meant the global restore -% was done systematically in case of absence of package \ctanpkg{tableof}. +% \csa{tof@finish} closed a group and could be undefined as well, but not if +% \csa{etocglobaldefstrue}. % -% If rather than |\@empty| the |\tof@finish| fall-back was |\relax| we could -% use here |\@ifundefined| to check in one go (matters of speaking because -% expansion of |\@ifundefined| is not in "one-go"). Maybe I should update +% If rather than |\@empty| the \csa{tof@finish} fall-back was |\relax| we could +% use here \csa{@ifundefined} to check in one go (matters of speaking because +% expansion of \csa{@ifundefined} is not in "one-go"). Maybe I should update % \ctanpkg{tableof}, but for time being I will simply add an extra test. All this is % probably lots of time on irrelevant issue. % \begin{macrocode} @@ -9269,13 +8869,6 @@ of real structure in a \LaTeX{} document body). \@gobble\etoc@ }% end of \Etoc@tableofcontents definition by \etocsettocstyle } -% \end{macrocode} -% |1.08| hacks the begin parts to update therein the \csbc{ifEtoc@isfirst} flag -% (|2015/03/09|). -% -% |1.08c| removes unneeded |\long| from the |\def|'s inside \csbc{etoc@setstyle} -% (|2015/03/29|). -% \begin{macrocode} \def\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} \long\def\etoc@setstyle#1#2#3#4#5{% \expandafter\def @@ -9329,29 +8922,24 @@ of real structure in a \LaTeX{} document body). % \ctanpkg{babel} and \ctanpkg{babel-french}, because \csa{frenchpartname} does things depending on % the current value of the counter |part|. The code in recent \ctanpkg{babel-french} (but % not yet |v2.5a| when \csbc{etocpartname} was introduced) constructs control -% sequences |\ordinali|, etc... If the part counter is zero, this gives -% |\ordinal|. Usually this is not defined, hence no error happens (as it is +% sequences \csa{ordinali}, etc... If the part counter is zero, this gives +% \csa{ordinal}. Usually this is not defined, hence no error happens (as it is % constructed via |\csname|), but under class \ctanpkg{memoir} the bug showed up. All % this to explain that I found out about this long lasting problem only on % |2015/03/14|. Probably a sign that \etoc's own line styles are rarely % used... % \begin{macrocode} -\def\etocpartname {Part}% modified 1.08b +\def\etocpartname {Part} \def\etocbookname {Book} % \end{macrocode} -% placeholder for comments % The macro \csbc{etocdefaultlines} was initially called \csbc{etoctoclines}. Now % \csbc{etoctoclines} just does \csa{Etoc@standardfalse}. -% Version |1.07e| has rewritten entirely the stuff related to penalties and -% \csa{addvspace}, as this was not satisfactory in the earlier versions, which -% were written at a early stage in the development of the -% package. Actually I am not fully satisfied with these line styles. % % Version |1.09f| wraps \csbc{etocbookname}, respectively % \csbc{etocpartname}, in the book, resp. part, line styles inside a % (potential) hyperlink together with the number. % \begin{macrocode} -\def\etocdefaultlines{\Etoc@standardfalse % +\def\etocdefaultlines{\Etoc@standardfalse %% `book': \etoc@setstyle{@minustwo} {\addpenalty\@M\etocskipfirstprefix} @@ -9424,7 +9012,7 @@ of real structure in a \LaTeX{} document body). \vbox{\etocname~% \leaders\box\z@\hfil\box\tw@ \baselineskip\etocbaselinespreadone\baselineskip - \par}% 1.08b adds the % here + \par}% \else \vbox{\etocname~% \leaders\copy\z@\hfil\break @@ -9486,7 +9074,7 @@ of real structure in a \LaTeX{} document body). % \begin{macrocode} \etoc@setstyle{@four}{}{}{}{}% \etoc@setstyle{@five}{}{}{}{}% -} % end of \etocdefaultlines! +} % \end{macrocode} % The \csbc{etocinnertopsep} default value is too big as well as \csbc{etocbelowtocskip} % and \csbc{etocabovetocskip}, I guess, but if I am remember correctly I chose them @@ -9500,14 +9088,6 @@ of real structure in a \LaTeX{} document body). \def\etocmulticoltolerance{200} \def\etocdefaultnbcol{2} \def\etocinnertopsep{2ex} -% \end{macrocode} -% |1.07i| adds a |\nobreak| before the \csbc{etocinnertopsep} and a test of vertical -% mode to see if truly adding a |\par| is a reasonable idea, in the -% case of single-column mode. -% -% |1.08b| revisits this old code written perhaps at a time I didn't know about -% |\expandafter| ! -% \begin{macrocode} \newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\let\etocoldpar\par @@ -9550,8 +9130,7 @@ of real structure in a \LaTeX{} document body). \def\etocleftrulecolorcmd{\relax} \def\etocrightrulecolorcmd{\relax} % \end{macrocode} -% |1.07i| moves the |\nobreak| to before the |\vskip\etocinnertopsep| -% (especially important for the single column case). +% placeholder % \begin{macrocode} \def\etoc@ruledheading #1{% \hb@xt@\linewidth{\color@begingroup @@ -9581,12 +9160,7 @@ of real structure in a \LaTeX{} document body). {\end{multicols}}% \addvspace{\etocbelowtocskip}}} % \end{macrocode} -% |1.07k| defines \csbc{Etoc@relax} and \csbc{etocbkgcolorcmd} as |\long|: the user -% manual says to use |\renewcommand\etocbkgcolorcmd|, and an |\ifx| test is used -% in the framed style. It was thus a bug to have non-long definitions before. Or -% I could have said in the user manual to use |\renewcommand*|, or in -% \csbc{etocframedstyle} I should test for the two, or I should pause to try to -% remember about this code and think about it. +% placeholder % \begin{macrocode} \def\etocframedmphook{\relax} \long\def\etocbkgcolorcmd{\relax} @@ -9806,7 +9380,9 @@ of real structure in a \LaTeX{} document body). {\ensureonecol \par \begingroup \phantomsection \ifx\Etoc@aftertitlehook\@empty \else - % non-starred variant +% \end{macrocode} +% non-starred variant +% \begin{macrocode} \ifmem@em@starred@listof \else \Etoc@addsuitablecontentsline @@ -9828,7 +9404,7 @@ of real structure in a \LaTeX{} document body). {\@nameuse {cfttocafterlisthook}\endgroup\restorefromonecol}} % \end{macrocode} % |1.09c| (|2020/05/15|) does an update as \ctanpkg{KOMA-script} has deprecated -% |\iftocfeature|. Thanks to Bilel Omrani for report. I did not check +% \csa{iftocfeature}. Thanks to Bilel Omrani for report. I did not check % if cloning of KOMA code required some further updates. % % Finally |1.09f| added some such updates. @@ -9841,9 +9417,6 @@ of real structure in a \LaTeX{} document body). \def\etocscrartclstyle{% \etocsettocstyle {\let\if@dynlist\if@tocleft -% \end{macrocode} -% Added at |1.07m 2015/01/23|. -% \begin{macrocode} \def\@currext{toc}% % \end{macrocode} % |1.09f| adds this \csa{list@fname} definition hunk although @@ -9858,10 +9431,6 @@ of real structure in a \LaTeX{} document body). {} {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }} {}% -% \end{macrocode} -% |1.07k|: next line to do as within current |scrartcl 2013/12/19 v3.12| -% KOMA-Script article class.^^A motivated \par in the env/macrocode/before hook -% \begin{macrocode} \etoc@Iftocfeature {toc}{numberline}{\def \nonumberline {\numberline {}}}{}% \expandafter\tocbasic@listhead\expandafter {\list@fname}% \begingroup \expandafter \expandafter \expandafter @@ -9964,25 +9533,12 @@ of real structure in a \LaTeX{} document body). {\renewcommand*\etocfontone{\normalfont\normalsize} \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle} \Etoc@redefetocstyle{chapter}}{} -% \end{macrocode} -%|1.07k (2014/03/06)| adds the |appendix| to the list of known levels if class -%\ctanpkg{memoir} is detected. -% \begin{macrocode} \@ifclassloaded{memoir} {\etocsetlevel{appendix}{0}% \renewcommand*\etocfontone{\normalfont\normalsize} \etocmemoirtoctotocfmt{chapter}{\contentsname}% \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle} \Etoc@redefetocstyle{chapter}}{} -% \end{macrocode} -%|1.07k (2014/03/06)| adds the compatibility with the \ctanpkg{tocloft} package; in -% compatibility mode etoc will obey the \ctanpkg{tocloft} customisation for the division -% headings as well as for the toc title. -% -%|1.07l (2014/04/02)| fixes the bug from the \ctanpkg{tocloft} compatibility layer which -%was \ctanpkg{memoir} incompatible: \ctanpkg{memoir} has its version of \ctanpkg{tocloft} which doesn't -%have the |\if@cftnctoc| boolean. -% \begin{macrocode} \def\etoctocloftstyle {% \etocsettocstyle {\@cfttocstart\par\begingroup @@ -10012,18 +9568,18 @@ of real structure in a \LaTeX{} document body). }% } % \end{macrocode} -% \LaTeX\ 2021 fall release lets |\contentsline| always grab four arguments, -% so with |1.09e 2021/09/23| we make sure our |\addtocontents| will always -% provide |\contentsline| with four arguments. This extra |{}| is done +% \LaTeX\ 2021 fall release lets \csa{contentsline} always grab four arguments, +% so with |1.09e 2021/09/23| we make sure our \csa{addtocontents} will always +% provide \csa{contentsline} with four arguments. This extra |{}| is done % without checking LaTeX's version by laziness, as an impact on documents % compiled with former LaTeX could be visible only with very special contexts % that only the author himself would ever consider. % -% Let's also add |\protected@file@percent| at |1.09e| although this is a +% Let's also add \csa{protected@file@percent} at |1.09e| although this is a % priori of no relevance as \etoc reads the toc file with |\endlinechar=-1| % regime. % -% When using |\addcontentsline| nothing needs to be done as both things are +% When using \csa{addcontentsline} nothing needs to be done as both things are % handled by \LaTeX\ upstream. % \begin{macrocode} \def\Etoc@addtocontents #1#2% @@ -10044,9 +9600,6 @@ of real structure in a \LaTeX{} document body). } \DeclareRobustCommand*{\etoctoccontentsline} {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}} -% \end{macrocode} -% |1.09f| adds \csbc{etocimmediatetoccontentsline}. -% \begin{macrocode} \def\Etoc@addtocontents@immediately#1#2{% \begingroup \let\Etoc@originalwrite\write @@ -10064,32 +9617,7 @@ of real structure in a \LaTeX{} document body). \DeclareRobustCommand*{\etocimmediatetoccontentsline} {\@ifstar{\Etoc@addcontentsline@@immediately}{\Etoc@addtocontents@immediately}} % \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 \ctanpkg{tocvsec2} -% compatible, if not re-doing all `toc' macros in \ctanpkg{tocvsec2} -% (|1.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 -% \ctanpkg{tocvsec2} (see its code line 143). -% -% I take this opportunity to add to the start of the toc file -% |\let\etoc@startlocaltoc\@gobble| in case \etoc is not detected, I should -% possibly have done that long ago (like I did in \ctanpkg{tableof}). -% -% In |1.07h| I decide that I should not have used |\Etoc@| but |\etoc@| for -% \csa{Etoc@settocdepth}. So I now use lowercase and add a temporary line for -% transition in the very improbable situation that someone actually did already -% use the just released |1.07g|. -% -% In |1.07i| the deactivation of \csbc{etoc@settocdepth} done at the start -% of the |.toc| file (for the case this file is used after having -% removed \etoc from the document, or imported in another document) is -% done via letting it to |\@gobble| rather than |\count@| (which would -% not be ok, as what follows would be undefined too). The reason for the -% |\count@| also used originally in \csbc{etocignoretoctocdepth} is that -% when I first worked on |1.07g| I possibly had more than one token -% after \csbc{etoc@settocdepth}, but I changed that later. -% -% |1.09| renames \csa{Etoc@resettocdepth} to \csbc{Etoc@restoretocdepth}. +% placeholder % \begin{macrocode} \def\Etoc@storetocdepth {\global\c@etoc@tocdepth\c@tocdepth } \def\Etoc@restoretocdepth {\global\c@tocdepth\c@etoc@tocdepth } @@ -10117,7 +9645,7 @@ of real structure in a \LaTeX{} document body). {\protect\etoc@settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}% } % \end{macrocode} -% |1.09f| adds \csbc{etocimmediatesettocdepth.toc}. +% placeholder % \begin{macrocode} \def\etocimmediatesettocdepth #1#{\Etoc@set@toctocdepth@immediately} \def\Etoc@set@toctocdepth@immediately #1{% @@ -10134,16 +9662,9 @@ of real structure in a \LaTeX{} document body). }% } % \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 -% \csbc{etocdepthtag.toc}\marg{name} and \csbc{etocsettagdepth}\marg{tag\_name}\marg{level} where -% level is numeric or -% alphabetical. The numeric -% level |-3| is now again not accepted by \csbc{etocsetlevel}, it can be used with -% \csbc{etocsettagdepth} (which accepts equivalently |none|). +% placeholder % \begin{macrocode} -\def\etocdepthtag #1#{\Etoc@depthtag } % \etocdepthtag.toc {name} +\def\etocdepthtag #1#{\Etoc@depthtag } \def\Etoc@depthtag #1{\addtocontents {toc}{\protect\etoc@depthtag {#1}}} % \end{macrocode} % |1.09f| adds \csbc{etocimmediatedepthtag.toc}. This can serve in some @@ -10173,9 +9694,7 @@ of real structure in a \LaTeX{} document body). % \end{macrocode} % We must cancel all \ctanpkg{tocvsec2} toc-related actions. But a check must be done % for the memoir class, as its \ctanpkg{tocvsec2} emulation does not have the -% incompatible things etoc needs to revert. This extra check added with etoc -% |1.07l|. Release |1.08g| modifies the info message under class memoir (and -% downgrades it from warning to info). +% incompatible things etoc needs to revert. % \begin{macrocode} \def\Etoc@tocvsec@err #1{\PackageError {etoc} {the command \protect#1\space is incompatible with etoc} @@ -10196,8 +9715,11 @@ of real structure in a \LaTeX{} document body). \def\resettocdepth {\@ifstar {\Etoc@tocvsec@err \resettocdepth }% {\Etoc@tocvsec@err \resettocdepth }% }% - \def\save@tocdepth #1#2#3{}% % if etoc is added to file previously - \let\reset@tocdepth\relax % using tocvsec2 +% \end{macrocode} +% If \etoc is added to a \LaTeX{} document using already \ctanpkg{tocvsec2}. +% \begin{macrocode} + \def\save@tocdepth #1#2#3{}% + \let\reset@tocdepth\relax \let\remax@tocdepth\relax \let\tableofcontents\etoctableofcontents \PackageWarning {etoc} @@ -10208,22 +9730,7 @@ of real structure in a \LaTeX{} document body). }% }% % \end{macrocode} -% |1.07g|. Initial version of \csbc{etocsetnexttocdepth}. -% -% |1.08h|: avoid after-effect of consecutive uses of \csbc{etocsetnexttocdepth} -% with no intervening TOC, due to the fact that the command did an immediate -% modification of the |tocdepth counter|. This is now delayed until -% the actual TOC typesetting. -% -% |1.09|: slight refactoring of \csbc{etocsetnexttocdepth} to let it be usable -% from first argument of \csbc{etocsettocstyle} although it is even simpler to -% use \csbc{etocsettocdepth} there, because the setting is automatically undone -% at end of TOC. -% -% Recall that etoc allows to change all numeric -% levels assigned to sectioning names, and the one used by -% \csbc{etocsetnexttocdepth} is determined at time of next toc only, when -% \csbc{Etoc@tocdepthset} will expand. +% placeholder % \begin{macrocode} \def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }% \def\invisiblelocaltableofcontents @@ -10245,13 +9752,8 @@ of real structure in a \LaTeX{} document body). \global\let\Etoc@tocdepthset\@empty }% }% -\let\Etoc@tocdepthreset\@empty % new 1.08h functioning of \etocsetnexttocdepth -\let\Etoc@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} +\let\Etoc@tocdepthreset\@empty +\let\Etoc@tocdepthset \@empty \def\etocsetlocaltop #1#{\Etoc@set@localtop}% \def\Etoc@set@localtop #1{% \@ifundefined{Etoc@#1@@}% @@ -10261,7 +9763,7 @@ of real structure in a \LaTeX{} document body). {\protect\etoc@setlocaltop\expandafter\protect\csname Etoc@#1@@\endcsname}}% }% % \end{macrocode} -% |1.09f| adds \csbc{etocimmediatesetlocaltop.toc}. +% placeholder % \begin{macrocode} \def\etocimmediatesetlocaltop #1#{\Etoc@set@localtop@immediately}% \def\Etoc@set@localtop@immediately #1{% @@ -10346,11 +9848,6 @@ of real structure in a \LaTeX{} document body). }% \def\Etoc@setlocaltop@doends@dobegins {\Etoc@doends\Etoc@dobegins\global\Etoc@skipprefixfalse}% -% \end{macrocode} -% \begin{macrocode} -% |1.07h|. In order for the |.toc| file to be usable without error even -% without etoc. In |1.07i| use of |\@gobble| for \csbc{etoc@settocdepth}. -% \begin{macrocode} \addtocontents {toc}{\protect\@ifundefined{etoctocstyle}% {\let\protect\etoc@startlocaltoc\protect\@gobble \let\protect\etoc@settocdepth\protect\@gobble @@ -10366,11 +9863,11 @@ of real structure in a \LaTeX{} document body). \etocstandarddisplaystyle \etocobeytoctocdepth \etocobeydepthtags -\let\etocaftertochook \@empty % public for end user. -\let\etocbeforetitlehook \@empty % new with 1.07m +\let\etocaftertochook \@empty +\let\etocbeforetitlehook \@empty % \end{macrocode} -% |listings| abuses |\tableofcontents| for its |\lstlistoflistings|. It -% doesn't seem worth to let my version of |\tableofcontents| have to check for +% |listings| abuses \csa{tableofcontents} for its \csa{lstlistoflistings}. It +% doesn't seem worth to let my version of \csbc{tableofcontents} have to check for % this special circumstance. So at |1.09d|, simply add this (and induced % annoying updates to documentation at at least two locations): % \begin{macrocode} diff --git a/macros/latex/contrib/etoc/etoc.pdf b/macros/latex/contrib/etoc/etoc.pdf Binary files differindex 1b24ab3fc6..545546bd53 100644 --- a/macros/latex/contrib/etoc/etoc.pdf +++ b/macros/latex/contrib/etoc/etoc.pdf |