diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-29 23:34:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-29 23:34:40 +0000 |
commit | 00db22e467544f6ebde833dc8fbb53ec70367306 (patch) | |
tree | 0bb96b3d97afb68e7c737c703e09d0818317bb59 /Master | |
parent | 5b6c07d1cfaefd42af46b1560695a8de0f6eeb79 (diff) |
etoc (29jan13)
git-svn-id: svn://tug.org/texlive/trunk@28984 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/etoc/README | 101 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/etoc/etoc.pdf | bin | 188046 -> 194309 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/etoc/etoc.dtx | 2127 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/etoc/etoc.ins | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/etoc/etoc.sty | 563 |
5 files changed, 1598 insertions, 1199 deletions
diff --git a/Master/texmf-dist/doc/latex/etoc/README b/Master/texmf-dist/doc/latex/etoc/README index 4b6fc1e839e..a01f4e76d45 100644 --- a/Master/texmf-dist/doc/latex/etoc/README +++ b/Master/texmf-dist/doc/latex/etoc/README @@ -1,6 +1,6 @@ - Package `etoc' (v1.06, 2012/12/07) - Copyright (C) 2012 by Jean-Francois Burnol + Package `etoc' (v1.07, 2013/01/29) + Copyright (C) 2012, 2013 by Jean-Francois Burnol The source file etoc.dtx and its derived files may be distributed and/or modified under the conditions of the @@ -13,8 +13,6 @@ and version 1.3 or later is part of all distributions of LaTeX version 2003/12/01 or later. -package version 1.06, 2012/12/07 -documentation updated 2013/01/25 Installation @@ -32,26 +30,81 @@ documentation updated 2013/01/25 the entries of the table of contents should be constituted from the name, number, and page number of each sectioning unit. This goes via the definition of 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 delegate the details of - the layout to packages dealing with list environments. - - The \tableofcontents command can be used arbitrarily many - times and has a variant \localtableofcontents which prints - tables of contents `local' to the current surrounding - document unit. An extension of the label/ref syntax allows - to reproduce at another location (and with another layout) - a TOC defined somewhere else in the document. - - The formatting inherited (possibly customized by other - packages) from the document class can also be used. - Regarding the global toc display, etoc provides styles - based on a multi-column format, optionally with a frame or - a ruled title. + 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. + + The \tableofcontents command may be used arbitrarily many + times and it has a variant \localtableofcontents which + prints tables of contents `local' to the current surrounding + document unit. An extension of the \label/\ref syntax allows + to reproduce (with another layout) a TOC defined somewhere + else in the document. + + The formatting inherited (and possibly customized by other + packages) from the document class may also be used in + compatibility mode. Regarding the global toc display, etoc + provides pre-defined styles based on a multi-column format, + optionally with a frame or a ruled title. As the assignment of levels to the sectioning units can be - changed at any time, etoc can be used to create custom - 'lists of' in a very general manner. It does not create - auxiliary files other than the usual .toc file. + changed at any time, etoc can be used in a quite general + manner to also create custom "lists of", additionally to the + tables of contents related to the document sectioning units. + No auxiliary file is used apart from the usual .toc file. + + Change log + + v1.02 [2012/11/18] + + initial version + + + v1.04 [2012/11/24] + + a (possibly local) table of contents can be labeled: + + \tableofcontents \label{toc:1} + + and reproduced elsewhere in the document (with a possibly + completely different layout): + + \tableofcontents \ref{toc:1} + + + v1.05 [2012/12/01] + + \localtableofcontents replaces \tableofcontents* (for + compatibility with the memoir class) + + compatibility with KOMA-script and memoir document + classes. + + + v1.06 [2012/12/07] + + the standard macros \l@section etc... are modified only + during the calls to \tableofcontents; they can thus be + customized as will by the user (with the help of a + package like tocloft) and this will be taken into account + by etoc for the TOCs typeset in compatibility mode. + + + v1.07 [2013/01/29] + + new commands: + + \etocthename, \etocthenumber, \etocthepage, \etoclink, + + \etoctoccontentsline, \etoctoccontentsline* + + \etocnopar, \etocaftercontentshook + + modified command: \etocmulticolstyle + + new documentation section `surprising uses of etoc' which + explains how to do `lists of arbitrary things', in + addition to the tables of contents. + diff --git a/Master/texmf-dist/doc/latex/etoc/etoc.pdf b/Master/texmf-dist/doc/latex/etoc/etoc.pdf Binary files differindex 5c67868e7c2..5790221a2aa 100644 --- a/Master/texmf-dist/doc/latex/etoc/etoc.pdf +++ b/Master/texmf-dist/doc/latex/etoc/etoc.pdf diff --git a/Master/texmf-dist/source/latex/etoc/etoc.dtx b/Master/texmf-dist/source/latex/etoc/etoc.dtx index 7c85fbb1215..9421280c006 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.dtx +++ b/Master/texmf-dist/source/latex/etoc/etoc.dtx @@ -1,17 +1,17 @@ % -*- coding: iso-latin-1; -*- %<*ins> \def\pkgname{etoc} -\def\pkgdate{2012/12/07} -\def\pkgversion{v1.06} +\def\pkgdate{2013/01/29} +\def\pkgversion{v1.07} \def\pkgdescription{easily customizable TOCs (jfB)} %</ins> %% %% Package `etoc' by Jean-Francois Burnol -%% Copyright (C) 2012 by Jean-Francois Burnol +%% Copyright (C) 2012, 2013 by Jean-Francois Burnol %% %<*none> -\def\lasttimestamp{Time-stamp: <25-01-2013 12:29:15 CET jfb>} -\def\docdate{2013/01/24} +\def\lasttimestamp{Time-stamp: <29-01-2013 15:19:54 CET jfb>} +\def\docdate{2013/01/29} \def\striptimestamp#1 <#2 #3 #4 #5>{#2 at #3 #4} \edef\dtxtimestamp{\expandafter\striptimestamp\lasttimestamp} \ProvidesFile{\pkgname.dtx} @@ -86,24 +86,24 @@ %<*none> \fi \documentclass[a4paper,11pt,abstract]{scrdoc} -\pagestyle{headings} -\usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} +\usepackage[latin1]{inputenc} \usepackage[hscale=0.66,vscale=0.75]{geometry} -\usepackage{verbatim} +\pagestyle{headings} \usepackage{txfonts} -%\usepackage{xspace} -%\usepackage{multicol} -\usepackage{enumitem} -%\usepackage{color} + \usepackage{xcolor} \usepackage{graphicx} +\usepackage{enumitem} \definecolor{joli}{RGB}{225,95,0} \definecolor{JOLI}{RGB}{225,95,0} \definecolor{BLUE}{RGB}{0,0,255} \colorlet{niceone}{green!35!blue!75} +\makeatletter\let\check@percent\relax\makeatother +\def\MacroFont{\ttfamily\small\baselineskip12pt\relax} + \usepackage[english]{babel} \AtBeginDocument{ \renewcommand\partname{Part} @@ -114,7 +114,8 @@ pdfencoding=pdfdoc,bookmarks=true]{hyperref} \hypersetup{% -linktoc=all,% +linktoc=all,% why is the important relatively recent stuff +bookmarksdepth=3,% in a hard to find README? breaklinks=true,% hidelinks,% pdfauthor={Jean-Fran\c cois Burnol},% @@ -131,43 +132,41 @@ pdfpagemode=UseOutlines} % \def\href#1#2{{#2}} % \makeatother -\MakeShortVerb{\|} - \DeclareRobustCommand\cs[1]{{\ttfamily\hyphenchar\font45\char`\\#1}} \DeclareRobustCommand\csb[1]{{% \color{blue}\ttfamily\hyphenchar\font45\char`\\#1}} \newcommand\cshyp[1]{\texorpdfstring{\cs{#1}}{\textbackslash #1}} \newcommand\csbhyp[1]{\texorpdfstring{\csb{#1}}{\textbackslash #1}} + \newcommand\lowast{\raisebox{-.25\height}{*}} \newcommand\starit[1]{\cs{#1\lowast}} \newcommand\staritb[1]{\csb{#1\lowast}} -\usepackage{etoc} % loads xspace and multicol +\usepackage{etoc} % will require xspace and multicol %-------- % add-ons for the new section `surprising uses of etoc' (2013/01/24) \newcounter{visibletoc} -\makeatletter -\renewcommand{\etocaftertitlehook}{\stepcounter{visibletoc}% - \addtocontents {toc}{\protect\contentsline - {visibletoc}{\thevisibletoc }{\thepage }{\@currentHref }}} -\makeatother -\etocsetlevel{visibletoc}{5} +\renewcommand{\etocaftertitlehook} + {\stepcounter{visibletoc}\etoctoccontentsline{visibletoc}{\thevisibletoc}} +\etocsetlevel{visibletoc}{6} %-------- % add-ons for the `fancy TOC' (2013/01/25) \newcounter{dummypart} \newcounter{dummychapter} \newcounter{dummysection} - \etocsetlevel{dummypart}{5} - \etocsetlevel{dummychapter}{5} - \etocsetlevel{dummysection}{5} + \etocsetlevel{dummypart}{6} + \etocsetlevel{dummychapter}{6} + \etocsetlevel{dummysection}{6} +%-------- \newcommand\toc{\cs{table\-of\-contents}\xspace} \newcommand\localtoc{\cs{local\-table\-of\-contents}\xspace} \newcommand\tocb{\csb{table\-of\-contents}\xspace} \newcommand\localtocb{\csb{local\-table\-of\-contents}\xspace} + \newcommand\etoc{% \texorpdfstring{{\color{joli}\ttfamily\bfseries etoc}}{etoc}\xspace} @@ -181,20 +180,11 @@ pdfpagemode=UseOutlines} \setcounter{secnumdepth}{3} -% ATTENTION HYPERREF TIENT COMPTE DE TOCDEPTH POUR LES BOOKMARKS! -\setcounter{tocdepth}{3} -% IL FAUT DONC TOUJOURS REMETTRE À 3 AVANT CHAQUE \section ou \subsection !!! - -\makeatletter -\def\verbatim@font{\ttfamily\small\baselineskip12pt }% -\makeatother - \begin{document} \rmfamily \thispagestyle{empty} - \begin{center} {\normalfont\Large The \etoc package}\\ \textsc{Jean-François Burnol}\par @@ -212,36 +202,39 @@ pdfpagemode=UseOutlines} 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 delegate the - details of the layout to packages dealing with list - environments. - - The \cs{tableofcontents} command can be used arbitrarily many - times and has a variant \cs{localtableofcontents} which prints - tables of contents `local' to the current surrounding - document unit. An extension of the \cs{label}/\cs{ref} syntax - allows to reproduce at another location (and with another + an example. The simplest usage though will be to use 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} + which prints tables of contents `local' to the current + surrounding document unit. An extension of the + \cs{label}/\cs{ref} syntax allows to reproduce (with another layout) a TOC defined somewhere else in the document. - The formatting inherited (possibly customized by other packages) - from the document class can also be used. Regarding the - \emph{global toc display}, \etoc provides styles based on a + The formatting inherited (and possibly customized by other + packages) from the document class may also be used in + \emph{compatibility mode}. Regarding the \emph{global toc + display}, \etoc provides pre-defined styles based on a multi-column format, optionally with a frame or a ruled title. As the assignment of levels to the sectioning units can be - changed at any time, \etoc can be used to create custom ``lists - of'' in a very general manner. It does not create auxiliary - files other than the usual |.toc| file. + changed at any time, \etoc can be used in a quite general + manner to also create custom ``lists of'', additionally to + the tables of contents related to the document sectioning + units. No auxiliary file is used apart from the usual |.toc| + file. \end{abstract} \section*{Foreword} Popular packages dealing with TOCs include |tocloft|, -|titletoc| and |minitoc|. Why another one? well, I started -\etoc for my own use, and only later found out about the above -mentioned packages . . . +|titletoc| and |minitoc|. Why another one? well, initially I +started \etoc for my own use, and only later found out about +the above mentioned packages ... As is well explained in the |tocloft| package documentation, the standard \LaTeX{} layout for the Table of Contents is @@ -266,7 +259,7 @@ found in a line of the |.toc| file) in a completely arbitrary manner: they are made available via the \csb{etocname}, \csb{etocnumber}, and \csb{etocpage} commands. -It is hoped that \etoc will turn out to be essentially +\etoc is compatible with the |article|, |book|, |report|, |scrartcl|, |scrbook|, |scrreprt| and |memoir| classes. @@ -277,15 +270,109 @@ compatible with the |article|, |book|, |report|, |scrartcl|, % test all their bells and whistles in the presence of % \etoc. \par -\clearpage + +\begingroup +\def\MacroFont{\footnotesize\normalfont\baselineskip10pt\relax} + +\section*{\bfseries\small Change history} + +\setlength{\columnsep}{\etoccolumnsep} + +\makeatletter +\def\@verbatim{\leftskip \z@ \parindent \z@ \parfillskip \@flushglue +\parskip \tw@\p@ plus 1fil\relax +\let \do \@makeother \dospecials\catcode`\~\active \obeyspaces} + +\def\endverbatim{} \let\@vobeyspaces\relax + + +\newdimen\jfdim +\everypar{\leftskip\jfdim\bgroup + \def\par{\egroup\jfdim\z@\@@par}% + \def\jfspace#1{\ifcat\noexpand#1\noexpand~\unskip\else\ \fi#1}} + +\begingroup\obeyspaces\def\x{\endgroup% +\def {\ifvmode\advance\jfdim.5em\relax\else\expandafter\jfspace\fi}}\x + +\begingroup \catcode `|=0 \catcode `[= 1 \catcode`]=2 +\catcode `\{=12 \catcode `\}=12 \catcode`\\=12 +|long|gdef|@xverbatim#1\end{verbatim}[#1|end[verbatim]] +|endgroup + +\makeatother + +\let~\columnbreak + +\hyphenation{etocthe-page} + +\begin{multicols}{2} +\begin{verbatim} +v1.02 [2012/11/18] + + initial version + + +v1.04 [2012/11/24] + + a (possibly local) table of contents can be labeled: + + \tableofcontents \label{toc:1} + + and reproduced elsewhere in the document (with a possibly + completely different layout): + + \tableofcontents \ref{toc:1} + + +v1.05 [2012/12/01] + + \localtableofcontents replaces \tableofcontents* (for + compatibility with the memoir class) + + compatibility with KOMA-script and memoir document + classes. + + +~v1.06 [2012/12/07] + + the standard macros \l@section etc... are modified only + during the calls to \tableofcontents; they can thus be + customized as will by the user (with the help of a + package like tocloft) and this will be taken into account + by etoc for the TOCs typeset in compatibility mode. + + +v1.07 [2013/01/29] + + new commands: + + \etocthename, \etocthenumber, \etocthepage, \etoclink, + + \etoctoccontentsline, \etoctoccontentsline* + + \etocnopar, \etocaftercontentshook + + modified command: \etocmulticolstyle + + new documentation section `surprising uses of etoc' which + explains how to do `lists of arbitrary things', in + addition to the tables of contents. + +\end{verbatim} +\end{multicols} +\endgroup \setcounter{tocdepth}{3} +% \errorcontextlines5 \etoctoclines \etocmarkboth\contentsname -\etocmulticolstyle{} -\tableofcontents \label{toc:main} +\etocmulticolstyle{\noindent\bfseries\Large + \leaders\hrule height1pt\hfill + \MakeUppercase{Table of Contents}} + +\tableofcontents \label{toc:main} \part{Overview} @@ -312,6 +399,7 @@ and the opening and closing may be for example customizing allowed by packages such as |enumitem|. \subsection{Limitations intrinsic to the use of environments} +\label{ssec:limitations} There is a first limitation to this method: the |.toc| file may contain other commands, such as language changing @@ -349,36 +437,35 @@ 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! -\section{Line styles and global style} +\section{Line styles and toc display style} -I should have distinguished between the \emph{line styles} -(the way the name, number and page numbers are used at each -level) which I was alluding to until now and the \emph{toc - display style} (I am using this for lack of a better name) -which tells how the title should be set, whether an entry in -the |.toc| file should be made, whether the contents should be -typeset with multiple columns, etc... +A distinction shall be made between the \emph{line styles}, +\emph{i.e.} the way the name, number and page numbers are +used at each level, and the \emph{toc display style} (for +lack of a better name) which tells how the title should be +set, whether an entry in the |.toc| file should be made, +whether the contents should be typeset with multiple columns, +etc... the latter is governed by the command +\cs{etocsettocstyle} (or some higher-level commands) and the +former by the command \cs{etocsetstyle}. \subsection{\csbhyp{etocsettocstyle} for the toc display} The low-level \csb{etocsettocstyle} command allows to decide what should be done before and after the line entries of the TOC are typeset, and in particular how the title should be -printed. +printed. It has two arguments, the first one is executed +before the TOC contents (typically it will print +``Contents'' and define suitable head-marks) and the second is +executed after the TOC contents. -\subsubsection{Multiple columns, ruled title, framed contents} - -\etoc provides four (customizable...) toc styles which are -variants on the use of the |multicol| package: +\etoc provides four (customizable) higher level toc styles: \csb{etocmulticolstyle}, \csb{etoctocstyle}, -\csb{etocruledstyle}, and \csb{etocframed\-style}. All use the +\csb{etocruledstyle}, and \csb{etocframedstyle}. All use the |multicol| package with a default of two columns (single-column mode is of course allowed). -These commands must be followed either by \toc or \localtoc, -and dropping the `style' in the command name gives shortcuts -(except for \cs{etoctoc} which does not exist) -for doing the whole thing in one go (and inside a group). +These commands must be followed either by \toc or \localtoc. \subsection{\csbhyp{etocsetstyle} for the line styles} @@ -388,50 +475,44 @@ The command to inform \etoc of what to do with \cs{etocname}, one is the name of the sectional unit: a priori known names are |book|, |part|, |chapter|, |section|, |subsection|, |subsubsection|, |paragraph|, and |subparagraph|. The four -other arguments say: 1) what to do when this level is first -encountered, down from a more general one, then 2) \& 3) (two -arguments, a `prefix' and a `contents') what to do when a new -entry of that type is found, and 4) the last argument is the +other arguments say: 1) \emph{what to do when this level is first +encountered, down from a more general one,} then 2) \& 3) (two +arguments, a `prefix' and a `contents') \emph{what to do when a new +entry of that type is found,} and 4) \emph{the last argument is the code to execute when a division unit of higher importance is -again hit upon. - -\subsubsection{Instructing \etoc about the document sectional division names} - -Other names (\emph{atom}, \emph{particle} . . .) for sectional -divisions may be made known to \etoc with the -command \csb{etocsetlevel}.\footnote{however, no - more than the eight distinct levels from -2 to +5 may be used.} +again hit upon.} \subsection{Compatibility mode} -Both for the ``line styles'' and the ``global style'', it is +Both for the ``line styles'' and the ``toc display style'', it is possible to switch into a compatibility mode which uses the -document class default style.\footnote{for the ``global style'' +defaults from the +document class.\footnote{for the ``toc display style'' \etoc checks if it knows the class, and if not defaults to - the |article| class layout.} This is activated by: -\begin{verbatim} -\etocstandardlines % `line entries' as without \usepackage{etoc} -\etocstandarddisplaystyle % `toc display' as without \usepackage{etoc} -\end{verbatim} -Actually, starting with version |1.05|, this is the default at -the start of the document, and just adding + the |article| class layout.} This is activated by:\\ +\makebox[5.2cm][l]{\csb{etocstandardlines}} + |% `line entries' as without \usepackage{etoc}|\\ +\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 document, at least for 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. +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. \section{Arbitrarily many TOCs, and local ones too} \etoc allows arbitrarily many \cs{tableofcontents} commands in -your document. The line styles and the global style may of +your document. The line styles and the toc display style may of course be changed in-between. Furthermore \cs{localtableofcontents} will print local tables of contents\footnote{Up to version |1.04| we called this @@ -441,23 +522,69 @@ contents\footnote{Up to version |1.04| we called this given chapter, or all subsubsections and lower inside a given subsection, etc . . . + + + + +\subsection{Labeling and reusing elsewhere} + +\etoc allows the labeling of a TOC with \cs{label\{toc:A\}} +and will redisplay it elsewhere when told +\cs{tableofcontents}\cs{ref\{toc:A\}}. The actual layout +(title inclusive) used for the cloned TOC will be decided +locally. The line styles and toc display style (including the +title) will be the current ones and the current value of the +|tocdepth| counter is obeyed. As an example here is the table +of contents of Part \ref{part:custom}: + +\begingroup + +\etocstandardlines +\renewcommand{\etocbkgcolorcmd}{\color{green!5}} +\fboxsep1ex + +\etocframed[1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone +\hyperref[toc:c]{I am from far away}}}} +\label{toc:d} +\ref{toc:c} + +\endgroup + +We actually did something like:\\ +\hbox to \linewidth{\hss + \toc\space\cs{label}|{toc:d}|\cs{ref}|{toc:c}|\hss} Hence +\hyperref[toc:d]{\color{niceone}the present location} +can itself now be referred to via |\ref{toc:d}|: it gives +the id of this TOC\footnote{\emph{i.e} +{\color{niceone}\ref{toc:d}}, there was an invisible +TOC with id 2 at the beginning of this part.} in the sequence of +document TOCs, and will be a link if package |hyperref| is +used. + +However one should not use elsewhere \toc|\ref{toc:d}|. Due to +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{On manually adding layout commands to the \texorpdfstring{\ttfamily .toc}{.toc} file} -When using in that way many tables of contents in the same -document one should of course beware of adding manually things -to the |.toc| file. For example the technique of inserting\\ +When displaying in that way many tables of contents in the same +document one should of course beware of the impact of adding +manually things +to the |.toc| file. For example, inserting\\ \hbox to \linewidth{\hss \cs{addtocontents}|{toc}{\string\clearpage}|\hss} just before a \cs{part} to fix the problem when some part entry (in -the table of contents) is isolated at the bottom of one page +the table of contents) is isolated at the bottom of one page, will cause problems with multiple TOCs: this \cs{clearpage} will be executed by \etoc each time a \toc or \localtoc command is encountered! The more prudent thing is to have issued rather:\\ \hbox to -\linewidth{\hss\cs{addtocontents}|{toc}{\string\myclearpage}|\hss} -and to use where needed something like: +\linewidth{\hss\cs{addtocontents}|{toc}{\string\myclearpage}|,\hss} +to have a |\let\myclearpage\relax| at the top level of the +document and to use where needed something like: \begin{verbatim} \let\myclearpage\clearpage \tableofcontents @@ -480,80 +607,48 @@ table of contents with the other |memoir| command \cs{maxtocdepth}. independently of \etoc, see page 170 of the |memoir| manual.} +\subsection{Shuffling the levels with \csbhyp{etocsetlevel}} -\subsection{Labeling and reusing elsewhere} +The intrinsic levels manipulated by \etoc are numeric: from +|-2| (which corresponds to |book| in the |memoir| class) down +to |5| (|subparagraph|). But the assignment of a numeric level +to a given name can be modified at any time with the command +\cs{etocsetlevel}\marg{level\_name}\marg{n}. In conjunction +with the use of the \LaTeX{} |tocdepth| counter, this has +powerful applications: \meta{level\_name} does not have to +coincide with an actual document sectioning command, and \etoc +can be used to print arbitrary ``lists of things'', using no +other auxiliary file than the |.toc| file. This is +explained further in the section \ref{sec:surprising}. -\etoc allows the labeling of a TOC with \cs{label\{toc:A\}} -and will redisplay it elsewhere when told -\cs{tableofcontents}\cs{ref\{toc:A\}}. Again, the actual -layout (title inclusive) is decided locally. The -line styles and global style (including the title) will be the -current ones and the current value of the |tocdepth| counter is -obeyed. As an example here is the table of contents of Part -\ref{part:custom}: - -\begingroup - -\etocstandardlines -\renewcommand{\etocbkgcolorcmd}{\color{green!5}} -\fboxsep1ex - -\etocframed[1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone I am from - \hyperref[toc:c]{far away}}}} -\label{toc:d} -\ref{toc:c} - -\endgroup - -We actually did something like:\\ -\hbox to \linewidth{\hss - \toc\space\cs{label}|{toc:d}|\cs{ref}|{toc:c}|\hss} Hence -\hyperref[toc:d]{\color{niceone}the present location} -can itself now be referred to via |\ref{toc:d}|: it gives -the id of this TOC\footnote{\emph{i.e} -{\color{niceone}\ref{toc:d}}, there was an invisible -TOC with id 2 at the beginning of this part.} in the sequence of -document TOCs, and will be a link if package |hyperref| is -used. +\subsection{Local table of contents for this part} -However one should not use elsewhere \toc|\ref{toc:d}|. Due to the way -\etoc implements the cloning,\footnote{The double cloning had a - different (but also wrong) effect in |v1.05| compared to |v1.06|.} - 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}|. - -The \cs{label} command should follow \toc before the reference via -\cs{ref} to the other TOC. Indeed a \cs{label} following it is -detected by \toc (skipping spaces and an optional \texttt\lowast). A -\cs{label} after the \cs{ref} will not be treated by \etoc -itself and will refer to the latest reference point, possibly -to some counter updated in the title of the TOC or, although -this would require the user to have done a suitable set-up in the -line styles, even some counter modified inside the TOC. - -As another example let us display a table of contents for -this first part of the document. Indeed, immediately after the +Immediately after the line in the source file starting with the first \cs{part} we wrote: - -\vspace{-.25cm} +% +% The \cs{label} command should follow \toc before the reference via +% \cs{ref} to the other TOC. Indeed a \cs{label} following it is +% detected by \toc (skipping spaces and an optional \texttt\lowast). A +% \cs{label} after the \cs{ref} will not be treated by \etoc +% itself and will refer to the latest reference point, possibly +% to some counter updated in the title of the TOC or, although +% this would require the user to have done a suitable set-up in the +% line styles, even some counter modified inside the TOC. \begin{verbatim} -\setcounter{tocdepth}{-3} -\localtableofcontents \label{toc:partone} -\setcounter{tocdepth}{3} + \setcounter{tocdepth}{-3} + \localtableofcontents \label{toc:partone} \end{verbatim} -The |tocdepth| being set to -3, nothing at all was inserted in the page +The |tocdepth| being set to -3, nothing at all was typeset in the page (\etoc cancels printing even the heading of the TOC if the |tocdepth| is -2 or less, except for the |memoir| class for which it needs to be -3 or less). -We can then display the TOC with: +We can then display here this TOC with: \begin{verbatim} -\subsection{Local table of contents for this part} -\tableofcontents \ref{toc:partone} + \setcounter{tocdepth}{3} + \tableofcontents \ref{toc:partone} \end{verbatim} -\subsection{Local table of contents for this part} - \setcounter{tocdepth}{3} \begingroup @@ -637,35 +732,53 @@ which serves as background for the entire thing. This design \hyperref[toc:clone]{\color{niceone}this other toc}, and the coding used is to be found at its location. + +\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. + + \section{Surprising uses of \etoc} \label{sec:surprising} \subsection{The TOC of TOCs} \begingroup -\makeatletter -% to get rid of the \par... -\def\table@fcontents{%\par - \refstepcounter{etoc@tocid}% - \Etoc@tocwithidfalse - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\makeatother - +\etocnopar \etocsetlevel{part}{1} \etocsetlevel{chapter}{1} \etocsetlevel{visibletoc}{0} -\etocsetstyle{visibletoc}{\etocskipfirstprefix}{, }{{\color{niceone}\etocname}}{} -\etocnakedtocdisplaystyle +\etocsetstyle{visibletoc} + {\etocskipfirstprefix} + {, } + {{\color{niceone}\etocname}} + {} +\etocsettocstyle{}{} \setcounter{tocdepth}{0} Here is the numbered and linked list of all tables of contents which are displayed within this document: -\tableofcontents\setcounter{tocdepth}{3}\endgroup. And to obtain +\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 -{\leftskip3cm\rightskip\leftskip +{\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} @@ -676,88 +789,101 @@ document...}\par\smallskip counts all TOCs, even those not displayed because the |tocdepth| value was |-2| or |-3|. -We could have added manually |\refstepcounter{visibletoc}| and -|\label| commands at -all suitable locations in the document source, and use here |\ref| -commands, but this requires quite some manual editing of the -source. - -There is a much better way: there is a hook -\cs{etocaftertitlehook} and we told it to increment the -|visibletoc| counter and to write a line to the |.toc| file, -exactly as sectioning commands such as |chapter|, |section|, or -|subsection| do. The name of the fictitious unit was chosen to be -again |visibletoc|. - -In the preamble of the document we did -|\etocsetlevel{visibletoc}{5}| and in this subsection -|\etocsetlevel{visibletoc}{0}|, |\setcounter{tocdepth}{0}|, and we -also assigned to |part| and |chapter| level |1|. So the printed -table of contents uses \emph{only} the `visibletoc' entries from -the |.toc| file. The other entries are just discarded. We also -defined a simple style with \cs{etocsetstyle} for inline display. - -To tell the entire truth the current version |1.06| of \etoc -issues |\par| automatically before typesetting a table of -contents, so we had to copy the suitable inner macro and remove -from it the |\par|. Next release of \etoc will have a public -command to tell the package not to do this |\par| (today I don't -want to modify the code source, only enhance a bit this -documentation). + We could have added manually |\refstepcounter{visibletoc}| + and |\label| commands at all suitable locations in the + document source, and we would then have used here |\ref| + commands, but this imposes heavy manual editing of the source. + + There is a much better way: there is a hook + \csb{etocaftertitlehook} and we told it to increment the + |visibletoc| counter and to write a line to the |.toc| file, + in a manner analogous to what sectioning commands such as + |chapter|, |section|, or |subsection| do. As \etoc + increments its own private counter even before typesetting + the title of a table of contents, this provides (most of the + time) a better link destination than any counter manipulated + from inside \cs{etocaftertitlehook} (for which the link + would target the area just after the title). So, rather than + including |\refstepcounter{visibletoc}| inside + \cs{etocaftertitlehook}, we just put there + |\stepcounter{visibletoc}| followed by the package command + \csb{etoctoccontentsline}\marg{level\_name}\marg{name}. This + command has the same effect as:\\ + \hbox to \linewidth{| |% + |\addcontentsline{toc}|\marg{level\_name}\marg{name}\hss} + but its usefulness is to circumvent the automatic creation + of bookmarks by the |hyperref| package, as they don't make + much sense here (and elicit a complaint + of |hyperref| that the bookmark level is `unknown'). + + The package provides a starred variant + \staritb{etoctoccontentsline}, which will allow the creation + of bookmarks but has a third mandatory argument which is the + level to be used by these bookmarks. + + Finally, the preamble of the document did + |\etocsetlevel{visibletoc}{6}|. The level |6| (or anything + with a higher number) is ignored, even if |tocdepth| has + value |10| for example; this is independently of whether \etoc + uses the document class default line styles or its own line + styles, or the ones defined by the user with the + \cs{etocsetstyle} command. So there is no need to worry that + something could go wrong. + + Then, only here we have set |\etocsetlevel{visibletoc}{0}|. + And to display only this kind of entries we assign + temporarily to |part| and |chapter| level |1| (or anything + higher than zero) and set |tocdepth| to the value |0|. + We also did \cs{etocsetstyle\{visibletoc\}\{\string\etocskipfirstprefix\}\{, \}\{\string\etocname\}\{\}} which + defines an inline display with the comma as separator. Finally, as + \etoc issues |\par| automatically by default just before + typesetting a table of contents, we had to use the command + \csb{etocnopar} to turn off this behavior. Here are the implementation details: \begingroup \begin{verbatim} -... in the preamble: +. . . in the preamble: \newcounter{visibletoc} -\makeatletter -\renewcommand{\etocaftertitlehook}{\stepcounter{visibletoc}% - % no \refstepcounter needed nor useful as etoc's inner counter - % for TOCs got incremented just before - \addtocontents {toc}{\protect\contentsline - {visibletoc}{\thevisibletoc }{\thepage }{\@currentHref }}} - % we do not use \addcontentsline which is patched by hyperref - % In this way no bookmark creation, only hyperlinks. -\makeatother - -% Only displayed TOCs will execute this hook. Invisible TOCs defined -% for display elsewhere do not. The package has a private counter -% which we didn't use as it counts all TOCs. The contentsline data -% defines an `unnumbered' entity (there is no \numberline macro -% in the last parameter), whose name is the current value of the -% counter visibletoc. So we will use \etocname. - -\etocsetlevel{visibletoc}{5} % hence the added data will remain - % invisible as long as tocdepth < 5 - +\renewcommand{\etocaftertitlehook} + {\stepcounter{visibletoc}\etoctoccontentsline{visibletoc}{\thevisibletoc}} +\etocsetlevel{visibletoc}{6} +. . . \begin{document} -... document body +. . . document body \subsection{Surprising uses of etoc} \begingroup -\etocsetlevel{part}{1} -\etocsetlevel{chapter}{1} -\etocsetlevel{visibletoc}{0} -\etocsetstyle{visibletoc} - {\etocskipfirstprefix}{, }{{\color{niceone}\etocname}}{} -\etocsettocstyle{}{} % don't set any title, rules or frame or multicol! -\setcounter{tocdepth}{0} % display only the `visibletoc' entries from .toc + \etocnopar + \etocsetlevel{part}{1} + \etocsetlevel{chapter}{1} + \etocsetlevel{visibletoc}{0} + \etocsetstyle{visibletoc} + {\etocskipfirstprefix}{, }{{\color{niceone}\etocname}}{} + \etocsettocstyle{}{} % don't set any title, rules or frame or multicol! + \setcounter{tocdepth}{0} % display only the `visibletoc' entries from .toc Here is the numbered and linked list of all tables of contents which are displayed within this document: \tableofcontents. \endgroup \end{verbatim} + \endgroup +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 +manner is to put everything inside a group. + Subsection \ref{subsec:interverting} gives another use of the shuffling of levels. -% ATTENTION HYPERREF TIENT COMPTE DE TOCDEPTH -% MAIS C'EST DEBILE ÇA ! IL DEVRAIT Y AVOIR UN -% SETTING GLOBAL -% \setcounter{tocdepth}{3} % fait plus haut -\subsection{Arbitrary ``List Of...''} +\subsection{Arbitrary ``Lists Of...''} + +\begingroup\parsep0pt\partopsep0pt +\def\MacroFont{\ttfamily\footnotesize\baselineskip11pt\relax} This idea of interverting the levels is very powerful and allows to let \etoc display lists of arbitrary things contained in the @@ -767,24 +893,30 @@ Example: imagine a document with dozens of exercises, perhaps defined as |\newtheorem{exercise}{}[section]|. Let us explain how to instruct \etoc to display an hyperlinked list of all these exercises. For this we put in the preamble: -\begingroup -\makeatletter -\def\verbatim@font{\ttfamily\small\baselineskip12pt }% -\makeatother \begin{verbatim} - \newtheorem{exerci}{}[section] - \newcommand{\exercisetotoc}{\addcontentsline{toc}{exercise}{\theexerci}} + \newtheorem{exerci}{}[section] + % the exercice number will be recoverable with \etocname: v--------v + \newcommand*{\exercisetotoc}{\etoctoccontentsline{exercise}{\theexerci}} \newenvironment{exercise}{\begin{exerci}\exercisetotoc}{\end{exerci}} - \etocsetlevel{exercise}{5} + \etocsetlevel{exercise}{6} \end{verbatim} -Then, the list of exercises can be typeset in a four-column format -with the following code: +The above was motivated by question |94766| on the +\TeX-StackExchange site. The counter |exerci| is already +incremented by the |exerci| theorem environment, and +provides the correct destination for the link added by package +|hyperref|. The command \cs{exercisetotoc} adds for each exercise a line +to the |.toc| file, corresponding to a fictitious document +unit with name `|exercise|'. A +four-column list, including the sections, can then be +typeset with the following code: \begin{verbatim} \begingroup + \setcounter{tocdepth}{2} % section is at level 1 \etocsetlevel{exercise}{2} - \etocsetlevel{chapter}{3} \etocsetlevel{subsection}{3} \etocsetlevel{part}{3} - \setcounter{tocdeph}{2} - \etocsetstyle{exercise}{}{} + \etocsetlevel{chapter}{3} % no chapters + \etocsetlevel{subsection}{3} % no subsections + \etocsetlevel{part}{3} % no parts + \etocsetstyle{exercise}{}{} % \etocname = exercise number {\noindent\etocname\strut\leaders\etoctoclineleaders\hfill\etocpage\par} {\pagebreak[2]\vskip\baselineskip} \etocsetstyle{section}{}{} @@ -793,33 +925,25 @@ with the following code: \etocruledstyle[4]{\Large\bfseries List of the exercises} \setlength{\columnseprule}{.4pt} \tableofcontents - \setcounter{tocdepth}{3} \endgroup \end{verbatim} -The above was motivated by question |94766| on the -\TeX-StackExchange site. - -When package |hyperref| is used, all -these exercise numbers will be hyperlinks. But |hyperref| will -also add bookmarks to be used if the output format is PDF. One -needs to inform it of a suitable level to be used for these -bookmarks, so here for example this could be |2|, so that for -bookmark purposes the exercises will be considered as sub-units of -sections. This goes in the preamble of the document: -\begin{verbatim} -\makeatletter -\providecommand*{\toclevel@exercise}{2} -\makeatother -\end{verbatim} -It is also possible to prevent |hyperref| from creating any bookmark -for the exercices. This does it: + + +We used \cs{etoctoccontentsline} and not +\cs{addcontentsline}|{toc}{..}{..}| as we didn't want to have bookmark +creation done by |hyperref|. To allow creation of bookmarks at +the specific level \meta{n}, one can use (here with \meta{n}$=$|2|): \begin{verbatim} -\makeatletter - \newcommand{\exercisetotoc}{% - \addtocontents {toc}{\protect\contentsline - {exercise}{\theexerci }{\thepage }{\@currentHref }}} -\makeatother + \newcommand{\exercisetotoc}{\etoctoccontentsline*{exercise}{\theexerci}{2}} \end{verbatim} + +In the above, recall that \LaTeX{} counters are global. The +current |tocdepth| value is |2|, and if not reset it will prevent +|hyperref| to assign bookmarks to sub-subsections (level |3|). +The global |hyperref| option \emph{bookmarksdepth} can be +used to avoid having to systematically reset |tocdepth| after +having changed it. + \endgroup \subsection{A TOC with a fancy layout} @@ -832,27 +956,18 @@ of course to be inserted automatically in the TOC). The next page is the result of my effort at using \etoc for this problem. How this was done will be found on the above cited site. -This is not an image inclusion, the TOC was recreated entirely -within this document via the creation of dummy part, chapter and -section units as a well as a dummy page count. The dummy data was -created using loops and found its way into the |.toc| file. -And the table of -contents was then displayed after issuing: +This is not an image inclusion, the TOC is produced from its original +|tex| source inserted in this document after replacement of +|part|, |chapter| or |section| with |dummypart|, |dummychapter| and +|dummysection| (and there is also a dummy page count). We +copied the line styles used in the original and +displayed the table of contents following: \begin{verbatim} - \etocsetlevel{dummypart}{-1} - \etocsetlevel{dummychapter}{0} - \etocsetlevel{dummysection}{1} - \etocsetlevel{part}{2} - \etocsetlevel{chapter}{2} - \etocsetlevel{section}{2} - \setcounter{tocdepth}{1} + \etocsetlevel{dummypart} {-1} \etocsetlevel{part} {2} + \etocsetlevel{dummychapter}{0} \etocsetlevel{chapter}{2} + \etocsetlevel{dummysection}{1} \etocsetlevel{section}{2} + \setcounter{tocdepth}{1} \end{verbatim} -In this way the styles used to typeset originally the TOC from a -dedicated |.tex| file could be -inserted in the present documentation (as the current version of -\etoc does not have user commands to import a |.toc| file from -another document, we had to create as mentioned above the -apparatus for the generation of these dummy parts, chapters, sections). \clearpage @@ -933,29 +1048,33 @@ apparatus for the generation of these dummy parts, chapters, sections). \leavevmode\vfill \tableofcontents \vfill\clearpage - \setcounter{tocdepth}{3} \makeatletter \def\adddummysection {\stepcounter{dummysection}% \addtocontents {toc}{\protect\contentsline - {dummysection}{\protect\numberline{\thedummysection}} - {\the\dummypage }{\@currentHref }}} - + {dummysection}{\protect\numberline{\thedummysection}}% + {\the\dummypage }% + \ifEtoc@hyperref{\@currentHref }\fi}} + \def\adddummychapter #1{\stepcounter{dummychapter}% \advance\dummypage2 \addtocontents {toc}{\protect\contentsline - {dummychapter}{\protect\numberline{\thedummychapter}#1} - {\the\dummypage }{\@currentHref }}} + {dummychapter}{\protect\numberline{\thedummychapter}#1}% + {\the\dummypage }% + \ifEtoc@hyperref{\@currentHref }\fi}} + \def\adddummychapno #1{\advance\dummypage2 \addtocontents {toc}{\protect\contentsline - {dummychapter}{#1}{\the\dummypage }{\@currentHref }}} + {dummychapter}{#1}{\the\dummypage }% + \ifEtoc@hyperref{\@currentHref }\fi}} \def\adddummypart #1{\stepcounter{dummypart}% \advance\dummypage4 \addtocontents {toc}{\protect\contentsline - {dummypart}{\protect\numberline{\Roman{dummypart}}#1} - {\the\dummypage }{\@currentHref }}} + {dummypart}{\protect\numberline{\Roman{dummypart}}#1}% + {\the\dummypage }% + \ifEtoc@hyperref{\@currentHref }\fi}} \makeatother @@ -1122,7 +1241,11 @@ apparatus for the generation of these dummy parts, chapters, sections). {\etocname\unskip} {.\hfil\par\endgroup\pagebreak[3]} -\etocruledstyle[1]{\etocfontminusone\color{green} +% 27 janvier 22:30 +% je définis les macros (non protégées) +% \etocthename, \etocthenumber, \etocthepage + +\etocruledstyle[1]{\etocfontminusone\color{green}% \fboxrule1pt\fboxsep1ex \framebox[\linewidth] {\normalcolor\hss Contents of this second part\hss}} @@ -1131,7 +1254,7 @@ apparatus for the generation of these dummy parts, chapters, sections). \section{The \csbhyp{etocsetstyle} command} -\subsection{An example} +\subsection{The \csbhyp{etocname} and \csbhyp{etocpage} commands} Let us explain how \etoc was used to produce the table of contents displayed at the beginning of this second part. @@ -1151,7 +1274,6 @@ obtained in the following manner:% \begingroup\small \begin{verbatim} -\setcounter{tocdepth}{3} \etocsetstyle{section} {\begin{enumerate}} {\normalsize\bfseries\rmfamily\item} @@ -1173,6 +1295,12 @@ obtained in the following manner:% \end{verbatim} \endgroup +These provisory style definitions rely on the automatic +numbering generated by the |enumerate| environments but it is +much better to use the further command \csb{etocnumber} inside +the item label, which gives the real thing. The improved +definitions will thus be explained later. + Each \csb{etocsetstyle} command has five mandatory arguments:\\ \hbox to \linewidth {\hfil\csb{etocsetstyle}\color{blue}\marg{levelname}% @@ -1189,29 +1317,24 @@ level toc entry. In the mean-time all entries for that level are typeset by executing first the \meta{prefix} code and then the \meta{contents} code. -\subsubsection{\csbhyp{etocname} and \csbhyp{etocpage}} -The line styles specifications use the commands \csb{etocname} -and \csb{etocpage} as synonyms for the name, respectively the -page number of the current 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.} Temporarily, we relied on -the automatic numbering of the |enumerate| environments but -there is also a command \csb{etocnumber} to get the real thing -from the |.toc| file. +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.} -\subsubsection{The \csbhyp{etocskipfirstprefix} command} +\subsection{The \csbhyp{etocskipfirstprefix} command} -The chosen |subsubsection| style specifies to list the names of -the subsubsections from a given subsection in an in-line -manner, with -- as a separator. The command +The chosen |subsubsection| style also uses the command \csb{etocskipfirstprefix}, which, if present, \emph{must} be -the very last one in the \emph{start} code, instructs to not -use that separator of the first item. +the very last one in the \emph{start} code. It instructs to not +use for the first item the specified ``prefix'' code. With this style, one would have to be imaginative to design something then for paragraph and @@ -1225,46 +1348,19 @@ where no provision is made for them and added the definitive: \end{verbatim} This is also the situation with the default package line styles! -\subsubsection{secnum\-depth and tocdepth} - -The \LaTeX{} counter |secnumdepth| decides down to which level division -headings are numbered. Numbered or not they are (at least in the standard -classes) written to the |.toc| file. The counter |tocdepth| decides then the -finest level which will be displayed in the table of contents: its local -value is obeyed by \etoc, and as the \toc command and its variants may now -be used multiple times, this is an important customization lever. +% \subsubsection{secnum\-depth and tocdepth} +% The \LaTeX{} counter |secnumdepth| decides down to which level division +% headings are numbered. Numbered or not they are (at least in the standard +% classes) written to the |.toc| file. The counter |tocdepth| decides then the +% finest level which will be displayed in the table of contents: its local +% value is obeyed by \etoc, and as the \toc command and its variants may now +% be used multiple times, this is an important customization lever. -\subsection{The \csbhyp{etocsetlevel} command} -If your document uses other sectioning names, such as, for -example \emph{molecule}, or \emph{atom}, it should inform \etoc of -this in the following way: -\begin{verbatim} -\etocsetlevel{cell}{0} -\etocsetlevel{molecule}{1} -\etocsetlevel{atom}{2} -\etocsetlevel{nucleus}{3} -\end{verbatim} -The accepted numbers range from -2 to 5 inclusive. The package code -does: -\begin{verbatim} -\etocsetlevel{book}{-2} -\etocsetlevel{part}{-1} -\etocsetlevel{chapter}{0} -\etocsetlevel{section}{1} -\etocsetlevel{subsection}{2} -\etocsetlevel{subsubsection}{3} -\etocsetlevel{paragraph}{4} -\etocsetlevel{subparagraph}{5} -\end{verbatim} - -\subsection{Further informations and let's make this a very long title to see how it will look like} - - -\subsubsection{The \csbhyp{etocnumber} command} +\subsection{The \csbhyp{etocnumber} command} So far, our specifications would use the numbering generated -by the |enumerate| environments, but it would be nicer to use +by the |enumerate| environments, but of course we generally want the actual numbers as found in the |.toc| file. This is available via the \csb{etocnumber} command. To get the labels in the |enumerate| list to use it we can proceed with the @@ -1277,7 +1373,9 @@ syntax {\ttfamily label=\char32} from the package |enumitem|: {\end{enumerate}} \end{verbatim} Rather than just \cs{etocnumber} we then used something like -|\fbox{\etocnumber}|. +|\fbox{\etocnumber}|. Note that \cs{etocnumber} is a protected +command which explains why it can be used inside the label specification +without needing an added |\protect|. \subsubsection{The \csbhyp{etocifnumbered} switch} @@ -1315,74 +1413,164 @@ vertical mode'. An additional \cs{par} token in the \meta{contents} part of the |section| level would have fixed this: |{...(page \etocpage)\par}|. +\subsection{The \csbhyp{etocthename}, \csbhyp{etocthenumber}, and +\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. + +These commands are not protected, so in moving argument +contexts (for example in a label specification) they should be +preceded by |\protect|. + +\subsection{The \csbhyp{etoclink} command} + +The command \csb{etoclink}\marg{linkname} can be used in the line style +specifications in a manner analogous to the argument-less +commands \cs{etocname}, \cs{etocnumber} and \cs{etocpage}. It +creates a link (if such a link was added by |hyperref| to the +|.toc| file entry) whose destination is the corresponding document +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. + +The +command \cs{etoclink} is protected. -\subsection{The \csbhyp{etocfontxxx...} commands} -The package predefines for use in its default line styles: +\subsection{The \csbhyp{etocsetlevel} command} + +As already explained in the section \ref{sec:surprising}, one +can inform \etoc of a level to associate to a given sectioning +command with \cs{etocsetlevel}. For example: \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} +\etocsetlevel{cell}{0} +\etocsetlevel{molecule}{1} +\etocsetlevel{atom}{2} +\etocsetlevel{nucleus}{3} \end{verbatim} -The same font is used for -the name, number, and page number, at each level (up to subsubsection). +Of course, in compatibility mode, it will be assumed here that the +macros |\l@cell|, |\l@molecule|, ..., pre-exist. If no table +of contents is typeset in compatibility mode, then all that +matters is that the line styles have been set. If for example +|section| is at level |1|, then there is no need to do a +\cs{etocsetstyle}|{molecule}| if \cs{etocsetstyle}|{section}| +has already been done (and it has been done by the package +itself in its definition of its own line styles). + +The accepted levels run from |-2| to |6| inclusive. Anything else is +mapped to |6|, which is a dummy level, never displayed. The package +does: +\begin{verbatim} +\etocsetlevel{book}{-2} +\etocsetlevel{part}{-1} +\etocsetlevel{chapter}{0} +\etocsetlevel{section}{1} +\etocsetlevel{subsection}{2} +\etocsetlevel{subsubsection}{3} +\etocsetlevel{paragraph}{4} +\etocsetlevel{subparagraph}{5} +\end{verbatim} +Its own line styles are activated by \cs{etoctoclines}. 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}. + -In document classes where there is a \cs{chapter} command, the -default font for the level 1 (`section') does not use the bold -series. +% \subsection{The \csbhyp{etocfontxxx...} commands} -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. +% 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}} +\begingroup +\footnotesize + \subsubsection{This is a (pale) red subsubsection for illustrative purposes} -Just before this subsubsection we inserted in the |.tex| file: +Just before this subsubsection we did: \begin{verbatim} \color{red!50} \addtocontents{toc}{\string\color{red!50}} \end{verbatim} -This entire subsubsection and its title is printed in red, as -well as the title of the next section (we cancel the color -change only after it). But what about its entry in the table -of contents? well it is red in the main table of contents at -the beginning of this document, which uses the package line -styles, and it is not red in the table of contents at the -beginning of this second document part. The reason is that the -\meta{finish} code for the subsubsection level closed a group, -whereas the \meta{start} and \meta{finish} code of the package -line styles do not contain group opening and closing -instructions. So here the group was closed while reading the -|.toc| file and this explains why the next entry in the local -TOC was not typeset in red. - -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. +The title here would +be red in the |article| class, but is black in the |scrartcl| +class. In both classes the corresponding entry in the main +table of contents at the beginning of this document is red; it +is not red in the table of contents at the beginning of this +second document part. The reason is that the \meta{finish} +code for the subsubsection level closed a group; the +definition was:\topsep0pt\partopsep0pt +\def\MacroFont{\footnotesize\ttfamily}% +\begin{verbatim} + \etocsetstyle{subsubsection} + {\par\nobreak\begingroup\normalfont + \footnotesize\itshape\etocskipfirstprefix} + {\allowbreak\,--\,} + {\etocname\unskip} + {.\hfil\par\endgroup\pagebreak[3]} <--- here is the \endgroup +\end{verbatim} +This illustrates the discussion from subsection \ref{ssec:limitations}. +The default package line styles +do not contain group opening and closing instructions, so the +influence (within TOCs such as the main one in this document) +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?} Well, actually no in this |scrartcl| class but I assure you I was in the -|article| class! - +|article| class!\topsep0pt\partopsep0pt \begin{verbatim} -\normalcolor -\addtocontents{toc}{\string\normalcolor} + \normalcolor + \addtocontents{toc}{\string\normalcolor} \end{verbatim} +\endgroup + \normalcolor \addtocontents{toc}{\string\normalcolor} @@ -1396,16 +1584,17 @@ the document. There is no easy general solution\footnote{one 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. +% \section*{An unnumbered section} +% \addcontentsline{toc}{section}{An unnumbered section} -\begin{verbatim} -\section*{An unnumbered section} -\addcontentsline{toc}{section}{An unnumbered section} -\end{verbatim} +% I don't have much to say here. I just added an unnumbered +% section, and made it appear in the |.toc| file. + +% \begin{verbatim} +% \section*{An unnumbered section} +% \addcontentsline{toc}{section}{An unnumbered section} +% \end{verbatim} @@ -1454,6 +1643,8 @@ provided by the document class, and a two-column layout: \hyperref[toc:test]{\color{niceone}the next TOC} it contains paragraph entries.}} +\clearpage + \tableofcontents We then switch to our set-up from the previous part and add to it: @@ -1481,20 +1672,17 @@ We then switch to our set-up from the previous part and add to it: \tableofcontents \label{toc:test} \ref{toc:main} -\setcounter{tocdepth}{3} -\part{Package commands for global styles} +\part{Package commands for toc display styles} \label{part:globalcmds} \begin{verbatim} \setcounter{tocdepth}{-3} \localtableofcontents \label{toc:globalcmds} -\setcounter{tocdepth}{3} \end{verbatim} \setcounter{tocdepth}{-3} \localtableofcontents \label{toc:globalcmds} -\setcounter{tocdepth}{3} \section{Specifying the toc display style} @@ -1532,7 +1720,7 @@ the \hyperref[toc:a]{% \color{niceone} start of the second part of this document} was obtained with: \begin{verbatim} -\etocruledstyle[1]{\etocfontminusone\color{green} +\etocruledstyle[1]{\etocfontminusone\color{green}% \fboxrule1pt\fboxsep1ex \framebox[\linewidth] {\normalcolor\hss Contents of this second part\hss}} @@ -1550,8 +1738,21 @@ environment). The \meta{heading} should be some `vertical' material like: \begin{center} \meta{heading} = {\ttfamily\string\section\lowast}\marg{title} \end{center} -After such a command, future \cs{tableofcontents} will use the -specified style. A shortcut for just one table of contents and +[\emph{New with 1.07}] An explicit |\par| not being accepted in the +\meta{heading} argument (this is actually a restriction +originating in the +|multicols| environment), an implicit one is automatically +added by \etoc at the end of the argument, as in this +example which shows how the main table of contents of this document was +configured: +\begin{verbatim} +\etocmulticolstyle{\noindent\bfseries\Large + \leaders\hrule height1pt\hfill + \MakeUppercase{Table of Contents}} +\end{verbatim} +After \cs{etocmulticolstyle} all future \cs{tableofcontents} will use the +specified style, if not changed in-between. A shortcut for +just one table of contents and not affecting the styles of later TOCs is:\\ \centerline{\cs{etocmulticol}\oarg{number\_of\_columns}\marg{heading}} And there is also @@ -1579,26 +1780,6 @@ actual display of the marks depends on the settings of the page style. There is variant \csb{etoctocstylewithmarksnouc} which does not uppercase. -\subsection{A point of some importance} - -There is an important difference between the -\cs{etocmulticolstyle} and \cs{etocruledstyle} commands. The -mandatory argument of the former can not be just some -\emph{naked text}. One can use things such as\\ -\hbox to \linewidth{\hss \starit{section}|{|\emph{some not so naked text}|}|\hss} -but \meta{heading}=\emph{naked text} gives an error:\\ -\hbox to \linewidth{\hss -|ERROR: LaTeX Error: Something's wrong--perhaps a missing \item.|\hss} -In the special case where the command was -also given the optional argument |[1]|, -it is possible to feed it with `|naked text\par|'. - - -On the other hand, it is exactly the \emph{opposite} for -\cs{etocruledstyle} (and \cs{etocframedstyle}) which expects -things which fit inside a horizontal box, hence it will gladly -accepts a \emph{naked text} as argument, but will choke on -\starit{section} or things ending with a \cs{par}. \paragraph{Do we really want paragraph entries in the TOC?} @@ -1606,7 +1787,8 @@ accepts a \emph{naked text} as argument, but will choke on \subsection{The command \csbhyp{etocruled}} -As a shortcut to set the style and issue a +As a shortcut to set the style with \csb{etocruledstyle} and +then issue a \cs{tableofcontents}, all inside a group so that future table of contents will not be affected, there is:\\ @@ -1627,6 +1809,66 @@ inside the \meta{title} argument to \cs{etocframedstyle} or \cs{etocframed}. There is also \cs{etoc\-localframedstyle} and \cs{etoclocalframed}. +\subsection{Headings, titles, \csbhyp{etocinnertopsep}} + +[\emph{modified in v1.07}] There is a slight difference +between \cs{etocmulticolstyle} and \cs{etocruledstyle} or +\cs{etocframedstyle}. For \cs{etocmulticolstyle} the mandatory +\meta{heading} argument can be something like: +\starit{section}% +|{|\emph{Table of Contents}|}|. On the contrary \cs{etocruledstyle} and +\cs{etocframedstyle} expect an argument +``in LR mode'' (to use the terminology from the \emph{LaTeX, a +document preparation system}). This means that multiline +contents arguments to \cs{etocruledstyle} or +\cs{etocframedstyle} must be enclosed in something like a \cs{parbox}. + +[\emph{new in v1.07}] The command \cs{etocmulticolstyle} now +also accepts horizontal mode material in its mandatory +argument \meta{heading}: it internally automatically adds a +closing |\par|. So one can use for example +|\etocmulticolstyle{Hello World}|. Speaking of |\par|, there +is a |multicols| aspect which has nothing to do with \etoc, +the input on the left creates a compilation error: +\begingroup\renewcommand\columnseprule{.4pt} +\begin{multicols}{2} +\begin{verbatim} +\begin{multicols}{2}[hello\par world] +someone here? +\end{multicols} +\end{verbatim} +\columnbreak +\begin{verbatim} +\let\oldpar\par +\begin{multicols}{2}[hello\oldpar world] + at least me. +\end{multicols} +\end{verbatim} +\end{multicols} +\endgroup +But the code on the right does not. So the package provides +\csb{etocoldpar} as a substitute for |\par| (it executes +|\let\etocoldpar\par| just before starting the |multicols| +environment and automatically add it to close the heading, and +before the vertical skip of value +\cs{etocinnertopsep}).\footnote{this command \cs{etocoldpar} (= +working \cs{par} in the argument to \cs{etocmulticolstyle}) is +not related to the switch \cs{etocnopar} whose purpose is to +tell \etoc not to do a \cs{par} before the table of +contents.} The command \csb{etocoldpar} can also be used +explicitely in the mandatory argument to +\cs{etocmulticolstyle}. + + +An important dimension used by all three of \cs{etocmulticolstyle}, +\cs{etocruledstyle} and \cs{etocframedstyle} is +\csb{etocinnertopsep}. It gives the amount of separation +between the heading and the start of the contents. Its default +value is |2ex| and it is changed by +|\renewcommand*{\etocinnertopsep}|\marg{new\_value}, not with +|\setlength|. + + \subsection{The command \csbhyp{etocsettocstyle}} This is a command with two mandatory arguments:\\ @@ -1634,7 +1876,15 @@ This is a command with two mandatory arguments:\\ \marg{after\_toc}} The \marg{before\_toc} part is responsible for typesetting the heading, for example it can be something like -\starit{section}|{\contentsname}|. It can also contain +\starit{section}|{\contentsname}|. + +Generally speaking this heading +should leave \TeX{} in vertical mode when the actual +typesetting of the contents will start: the line styles (either +from the standard classes or the package default line styles) +expect to start in `vertical mode'. + +It can also contain instructions to mark the page headings. Or it could check (book class) to see if two-column mode is on, and switch to one-column style, and the \meta{after\_toc} part @@ -1642,7 +1892,9 @@ would then reenact the two-column mode. The previously described commands \cs{etocmulticolstyle}, \cs{etocruledstyle}, and \cs{etocframedstyle} actually call -\cs{etocsettocstyle} as a lower-level routine. +\cs{etocsettocstyle} as a lower-level routine, and start a +|multicols| environment in \marg{before\_toc} to close it in +\marg{after\_toc}. \subsection{The compatibility mode \csbhyp{etocstandarddisplaystyle}} @@ -1651,7 +1903,7 @@ done regarding the global display style of the table of contents, in its absence. All customizing from inside the class should be obeyed, too. -\section{The starred variants of the \csbhyp{tableofcontents} +\section{Starred variants of the \csbhyp{tableofcontents} etc... commands} The \toc, \localtoc, \cs{etocmulticol}, etc... have starred @@ -1690,19 +1942,42 @@ generally speaking a hook macro called \csb{etocaftertitlehook} which is inhibited by using the starred variants of the displaying commands. Except for the |memoir| class, this hook is initially defined to do nothing. +There is also \csb{etocaftercontentshook}, similarly +defined to do nothing. They can be used for some special +effects. + +\section{Table of contents for this part} + -\section{Table of contents for part \ref{part:globalcmds}} +\subsection{Testing the compatibility mode} As a third example we now print the local table of contents -for this part. We opt for a +for this part. First we will test the compatibility mode.\footnote{the +present document uses the |scrartcl| class, and we check here that +the \etoc compatibility mode does respect the customizing done via the +class commands.} The original was invisibly defined with a label at the +beginning of this part \ref{part:globalcmds}. +\begin{verbatim} +\KOMAoptions{toc=left} +\etocstandarddisplaystyle % necessary for the display to obey toc=left +\etocstandardlines +\setcounter{tocdepth}{3} +\tableofcontents \ref{toc:globalcmds} +\end{verbatim} +\KOMAoptions{toc=left} +\etocstandarddisplaystyle +\etocstandardlines +\setcounter{tocdepth}{3} +\tableofcontents \ref{toc: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. The original was invisibly defined with a label at the -beginning of this part \ref{part:globalcmds}. +defaults. \begingroup -\baselineskip10pt -\footnotesize \begin{verbatim} \etoctoclines \begingroup % we use a group to limit the scope of the next commands @@ -1731,6 +2006,7 @@ beginning of this part \ref{part:globalcmds}. 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} @@ -1765,20 +2041,6 @@ beginning of this part \ref{part:globalcmds}. \tableofcontents \label{toc:b} \ref{toc:globalcmds} \endgroup -We can also display it in the document standard manner:\footnote{the -present document uses the |scrartcl| class, and we check here that -the \etoc compatibility mode does respect the customizing done via the -class commands.} -\begin{verbatim} -\KOMAoptions{toc=left} -\etocstandarddisplaystyle % necessary for the display to obey toc=left -\etocstandardlines -\tableofcontents \ref{toc:globalcmds} -\end{verbatim} -\KOMAoptions{toc=left} -\etocstandarddisplaystyle -\etocstandardlines -\tableofcontents \ref{toc:globalcmds} \part{Using and customizing \etoc} \label{part:custom} @@ -1808,10 +2070,11 @@ class commands.} \cs{etocsetstyle}\marg{levelname}% \marg{start}\marg{prefix}\marg{contents}\marg{finish}\\ \cs{etocname}, \cs{etocnumber}, \cs{etocpage}, -\cs{etocifnumbered}\marg{A}\marg{B}% +\cs{etocifnumbered}\marg{A}\marg{B}\\ +\cs{etocthename}, \cs{etocthenumber}, \cs{etocthepage}, \cs{etoclink} }}} -\subsection{Setting up global styles} +\subsection{Setting up toc display styles} \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em @@ -1830,7 +2093,7 @@ class commands.} \cs{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\ \cs{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}}} -\subsection{Displaying Tables of Contents} +\subsection{Displaying Table of Contents} \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em @@ -1873,7 +2136,7 @@ contents do \emph{not} react to a \cs{ref} following them. When re-displaying another toc, only its contents are transferred: -both the line styles and the global style are the ones +both the line styles and the toc display style are the ones currently defined, not the ones from the cloned toc. \subsection{An example} @@ -1890,8 +2153,6 @@ this example so we included the title as part of the the frame. \begingroup -\baselineskip10pt -\footnotesize \begin{verbatim} \setcounter{tocdepth}{3} \begingroup @@ -1921,24 +2182,24 @@ the frame. \vskip#2} \etocsetstyle{subsubsection}{\etocskipfirstprefix} -{\shiftedwhiterule{\leftskip}{6pt}} -{\sffamily\footnotesize -\leftskip2.5cm\hangindent1cm\rightskip1cm\noindent -\hbox to 1cm{\color{subsecnum}\etocnumber\hss}% -\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill -\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par -\nointerlineskip\vskip3pt} -{} + {\shiftedwhiterule{\leftskip}{6pt}} + {\sffamily\footnotesize + \leftskip2.5cm\hangindent1cm\rightskip1cm\noindent + \hbox to 1cm{\color{subsecnum}\etocnumber\hss}% + \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill + \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par + \nointerlineskip\vskip3pt} + {} \etocsetstyle{subsection}{\etocskipfirstprefix} -{\shiftedwhiterule{1.5cm}{6pt}} -{\sffamily\small -\leftskip1.5cm\hangindent1cm\rightskip1cm\noindent -\hbox to 1cm{\color{subsecnum}\etocnumber\hss}% -\color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill -\rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par -\nointerlineskip\vskip6pt} -{} + {\shiftedwhiterule{1.5cm}{6pt}} + {\sffamily\small + \leftskip1.5cm\hangindent1cm\rightskip1cm\noindent + \hbox to 1cm{\color{subsecnum}\etocnumber\hss}% + \color{black}\etocname\leaders\hbox to .2cm{\hss.}\hfill + \rlap{\hbox to 1cm{\hss\etocpage\hskip.2cm}}\par + \nointerlineskip\vskip6pt} + {} \newcommand{\coloredstuff}[2]{% \leftskip0pt\rightskip0pt\parskip0pt @@ -1950,15 +2211,14 @@ the frame. \vskip3pt}}% \par\nointerlineskip} -\etocsetstyle{section}{\coloredstuff{white} +\etocsetstyle{section} + {\coloredstuff{white} {\hfil \hyperref[toc:b]{\bfseries\large I am a twin of that other TOC (click me!)}\hfil}} -{\vskip3pt\sffamily\small} -{\coloredstuff{white}{\hbox to 1.5cm{\hss\etocnumber\hskip.2cm}% - \etocname\hfill -\hbox{\etocpage\hskip.2cm}}% - \vskip6pt} -{} + {\vskip3pt\sffamily\small} + {\coloredstuff{white}{\hbox to 1.5cm{\hss\etocnumber\hskip.2cm}% + \etocname\hfill\hbox{\etocpage\hskip.2cm}}\vskip6pt} + {} \etocframedstyle[1]{} \tableofcontents \label{toc:clone} \ref{toc:globalcmds} @@ -1967,7 +2227,8 @@ the frame. \endgroup -The coding is a bit involved as it does not use any additional +The coding is a bit involved\footnote{and reveals the author's +preference for the \TeX{} syntax...} as it does not use any additional package. A better solution would be to use some package to set up a background color possibly extending accross pages, as the framed style (which we used to get this background @@ -2041,9 +2302,7 @@ use or not colors is left to the user. that other TOC (click me!)}\hfil}} {\vskip3pt\sffamily\small} {\coloredstuff{white}{\hbox to 1.5cm{\hss\etocnumber\hskip.2cm}% - \etocname\hfill -\hbox{\etocpage\hskip.2cm}}% - \vskip6pt} + \etocname\hfill\hbox{\etocpage\hskip.2cm}}\vskip6pt} {} \etocframedstyle[1]{} @@ -2065,38 +2324,38 @@ package. Customizing them goes through suitable \cs{renewcommand}s: \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} - -\newcommand\etocsepminustwo{4ex plus .5ex minus .5ex} -\newcommand\etocsepminusone{4ex plus .5ex minus .5ex} -\newcommand\etocsepzero{2.5ex plus .4ex minus .4ex} -\newcommand\etocsepone{1.5ex plus .3ex minus .3ex} -\newcommand\etocseptwo{1ex plus .15ex minus .15ex} -\newcommand\etocsepthree{.25ex plus .05ex minus .05ex} - -\newcommand\etocminustwoleftmargin{1.5em plus 0.5fil} -\newcommand\etocminustworightmargin{1.5em plus -0.5fil} -\newcommand\etocminusoneleftmargin{1em} -\newcommand\etocminusonerightmargin{1em} - -\newcommand\etocbaselinespreadminustwo{1} -\newcommand\etocbaselinespreadminusone{1} -\newcommand\etocbaselinespreadzero{1} -\newcommand\etocbaselinespreadone{1} -\newcommand\etocbaselinespreadtwo{1} -\newcommand\etocbaselinespreadthree{.9} - -\newcommand\etoctoclineleaders +\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} + +\newcommand*\etocsepminustwo{4ex plus .5ex minus .5ex} +\newcommand*\etocsepminusone{4ex plus .5ex minus .5ex} +\newcommand*\etocsepzero{2.5ex plus .4ex minus .4ex} +\newcommand*\etocsepone{1.5ex plus .3ex minus .3ex} +\newcommand*\etocseptwo{1ex plus .15ex minus .15ex} +\newcommand*\etocsepthree{.25ex plus .05ex minus .05ex} + +\newcommand*\etocminustwoleftmargin{1.5em plus 0.5fil} +\newcommand*\etocminustworightmargin{1.5em plus -0.5fil} +\newcommand*\etocminusoneleftmargin{1em} +\newcommand*\etocminusonerightmargin{1em} + +\newcommand*\etocbaselinespreadminustwo{1} +\newcommand*\etocbaselinespreadminusone{1} +\newcommand*\etocbaselinespreadzero{1} +\newcommand*\etocbaselinespreadone{1} +\newcommand*\etocbaselinespreadtwo{1} +\newcommand*\etocbaselinespreadthree{.9} + +\newcommand*\etoctoclineleaders {\hbox{\normalfont\normalsize\hbox to 2ex {\hss.\hss}}} -\newcommand\etocabbrevpagename{p.~} -\newcommand\etocpartname{\partname} -\newcommand\etocbookname{Book} +\newcommand*\etocabbrevpagename{p.~} +\newcommand*\etocpartname{\partname} +\newcommand*\etocbookname{Book} \end{verbatim} No customizing of the standard line styles is possible from @@ -2117,11 +2376,12 @@ 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} (obviously) or even just one -\cs{etocsetstyle} command turns off the compatibility mode -(all of this obeys the scoping mecanism of \TeX/\LaTeX{} groups). +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. -\subsection{Customizing the global styles} +\subsection{Customizing the toc display styles} Again we list the relevant macros, what they do should be @@ -2131,31 +2391,31 @@ lengths, and that color commands are not just color specifications, they must include \cs{color}, and are canceled by re-defining them to do \cs{relax}. \begin{verbatim} -\newcommand\etocabovetocskip{3.5ex plus 1ex minus .2ex} -\newcommand\etocbelowtocskip{3.5ex plus 1ex minus .2ex} - -\newcommand\etoccolumnsep{2em} -\newcommand\etocmulticolsep{0ex} -\newcommand\etocmulticolpretolerance{-1} -\newcommand\etocmulticoltolerance{200} -\newcommand\etocdefaultnbcol{2} -\newcommand\etocinnertopsep{2ex} -\newcommand\etoctoprule{\hrule} -\newcommand\etoctoprulecolorcmd{\relax} +\newcommand*\etocabovetocskip{3.5ex plus 1ex minus .2ex} +\newcommand*\etocbelowtocskip{3.5ex plus 1ex minus .2ex} + +\newcommand*\etoccolumnsep{2em} +\newcommand*\etocmulticolsep{0ex} +\newcommand*\etocmulticolpretolerance{-1} +\newcommand*\etocmulticoltolerance{200} +\newcommand*\etocdefaultnbcol{2} +\newcommand*\etocinnertopsep{2ex} +\newcommand*\etoctoprule{\hrule} +\newcommand*\etoctoprulecolorcmd{\relax} % for the framed style only: -\newcommand\etocinnerleftsep{2em} -\newcommand\etocinnerrightsep{2em} -\newcommand\etocinnerbottomsep{3.5ex} +\newcommand*\etocinnerleftsep{2em} +\newcommand*\etocinnerrightsep{2em} +\newcommand*\etocinnerbottomsep{3.5ex} -\newcommand\etocleftrule{\vrule} -\newcommand\etocrightrule{\vrule} -\newcommand\etocbottomrule{\hrule} -\newcommand\etocleftrulecolorcmd{\relax} -\newcommand\etocrightrulecolorcmd{\relax} -\newcommand\etocbottomrulecolorcmd{\relax} +\newcommand*\etocleftrule{\vrule} +\newcommand*\etocrightrule{\vrule} +\newcommand*\etocbottomrule{\hrule} +\newcommand*\etocleftrulecolorcmd{\relax} +\newcommand*\etocrightrulecolorcmd{\relax} +\newcommand*\etocbottomrulecolorcmd{\relax} -\newcommand\etocbkgcolorcmd{\relax} +\newcommand*\etocbkgcolorcmd{\relax} % hooks \newcommand\etocframedmphook{\relax} @@ -2273,89 +2533,66 @@ label=,leftmargin=0pt]} |hyperref| aware and hopefully |hyperref| compatible! It doesn't matter whether \etoc or |hyperref| is loaded first. -It seems that package |hyperref| takes into account the current -value of the |tocdepth| counter to decide whether to create a -bookmark for the next sectioning unit. So it is recommended if -this value is modified for the needs of displaying a table of -contents to immediately reset it to the global document value, as -this will decide the depth of the bookmarks added in the PDF -output (\emph{e.g.} if one displays inside a section a table of contents with -|tocdepth| set to zero, the next section will not make it to the -bookmarks if |tocdepth| is not reset to at least one). Also, -recall that \LaTeX{} counters are global: a -change to |tocdepth| in a group or environment does modify its -(global) value. - -The macros \cs{etocname}, \cs{etocnumber}, and \cs{etocpage} -contain the |hyperref| links,\footnote{a future version of the -package will provide additionally macros without the -\texttt{hyperref} or \texttt{xspace} `decoration', as this can be -useful in certain circumstances.} if present (note that the -|linktoc=all| option of |hyperref| tells it to put a link also in -the page number corresponding to a given toc entry). The tables of -contents of the present document are fully linked. + + The contents of the |.toc| file (if it exists) are read into memory by \etoc once, at the time of \cs{usepackage\{etoc\}}. The |.toc| file will be opened for write operations only at -the time of the first TOC displaying command. \footnote{up to - version |v1.05| both things were done by \etoc at - \cs{begin\{document\}}.} \footnote{As soon as the |.toc| - file is opened for write, it becomes empty, so its contents - should be read by other packages or user defined macros - before the first TOC displaying command (this is the same - situation in the standard classes with the standard \toc - command.)} +the time of the first TOC displaying command. When a \localtoc is inserted by the user in the document, a line containing an \etoc inner command and an identification number is added to the |.toc| file. The correct local table of contents will be displayed only on the next |latex| run. -This is the only kind of data written by \etoc to the |.toc| -file, but of course it does mean that if you remove usage of -\etoc from the document, you should trash the |.toc| file. -The commands written by \etoc to the |.toc| file do nothing -when not used by \etoc itself, so other packages may -also read the |.toc| file and execute its -contents.\footnote{see previous footnote.} - -If the document class does not use the extension |.toc| for -the file where the TOC data is preserved, then \etoc will -fail. If the data written in the |.toc| file does not contain -the name, number and page numbers in \cs{contentsline} lines, -then \etoc will fail. If the typesetting of entries of type -\emph{kind} is not done by a macro with name \cs{l@kind}, then -\etoc will fail. - -The macros \cs{l@section}, \cs{l@subsection} . . ., more -generally \cs{l@kind} where \emph{kind} has been declared to -\etoc with \cs{etocsetlevel} may be customized throughout the -document and it is their current definitions which will be -used in compatibility mode.\footnote{in versions up to - |v1.05|, the default definitions of \cs{l@section} etc . . - . were re-established (to their values at the - \cs{begin\{document\}}, or at the latest \cs{etocsetlevel}) - only temporarily by \etoc at the time of displaying a TOC - in compatibility mode. This made it impossible to customize - them by trying to add for example some font changing prefix - to the pre-existing macro (but customization via commands - of packages like |tocloft| which re-define \cs{l@section} - to have customizing hooks did work as advertised). The new - implementation in |v1.06| changes the meaning of - \cs{l@section} and similar macros only at the time of - actually typesetting the tables of contents.} +% This is the only kind of data written by \etoc to the |.toc| +% file, but of course it does mean that if you remove usage of +% \etoc from the document, you should trash the |.toc| file. +% The commands written by \etoc to the |.toc| file do nothing +% when not used by \etoc itself, so other packages may +% also read the |.toc| file and execute its +% contents.\footnote{see previous footnote.} + +\etoc expects the document sectioning units to write their +data into the file having extension |.toc|, in the form of +lines containing the \cs{contentsline} command and its +arguments. The macros \cs{etocname}, \cs{etocnumber}, and +\cs{etocpage} contain the |hyperref| links, if present (note +that the \emph{linktoc=all} option of |hyperref| tells it to +put a link also in the page number corresponding to a given +toc entry). The tables of contents of the present document are +fully linked. + +It is possible to customize (using package |tocloft| for +example) throughout the document the macros \cs{l@section}, +\cs{l@subsection} ... and the effect will be seen in the next +table of contents typeset by \etoc in compatibility mode. \subsection{\TeX nical matters} The \cs{etocname}, \cs{etocnumber}, \cs{etocpage} and -\cs{etocifnumbered} macros are protected against premature -expansion. They end with an \cs{xspace}. The style customizing -commands (local and global) such as \cs{etocsetstyle}, -\cs{etocsetlevel}, \cs{etocsettocstyle}, -\cs{etocmulticolstyle}, \cs{etocruledstyle}, -\cs{etocframedstyle} do obey \LaTeX{}'s groups. All TOCs are -typeset inside groups. +\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 +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. + + +The commands such as \cs{etocsetstyle}, \cs{etocsetlevel}, +\cs{etocsettocstyle}, \cs{etocmulticolstyle}, +\cs{etocruledstyle}, \cs{etocframedstyle} obey \LaTeX{}'s +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 @@ -2367,13 +2604,6 @@ instructions should be done in such a way that they can be activated or deactivated easily from the document source, as need be. -\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. - Do not clone a clone but produce rather twins by cloning the same original local table of contents. @@ -2381,18 +2611,18 @@ 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.} +% 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.} \part{The code} @@ -2463,6 +2693,8 @@ release. % placeholder for comments % \begin{macrocode} \newtoks\Etoc@toctoks +\def\Etoc@par{\par} +\newcommand*{\etocnopar}{\def\Etoc@par{}} \newif\ifEtoc@jj % book \newif\ifEtoc@j % part \newif\ifEtoc@ % chapter @@ -2492,10 +2724,10 @@ release. \@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}} \def\Etoc@@minustwo@@{-\tw@} \let\Etoc@@minusone@@\m@ne -\chardef\Etoc@@zero@@\z@ -\chardef\Etoc@@one@@\@ne -\chardef\Etoc@@two@@\tw@ -\chardef\Etoc@@three@@\thr@@ +\chardef\Etoc@@zero@@ 0 +\let\Etoc@@one@@ \@ne +\let\Etoc@@two@@ \tw@ +\let\Etoc@@three@@ \thr@@ \chardef\Etoc@@four@@ 4 \chardef\Etoc@@five@@ 5 \chardef\Etoc@@six@@ 6 @@ -2508,6 +2740,7 @@ release. \def\Etoc@@three@{three} \def\Etoc@@four@{four} \def\Etoc@@five@{five} +%\def\Etoc@@six@{six} % \end{macrocode} % placeholder for comments % \begin{macrocode} @@ -2516,44 +2749,41 @@ release. \def\Etoc@levellist@elt{\noexpand\Etoc@levellist@elt\noexpand}% \edef\Etoc@levellist{\Etoc@levellist\Etoc@levellist@elt#1}} \def\etocsetlevel#1#2{% - \let\Etoc@next\@firstofone - \ifcase#2\or\or\or\or\or - \else\ifnum#2=\m@ne\else\ifnum#2=-\tw@\else - \PackageWarning{etoc} - {unexpected value `#2' in \string\etocsetlevel.^^J% - Should be -2,-1, 0, 1, 2, 3, 4 or 5. Set to -1}% - \expandafter\def\csname Etoc@#1@\endcsname{minusone}% - \expandafter\let\csname Etoc@#1@@\endcsname\m@ne - \let\Etoc@next\@gobble\fi\fi\fi \expandafter\Etoc@newlevel\csname l@#1\endcsname - \Etoc@next - {\ifcase#2\relax + \ifcase#2\relax \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@ - \expandafter\def \csname Etoc@#1@\endcsname{zero}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@one@@ - \expandafter\def \csname Etoc@#1@\endcsname{one}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@one@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@two@@ - \expandafter\def \csname Etoc@#1@\endcsname{two}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@two@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@three@@ - \expandafter\def \csname Etoc@#1@\endcsname{three}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@three@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@four@@ - \expandafter\def \csname Etoc@#1@\endcsname{four}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@four@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@ - \expandafter\def \csname Etoc@#1@\endcsname{five}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@five@ + \or + \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@ \else - \ifnum#2=\m@ne + \ifnum#2=\m@ne \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@ - \expandafter\def \csname Etoc@#1@\endcsname{minusone}% - \else + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@ + \else + \ifnum#2=-\tw@ \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minustwo@@ - \expandafter\def \csname Etoc@#1@\endcsname{minustwo}% - \fi - \fi}} + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minustwo@ + \else + \PackageWarning{etoc} + {unexpected value `#2' in \string\etocsetlevel.^^J% + Should be -2,-1, 0, 1, 2, 3, 4, 5, or 6. Set to 6 (=ignored)}% + \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@ +\fi\fi\fi} \etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} @@ -2565,27 +2795,6 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\AtBeginDocument{% -\@ifpackageloaded{hyperref} -{\Etoc@hyperreftrue -\def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}} -{\Etoc@hyperreffalse -\def\Etoc@et@hop#1#2#3#4{#1{#3}{#4}#2}}} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} - \def\Etoc@swa#1{% - \Etoc@et@hop - {\Etoc@savedcontentsline{#1}} - {\Etoc@prefix\Etoc@contents}} - \def\Etoc@swb#1{% - \Etoc@et@hop - {\Etoc@savedcontentsline{#1}} - {\Etoc@contents}} -\let\etocskipfirstprefix\@thirdofthree -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} \def\Etoc@setflags #1{% \ifcase #1\relax \global\Etoc@vfalse @@ -2637,6 +2846,23 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} +\AtBeginDocument{% +\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue + \def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}} + {\Etoc@hyperreffalse + \def\Etoc@et@hop#1#2#3#4{#1{#3}{#4}#2}}} + \def\Etoc@swa#1{% + \Etoc@et@hop + {\Etoc@savedcontentsline{#1}} + {\Etoc@prefix\Etoc@contents}} + \def\Etoc@swb#1{% + \Etoc@et@hop + {\Etoc@savedcontentsline{#1}} + {\Etoc@contents}} +\let\etocskipfirstprefix\@thirdofthree +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} \def\Etoc@etoccontentsline#1{% \global\expandafter\let\expandafter\Etoc@tmp\csname Etoc@#1@@\endcsname \Etoc@skipthisonefalse @@ -2645,20 +2871,24 @@ release. \else \def\Etoc@next{\expandafter\@gobble\@gobblefour}% \fi - \ifEtoc@localtoc - \let\Etoc@prenext\relax - \ifEtoc@stoptoc - \Etoc@skipthisonetrue - \fi - \ifnum\Etoc@tmp<\Etoc@localtop + \ifnum\Etoc@tmp=\Etoc@@six@@ + \Etoc@skipthisonetrue + \else + \ifEtoc@localtoc + \let\Etoc@prenext\relax + \ifEtoc@stoptoc + \Etoc@skipthisonetrue + \fi + \ifnum\Etoc@tmp<\Etoc@localtop \def\Etoc@prenext{\global\Etoc@stoptoctrue}% \Etoc@skipthisonetrue - \fi - \ifEtoc@notactive + \fi + \ifEtoc@notactive \def\Etoc@prenext{\Etoc@setflags{\Etoc@tmp}}% \Etoc@skipthisonetrue - \fi - \Etoc@prenext + \fi + \Etoc@prenext + \fi \fi \ifnum\c@tocdepth<\Etoc@tmp\relax\else \ifEtoc@skipthisone\else @@ -2726,89 +2956,136 @@ release. \def\Etoc@prefix{\Etoc@prefix@minustwo}% \fi \fi - \ifnum\Etoc@tmp=\m@ne\Etoc@parttrue\else\Etoc@partfalse\fi - \Etoc@setflags{\Etoc@tmp}% + \ifnum\Etoc@tmp=\m@ne\Etoc@parttrue\else\Etoc@partfalse\fi + \Etoc@setflags{\Etoc@tmp}% \fi\fi \Etoc@next \@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\Etoc@lxyz #1#2{\@namedef{etocname }{\leavevmode #1\xspace}% - \@namedef{etocpage }{\leavevmode #2\xspace}% +\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\ifEtoc@part - \Etoc@getit #1\hspace\relax\etoc@\fi\fi} + \ifEtoc@number\else + \ifEtoc@part + \Etoc@getit #1\hspace\relax\etoc@ + \fi + \fi} % \end{macrocode} % placeholder for comments % \begin{macrocode} \def\Etoc@getnb #1{\let\Etoc@next\Etoc@getnb@nohyp -\ifEtoc@hyperref\ifx #1\hyper@linkstart - \let\Etoc@next\Etoc@getnb@hyp\fi\fi\Etoc@next #1} + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getnb@hyp + \fi\fi + \Etoc@next #1} +% \def\Etoc@getit #1{\let\Etoc@next\Etoc@getit@nohyp -\ifEtoc@hyperref\ifx #1\hyper@linkstart - \let\Etoc@next\Etoc@getit@hyp\fi\fi\Etoc@next #1} + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getit@hyp + \fi\fi + \Etoc@next #1} +% +\def\Etoc@getthepage #1{\let\Etoc@next\Etoc@getthepage@nohyp + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getthepage@hyp + \fi\fi + \Etoc@next #1} +\def\Etoc@getthepage@nohyp #1\etoc@{\def\etocthepage{#1}} +\def\Etoc@getthepage@hyp #1#2#3#4#5\etoc@{% + \@namedef{etoclink }##1{#1{#2}{#3}{##1}#5}% + \def\etocthepage{#4}} % \end{macrocode} % placeholder for comments % \begin{macrocode} +% \def\Etoc@getnb@nohyp #1#2#3\etoc@{% -\ifx #1\numberline -\@namedef{etocnumber }{\leavevmode #2\xspace}\Etoc@numbertrue -\else -\@namedef{etocnumber }{\leavevmode\xspace}\Etoc@numberfalse -\fi} + \def\Etoc@getname ##1\relax\relax\etoc@{% + \@namedef{etocname }{\leavevmode ##1\xspace}% + \def\etocthename{##1}% + }% + \ifx #1\numberline + \@namedef{etocnumber }{\leavevmode #2\xspace}% + \def\etocthenumber{#2}% + \Etoc@numbertrue + \Etoc@getname #3\etoc@ + \else + \@namedef{etocnumber }{\leavevmode\xspace}% + \def\etocthenumber{}% + \Etoc@numberfalse + \fi +} % \end{macrocode} % placeholder for comments % \begin{macrocode} \def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@{% - \def\Etoc@getnbr ##1##2##3\etoc@{% - \ifx ##1\numberline - \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}% - \Etoc@numbertrue - \else - \@namedef{etocnumber }{\leavevmode\xspace}% - \Etoc@numberfalse - \fi}% - \Etoc@getnbr #4\relax\relax\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}% + \def\etocthename{##1}% + }% + \def\Etoc@getnbr ##1##2##3\etoc@{% + \ifx ##1\numberline + \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}% + \def\etocthenumber{##2}% + \Etoc@numbertrue + \Etoc@getname ##3\etoc@ + \else + \@namedef{etocnumber }{\leavevmode\xspace}% + \def\etocthenumber{}% + \Etoc@numberfalse + \def\etocthename{#4}% + \fi}% + \Etoc@getnbr #4\relax\relax\etoc@ +} % \end{macrocode} % placeholder for comments % \begin{macrocode} \def\Etoc@getit@nohyp #1\hspace#2#3\etoc@{% \def\Etoc@getname ##1\hspace\relax\etoc@{% - \@namedef{etocname }{\leavevmode ##1\xspace}}% - \ifx \relax#2\else + \@namedef{etocname }{\leavevmode ##1\xspace}% + \def\etocthename{##1}% + }% + \ifx\relax#2\else \@namedef{etocnumber }{\leavevmode #1\xspace}% + \def\etocthenumber{#1}% \Etoc@numbertrue - \Etoc@getname #3\etoc@\fi} + \Etoc@getname #3\etoc@ + \fi +} % \end{macrocode} % placeholder for comments % \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\xspace}% + \def\etocthename{##1}% + }% \def\Etoc@getnbr ##1\hspace##2##3\etoc@{% - \ifx\relax##2\else - \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% - \Etoc@numbertrue - \Etoc@getname ##3\etoc@\fi}% + \ifx\relax##2\else + \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% + \def\etocthenumber{##1}% + \Etoc@numbertrue + \Etoc@getname ##3\etoc@ + \fi}% \Etoc@getnbr #4\hspace\relax\etoc@} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\edef\etocpage{\noexpand\protect\expandafter\noexpand - \csname etocpage \endcsname} -\edef\etocname{\noexpand\protect\expandafter\noexpand - \csname etocname \endcsname} -\edef\etocnumber{\noexpand\protect\expandafter\noexpand - \csname etocnumber \endcsname} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} +\edef\etocpage{\noexpand\protect\expandafter + \noexpand\csname etocpage \endcsname} +\edef\etocname{\noexpand\protect\expandafter + \noexpand\csname etocname \endcsname} +\edef\etocnumber{\noexpand\protect\expandafter + \noexpand\csname etocnumber \endcsname} +\edef\etoclink{\noexpand\protect\expandafter + \noexpand\csname etoclink \endcsname} \@namedef{etocifnumbered }{\ifEtoc@number -\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} + \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} \edef\etocifnumbered{\noexpand\protect\expandafter\noexpand \csname etocifnumbered \endcsname} % \end{macrocode} @@ -2862,21 +3139,20 @@ release. \global\Etoc@jfalse \global\Etoc@jjfalse \ifEtoc@standard -\etoc@setstyle{@minustwo}{}{}{}{}% -\etoc@setstyle{@minusone}{}{}{}{}% -\etoc@setstyle{@zero}{}{}{}{}% -\etoc@setstyle{@one}{}{}{}{}% -\etoc@setstyle{@two}{}{}{}{}% -\etoc@setstyle{@three}{}{}{}{}% -\etoc@setstyle{@four}{}{}{}{}% -\etoc@setstyle{@five}{}{}{}{}% + \etoc@setstyle{@minustwo}{}{}{}{}% + \etoc@setstyle{@minusone}{}{}{}{}% + \etoc@setstyle{@zero}{}{}{}{}% + \etoc@setstyle{@one}{}{}{}{}% + \etoc@setstyle{@two}{}{}{}{}% + \etoc@setstyle{@three}{}{}{}{}% + \etoc@setstyle{@four}{}{}{}{}% + \etoc@setstyle{@five}{}{}{}{}% \else -\def\Etoc@levellist@elt##1{\let##1\Etoc@lxyz}% -\Etoc@levellist -\let\numberline\@gobble -\let\booknumberline\numberline -\let\partnumberline\numberline -\let\chapternumberline\numberline + \def\Etoc@levellist@elt##1{\let##1\Etoc@lxyz}% + \Etoc@levellist + \let\booknumberline\numberline + \let\partnumberline\numberline + \let\chapternumberline\numberline \fi \the\Etoc@toctoks \ifEtoc@notactive\else @@ -2921,7 +3197,7 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\long\def\Etoc@localtableofcontents#1{% +\def\Etoc@localtableofcontents#1{% \edef\Etoc@tmp{#1}% \ifnum\Etoc@tmp<\@ne \PackageWarning{etoc} @@ -2972,11 +3248,11 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\table@fcontents{\par +\def\table@fcontents{% \refstepcounter{etoc@tocid}% \Etoc@tocwithidfalse \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\def\localtable@fcontents{\par +\def\localtable@fcontents{% \refstepcounter{etoc@tocid}% \addtocontents{toc} {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% @@ -2985,47 +3261,48 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocaftertitlehook{} -\def\tableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi +\newcommand*\etocaftertitlehook{} +\newcommand*\etocaftercontentshook{} +\renewcommand*\tableofcontents{% + \ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi \global\Etoc@tocopenedforwritetrue - \begingroup + \Etoc@par\begingroup \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}% \@ifstar - {\let\Etoc@aftertitlehook\relax\table@fcontents} + {\def\Etoc@aftertitlehook{}\table@fcontents} {\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}} -\def\localtableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi +\newcommand*\localtableofcontents{% + \ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi \global\Etoc@tocopenedforwritetrue - \begingroup\@ifstar - {\let\Etoc@aftertitlehook\relax\localtable@fcontents} + \Etoc@par\begingroup\@ifstar + {\def\Etoc@aftertitlehook{}\localtable@fcontents} {\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}} % \end{macrocode} % placeholder for comments % \begin{macrocode} \newcommand\etocsettocstyle[2]{% -\long\def\Etoc@tableofcontents +\def\Etoc@tableofcontents {\ifnum\c@tocdepth>\Etoc@minf\let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble\fi \Etoc@@next{#1\Etoc@aftertitlehook \let\Etoc@savedcontentsline\contentsline \let\contentsline\Etoc@etoccontentsline - \Etoc@toctoc\let\Etoc@n@xt\relax - \ifEtoc@tocwithid\else - \ifEtoc@localtoc - \ifEtoc@notactive - \def\Etoc@n@xt{\Etoc@localtocfalse + \Etoc@toctoc + \let\Etoc@n@xt\relax + \ifEtoc@tocwithid\else + \ifEtoc@localtoc + \ifEtoc@notactive + \def\Etoc@n@xt{\Etoc@localtocfalse \global\Etoc@notactivefalse \Etoc@toctoc}% - \fi\fi\fi\Etoc@n@xt + \fi\fi\fi + \Etoc@n@xt + \etocaftercontentshook #2}}} -\newcommand\etocextendtocstyle[2]{% -\toks0=\expandafter{\Etoc@tableofcontents #2}% -\toks2={#1}% -\long\edef\Etoc@tableofcontents{\the\toks2 \the\toks0}} -% % je me fais avoir ^ à chaque fois! % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} +\newcommand*\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} \long\def\etoc@setstyle#1#2#3#4#5{% \long\expandafter\def \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname {#2}% @@ -3038,42 +3315,42 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\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} +\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{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocsepminustwo{4ex \@plus .5ex \@minus .5ex} -\newcommand\etocsepminusone{4ex \@plus .5ex \@minus .5ex} -\newcommand\etocsepzero{2.5ex \@plus .4ex \@minus .4ex} -\newcommand\etocsepone{1.5ex \@plus .3ex \@minus .3ex} -\newcommand\etocseptwo{1ex \@plus .15ex \@minus .15ex} -\newcommand\etocsepthree{.25ex \@plus .05ex \@minus .05ex} +\newcommand*\etocsepminustwo{4ex \@plus .5ex \@minus .5ex} +\newcommand*\etocsepminusone{4ex \@plus .5ex \@minus .5ex} +\newcommand*\etocsepzero{2.5ex \@plus .4ex \@minus .4ex} +\newcommand*\etocsepone{1.5ex \@plus .3ex \@minus .3ex} +\newcommand*\etocseptwo{1ex \@plus .15ex \@minus .15ex} +\newcommand*\etocsepthree{.25ex \@plus .05ex \@minus .05ex} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocbaselinespreadminustwo{1} -\newcommand\etocbaselinespreadminusone{1} -\newcommand\etocbaselinespreadzero{1} -\newcommand\etocbaselinespreadone{1} -\newcommand\etocbaselinespreadtwo{1} -\newcommand\etocbaselinespreadthree{.9} +\newcommand*\etocbaselinespreadminustwo{1} +\newcommand*\etocbaselinespreadminusone{1} +\newcommand*\etocbaselinespreadzero{1} +\newcommand*\etocbaselinespreadone{1} +\newcommand*\etocbaselinespreadtwo{1} +\newcommand*\etocbaselinespreadthree{.9} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocminustwoleftmargin{1.5em plus 0.5fil} -\newcommand\etocminustworightmargin{1.5em plus -0.5fil} -\newcommand\etocminusoneleftmargin{1em} -\newcommand\etocminusonerightmargin{1em} -\newcommand\etoctoclineleaders +\newcommand*\etocminustwoleftmargin{1.5em plus 0.5fil} +\newcommand*\etocminustworightmargin{1.5em plus -0.5fil} +\newcommand*\etocminusoneleftmargin{1em} +\newcommand*\etocminusonerightmargin{1em} +\newcommand*\etoctoclineleaders {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}} -\newcommand\etocabbrevpagename{p.~} -\newcommand\etocpartname{\partname} -\newcommand\etocbookname{Book} +\newcommand*\etocabbrevpagename{p.~} +\newcommand*\etocpartname{\partname} +\newcommand*\etocbookname{Book} % \end{macrocode} % placeholder for comments % \begin{macrocode} @@ -3198,27 +3475,26 @@ release. % placeholder for comments % \begin{macrocode} \etoc@setstyle{@four}{}{}{}{}% -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} \etoc@setstyle{@five}{}{}{}{}% } % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand\etoccolumnsep{2em} -\newcommand\etocmulticolsep{0ex} -\newcommand\etocmulticolpretolerance{-1} -\newcommand\etocmulticoltolerance{200} -\newcommand\etocdefaultnbcol{2} +\newcommand*\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} +\newcommand*\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} +\newcommand*\etoccolumnsep{2em} +\newcommand*\etocmulticolsep{0ex} +\newcommand*\etocmulticolpretolerance{-1} +\newcommand*\etocmulticoltolerance{200} +\newcommand*\etocdefaultnbcol{2} +\newcommand*\etocinnertopsep{2ex} % \end{macrocode} % placeholder for comments % \begin{macrocode} \newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle - {\addvspace{\etocabovetocskip}% + {\let\etocoldpar\par + \addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo \else \let\Etoc@next\@secondoftwo\fi \Etoc@next{% @@ -3226,8 +3502,10 @@ release. \multicoltolerance\etocmulticoltolerance \setlength{\columnsep}{\etoccolumnsep}% \setlength{\multicolsep}{\etocmulticolsep}% - \begin{multicols}{#1}[#2\addvspace{\etocsepminusone}]} - {#2\addvspace{\etocsepminusone}% + \begin{multicols}{#1}[#2\etocoldpar\addvspace{\etocinnertopsep}]} +% 2013/01/29: erroneous \etocsepminusone at last replaced by \etocinnertopsep +% and definition of \etocoldpar added as multicols chokes on \par as part of #2 + {#2\par\addvspace{\etocinnertopsep}% \pretolerance\etocmulticolpretolerance \tolerance\etocmulticoltolerance}} {\ifnum #1>\@ne\let\Etoc@next\@firstofone @@ -3237,32 +3515,31 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocinnertopsep{2ex} -\newcommand\etocinnerbottomsep{3.5ex} -\newcommand\etocinnerleftsep{2em} -\newcommand\etocinnerrightsep{2em} -\newcommand\etoctoprule{\hrule} -\newcommand\etocleftrule{\vrule} -\newcommand\etocrightrule{\vrule} -\newcommand\etocbottomrule{\hrule} -\newcommand\etoctoprulecolorcmd{\relax} -\newcommand\etocbottomrulecolorcmd{\relax} -\newcommand\etocleftrulecolorcmd{\relax} -\newcommand\etocrightrulecolorcmd{\relax} +\newcommand*\etocinnerbottomsep{3.5ex} +\newcommand*\etocinnerleftsep{2em} +\newcommand*\etocinnerrightsep{2em} +\newcommand*\etoctoprule{\hrule} +\newcommand*\etocleftrule{\vrule} +\newcommand*\etocrightrule{\vrule} +\newcommand*\etocbottomrule{\hrule} +\newcommand*\etoctoprulecolorcmd{\relax} +\newcommand*\etocbottomrulecolorcmd{\relax} +\newcommand*\etocleftrulecolorcmd{\relax} +\newcommand*\etocrightrulecolorcmd{\relax} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etoc@ruledheading[1]{% +\def\etoc@ruledheading #1{% \hb@xt@\linewidth{\color@begingroup \hss #1\hss\hskip-\linewidth \etoctoprulecolorcmd\leaders\etoctoprule\hss \phantom{#1}% \leaders\etoctoprule\hss\color@endgroup}% - \nointerlineskip\vskip\etocinnertopsep} + \nointerlineskip\vskip\etocinnertopsep} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocruledstyle[2][\etocdefaultnbcol]{% +\newcommand*\etocruledstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -3284,11 +3561,11 @@ release. % placeholder for comments % \begin{macrocode} \newcommand\etocframedmphook{\relax} -\newcommand\etocbkgcolorcmd{\relax} -\newcommand\Etoc@relax{\relax} +\newcommand*\etocbkgcolorcmd{\relax} +\def\Etoc@relax{\relax} \newbox\etoc@framed@titlebox \newbox\etoc@framed@contentsbox -\newcommand\etocframedstyle[2][\etocdefaultnbcol]{% +\newcommand*\etocframedstyle[2][\etocdefaultnbcol]{% \etocsettocstyle{% \addvspace{\etocabovetocskip}% \sbox\z@{#2}% @@ -3370,76 +3647,76 @@ release. % placeholder for comments % \begin{macrocode} \newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\tableofcontents} + \etocmulticolstyle[#1]{#2}% + \tableofcontents} \newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\tableofcontents*} + \etocmulticolstyle[#1]{#2}% + \tableofcontents*} \newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\localtableofcontents} + \etocmulticolstyle[#1]{#2}% + \localtableofcontents} \newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\localtableofcontents*} + \etocmulticolstyle[#1]{#2}% + \localtableofcontents*} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etoc@ruledtoc[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\tableofcontents} -\newcommand\etoc@ruledtoci[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\tableofcontents*} -\newcommand\etoc@local@ruledtoc[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\localtableofcontents} -\newcommand\etoc@local@ruledtoci[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\localtableofcontents*} +\newcommand*\etoc@ruledtoc[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \tableofcontents} +\newcommand*\etoc@ruledtoci[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \tableofcontents*} +\newcommand*\etoc@local@ruledtoc[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \localtableofcontents} +\newcommand*\etoc@local@ruledtoci[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \localtableofcontents*} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etoc@framedtoc[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\tableofcontents} -\newcommand\etoc@framedtoci[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\tableofcontents*} -\newcommand\etoc@local@framedtoc[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\localtableofcontents} -\newcommand\etoc@local@framedtoci[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\localtableofcontents*} +\newcommand*\etoc@framedtoc[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \tableofcontents} +\newcommand*\etoc@framedtoci[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \tableofcontents*} +\newcommand*\etoc@local@framedtoc[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \localtableofcontents} +\newcommand*\etoc@local@framedtoci[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \localtableofcontents*} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocmulticol{\begingroup +\def\etocmulticol{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@multicoltoci} {\etoc@multicoltoc}} -\newcommand\etocruled{\begingroup +\def\etocruled{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@ruledtoci} {\etoc@ruledtoc}} -\newcommand\etocframed{\begingroup +\def\etocframed{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@framedtoci} {\etoc@framedtoc}} -\newcommand\etoclocalmulticol{\begingroup +\def\etoclocalmulticol{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@multicoltoci} {\etoc@local@multicoltoc}} -\newcommand\etoclocalruled{\begingroup +\def\etoclocalruled{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@ruledtoci} {\etoc@local@ruledtoc}} -\newcommand\etoclocalframed{\begingroup +\def\etoclocalframed{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@framedtoci} @@ -3447,53 +3724,39 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocarticlestyle{% +\def\etocarticlestyle{% \etocsettocstyle {\section *{\contentsname \@mkboth {\MakeUppercase \contentsname} {\MakeUppercase \contentsname}}} {}} -\newcommand\etocarticlestylenomarks{% +\def\etocarticlestylenomarks{% \etocsettocstyle {\section *{\contentsname}} {}} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocbookstyle{% +\def\etocbookstyle{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi \chapter *{\contentsname \@mkboth {\MakeUppercase \contentsname} {\MakeUppercase \contentsname}}} {\if@restonecol \twocolumn \fi}} -\newcommand\etocbookstylenomarks{% +\def\etocbookstylenomarks{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi \chapter *{\contentsname}} {\if@restonecol \twocolumn \fi}} \let\etocreportstyle\etocbookstyle \let\etocreportstylenomarks\etocbookstylenomarks -% \end{macrocode} -% placeholder for comments. December 1, 11:33 Very weird -% problem with the two successive \cs{addtocontents} (one for -% \cs{etoc@startlocaltoc} and the next one here for the memoir -% class and unstarred \cs{tableofcontents}). They are not put -% in the correct order into the aux file hence into the toc -% file. It is very weird that if the aux file already exists -% due to a previous latex run where the user had put * after -% the TOC displaying command, the things end up in the correct -% order in the new aux file, hence things work correctly. -% Anyway, \cs{etocaftertitlehook} is defined here in a strange -% way which empirically seems to solve the problem. v1.05a -% \begin{macrocode} -\newcommand\Etoc@addcontentsline{} -\newcommand\etocmemoirtoctotocfmt[2]{% - \renewcommand\Etoc@addcontentsline{\addcontentsline {toc}{#1}{#2}}% - \renewcommand\etocaftertitlehook{% +\def\etocmemoirtoctotocfmt #1#2{% + \def\Etoc@addsuitablecontentsline{\addcontentsline {toc}{#1}{#2}}% + \renewcommand*\etocaftertitlehook{% \ifmem@em@starred@listof - \else\phantomsection\aftergroup\Etoc@addcontentsline\fi}} -\newcommand\etocmemoirstyle{% + \else\phantomsection\aftergroup\Etoc@addsuitablecontentsline\fi}} +\def\etocmemoirstyle{% \etocsettocstyle {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle} \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax @@ -3502,7 +3765,7 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocscrartclstyle{% +\def\etocscrartclstyle{% \etocsettocstyle {\let\if@dynlist\if@tocleft \iftocfeature {toc}{onecolumn} @@ -3533,11 +3796,10 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocnakedtocdisplaystyle{\etocsettocstyle{}{}} -\newcommand\etocstandarddisplaystyle{\etocarticlestyle} -\newcommand\etocmarkboth[1]{% +\newcommand*\etocstandarddisplaystyle{\etocarticlestyle} +\newcommand*\etocmarkboth[1]{% \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} -\newcommand\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} +\newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} \newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]% {\csname #1\endcsname *{#3}}} \newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]% @@ -3557,35 +3819,52 @@ release. \renewcommand\etoctocstyle[3][#1]{% \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}} \@ifclassloaded{scrartcl} - {\renewcommand\etocstandarddisplaystyle{\etocscrartclstyle}}{} + {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{} \@ifclassloaded{book} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocbookstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocbookstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{report} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocreportstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocreportstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{scrbook} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocscrbookstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocscrbookstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{scrreprt} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocscrreprtstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{memoir} - {\renewcommand\etocfontone{\normalfont\normalsize} + {\renewcommand*\etocfontone{\normalfont\normalsize} \etocmemoirtoctotocfmt{chapter}{\contentsname}% - \renewcommand\etocstandarddisplaystyle{\etocmemoirstyle} + \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle} \Etoc@redefetocstyle{chapter}}{} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocstandardlines{\Etoc@standardtrue} +\newcommand*\etocstandardlines{\Etoc@standardtrue} +% +\def\Etoc@addtocontents #1#2% + {\ifEtoc@hyperref + \addtocontents {toc}{\protect\contentsline + {#1}{#2}% + {\thepage }{\@currentHref }}% + \else + \addtocontents {toc}{\protect\contentsline + {#1}{#2}{\thepage }}% + \fi} +\def\Etoc@addcontentsline@ #1#2#3% + {\@namedef{toclevel@#1}{#3}% + \addcontentsline {toc}{#1}{#2}} +\DeclareRobustCommand*{\etoctoccontentsline} + {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}} +% \etoctoclines +\AtBeginDocument{ \etocstandardlines -\etocstandarddisplaystyle +\etocstandarddisplaystyle} \endinput % \end{macrocode} % \MakePercentComment @@ -3605,7 +3884,7 @@ release. Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum{2484} +\CheckSum{2580} \Finale %% diff --git a/Master/texmf-dist/source/latex/etoc/etoc.ins b/Master/texmf-dist/source/latex/etoc/etoc.ins index a414f5c64b3..ab5f5642dd7 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.ins +++ b/Master/texmf-dist/source/latex/etoc/etoc.ins @@ -1,10 +1,10 @@ \def\pkgname{etoc} -\def\pkgdate{2012/12/07} -\def\pkgversion{v1.06} +\def\pkgdate{2013/01/29} +\def\pkgversion{v1.07} \def\pkgdescription{easily customizable TOCs (jfB)} %% %% Package `etoc' by Jean-Francois Burnol -%% Copyright (C) 2012 by Jean-Francois Burnol +%% Copyright (C) 2012, 2013 by Jean-Francois Burnol %% %% This file `etoc.ins' is provided for compatibility with TeX distributions %% expecting to find it for installation of `etoc.sty'. diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index 837487b6d2f..b17bd0c9730 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -22,10 +22,10 @@ %% in the same archive or directory.) %% \ProvidesPackage{etoc} - [2012/12/07 v1.06 easily customizable TOCs (jfB)] + [2013/01/29 v1.07 easily customizable TOCs (jfB)] %% %% Package `etoc' by Jean-Francois Burnol -%% Copyright (C) 2012 by Jean-Francois Burnol +%% Copyright (C) 2012, 2013 by Jean-Francois Burnol %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{multicol} @@ -33,6 +33,8 @@ \DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} \ProcessOptions\relax \newtoks\Etoc@toctoks +\def\Etoc@par{\par} +\newcommand*{\etocnopar}{\def\Etoc@par{}} \newif\ifEtoc@jj % book \newif\ifEtoc@j % part \newif\ifEtoc@ % chapter @@ -56,10 +58,10 @@ \@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}} \def\Etoc@@minustwo@@{-\tw@} \let\Etoc@@minusone@@\m@ne -\chardef\Etoc@@zero@@\z@ -\chardef\Etoc@@one@@\@ne -\chardef\Etoc@@two@@\tw@ -\chardef\Etoc@@three@@\thr@@ +\chardef\Etoc@@zero@@ 0 +\let\Etoc@@one@@ \@ne +\let\Etoc@@two@@ \tw@ +\let\Etoc@@three@@ \thr@@ \chardef\Etoc@@four@@ 4 \chardef\Etoc@@five@@ 5 \chardef\Etoc@@six@@ 6 @@ -77,44 +79,41 @@ \def\Etoc@levellist@elt{\noexpand\Etoc@levellist@elt\noexpand}% \edef\Etoc@levellist{\Etoc@levellist\Etoc@levellist@elt#1}} \def\etocsetlevel#1#2{% - \let\Etoc@next\@firstofone - \ifcase#2\or\or\or\or\or - \else\ifnum#2=\m@ne\else\ifnum#2=-\tw@\else - \PackageWarning{etoc} - {unexpected value `#2' in \string\etocsetlevel.^^J% - Should be -2,-1, 0, 1, 2, 3, 4 or 5. Set to -1}% - \expandafter\def\csname Etoc@#1@\endcsname{minusone}% - \expandafter\let\csname Etoc@#1@@\endcsname\m@ne - \let\Etoc@next\@gobble\fi\fi\fi \expandafter\Etoc@newlevel\csname l@#1\endcsname - \Etoc@next - {\ifcase#2\relax + \ifcase#2\relax \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@ - \expandafter\def \csname Etoc@#1@\endcsname{zero}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@zero@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@one@@ - \expandafter\def \csname Etoc@#1@\endcsname{one}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@one@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@two@@ - \expandafter\def \csname Etoc@#1@\endcsname{two}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@two@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@three@@ - \expandafter\def \csname Etoc@#1@\endcsname{three}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@three@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@four@@ - \expandafter\def \csname Etoc@#1@\endcsname{four}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@four@ \or \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@ - \expandafter\def \csname Etoc@#1@\endcsname{five}% + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@five@ + \or + \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@six@@ \else - \ifnum#2=\m@ne + \ifnum#2=\m@ne \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minusone@@ - \expandafter\def \csname Etoc@#1@\endcsname{minusone}% - \else + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minusone@ + \else + \ifnum#2=-\tw@ \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minustwo@@ - \expandafter\def \csname Etoc@#1@\endcsname{minustwo}% - \fi - \fi}} + \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minustwo@ + \else + \PackageWarning{etoc} + {unexpected value `#2' in \string\etocsetlevel.^^J% + Should be -2,-1, 0, 1, 2, 3, 4, 5, or 6. Set to 6 (=ignored)}% + \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@ +\fi\fi\fi} \etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} @@ -123,21 +122,6 @@ \etocsetlevel{subsubsection}{3} \etocsetlevel{paragraph}{4} \etocsetlevel{subparagraph}{5} -\AtBeginDocument{% -\@ifpackageloaded{hyperref} -{\Etoc@hyperreftrue -\def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}} -{\Etoc@hyperreffalse -\def\Etoc@et@hop#1#2#3#4{#1{#3}{#4}#2}}} - \def\Etoc@swa#1{% - \Etoc@et@hop - {\Etoc@savedcontentsline{#1}} - {\Etoc@prefix\Etoc@contents}} - \def\Etoc@swb#1{% - \Etoc@et@hop - {\Etoc@savedcontentsline{#1}} - {\Etoc@contents}} -\let\etocskipfirstprefix\@thirdofthree \def\Etoc@setflags #1{% \ifcase #1\relax \global\Etoc@vfalse @@ -186,6 +170,20 @@ \global\Etoc@jjtrue \fi \fi} +\AtBeginDocument{% +\@ifpackageloaded{hyperref}{\Etoc@hyperreftrue + \def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}} + {\Etoc@hyperreffalse + \def\Etoc@et@hop#1#2#3#4{#1{#3}{#4}#2}}} + \def\Etoc@swa#1{% + \Etoc@et@hop + {\Etoc@savedcontentsline{#1}} + {\Etoc@prefix\Etoc@contents}} + \def\Etoc@swb#1{% + \Etoc@et@hop + {\Etoc@savedcontentsline{#1}} + {\Etoc@contents}} +\let\etocskipfirstprefix\@thirdofthree \def\Etoc@etoccontentsline#1{% \global\expandafter\let\expandafter\Etoc@tmp\csname Etoc@#1@@\endcsname \Etoc@skipthisonefalse @@ -194,20 +192,24 @@ \else \def\Etoc@next{\expandafter\@gobble\@gobblefour}% \fi - \ifEtoc@localtoc - \let\Etoc@prenext\relax - \ifEtoc@stoptoc + \ifnum\Etoc@tmp=\Etoc@@six@@ + \Etoc@skipthisonetrue + \else + \ifEtoc@localtoc + \let\Etoc@prenext\relax + \ifEtoc@stoptoc \Etoc@skipthisonetrue - \fi - \ifnum\Etoc@tmp<\Etoc@localtop + \fi + \ifnum\Etoc@tmp<\Etoc@localtop \def\Etoc@prenext{\global\Etoc@stoptoctrue}% \Etoc@skipthisonetrue - \fi - \ifEtoc@notactive + \fi + \ifEtoc@notactive \def\Etoc@prenext{\Etoc@setflags{\Etoc@tmp}}% \Etoc@skipthisonetrue - \fi - \Etoc@prenext + \fi + \Etoc@prenext + \fi \fi \ifnum\c@tocdepth<\Etoc@tmp\relax\else \ifEtoc@skipthisone\else @@ -275,62 +277,112 @@ \def\Etoc@prefix{\Etoc@prefix@minustwo}% \fi \fi - \ifnum\Etoc@tmp=\m@ne\Etoc@parttrue\else\Etoc@partfalse\fi - \Etoc@setflags{\Etoc@tmp}% + \ifnum\Etoc@tmp=\m@ne\Etoc@parttrue\else\Etoc@partfalse\fi + \Etoc@setflags{\Etoc@tmp}% \fi\fi \Etoc@next \@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}} -\def\Etoc@lxyz #1#2{\@namedef{etocname }{\leavevmode #1\xspace}% - \@namedef{etocpage }{\leavevmode #2\xspace}% +\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\ifEtoc@part - \Etoc@getit #1\hspace\relax\etoc@\fi\fi} + \ifEtoc@number\else + \ifEtoc@part + \Etoc@getit #1\hspace\relax\etoc@ + \fi + \fi} \def\Etoc@getnb #1{\let\Etoc@next\Etoc@getnb@nohyp -\ifEtoc@hyperref\ifx #1\hyper@linkstart - \let\Etoc@next\Etoc@getnb@hyp\fi\fi\Etoc@next #1} + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getnb@hyp + \fi\fi + \Etoc@next #1} \def\Etoc@getit #1{\let\Etoc@next\Etoc@getit@nohyp -\ifEtoc@hyperref\ifx #1\hyper@linkstart - \let\Etoc@next\Etoc@getit@hyp\fi\fi\Etoc@next #1} + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getit@hyp + \fi\fi + \Etoc@next #1} +\def\Etoc@getthepage #1{\let\Etoc@next\Etoc@getthepage@nohyp + \ifEtoc@hyperref\ifx #1\hyper@linkstart + \let\Etoc@next\Etoc@getthepage@hyp + \fi\fi + \Etoc@next #1} +\def\Etoc@getthepage@nohyp #1\etoc@{\def\etocthepage{#1}} +\def\Etoc@getthepage@hyp #1#2#3#4#5\etoc@{% + \@namedef{etoclink }##1{#1{#2}{#3}{##1}#5}% + \def\etocthepage{#4}} \def\Etoc@getnb@nohyp #1#2#3\etoc@{% -\ifx #1\numberline -\@namedef{etocnumber }{\leavevmode #2\xspace}\Etoc@numbertrue -\else -\@namedef{etocnumber }{\leavevmode\xspace}\Etoc@numberfalse -\fi} + \def\Etoc@getname ##1\relax\relax\etoc@{% + \@namedef{etocname }{\leavevmode ##1\xspace}% + \def\etocthename{##1}% + }% + \ifx #1\numberline + \@namedef{etocnumber }{\leavevmode #2\xspace}% + \def\etocthenumber{#2}% + \Etoc@numbertrue + \Etoc@getname #3\etoc@ + \else + \@namedef{etocnumber }{\leavevmode\xspace}% + \def\etocthenumber{}% + \Etoc@numberfalse + \fi +} \def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@{% - \def\Etoc@getnbr ##1##2##3\etoc@{% - \ifx ##1\numberline - \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}% - \Etoc@numbertrue - \else - \@namedef{etocnumber }{\leavevmode\xspace}% - \Etoc@numberfalse - \fi}% - \Etoc@getnbr #4\relax\relax\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}% + \def\etocthename{##1}% + }% + \def\Etoc@getnbr ##1##2##3\etoc@{% + \ifx ##1\numberline + \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}% + \def\etocthenumber{##2}% + \Etoc@numbertrue + \Etoc@getname ##3\etoc@ + \else + \@namedef{etocnumber }{\leavevmode\xspace}% + \def\etocthenumber{}% + \Etoc@numberfalse + \def\etocthename{#4}% + \fi}% + \Etoc@getnbr #4\relax\relax\etoc@ +} \def\Etoc@getit@nohyp #1\hspace#2#3\etoc@{% \def\Etoc@getname ##1\hspace\relax\etoc@{% - \@namedef{etocname }{\leavevmode ##1\xspace}}% - \ifx \relax#2\else + \@namedef{etocname }{\leavevmode ##1\xspace}% + \def\etocthename{##1}% + }% + \ifx\relax#2\else \@namedef{etocnumber }{\leavevmode #1\xspace}% + \def\etocthenumber{#1}% \Etoc@numbertrue - \Etoc@getname #3\etoc@\fi} + \Etoc@getname #3\etoc@ + \fi +} \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\xspace}% + \def\etocthename{##1}% + }% \def\Etoc@getnbr ##1\hspace##2##3\etoc@{% - \ifx\relax##2\else - \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% - \Etoc@numbertrue - \Etoc@getname ##3\etoc@\fi}% + \ifx\relax##2\else + \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% + \def\etocthenumber{##1}% + \Etoc@numbertrue + \Etoc@getname ##3\etoc@ + \fi}% \Etoc@getnbr #4\hspace\relax\etoc@} -\edef\etocpage{\noexpand\protect\expandafter\noexpand - \csname etocpage \endcsname} -\edef\etocname{\noexpand\protect\expandafter\noexpand - \csname etocname \endcsname} -\edef\etocnumber{\noexpand\protect\expandafter\noexpand - \csname etocnumber \endcsname} +\edef\etocpage{\noexpand\protect\expandafter + \noexpand\csname etocpage \endcsname} +\edef\etocname{\noexpand\protect\expandafter + \noexpand\csname etocname \endcsname} +\edef\etocnumber{\noexpand\protect\expandafter + \noexpand\csname etocnumber \endcsname} +\edef\etoclink{\noexpand\protect\expandafter + \noexpand\csname etoclink \endcsname} \@namedef{etocifnumbered }{\ifEtoc@number -\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} + \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} \edef\etocifnumbered{\noexpand\protect\expandafter\noexpand \csname etocifnumbered \endcsname} \def\Etoc@readtoc#1{% @@ -375,21 +427,20 @@ \global\Etoc@jfalse \global\Etoc@jjfalse \ifEtoc@standard -\etoc@setstyle{@minustwo}{}{}{}{}% -\etoc@setstyle{@minusone}{}{}{}{}% -\etoc@setstyle{@zero}{}{}{}{}% -\etoc@setstyle{@one}{}{}{}{}% -\etoc@setstyle{@two}{}{}{}{}% -\etoc@setstyle{@three}{}{}{}{}% -\etoc@setstyle{@four}{}{}{}{}% -\etoc@setstyle{@five}{}{}{}{}% + \etoc@setstyle{@minustwo}{}{}{}{}% + \etoc@setstyle{@minusone}{}{}{}{}% + \etoc@setstyle{@zero}{}{}{}{}% + \etoc@setstyle{@one}{}{}{}{}% + \etoc@setstyle{@two}{}{}{}{}% + \etoc@setstyle{@three}{}{}{}{}% + \etoc@setstyle{@four}{}{}{}{}% + \etoc@setstyle{@five}{}{}{}{}% \else -\def\Etoc@levellist@elt##1{\let##1\Etoc@lxyz}% -\Etoc@levellist -\let\numberline\@gobble -\let\booknumberline\numberline -\let\partnumberline\numberline -\let\chapternumberline\numberline + \def\Etoc@levellist@elt##1{\let##1\Etoc@lxyz}% + \Etoc@levellist + \let\booknumberline\numberline + \let\partnumberline\numberline + \let\chapternumberline\numberline \fi \the\Etoc@toctoks \ifEtoc@notactive\else @@ -428,7 +479,7 @@ \fi\fi \Etoc@next} \let\etoc@startlocaltoc\@gobble -\long\def\Etoc@localtableofcontents#1{% +\def\Etoc@localtableofcontents#1{% \edef\Etoc@tmp{#1}% \ifnum\Etoc@tmp<\@ne \PackageWarning{etoc} @@ -470,50 +521,52 @@ \ifEtoc@mustclosegroup\expandafter\endgroup\fi}% \fi \fi\fi\fi\Etoc@next} -\def\table@fcontents{\par +\def\table@fcontents{% \refstepcounter{etoc@tocid}% \Etoc@tocwithidfalse \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\def\localtable@fcontents{\par +\def\localtable@fcontents{% \refstepcounter{etoc@tocid}% \addtocontents{toc} {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% \Etoc@tocwithidtrue \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\newcommand\etocaftertitlehook{} -\def\tableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi +\newcommand*\etocaftertitlehook{} +\newcommand*\etocaftercontentshook{} +\renewcommand*\tableofcontents{% + \ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi \global\Etoc@tocopenedforwritetrue - \begingroup + \Etoc@par\begingroup \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}% \@ifstar - {\let\Etoc@aftertitlehook\relax\table@fcontents} + {\def\Etoc@aftertitlehook{}\table@fcontents} {\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}} -\def\localtableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi +\newcommand*\localtableofcontents{% + \ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi \global\Etoc@tocopenedforwritetrue - \begingroup\@ifstar - {\let\Etoc@aftertitlehook\relax\localtable@fcontents} + \Etoc@par\begingroup\@ifstar + {\def\Etoc@aftertitlehook{}\localtable@fcontents} {\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}} \newcommand\etocsettocstyle[2]{% -\long\def\Etoc@tableofcontents +\def\Etoc@tableofcontents {\ifnum\c@tocdepth>\Etoc@minf\let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble\fi \Etoc@@next{#1\Etoc@aftertitlehook \let\Etoc@savedcontentsline\contentsline \let\contentsline\Etoc@etoccontentsline - \Etoc@toctoc\let\Etoc@n@xt\relax - \ifEtoc@tocwithid\else - \ifEtoc@localtoc - \ifEtoc@notactive - \def\Etoc@n@xt{\Etoc@localtocfalse + \Etoc@toctoc + \let\Etoc@n@xt\relax + \ifEtoc@tocwithid\else + \ifEtoc@localtoc + \ifEtoc@notactive + \def\Etoc@n@xt{\Etoc@localtocfalse \global\Etoc@notactivefalse \Etoc@toctoc}% - \fi\fi\fi\Etoc@n@xt + \fi\fi\fi + \Etoc@n@xt + \etocaftercontentshook #2}}} -\newcommand\etocextendtocstyle[2]{% -\toks0=\expandafter{\Etoc@tableofcontents #2}% -\toks2={#1}% -\long\edef\Etoc@tableofcontents{\the\toks2 \the\toks0}} -\newcommand\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} +\newcommand*\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} \long\def\etoc@setstyle#1#2#3#4#5{% \long\expandafter\def \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname {#2}% @@ -523,33 +576,33 @@ \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}% \long\expandafter\def \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname {#5}} -\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} -\newcommand\etocsepminustwo{4ex \@plus .5ex \@minus .5ex} -\newcommand\etocsepminusone{4ex \@plus .5ex \@minus .5ex} -\newcommand\etocsepzero{2.5ex \@plus .4ex \@minus .4ex} -\newcommand\etocsepone{1.5ex \@plus .3ex \@minus .3ex} -\newcommand\etocseptwo{1ex \@plus .15ex \@minus .15ex} -\newcommand\etocsepthree{.25ex \@plus .05ex \@minus .05ex} -\newcommand\etocbaselinespreadminustwo{1} -\newcommand\etocbaselinespreadminusone{1} -\newcommand\etocbaselinespreadzero{1} -\newcommand\etocbaselinespreadone{1} -\newcommand\etocbaselinespreadtwo{1} -\newcommand\etocbaselinespreadthree{.9} -\newcommand\etocminustwoleftmargin{1.5em plus 0.5fil} -\newcommand\etocminustworightmargin{1.5em plus -0.5fil} -\newcommand\etocminusoneleftmargin{1em} -\newcommand\etocminusonerightmargin{1em} -\newcommand\etoctoclineleaders +\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} +\newcommand*\etocsepminustwo{4ex \@plus .5ex \@minus .5ex} +\newcommand*\etocsepminusone{4ex \@plus .5ex \@minus .5ex} +\newcommand*\etocsepzero{2.5ex \@plus .4ex \@minus .4ex} +\newcommand*\etocsepone{1.5ex \@plus .3ex \@minus .3ex} +\newcommand*\etocseptwo{1ex \@plus .15ex \@minus .15ex} +\newcommand*\etocsepthree{.25ex \@plus .05ex \@minus .05ex} +\newcommand*\etocbaselinespreadminustwo{1} +\newcommand*\etocbaselinespreadminusone{1} +\newcommand*\etocbaselinespreadzero{1} +\newcommand*\etocbaselinespreadone{1} +\newcommand*\etocbaselinespreadtwo{1} +\newcommand*\etocbaselinespreadthree{.9} +\newcommand*\etocminustwoleftmargin{1.5em plus 0.5fil} +\newcommand*\etocminustworightmargin{1.5em plus -0.5fil} +\newcommand*\etocminusoneleftmargin{1em} +\newcommand*\etocminusonerightmargin{1em} +\newcommand*\etoctoclineleaders {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}} -\newcommand\etocabbrevpagename{p.~} -\newcommand\etocpartname{\partname} -\newcommand\etocbookname{Book} +\newcommand*\etocabbrevpagename{p.~} +\newcommand*\etocpartname{\partname} +\newcommand*\etocbookname{Book} \def\etoctoclines{\Etoc@standardfalse \etoc@setstyle{@minustwo}{\etocskipfirstprefix}{\pagebreak[3]} {\begingroup \etocfontminustwo @@ -658,16 +711,18 @@ \etoc@setstyle{@four}{}{}{}{}% \etoc@setstyle{@five}{}{}{}{}% } -\newcommand\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand\etoccolumnsep{2em} -\newcommand\etocmulticolsep{0ex} -\newcommand\etocmulticolpretolerance{-1} -\newcommand\etocmulticoltolerance{200} -\newcommand\etocdefaultnbcol{2} +\newcommand*\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} +\newcommand*\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} +\newcommand*\etoccolumnsep{2em} +\newcommand*\etocmulticolsep{0ex} +\newcommand*\etocmulticolpretolerance{-1} +\newcommand*\etocmulticoltolerance{200} +\newcommand*\etocdefaultnbcol{2} +\newcommand*\etocinnertopsep{2ex} \newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle - {\addvspace{\etocabovetocskip}% + {\let\etocoldpar\par + \addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo \else \let\Etoc@next\@secondoftwo\fi \Etoc@next{% @@ -675,34 +730,33 @@ \multicoltolerance\etocmulticoltolerance \setlength{\columnsep}{\etoccolumnsep}% \setlength{\multicolsep}{\etocmulticolsep}% - \begin{multicols}{#1}[#2\addvspace{\etocsepminusone}]} - {#2\addvspace{\etocsepminusone}% + \begin{multicols}{#1}[#2\etocoldpar\addvspace{\etocinnertopsep}]} + {#2\par\addvspace{\etocinnertopsep}% \pretolerance\etocmulticolpretolerance \tolerance\etocmulticoltolerance}} {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% \addvspace{\etocbelowtocskip}}} -\newcommand\etocinnertopsep{2ex} -\newcommand\etocinnerbottomsep{3.5ex} -\newcommand\etocinnerleftsep{2em} -\newcommand\etocinnerrightsep{2em} -\newcommand\etoctoprule{\hrule} -\newcommand\etocleftrule{\vrule} -\newcommand\etocrightrule{\vrule} -\newcommand\etocbottomrule{\hrule} -\newcommand\etoctoprulecolorcmd{\relax} -\newcommand\etocbottomrulecolorcmd{\relax} -\newcommand\etocleftrulecolorcmd{\relax} -\newcommand\etocrightrulecolorcmd{\relax} -\newcommand\etoc@ruledheading[1]{% +\newcommand*\etocinnerbottomsep{3.5ex} +\newcommand*\etocinnerleftsep{2em} +\newcommand*\etocinnerrightsep{2em} +\newcommand*\etoctoprule{\hrule} +\newcommand*\etocleftrule{\vrule} +\newcommand*\etocrightrule{\vrule} +\newcommand*\etocbottomrule{\hrule} +\newcommand*\etoctoprulecolorcmd{\relax} +\newcommand*\etocbottomrulecolorcmd{\relax} +\newcommand*\etocleftrulecolorcmd{\relax} +\newcommand*\etocrightrulecolorcmd{\relax} +\def\etoc@ruledheading #1{% \hb@xt@\linewidth{\color@begingroup \hss #1\hss\hskip-\linewidth \etoctoprulecolorcmd\leaders\etoctoprule\hss \phantom{#1}% \leaders\etoctoprule\hss\color@endgroup}% - \nointerlineskip\vskip\etocinnertopsep} -\newcommand\etocruledstyle[2][\etocdefaultnbcol]{% + \nointerlineskip\vskip\etocinnertopsep} +\newcommand*\etocruledstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -721,11 +775,11 @@ \Etoc@next{\end{multicols}}% \addvspace{\etocbelowtocskip}}} \newcommand\etocframedmphook{\relax} -\newcommand\etocbkgcolorcmd{\relax} -\newcommand\Etoc@relax{\relax} +\newcommand*\etocbkgcolorcmd{\relax} +\def\Etoc@relax{\relax} \newbox\etoc@framed@titlebox \newbox\etoc@framed@contentsbox -\newcommand\etocframedstyle[2][\etocdefaultnbcol]{% +\newcommand*\etocframedstyle[2][\etocdefaultnbcol]{% \etocsettocstyle{% \addvspace{\etocabovetocskip}% \sbox\z@{#2}% @@ -804,108 +858,107 @@ \leaders\etocbottomrule\hss\color@endgroup}} \addvspace{\etocbelowtocskip}}} \newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\tableofcontents} + \etocmulticolstyle[#1]{#2}% + \tableofcontents} \newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\tableofcontents*} + \etocmulticolstyle[#1]{#2}% + \tableofcontents*} \newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\localtableofcontents} + \etocmulticolstyle[#1]{#2}% + \localtableofcontents} \newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{% -\etocmulticolstyle[#1]{#2}% -\localtableofcontents*} -\newcommand\etoc@ruledtoc[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\tableofcontents} -\newcommand\etoc@ruledtoci[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\tableofcontents*} -\newcommand\etoc@local@ruledtoc[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\localtableofcontents} -\newcommand\etoc@local@ruledtoci[2][\etocdefaultnbcol]{% -\etocruledstyle[#1]{#2}% -\localtableofcontents*} -\newcommand\etoc@framedtoc[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\tableofcontents} -\newcommand\etoc@framedtoci[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\tableofcontents*} -\newcommand\etoc@local@framedtoc[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\localtableofcontents} -\newcommand\etoc@local@framedtoci[2][\etocdefaultnbcol]{% -\etocframedstyle[#1]{#2}% -\localtableofcontents*} -\newcommand\etocmulticol{\begingroup + \etocmulticolstyle[#1]{#2}% + \localtableofcontents*} +\newcommand*\etoc@ruledtoc[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \tableofcontents} +\newcommand*\etoc@ruledtoci[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \tableofcontents*} +\newcommand*\etoc@local@ruledtoc[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \localtableofcontents} +\newcommand*\etoc@local@ruledtoci[2][\etocdefaultnbcol]{% + \etocruledstyle[#1]{#2}% + \localtableofcontents*} +\newcommand*\etoc@framedtoc[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \tableofcontents} +\newcommand*\etoc@framedtoci[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \tableofcontents*} +\newcommand*\etoc@local@framedtoc[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \localtableofcontents} +\newcommand*\etoc@local@framedtoci[2][\etocdefaultnbcol]{% + \etocframedstyle[#1]{#2}% + \localtableofcontents*} +\def\etocmulticol{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@multicoltoci} {\etoc@multicoltoc}} -\newcommand\etocruled{\begingroup +\def\etocruled{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@ruledtoci} {\etoc@ruledtoc}} -\newcommand\etocframed{\begingroup +\def\etocframed{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@framedtoci} {\etoc@framedtoc}} -\newcommand\etoclocalmulticol{\begingroup +\def\etoclocalmulticol{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@multicoltoci} {\etoc@local@multicoltoc}} -\newcommand\etoclocalruled{\begingroup +\def\etoclocalruled{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@ruledtoci} {\etoc@local@ruledtoc}} -\newcommand\etoclocalframed{\begingroup +\def\etoclocalframed{\begingroup \Etoc@mustclosegrouptrue \@ifstar {\etoc@local@framedtoci} {\etoc@local@framedtoc}} -\newcommand\etocarticlestyle{% +\def\etocarticlestyle{% \etocsettocstyle {\section *{\contentsname \@mkboth {\MakeUppercase \contentsname} {\MakeUppercase \contentsname}}} {}} -\newcommand\etocarticlestylenomarks{% +\def\etocarticlestylenomarks{% \etocsettocstyle {\section *{\contentsname}} {}} -\newcommand\etocbookstyle{% +\def\etocbookstyle{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi \chapter *{\contentsname \@mkboth {\MakeUppercase \contentsname} {\MakeUppercase \contentsname}}} {\if@restonecol \twocolumn \fi}} -\newcommand\etocbookstylenomarks{% +\def\etocbookstylenomarks{% \etocsettocstyle {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi \chapter *{\contentsname}} {\if@restonecol \twocolumn \fi}} \let\etocreportstyle\etocbookstyle \let\etocreportstylenomarks\etocbookstylenomarks -\newcommand\Etoc@addcontentsline{} -\newcommand\etocmemoirtoctotocfmt[2]{% - \renewcommand\Etoc@addcontentsline{\addcontentsline {toc}{#1}{#2}}% - \renewcommand\etocaftertitlehook{% +\def\etocmemoirtoctotocfmt #1#2{% + \def\Etoc@addsuitablecontentsline{\addcontentsline {toc}{#1}{#2}}% + \renewcommand*\etocaftertitlehook{% \ifmem@em@starred@listof - \else\phantomsection\aftergroup\Etoc@addcontentsline\fi}} -\newcommand\etocmemoirstyle{% + \else\phantomsection\aftergroup\Etoc@addsuitablecontentsline\fi}} +\def\etocmemoirstyle{% \etocsettocstyle {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle} \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax \parskip \cftparskip \@nameuse {cfttocbeforelisthook}} {\@nameuse {cfttocafterlisthook}\endgroup\restorefromonecol}} -\newcommand\etocscrartclstyle{% +\def\etocscrartclstyle{% \etocsettocstyle {\let\if@dynlist\if@tocleft \iftocfeature {toc}{onecolumn} @@ -933,11 +986,10 @@ \csname tocbasic@@after@hook\endcsname}} \let\etocscrbookstyle\etocscrartclstyle \let\etocscrreprtstyle\etocscrartclstyle -\newcommand\etocnakedtocdisplaystyle{\etocsettocstyle{}{}} -\newcommand\etocstandarddisplaystyle{\etocarticlestyle} -\newcommand\etocmarkboth[1]{% +\newcommand*\etocstandarddisplaystyle{\etocarticlestyle} +\newcommand*\etocmarkboth[1]{% \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} -\newcommand\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} +\newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} \newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]% {\csname #1\endcsname *{#3}}} \newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]% @@ -954,32 +1006,47 @@ \renewcommand\etoctocstyle[3][#1]{% \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}} \@ifclassloaded{scrartcl} - {\renewcommand\etocstandarddisplaystyle{\etocscrartclstyle}}{} + {\renewcommand*\etocstandarddisplaystyle{\etocscrartclstyle}}{} \@ifclassloaded{book} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocbookstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocbookstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{report} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocreportstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocreportstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{scrbook} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocscrbookstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocscrbookstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{scrreprt} - {\renewcommand\etocfontone{\normalfont\normalsize} - \renewcommand\etocstandarddisplaystyle{\etocscrreprtstyle} + {\renewcommand*\etocfontone{\normalfont\normalsize} + \renewcommand*\etocstandarddisplaystyle{\etocscrreprtstyle} \Etoc@redefetocstyle{chapter}}{} \@ifclassloaded{memoir} - {\renewcommand\etocfontone{\normalfont\normalsize} + {\renewcommand*\etocfontone{\normalfont\normalsize} \etocmemoirtoctotocfmt{chapter}{\contentsname}% - \renewcommand\etocstandarddisplaystyle{\etocmemoirstyle} + \renewcommand*\etocstandarddisplaystyle{\etocmemoirstyle} \Etoc@redefetocstyle{chapter}}{} -\newcommand\etocstandardlines{\Etoc@standardtrue} +\newcommand*\etocstandardlines{\Etoc@standardtrue} +\def\Etoc@addtocontents #1#2% + {\ifEtoc@hyperref + \addtocontents {toc}{\protect\contentsline + {#1}{#2}% + {\thepage }{\@currentHref }}% + \else + \addtocontents {toc}{\protect\contentsline + {#1}{#2}{\thepage }}% + \fi} +\def\Etoc@addcontentsline@ #1#2#3% + {\@namedef{toclevel@#1}{#3}% + \addcontentsline {toc}{#1}{#2}} +\DeclareRobustCommand*{\etoctoccontentsline} + {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}} \etoctoclines +\AtBeginDocument{ \etocstandardlines -\etocstandarddisplaystyle +\etocstandarddisplaystyle} \endinput %% %% End of file `etoc.sty'. |