From 05feb8ba1f91b7ff8d584fcc7b8497e76b58be5c Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sat, 2 Feb 2013 22:45:32 +0000
Subject: etoc 1.07 (2feb13)

git-svn-id: svn://tug.org/texlive/trunk@29011 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/latex/etoc/etoc.dtx | 565 ++++++++++++++++-----------
 1 file changed, 337 insertions(+), 228 deletions(-)

(limited to 'Master/texmf-dist/source/latex/etoc/etoc.dtx')

diff --git a/Master/texmf-dist/source/latex/etoc/etoc.dtx b/Master/texmf-dist/source/latex/etoc/etoc.dtx
index 9421280c006..caeaf1038aa 100644
--- a/Master/texmf-dist/source/latex/etoc/etoc.dtx
+++ b/Master/texmf-dist/source/latex/etoc/etoc.dtx
@@ -1,8 +1,8 @@
 % -*- coding: iso-latin-1; -*-
 %<*ins>
 \def\pkgname{etoc}
-\def\pkgdate{2013/01/29}
-\def\pkgversion{v1.07}
+\def\pkgdate{2013/02/02}
+\def\pkgversion{v1.07b}
 \def\pkgdescription{easily customizable TOCs (jfB)}
 %</ins>
 %%
@@ -10,8 +10,8 @@
 %% Copyright (C) 2012, 2013 by Jean-Francois Burnol
 %%
 %<*none>
-\def\lasttimestamp{Time-stamp: <29-01-2013 15:19:54 CET jfb>}
-\def\docdate{2013/01/29}
+\def\lasttimestamp{Time-stamp: <02-02-2013 10:50:15 CET jfb>}
+\def\docdate{2013/02/02}
 \def\striptimestamp#1 <#2 #3 #4 #5>{#2 at #3 #4}
 \edef\dtxtimestamp{\expandafter\striptimestamp\lasttimestamp}
 \ProvidesFile{\pkgname.dtx}
@@ -35,7 +35,7 @@
 %  ============
 %
 % `latex etoc.dtx'
-% `latex etoc.dtx' (again) finishes producing the documentation
+% `latex etoc.dtx' (twice more) finishes producing the documentation
 %
 %  The file `etoc.sty' was generated in the first latex run.
 %
@@ -92,6 +92,7 @@
 \pagestyle{headings}
 \usepackage{txfonts}
 
+\usepackage{xspace}
 \usepackage{xcolor}
 \usepackage{graphicx}
 \usepackage{enumitem}
@@ -144,7 +145,7 @@ pdfpagemode=UseOutlines}
 \newcommand\staritb[1]{\csb{#1\lowast}}
 
 
-\usepackage{etoc}  % will require xspace and multicol
+\usepackage{etoc}  % does \RequirePackage{multicol}
 %--------
 % add-ons for the new section `surprising uses of etoc' (2013/01/24)
 \newcounter{visibletoc}
@@ -201,10 +202,10 @@ pdfpagemode=UseOutlines}
   from the \emph{name}, \emph{number}, and \emph{page number}
   of each sectioning unit. This goes via the definition of
   \emph{line styles} for each sectioning level used in the
-  document. The package provides its own custom line styles as
-  an example. The simplest usage though will be to use the
-  layout facilities of packages dealing with list
-  environments.
+  document. The package provides its own custom line styles.
+  Simpler ones are given as examples in the documentation. The
+  simplest usage will be to take advantage the layout facilities
+  of packages dealing with list environments.
 
   The \cs{tableofcontents} command may be used arbitrarily
   many times and it has a variant \cs{localtableofcontents}
@@ -333,7 +334,7 @@ v1.05 [2012/12/01]
    classes.
 
 
-~v1.06 [2012/12/07]
+v1.06 [2012/12/07]
 
    the standard macros \l@section etc... are modified only
    during the calls to \tableofcontents; they can thus be
@@ -358,6 +359,13 @@ v1.07 [2013/01/29]
    explains how to do `lists of arbitrary things', in
    addition to the tables of contents.
 
+v1.07b [2013/02/02]
+
+   decision is made to remove the \xspace from the
+   macros \etocname, \etocnumber, \etocpage.
+
+   additional examples in the documentation.
+
 \end{verbatim}
 \end{multicols}
 \endgroup  
@@ -431,11 +439,8 @@ indeed, but the syntax and option names to memorize are in no
 way related only to matters of tables of contents, hence an
 economy of use of the poor brain.
 
-Still a different sort of example,
-less elementary and not making use at all of list-making
-environments, is built-in in \etoc own ``line styles''. They
-are activated by the command \csb{etoctoclines}... and do
-come with their own set of customizing macros!
+The built-in default ``line styles'' provided by the package
+do not make use of environments.
 
 \section{Line styles and toc display style}
 
@@ -495,19 +500,26 @@ document class.\footnote{for the ``toc display style''
 \makebox[5.2cm][l]{\csb{etocstandarddisplaystyle}}
  |% `toc display'  as without \usepackage{etoc}|
 
-This is the default at the start of the document, and adding
-\cs{usepackage\{etoc\}} should hopefully not change anything
-to the look of a previously existing document, under the
-|article|, |book|, |report|, |scrartcl|, |scrbook|, |scrreprt|
-and |memoir| classes.
 
-% After declaring a document division name to \etoc with
-% \cs{etocsetlevel}, the \cs{etocstandardlines} compatibility switch
-% should be functional under the condition that the document class does
-% things in a manner analogous to the standard classes. But at any rate
-% the \etoc default line styles and the ones defined via \cs{etocsetstyle}
-% will work. Except that maybe \etoc will fail to separate the number from
-% the name.
+If the command \cs{etocsetstyle} has not been used in the
+preamble the package will be at |\begin{document}| in this
+  compatibility mode: hence just adding \cs{usepackage\{etoc\}}
+  should hopefully not change anything to the look of a
+  previously existing document, under the |article|, |book|,
+  |report|, |scrartcl|, |scrbook|, |scrreprt| and |memoir|
+  classes.
+
+  Any use of \cs{etocsetstyle} in the preamble or body of the
+  document turns off the compatibility mode for line styles
+  (but not for the global display style; for this one needs to
+  use the command \cs{etocsettocstyle}).
+
+To exit after \cs{etocstandardlines} from compatibility mode
+one uses the command \csb{etoctoclines}, which re-activates
+the latest line styles as defined by \cs{etocsetstyle} (if
+their scope was not limited to a group or environment). The
+command \csb{etocdefaultlines} resets the line styles to be
+the package initial default ones.
 
 \section{Arbitrarily many TOCs, and local ones too}
 
@@ -566,6 +578,25 @@ the way \etoc implements the cloning, the doubly cloned TOC
 will be typeset as a full table of contents. So to clone
 again, one should use the original: \toc|\ref{toc:c}|.
 
+\subsection{The hyperref option \emph{bookmarksdepth}}
+\label{ssec:bookmarksdepth}
+
+When modifying the counter |tocdepth| for the purposes of
+multiple uses of \toc or \localtoc, one should consider that
+package |hyperref| by default takes into account the
+\emph{current} value of the |tocdepth| counter to decide
+whether the final |pdf| output will contain a bookmark
+corresponding to the used sectioning command. Thus, one 
+often will have to reset |tocdepth| to its previous value
+immediately after the display of the table of contents. 
+
+Or, there is the \emph{bookmarksdepth=n} option of package
+|hyperref|, with \emph{n} the desired document bookmarks
+depth, which can be numeric or the name of a level known to
+|hyperref|. The present document passed |bookmarksdepth=3| as
+option to |hyperref|, so as to not have to reset |tocdepth|
+each time its value was changed.
+
 \subsection{On manually adding layout commands to the
   \texorpdfstring{\ttfamily .toc}{.toc} file}
 
@@ -718,7 +749,7 @@ We can then display here this TOC with:
 
 \etocframedstyle[1]{}
 
-\tableofcontents* \ref{toc:partone}
+\tableofcontents \ref{toc:partone}
 
 \endgroup
 
@@ -730,28 +761,109 @@ frame borders have been set to have the same color as the one
 which serves as background for the entire thing. This design
 (with other colors) is in use also for
 \hyperref[toc:clone]{\color{niceone}this other toc},
-and the coding used is to be found at its location.
+and the coding used is to be found at its location. 
 
+Here is now a far simpler design.
 
-\subsection{The hyperref option \emph{bookmarksdepth}}
-\label{ssec:bookmarksdepth}
 
-When modifying the counter |tocdepth| for the purposes of
-multiple uses of \toc or \localtoc, one should consider that
-package |hyperref| by default takes into account the
-\emph{current} value of the |tocdepth| counter to decide
-whether the final |pdf| output will contain a bookmark
-corresponding to the used sectioning command. Thus, one 
-often will have to reset |tocdepth| to its previous value
-immediately after the display of the table of contents. 
+\section{A simple example}
 
-Or, there is the \emph{bookmarksdepth=n} option of package
-|hyperref|, with \emph{n} the desired document bookmarks
-depth, which can be numeric or the name of a level known to
-|hyperref|. The present document passed |bookmarksdepth=3| as
-option to |hyperref|, so as to not have to reset |tocdepth|
-each time its value was changed.
+Here is a simple example of use of the package
+functionalities. We display again the local table of contents
+for this part but
+choose font sizes and style which would be used rather
+for, respectively, chapters and sections in an average length
+memoir. 
+
+\begingroup
+\newlength{\tocleftmargin}
+\setlength{\tocleftmargin}{5cm}
+\newlength{\tocrightmargin}
+\setlength{\tocrightmargin}{1cm}
+
+\etocsetstyle{section}
+{\addvspace{1ex}\parfillskip0pt
+ \leftskip\tocleftmargin
+ \rightskip\the\tocrightmargin plus 1fil
+ \parindent0pt\color{cyan}}
+{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
+{\llap{Chapter\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
+ \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
+{}
 
+\etocsetstyle{subsection}
+{}
+{\mdseries\large\addvspace{.5ex}\leavevmode}
+{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
+ \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
+{}
+
+\etocsettocstyle{\color{cyan}\parindent0pt\leftskip\tocleftmargin
+  \leavevmode\leaders\hrule height 1pt\hfill\ 
+  \huge\textit{My Beautiful Thesis}\par}{\bigskip}
+
+% \color{cyan}\parindent0pt is repeated in the <start> code
+% of the section style, for clarity of code.
+
+\tableofcontents \ref{toc:partone}
+\endgroup
+
+And now, the line style specifications. They have some
+redundancy for clarity, and do not care about what to do at
+possible page breaks. Also, this does not care about potential 
+multi-column use.
+
+\begin{verbatim}
+\begingroup % we start a group to keep the style changes local
+% the changes to paragraph layout parameters done in the style
+% specifications would anyhow have been kept local as the TOCs are 
+% always typeset by the package in a group. 
+\newlength{\tocleftmargin}    \setlength{\tocleftmargin}{5cm}
+\newlength{\tocrightmargin}   \setlength{\tocrightmargin}{1cm}
+
+\etocsetstyle{section}              % would be chapter in real life
+{\addvspace{1ex}\parfillskip0pt
+ \leftskip\tocleftmargin            % was already done in title
+ \rightskip\the\tocrightmargin plus 1fil
+ \parindent0pt\color{cyan}}         % again this was already done
+{\bfseries\LARGE\upshape\addvspace{1ex}\leavevmode}
+{\llap{Chapter\hspace{.5em}{\etocnumber}\hspace{.75cm}}\etocname
+ \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
+{}
+
+\etocsetstyle{subsection}           % would be section in real life
+{}
+{\mdseries\large\addvspace{.5ex}\leavevmode}
+{\llap{\etocnumber\hspace{.75cm}}\textit{\etocname}%
+ \hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
+{}
+
+% \color{cyan}\parindent0pt and \leftskip\tocleftmargin
+% were repeated in the <start> code of the ``section style'', 
+% for clarity of code.
+
+\etocsettocstyle{\color{cyan}\parindent0pt \leftskip\tocleftmargin
+  \leavevmode\leaders\hrule height 1pt\hfill\ 
+  \huge\textit{My Beautiful Thesis}\par}{\bigskip}
+
+\tableofcontents \ref{toc:partone}
+\endgroup
+\end{verbatim}
+
+As one can see, the code uses the basic commands from
+\TeX/\LaTeX{} for paragraph layouts and an efficient mix of
+plain \TeX{} and \LaTeX{} syntaxes.
+
+Users not so knowledgeable in the \TeX{} syntax (for cause of having
+been exposed only to \LaTeX{} ``introductions'')
+have the possibility explained earlier to use nested
+|enumerate| environments, of course this means mastering
+another syntax.
+
+However, using as here the \TeX{} primitives |\par|,
+|\leftskip|, |\rightskip|, \cs{parfillskip}, ... is by far the
+surest way to completely understand and master what happens.
+Any user of \LaTeX{} should learn their signification.
 
 \section{Surprising uses of \etoc}
 \label{sec:surprising}
@@ -775,13 +887,13 @@ each time its value was changed.
 Here is the numbered and linked list of all tables of contents which are
 displayed within this document: 
 \tableofcontents\endgroup. And to obtain
-it here we just wrote:\footnote{click the `3' from the list to confirm 
-that this is indeed the third visible table of contents of this
-document...}\par\smallskip
+it here we just wrote:\footnote{click the `\protect\thevisibletoc'
+  in the list to get confirmation...}\par\smallskip
 {\leftskip1cm\rightskip5cm
-    \ttfamily\small\baselineskip11pt \noindent Here is the numbered and
-    linked list of all tables of contents which are displayed
-    within this document:~\string\tableofcontents.\par}
+  \ttfamily\small\baselineskip11pt \noindent Here is the
+  numbered and linked list of all tables of contents which are
+  displayed within this
+  document:~\string\tableofcontents.\par}
 
   The preparatory work was the following. First, we defined a
   counter |visibletoc| whose vocation is to get incremented at
@@ -870,7 +982,7 @@ displayed within this document: \tableofcontents.
 
 \endgroup
 
-After |\etocsetstyle{visibletoc}...|, all future TOCs (not in
+After |\etocsetstyle{visibletoc}{..}{..}{..}{..}|, all future TOCs (not in
 compatibility mode) will use the
 defined style for level |0| (which is normally the level for
 chapters). To keep these changes strictly local the simplest
@@ -882,8 +994,7 @@ shuffling of levels.
 
 \subsection{Arbitrary ``Lists Of...''}
 
-\begingroup\parsep0pt\partopsep0pt
-\def\MacroFont{\ttfamily\footnotesize\baselineskip11pt\relax}
+\begingroup
 
 This idea of interverting the levels is very powerful and allows
 to let \etoc display lists of arbitrary things contained in the
@@ -1006,7 +1117,7 @@ displayed the table of contents following:
         {\makebox[.15\linewidth][r]{\bfseries\etocnumber.}}
         {\hspace*{.15\linewidth}}}
     {\hbox to .65\linewidth
-        {\hspace{1em}\etocname\unskip\leaders\mytocleaders\hss}%
+        {\hspace{1em}\etocname\leaders\mytocleaders\hss}%
      \hskip-.1\linewidth
      \hbox to .2\linewidth{\hspace{1.5em}...\hss
                     \etocifnumbered
@@ -1226,19 +1337,19 @@ displayed the table of contents following:
 % and there is no problem anymore. Also I don't have now to
 % use \normalcolor which already needed protection.
 {\normalsize\bfseries\rmfamily\item}
-{\etocname (page \etocpage)}
+{\etocname{} (page \etocpage)}
 {\end{enumerate}}
 
 \etocsetstyle{subsection}
 {\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
 {\normalfont \item}
-{\etocname (p.~\etocpage)}
+{\etocname{} (p.~\etocpage)}
 {\end{enumerate}}
 
 \etocsetstyle{subsubsection}
 {\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix}
 {\allowbreak\,--\,}
-{\etocname\unskip}
+{\etocname}
 {.\hfil\par\endgroup\pagebreak[3]}
 
 % 27 janvier 22:30
@@ -1277,20 +1388,20 @@ obtained in the following manner:%
 \etocsetstyle{section}
 {\begin{enumerate}}
 {\normalsize\bfseries\rmfamily\item}
-{\etocname (page \etocpage)}
+{\etocname{} (page \etocpage)}
 {\end{enumerate}}
 
 \etocsetstyle{subsection}
 {\begin{enumerate}}
 {\normalfont\item}
-{\etocname (p.~\etocpage)}
+{\etocname{} (p.~\etocpage)}
 {\end{enumerate}}
 
 \etocsetstyle{subsubsection}
 {\par\nobreak\begingroup\normalfont
         \footnotesize\itshape\etocskipfirstprefix}
 {\allowbreak\,--\,}
-{\etocname\unskip}
+{\etocname}
 {.\hfil\par\endgroup\pagebreak[3]}
 \end{verbatim}
 \endgroup
@@ -1318,16 +1429,15 @@ typeset by executing first the \meta{prefix} code and then the
 \meta{contents} code. 
 
 
-The commands \csb{etocname}, \csb{etocnumber} and
-\csb{etocpage} are provided for use inside the \marg{prefix}
-and \marg{contents} parts of the \cs{etocsetstyle}
-specification. They represent of course, the name, number, and
-page number of the corresponding toc entry.\footnote{\etoc uses the
-|xspace| package, and there is no need to write
-\cs{etocname\string{\string} text} rather than just
-\cs{etocname text} for example. However, this forced us to add
-a mysterious \cs{unskip} in the subsubsection style.} 
-
+The commands \csb{etocname}, \csb{etocnumber} and \csb{etocpage} are provided
+for use inside the \marg{prefix} and \marg{contents} parts of the
+\cs{etocsetstyle} specification. They represent of course, the name, number, and
+page number of the corresponding toc
+entry.\footnote{\protect\fbox{%
+\parbox{.9\textwidth}{up to version
+\texttt{1.07a} the package put an \cs{xspace} in each of
+\cs{etocname}, \cs{etocnumber}, and \cs{etocpage}, but this
+wasn't such a great idea and has now been removed.}}} 
 
 \subsection{The \csbhyp{etocskipfirstprefix} command}
 
@@ -1369,7 +1479,7 @@ syntax {\ttfamily label=\char32} from the package |enumitem|:
 \etocsetstyle{section}
 {\begin{enumerate}[label=\etocnumber]}
 {\normalsize\bfseries\rmfamily\item}
-{\etocname (page \etocpage)}
+{\etocname{} (page \etocpage)}
 {\end{enumerate}}
 \end{verbatim}
 Rather than just \cs{etocnumber} we then used something like
@@ -1396,13 +1506,13 @@ it in the code which was finally chosen for the |section| level:
 {\begin{enumerate}[leftmargin=.75cm, label=\etocifnumbered
       {{\fboxrule1pt\fcolorbox{green}{white}{\etocnumber}}}{}]}
 {\normalsize\bfseries\rmfamily\item}
-{\etocname (page \etocpage)}
+{\etocname{} (page \etocpage)}
 {\end{enumerate}}
 
 \etocsetstyle{subsection}
 {\begin{enumerate}[leftmargin=0cm, label=\etocnumber]}
 {\normalfont \item}
-{\etocname (p.~\etocpage)}
+{\etocname{} (p.~\etocpage)}
 {\end{enumerate}}
 \end{verbatim}
 
@@ -1417,12 +1527,12 @@ this: |{...(page \etocpage)\par}|.
 \csbhyp{etocthepage} commands}
 
 It is sometimes desirable to have access to the name, number
-and page number without the hyperref link data (and without an
-|\xspace|): something similar to the starred variant
-of the \cs{ref} command, when package |hyperref| is used. For
-example one may wish to use the unit or page number in some kind of numeric
-context, or change its formatting. This is provided by the
-|\etocthe...| commands. 
+and page number without the hyperref link data: something
+similar to the starred variant of the \cs{ref} command, when
+package |hyperref| is used. For example one may wish to use
+the unit or page number in some kind of numeric context, or
+change its formatting. This is provided by the |\etocthe...|
+commands.
 
 These commands are not protected, so in moving argument
 contexts (for example in a label specification) they should be
@@ -1438,11 +1548,10 @@ creates a link (if such a link was added by |hyperref| to the
 unit and whose name is the given argument. 
 
 Hence |\etoclink{\etocthename}| is like the original
-|\etocname|, except that there is no |\xspace| involved. Also,
-\cs{etocname}
-actually starts with a \cs{leavevmode}: this was found out
-to be necessary when |hyperref| has added its link data,
-during testing of various uses of the first versions of \etoc. 
+|\etocname|, except that \cs{etocname} starts with a
+\cs{leavevmode} (this was found out to be necessary when
+|hyperref| has added its link data, during testing of various
+uses of the first versions of \etoc).
 
 The
 command \cs{etoclink} is protected.
@@ -1481,38 +1590,12 @@ does:
 \etocsetlevel{paragraph}{4}
 \etocsetlevel{subparagraph}{5}
 \end{verbatim}
-Its own line styles are activated by \cs{etoctoclines}. They
+Its own line styles are activated by \cs{etocdefaultlines}. They
 are illustrated by the main table of contents of this
 document. The level assignments can be modified at anytime, as has been
 explained in the section \ref{sec:surprising}.
 
 
-% \subsection{The \csbhyp{etocfontxxx...} commands}
-
-% The package predefines for use in its default line styles:
-% \begin{verbatim}
-% \newcommand\etocfontminustwo{\normalfont \LARGE \bfseries}
-% \newcommand\etocfontminusone{\normalfont \large \bfseries}
-% \newcommand\etocfontzero{\normalfont \large \bfseries}
-% \newcommand\etocfontone{\normalfont \normalsize \bfseries}
-% \newcommand\etocfonttwo{\normalfont \normalsize}
-% \newcommand\etocfontthree{\normalfont \footnotesize}
-% \end{verbatim}
-% The same font is used for
-% the name, number, and page number, at each level (up to subsubsection).
-
-% In document classes where there is a \cs{chapter} command, the
-% default font for the level 1 (`section') does not use the bold
-% series. 
-
-% These font commands only impact the package default line
-% styles and do nothing under the \cs{etocstandardlines} regime.
-% And, let us recall, levels four (paragraph) and five
-% (subparagraphs) are actually not displayed by the package
-% default line styles.
-
-
-
 \color{red!50}
 \addtocontents{toc}{\string\color{red!50}}
 
@@ -1540,7 +1623,7 @@ definition was:\topsep0pt\partopsep0pt
     {\par\nobreak\begingroup\normalfont
         \footnotesize\itshape\etocskipfirstprefix}
     {\allowbreak\,--\,}
-    {\etocname\unskip}
+    {\etocname}
     {.\hfil\par\endgroup\pagebreak[3]}  <--- here is the \endgroup
 \end{verbatim}
 This illustrates the discussion from subsection \ref{ssec:limitations}.
@@ -1551,15 +1634,6 @@ of the added line in the |.toc| file will propagate until
 it is cancelled by another explicit such command inserted in
 the |.toc| file. 
 
-% In the present case the group at the subsubsection level is
-% there to confine the font changes, but this could be made
-% superfluous via adding a \cs{normalsize} to the
-% |subsection| specification. 
-
-% I take this opportunity to mention
-% that \etoc always typesets the entire table of contents inside
-% a group, hence no font change therein can propagate to the outside.
-
 
 \section{Am I also red?}
 
@@ -1585,9 +1659,6 @@ concern only a minority of cases. Again, the line styles
 defined by \etoc do not use groups.
 
 
-% \section*{An unnumbered section}
-% \addcontentsline{toc}{section}{An unnumbered section}
-
 % I don't have much to say here. I just added an unnumbered
 % section, and made it appear in the |.toc| file.
 
@@ -1972,21 +2043,18 @@ beginning of this part \ref{part:globalcmds}.
 
 \subsection{A framed display}
 
-We now opt for a
-``framed'' style, and specify some colors (including a
-background color). We modify various things from the package
-defaults.
+We now opt for a ``framed'' style, using the package default
+line styles and some colors added. 
 
-\begingroup
-\begin{verbatim}
-\etoctoclines
-\begingroup % we use a group to limit the scope of the next commands
+\clearpage
+
+\etocdefaultlines
+\begingroup 
 \renewcommand{\etoccolumnsep}{3em}
 \renewcommand{\etocinnerleftsep}{2em}
 \renewcommand{\etocinnerrightsep}{2em}
 % specify a background color for the toc contents
 \renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
-%\renewcommand{\etocbkgcolorcmd}{\relax}
 % set up the top and bottom rules 
 \renewcommand{\etoctoprule}{\hrule height 1pt}
 \renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
@@ -2006,19 +2074,20 @@ defaults.
       in a frame, it has to be small enough to fit on the 
       current page. It has the label |toc:b|.}}}
 % set up a label for future (or earlier...) reference
-\setcounter{tocdepth}{3}
 \tableofcontents \label{toc:b} \ref{toc:globalcmds}
 \endgroup
-\end{verbatim}
-\endgroup
 
-\etoctoclines
-\begingroup 
+\begingroup
+\def\MacroFont{\footnotesize\ttfamily}%
+\begin{verbatim}
+\etocdefaultlines
+\begingroup % we use a group to limit the scope of the next commands
 \renewcommand{\etoccolumnsep}{3em}
 \renewcommand{\etocinnerleftsep}{2em}
 \renewcommand{\etocinnerrightsep}{2em}
 % specify a background color for the toc contents
 \renewcommand{\etocbkgcolorcmd}{\color{yellow!10}}
+%\renewcommand{\etocbkgcolorcmd}{\relax}
 % set up the top and bottom rules 
 \renewcommand{\etoctoprule}{\hrule height 1pt}
 \renewcommand{\etoctoprulecolorcmd}{\color{red!25}}
@@ -2038,15 +2107,60 @@ defaults.
       in a frame, it has to be small enough to fit on the 
       current page. It has the label |toc:b|.}}}
 % set up a label for future (or earlier...) reference
+\setcounter{tocdepth}{3}
 \tableofcontents \label{toc:b} \ref{toc:globalcmds}
 \endgroup
+\end{verbatim}
+\endgroup
+
+\subsection{A (crazy) inline display}
+
+Let us finally make some crazy inline display of the table of
+contents of this entire document. We will typeset the subsections as
+footnotes... This kind of style is suitable for a hyperlinked
+document, not for print! 
+
+
+\begingroup
+\setcounter{tocdepth}{3}
+\newsavebox{\forsubsections}
+\etocsetstyle{part}{\etocskipfirstprefix}{. \upshape}{\bfseries\etocname:~~}{}
+\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }{\mdseries\etocname}{}
+\etocsetstyle{subsection}
+   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
+   {; }
+   {\etocname}
+   {\end{lrbox}\footnote{\unhbox\forsubsections.}}
+\etocsetstyle{subsubsection}{ (\itshape\etocskipfirstprefix}
+  {, }{\etocname}{\/\upshape)}
+\etocsettocstyle{Here is the inline table of contents. }{.\par}
+\tableofcontents
+\endgroup
+
+\begin{verbatim}
+\begingroup
+\setcounter{tocdepth}{3}
+\newsavebox{\forsubsections}
+\etocsetstyle{part}{\etocskipfirstprefix}{. \upshape}{\bfseries\etocname:~~}{}
+\etocsetstyle{section}{\itshape\etocskipfirstprefix}{, }{\mdseries\etocname}{}
+\etocsetstyle{subsection}
+   {\begin{lrbox}{\forsubsections}\upshape\etocskipfirstprefix}
+   {; }
+   {\etocname}
+   {\end{lrbox}\footnote{\unhbox\forsubsections.}}
+\etocsetstyle{subsubsection}{ (\itshape\etocskipfirstprefix}
+  {, }{\etocname}{\/\upshape)}
+\etocsettocstyle{Here is the inline table of contents. }{.\par}
+\tableofcontents
+\endgroup
+\end{verbatim}
 
 
 \part{Using and customizing \etoc}
 \label{part:custom}
 
 
-\etoctoclines
+\etocdefaultlines
 \renewcommand{\etoctoprule}{\hrule height2pt depth0pt}
 \renewcommand{\etoctoprulecolorcmd}{\color{red}}
 
@@ -2055,7 +2169,7 @@ defaults.
       contents for the sections and
       subsections in this part. It carries the label |toc:c|}}} 
 
-\localtableofcontents* \label{toc:c}
+\localtableofcontents \label{toc:c}
 
 
 \section{Summary of the main style commands}
@@ -2093,7 +2207,7 @@ defaults.
 \cs{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\
 \cs{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}}}
 
-\subsection{Displaying Table of Contents}
+\subsection{Displaying tables of contents}
 
 
 \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em
@@ -2152,7 +2266,8 @@ this example so we included the title as part of the
 \meta{start} code at section level, to get it \emph{inside}
 the frame.
 
-\begingroup
+\begingroup\def\MacroFont{\footnotesize\ttfamily}%
+
 \begin{verbatim}
 \setcounter{tocdepth}{3}
 \begingroup
@@ -2369,17 +2484,16 @@ happened in the absence of \etoc.\footnote{with the
   KOMA options |toc=left| to be active at the level of the line entries.}  
 
 
-The \cs{etocstandardlines} mechanism will work also with
+The \cs{etocstandardlines} compatibility mode will work also with
 sectioning commands made known to \etoc via \cs{etocsetlevel},
 under the condition of course that these sectioning commands
 are accompanied with all the relevant definitions for
 typesetting toc entries in the \LaTeX{} default manner
 (existence of the macros \cs{l@something} . . .).
 
-Using the \cs{etoctoclines} or even just one \cs{etocsetstyle}
-command has the effect (when done in the document body, not in the
-preamble) of switching off the compatibility
-mode. 
+Using the command \cs{etocsetstyle}, be it in the preamble or
+in the body of the document, has the secondary effect of
+switching off the compatibility mode.
 
 \subsection{Customizing the toc display styles}
 
@@ -2494,7 +2608,7 @@ section \ref{sec:surprising} for other uses of this technique):
 \etocsetstyle{subsection}{\begin{enumerate}[itemsep=0pt,%
 label=,leftmargin=0pt]}
 {\normalfont\bfseries\item}
-{\roman{enumi}. \normalfont\etocname (\etocnumber, p.~\etocpage)}
+{\roman{enumi}. \normalfont\etocname{} (\etocnumber, p.~\etocpage)}
 {\end{enumerate}}
 \renewcommand{\etoccolumnsep}{2.75em}
 \renewcommand{\columnseprule}{1pt}
@@ -2506,7 +2620,7 @@ label=,leftmargin=0pt]}
 \setcounter{tocdepth}{2}
 
 \begingroup
-\etoctoclines
+\etocdefaultlines
 \etocstandarddisplaystyle
 \etocsetlevel{book}{3}
 \etocsetlevel{part}{3}
@@ -2515,7 +2629,7 @@ label=,leftmargin=0pt]}
 \etocsetstyle{subsection}{%
 \begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]}
 {\normalfont\bfseries\item}
-{\roman{enumi}. \normalfont\etocname (\etocnumber, p.~\etocpage)}
+{\roman{enumi}. \normalfont\etocname{} (\etocnumber, p.~\etocpage)}
 {\end{enumerate}}
 
 \renewcommand{\etoccolumnsep}{2.75em}
@@ -2529,7 +2643,9 @@ label=,leftmargin=0pt]}
 
 \subsection{Compatibility with other packages}
 
-\etoc uses the packages |multicol| and |xspace|. It is
+\etoc uses the packages |multicol|.\footnote{\protect\fbox{up to version
+\texttt{1.07a} it also used package \texttt{xspace}, and but this
+has been removed.}} It is
 |hyperref| aware and hopefully |hyperref| compatible! It
 doesn't matter whether \etoc or |hyperref| is loaded first.
 
@@ -2572,15 +2688,14 @@ table of contents typeset by \etoc in compatibility mode.
 \subsection{\TeX nical matters}
 
 The \cs{etocname}, \cs{etocnumber}, \cs{etocpage} and
-\cs{etocifnumbered} macros end with an \cs{xspace}. They are
-protected against premature expansion. And they will contain
-the suitable |hyperref| links. The command \cs{etoclink} is
+\cs{etocifnumbered} are protected against premature expansion.
+They contain suitable |hyperref| links if package |hyperref|
+is loaded and active for the TOC. The command \cs{etoclink} is
 also protected against premature expansion.
 
 On the other hand \cs{etocthename}, \cs{etocthenumber},
-\cs{etocthepage} do not end with \cs{xspace}, do not represent
-|hyperref| links, and are not protected against expansion.
-
+\cs{etocthepage} do not represent |hyperref| links, and are
+\emph{not} protected against expansion.
 
 The commands such as \cs{etocsetstyle}, \cs{etocsetlevel},
 \cs{etocsettocstyle}, \cs{etocmulticolstyle},
@@ -2589,40 +2704,31 @@ groups. All TOCs are typeset inside groups.
 
 \subsection{Errors and catastrophes}
 
-After using \cs{etocsetstyle} for one level, the remaining
-uncustomized levels use the \etoc's default styles. One has to
-make sure that all levels needed for the next table of
-contents are mutually compatible.
-
-When using multiple \toc commands in a document, one should
-beware from adding typesetting instructions directly in the
-|.toc| file, as they will be executed by \etoc for all TOCs:
-even for a \localtoc it doesn't matter if that instruction
-seems to concern material outside of its scope, it will get
-executed nevertheless. If absolutely necessary these
-instructions should be done in such a way that they can
-be activated or deactivated easily from the document source,
-as need be.
-
-Do not clone a clone but produce rather twins by cloning the
-same original local table of contents.
-
-As is usual with toc and labels, after each change, one has to
-run latex a certain number of times to let the produced
-document get its final appearance (at least twice). 
-
-% In certain extreme cases (\emph{e.g.} if one removes the
-% |hyperref| package from a previously hyperlinked document),
-% one must trash the previous |.aux| and |.toc| files. But
-% adding \cs{usepackage\{hyperref\}} to a non-hyperlinked
-% source should cause no trouble at all (the old |.toc| file
-% will not be used, the new one, whose format differs, will be
-% used on the next run).\footnote{Note though that an error
-%   results when one adds \cs{usepackage\{hyperref\}} to a
-%   document having some \cs{label}'s and \cs{ref}'s;
-%   one must run |latex| another time or trash the |.aux| file to
-%   get rid of the error. This is related neither with \etoc nor with the
-% |.toc| file.}
+\begin{small}
+  After using \cs{etocsetstyle} for one level, the remaining
+  uncustomized levels use the \etoc's default styles (those
+  which are activated by \cs{etocdefaultlines}). One has to
+  make sure that all levels needed for the next table of
+  contents are mutually compatible.
+
+  When using multiple \toc commands in a document, one should
+  beware from adding typesetting instructions directly in the
+  |.toc| file, as they will be executed by \etoc for all TOCs:
+  even for a \localtoc it doesn't matter if that instruction
+  seems to concern material outside of its scope, it will get
+  executed nevertheless. If absolutely necessary these
+  instructions should be done in such a way that they can be
+  activated or deactivated easily from the document source, as
+  need be.
+
+  Do not clone a clone but produce rather twins by cloning the
+  same original local table of contents.
+
+  As is usual with toc and labels, after each change, one has
+  to run latex a certain number of times to let the produced
+  document get its final appearance (at least twice).\par
+\end{small}
+
 
 
 \part{The code}
@@ -2686,7 +2792,7 @@ release.
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{multicol}
-\RequirePackage{xspace}
+%% \RequirePackage{xspace} %% REMOVED (1.07b)
 \DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}}
 \ProcessOptions\relax
 %    \end{macrocode}
@@ -2965,16 +3071,17 @@ release.
 % placeholder for comments
 %    \begin{macrocode}
 \def\Etoc@lxyz #1#2{%
-    \@namedef{etocpage }{\leavevmode #2\xspace}%
-    \Etoc@getthepage #2\etoc@
-    \@namedef{etocname }{\leavevmode #1\xspace}%
-    \def\etocthename{#1}%
-    \Etoc@getnb #1\relax\relax\etoc@
-    \ifEtoc@number\else
+   \@namedef{etoclink }##1{##1}% fall-back if no links
+   \@namedef{etocpage }{\leavevmode #2}%
+   \Etoc@getthepage #2\etoc@
+   \@namedef{etocname }{\leavevmode #1}%
+   \def\etocthename{#1}%
+   \Etoc@getnb #1\relax\relax\etoc@
+   \ifEtoc@number\else
       \ifEtoc@part 
         \Etoc@getit #1\hspace\relax\etoc@
       \fi
-    \fi}
+   \fi}
 %    \end{macrocode}
 % placeholder for comments
 %    \begin{macrocode}
@@ -3005,16 +3112,16 @@ release.
 %
 \def\Etoc@getnb@nohyp #1#2#3\etoc@{%
     \def\Etoc@getname ##1\relax\relax\etoc@{%
-      \@namedef{etocname }{\leavevmode ##1\xspace}%
+      \@namedef{etocname }{\leavevmode ##1}%
       \def\etocthename{##1}%
      }%
   \ifx #1\numberline
-    \@namedef{etocnumber }{\leavevmode #2\xspace}%
+    \@namedef{etocnumber }{\leavevmode #2}%
     \def\etocthenumber{#2}%
     \Etoc@numbertrue
     \Etoc@getname #3\etoc@
   \else
-    \@namedef{etocnumber }{\leavevmode\xspace}%
+    \@namedef{etocnumber }{\leavevmode}%
     \def\etocthenumber{}%
     \Etoc@numberfalse
   \fi
@@ -3025,17 +3132,17 @@ release.
 \def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@{%
     \@namedef{etoclink }##1{#1{#2}{#3}{##1}#5}%
     \def\Etoc@getname ##1\relax\relax\etoc@{%
-      \@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5\xspace}%
+      \@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5}%
       \def\etocthename{##1}%
      }%
     \def\Etoc@getnbr ##1##2##3\etoc@{%
       \ifx ##1\numberline
-        \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}%
+        \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5}%
         \def\etocthenumber{##2}%
         \Etoc@numbertrue
         \Etoc@getname ##3\etoc@
       \else
-        \@namedef{etocnumber }{\leavevmode\xspace}%
+        \@namedef{etocnumber }{\leavevmode}%
         \def\etocthenumber{}%
         \Etoc@numberfalse
         \def\etocthename{#4}%
@@ -3047,11 +3154,11 @@ release.
 %    \begin{macrocode}
 \def\Etoc@getit@nohyp #1\hspace#2#3\etoc@{%
     \def\Etoc@getname ##1\hspace\relax\etoc@{%
-       \@namedef{etocname }{\leavevmode ##1\xspace}%
+       \@namedef{etocname }{\leavevmode ##1}%
        \def\etocthename{##1}%
     }%
   \ifx\relax#2\else 
-        \@namedef{etocnumber }{\leavevmode #1\xspace}%
+        \@namedef{etocnumber }{\leavevmode #1}%
         \def\etocthenumber{#1}%
         \Etoc@numbertrue
         \Etoc@getname #3\etoc@
@@ -3062,12 +3169,12 @@ release.
 %    \begin{macrocode}
 \def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@{%
   \def\Etoc@getname ##1\hspace\relax\etoc@{%
-       \@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5\xspace}%
+       \@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5}%
        \def\etocthename{##1}%
     }%
   \def\Etoc@getnbr ##1\hspace##2##3\etoc@{%
        \ifx\relax##2\else
-         \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}%
+         \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5}%
          \def\etocthenumber{##1}%
          \Etoc@numbertrue
          \Etoc@getname ##3\etoc@
@@ -3255,7 +3362,7 @@ release.
 \def\localtable@fcontents{%
     \refstepcounter{etoc@tocid}%
     \addtocontents{toc}
-       {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}%
+       {\string\etoc@startlocaltoc{\arabic{etoc@tocid}}}%
     \Etoc@tocwithidtrue
     \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
 %    \end{macrocode}
@@ -3353,8 +3460,10 @@ release.
 \newcommand*\etocbookname{Book}
 %    \end{macrocode}
 % placeholder for comments
+% The macro \cs{etocdefaultlines} was initially called \cs{etoctoclines}. Now
+% \cs{etoctoclines} just does \cs{Etoc@standardfalse}.
 %    \begin{macrocode}
-\def\etoctoclines{\Etoc@standardfalse
+\def\etocdefaultlines{\Etoc@standardfalse
 %    \end{macrocode}
 % placeholder for comments
 %    \begin{macrocode}
@@ -3403,7 +3512,7 @@ release.
 \parindent \z@ \parfillskip \z@ 
 \setbox\z@\vbox{\parfillskip\@flushglue
 \etocname\par\setbox\tw@\lastbox
-\global\setbox\@ne\hbox{\unhbox\tw@}}%
+\global\setbox\@ne\hbox{\unhbox\tw@\ }}%
 \dimen\z@=\wd\@ne
 \setbox\z@=\etoctoclineleaders
 \advance\dimen\z@\wd\z@
@@ -3412,12 +3521,12 @@ release.
 {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
 \advance\dimen\z@\wd\tw@
 \ifdim\dimen\z@ < \linewidth
-       \vbox{\etocname\nobreak
+       \vbox{\etocname~% modified in 1.07b (after removal of \xspace)
        \leaders\box\z@\hfil\box\tw@
        \baselineskip\etocbaselinespreadone\baselineskip\par}
    \else
-       \vbox{\etocname\nobreak
-       \ifdim\wd\@ne<\linewidth\leaders\copy\z@\hfil\break\fi
+       \vbox{\etocname~% modified in 1.07b
+       \leaders\copy\z@\hfil\break 
        \hbox{}\leaders\box\z@\hfil\box\tw@
        \baselineskip\etocbaselinespreadone\baselineskip\par}
 \fi
@@ -3444,12 +3553,12 @@ release.
 {\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}%
 \advance\dimen\z@\wd\tw@
 \ifdim\dimen\z@ < \linewidth
-       \vbox{\etocname\nobreak
+       \vbox{\etocname~%
        \leaders\box\z@\hfil\box\tw@
        \baselineskip\etocbaselinespreadtwo\baselineskip\par}
    \else
-       \vbox{\etocname\nobreak
-       \ifdim\wd\@ne<\linewidth\leaders\copy\z@\hfil\break\fi
+       \vbox{\etocname~%
+       \leaders\copy\z@\hfil\break 
        \hbox{}\leaders\box\z@\hfil\box\tw@
        \baselineskip\etocbaselinespreadtwo\baselineskip\par}
 \fi
@@ -3466,7 +3575,7 @@ release.
 \nointerlineskip\noindent
 \etocskipfirstprefix}
 {\allowbreak\,--\,}
-{\etocname\unskip}  % \xspace in \etocname
+{\etocname}
 {.\hfil\begingroup
 \baselineskip\etocbaselinespreadthree\baselineskip
 \par\endgroup
@@ -3844,8 +3953,6 @@ release.
 %    \end{macrocode}
 % placeholder for comments
 %    \begin{macrocode}
-\newcommand*\etocstandardlines{\Etoc@standardtrue}
-%
 \def\Etoc@addtocontents #1#2%
     {\ifEtoc@hyperref
        \addtocontents {toc}{\protect\contentsline 
@@ -3861,10 +3968,12 @@ release.
 \DeclareRobustCommand*{\etoctoccontentsline}
     {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}}
 %
-\etoctoclines
-\AtBeginDocument{
-\etocstandardlines
-\etocstandarddisplaystyle}
+\newcommand*\etocstandardlines{\Etoc@standardtrue}
+\newcommand*\etoctoclines{\Etoc@standardfalse} % 1.07b
+%
+\etocdefaultlines  % for initialization
+\etocstandardlines % removed silly AtBeginDocument temporarily added for 1.07
+\etocstandarddisplaystyle
 \endinput
 %    \end{macrocode}
 % \MakePercentComment
@@ -3884,7 +3993,7 @@ release.
   Grave accent  \`     Left brace    \{     Vertical bar  \|
   Right brace   \}     Tilde         \~}
 
-\CheckSum{2580}
+\CheckSum{2554}
 
 \Finale
 %%
-- 
cgit v1.2.3

