From 76def1765b0dafeba9f05e03b8ae3d89bf3b234d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 30 Nov 2012 23:32:59 +0000 Subject: etoc (30nov12) git-svn-id: svn://tug.org/texlive/trunk@28397 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/etoc/README | 39 +- Master/texmf-dist/doc/latex/etoc/etoc.pdf | Bin 138278 -> 236632 bytes Master/texmf-dist/source/latex/etoc/etoc.dtx | 1920 +++++++++++++++++--------- Master/texmf-dist/source/latex/etoc/etoc.ins | 5 +- Master/texmf-dist/tex/latex/etoc/etoc.sty | 476 +++++-- 5 files changed, 1598 insertions(+), 842 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/etoc/README b/Master/texmf-dist/doc/latex/etoc/README index a56154e7c48..49aa20e60e6 100644 --- a/Master/texmf-dist/doc/latex/etoc/README +++ b/Master/texmf-dist/doc/latex/etoc/README @@ -1,5 +1,5 @@ - Package `etoc' (v1.04, 2012/11/24) + Package `etoc' (v1.05, 2012/11/28) Copyright (C) 2012 by Jean-Francois Burnol The source file etoc.dtx and its derived files may be @@ -26,18 +26,25 @@ Abstract - The etoc package gives to the user complete control on how 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, next to the standard formatting inherited from the - LaTeX document classes. But the idea is to give the means to the - user to delegate the details to packages dealing with list making - environments (such as enumitem). Regarding the global style, etoc - typesets by default tables of contents in a multi-column format, - with either a standard heading, or a ruled title, optionally with - a frame around the table of contents. The \tableofcontents command - can be used arbitrarily many times in the same document, and comes - with a starred variant which gives local table of contents. - + The etoc package gives to the user complete control on how + 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 + (surprise!) `local' tables of contents. 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 possibly + multi-column format, with either a heading or a title + in-between rules, optionally with a frame around the table + of contents. Using labels, one can reproduce at another + location (and with another layout) a (local) TOC defined + somewhere in the document. + + See the pdf documentation for the user manual. diff --git a/Master/texmf-dist/doc/latex/etoc/etoc.pdf b/Master/texmf-dist/doc/latex/etoc/etoc.pdf index 89ac80f6817..0e57369b29a 100644 Binary files a/Master/texmf-dist/doc/latex/etoc/etoc.pdf and b/Master/texmf-dist/doc/latex/etoc/etoc.pdf differ diff --git a/Master/texmf-dist/source/latex/etoc/etoc.dtx b/Master/texmf-dist/source/latex/etoc/etoc.dtx index f6fc5c2b943..43d05544b5d 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.dtx +++ b/Master/texmf-dist/source/latex/etoc/etoc.dtx @@ -3,13 +3,13 @@ %% Copyright (C) 2012 by Jean-Francois Burnol %<*ins> \def\pkgname{etoc} -\def\pkgdate{2012/11/24} -\def\pkgversion{v1.04} +\def\pkgdate{2012/11/28} +\def\pkgversion{v1.05} \def\pkgdescription{easily customizable TOCs (jfB)} % %<*none> -\def\lasttimestamp{Time-stamp: <24-11-2012 23:29:16 CET jfb>} -\def\docdate{2012/11/24} +\def\lasttimestamp{Time-stamp: <29-11-2012 19:26:40 CET jfb>} +\def\docdate{2012/11/29} \def\striptimestamp#1 <#2 #3 #4 #5>{#2 at #3 #4} \edef\dtxtimestamp{\expandafter\striptimestamp\lasttimestamp} \ProvidesFile{\pkgname.dtx} @@ -82,22 +82,23 @@ % %<*none> \fi -\documentclass[a4paper,12pt]{ltxdoc} - +\documentclass[a4paper,11pt,abstract]{scrdoc} +\pagestyle{headings} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage[hscale=0.66,vscale=0.75]{geometry} \usepackage{verbatim} \usepackage{txfonts} - \usepackage{xspace} \usepackage{multicol} - \usepackage{enumitem} - +\usepackage{color} \usepackage{xcolor} \definecolor{joli}{RGB}{225,95,0} -\renewcommand\partname{Part} +\definecolor{JOLI}{RGB}{225,95,0} +\definecolor{BLUE}{RGB}{0,0,255} + +\usepackage[english]{babel} \usepackage[%dvipdfmx,% pdfencoding=pdfdoc,bookmarks=true]{hyperref} @@ -120,35 +121,44 @@ 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}} + +\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} + \usepackage{etoc} + \newcommand\etoc{% \texorpdfstring{{\color{joli}\ttfamily\bfseries etoc}\xspace} {\textbackslash etoc\xspace}} -\newcommand\csi[1]{{\ttfamily\hyphenchar\font45\char92#1}} -\newcommand\csbi[1]{{\color{blue}\ttfamily\hyphenchar\font45\char92#1}} -\newcommand\csa[1]{\texorpdfstring{\csi{#1}}{\textbackslash #1}} -\newcommand\csb[1]{\texorpdfstring{\csbi{#1}}{\textbackslash #1}} -\newcommand\lowast{{\ttfamily \raisebox{-.25\height}{*}}} -\newcommand\starit[1]{\csi{#1}\lowast} -\newcommand\staritb[1]{{\color{blue}\csi{#1}\lowast}} -\newcommand\toc{\csa{tableofcontents}\xspace} -\newcommand\tocb{\csb{tableofcontents}\xspace} -\newcommand\tocstar{\starit{tableofcontents}\xspace} -\newcommand\tocstarb{\staritb{tableofcontents}\xspace} - -\hyphenation{sec-num-depth toc-num-depth etoc-set-style etoc-set-level -etoc-set-toc-style etoc-if-num-bered etoc-name etoc-page etoc-number -etoc-framed-style etoc-multi-col-style etoc-ruled-style -etoc-skip-first-pre-fix etoc-ref} +\hyphenation{toc-depth sec-num-depth etoc-framed-style etoc-ruled-style} +\hyphenation{etoc-toc-style-with-marks etoc-ruled etoc-framed} +\hyphenation{etoc-standard-display-style} \frenchspacing \renewcommand\familydefault\sfdefault -\begin{document} +\setcounter{secnumdepth}{3} +\setcounter{tocdepth}{3} -\rmfamily +\begin{document}\rmfamily +\thispagestyle{empty} +\addto\captionsenglish{\renewcommand\partname{Part}} +\renewcommand\partname{Part} \begin{center} {\normalfont\Large The \etoc package}\\ @@ -160,142 +170,285 @@ etoc-skip-first-pre-fix etoc-ref} with timestamp ``\dtxtimestamp'' \end{center} - \begin{abstract} - The \etoc package gives to the user complete control on - how the entries of the table of contents should be - constituted from the \emph{name}, \emph{number}, and - \emph{page number} of each sectioning unit. This goes via - the definition of \emph{line styles} for each sectioning - level used in the document. The package provides its own - custom line styles as an example, next to the standard - formatting inherited from the \LaTeX{} document classes. But - the idea is to give the means to the user to delegate the - details to packages dealing with list making environments - (such as |enumitem|). Regarding the \emph{global style}, - \etoc typesets by default tables of contents in a - multi-column format, with either a standard heading, or a - ruled title, optionally with a frame around the table of - contents. The \csa{tableofcontents} command can be used - arbitrarily many times in the same document, and comes with - a starred variant which gives local table of contents. + The \etoc package gives to the user complete control on how + the entries of the table of contents should be constituted + from the \emph{name}, \emph{number}, and \emph{page number} + of each sectioning unit. This goes via the definition of + \emph{line styles} for each sectioning level used in the + document. The package provides its own custom line styles as + an example. The simplest usage though will be to 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 (surprise!) `local' tables of contents. 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 possibly multi-column format, with either a + heading or a title in-between rules, optionally with a frame + around the table of contents. Using labels, one can + reproduce at another location (and with another layout) a + (local) TOC defined somewhere in the document.\par \end{abstract} -\tableofcontents \label{toc:main} - -\part{Although this is a short document, we are going to use - many sectioning commands} +\section*{Foreword} -\setcounter{tocdepth}{-2} +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 . . . + +As is well explained in the |tocloft| package documentation, +the standard \LaTeX{} layout for the Table of Contents is +buried in the class definitions. In particular, most of the +lengths therein are hardcoded, and the only way for the user +to change them is to recopy the class definitions into the +document and then change them to obtain what is desired +(within suitable \cs{makeatletter} and \cs{makeatother}). +The more reasonable alternative is to use a dedicated package such as +|tocloft| or to use another flexible document class. + +However, although now things are hopefully not hard-coded, one +still has to go through the package or class interface. This +means one has to memorize a (possibly large) number of macros +which will serve only to this task, and one will always be +constrained to customizing one initially given layout. + +The spirit of \etoc is something else. The user will deal with +the \emph{name}, the \emph{number} and the \emph{page number} +corresponding to each document sectional division (and +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 +compatible with the |article|, |book|, |report|, |scrartcl|, +|scrbook|, |scrreprt| and |memoir| classes. Preliminary +testing is positive, but the author not being familiar with the +latter classes,\footnote{latter=all but |article|...} he does +not have a stock of documents which could have been used to +test all their bells and whistles in the presence of +\etoc. \par -\tableofcontents* \label{toc:partone} +\clearpage \setcounter{tocdepth}{3} -\section{Overview} +\etoctoclines +\etocmarkboth\contentsname +\etocmulticolstyle{} +\tableofcontents* \label{toc:main} -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 . . . I realize (to some extent, as I still -haven't read closely the documentations) that most if not all -of the \etoc functionality could well be already available in -the above mentioned packages. -\subsection{Initial motivation} +\part{Overview} -The specific initial impetus was to transform the `flat' data -contained in the |.toc| file into a nested structure which -could be given to list making environments.\footnote{I got +\setcounter{tocdepth}{-3} +\localtableofcontents \label{toc:partone} +\setcounter{tocdepth}{3} + +\section{Initial motivation: nested lists} + +The initial impetus was to feed nested +list environments with the data consisting of the \emph{name}, +\emph{number}, and \emph{page number} as recorded in the +|.toc| file.\footnote{I got started about this through reading this question on the \TeX{} Stackexchange site:\\ \href{http://tex.stackexchange.com/questions/79682/can-i-get-a-list-of-all-sections-as-a-simple-enumerate-list}{tex.stackexchange.com/questions/79682}} For example, typesetting the line corresponding to the first sub-section in a given -section would open a group which would be closed only when a +section would open a list environment which would be closed only when a section, chapter, or part line entry in the |.toc| file would -be encountered. Package \etoc allows to do this very easily -and the opening and closing of the groups can be for example +be encountered. \etoc allows to do this very easily +and the opening and closing may be for example |\begin{enumerate}| and |\end{enumerate}| pairs, will all the customizing allowed by packages such as |enumitem|. -Although there is a limitation to this method (the |.toc| file +\subsection{Limitations intrinsic to the use of environments} + +There is a first limitation to this method: the |.toc| file may contain other commands, such as language changing commands, which do not expect to see their scope limited in -this way inside a group), I believe this procedure will be -found the most convenient in many cases. However the own -package custom line styles (illustrated by the main table of -contents in this document) do not make use of environments to -avoid that problem. - -\subsection{Line styles} - -To implement the above idea, the command \csb{etocsetstyle} -will inform \etoc of what it should do at each sectioning -level, from |part| down to |subparagraph|. Other sectioning -names can be used too, if present in the document. - -\subsubsection{\csb{etocetoclines} vs \csb{etocstandardlines}} - -The \csb{etocetoclines} command selects the package predefined -line styles, and \csb{etocstandardlines} uses the standard -default formatting from the |article|, |book|, |report|, or -also |scrartcl| classes. For any document class proceeding in -a manner compatible to the |article| class in its -typesetting of the table of contents, the -\csb{etocstandardlines} should be functional: indeed nothing -is hard-coded into the package code; rather, when -\csb{etocstandardlines} is issued by the user, the package -cancels its own mechanism and gives back the leadership to the -class layer. Note though that this means that \etoc does not -provide utilities to change this or that length from the -\LaTeX{} default formatting of TOC entries. But if some other -package has done it, then this should work correctly also when -\etoc is in use (for its other aspects as will be described below). - -\subsubsection{Instructing \etoc about sectioning command names} - -If the document class uses other names, such as \emph{atom}, -or \emph{particle}, the command \csb{etocsetlevel} will -instruct \etoc about it. - -\subsection{Global style: multiple columns, ruled heading, framed table of contents} - -At the global level, the default of \etoc is to typeset the -TOC on two columns, using the package |multicol|. -Additionally, the heading can be formatted as in the default -manner, or as a ruled heading, or the entire TOC can be -encapsulated in a frame (if it fits on the current page). And -the user can specify to use a single column output, or three -columns, etc . . . - -\subsection{Local tables of contents} - -With \etoc, the \csb{tableofcontents} command can be used -arbitrarily many times and it has a starred variant \tocstarb -which will print a local table of contents: i.e. all subsections -etc . . . inside a given section, or all subsubsections and -lower inside a given subsection, etc . . . - -\subsection{Displaying tables of contents defined - elsewhere in the document} - -A \LaTeX{} counter is associated with the successive tables of -contents. To set a reference point (which will become an -anchor if package |hyperref| is loaded) one just uses the -\cs{label} command as usual. -For example:\\ +this way inside a group (\LaTeX's environments create groups). +Therefore the package own line styles +(illustrated by the main table of contents in this document) +do not make use of environments to avoid that problem. + +A second limitation is that one may nest at most 4 levels of +enumerate environments, and 4 levels of itemize environment. I +tried alternating them and did succeed to nest 6 levels (and +not 8 alas . . . \footnote{this is + surely a well-known issue which I did not at all + investigate any further.}). With +\csb{etocnumber} as the optional parameter to \cs{item}: +\cs{item}|[\etocnumber]| one may transform the itemize into an +enumerated list... anyway, 4 levels of sectional divisions in +a TOC are generally sufficient, and again using |enumerate| +environments is only a possibility provided by \etoc, it is by +no means mandatory to use them in the line styles +specifications. + +We will give in this manual a simple-minded example of nested +use of |enumerate| environments. More sophisticated examples +would use more sophisticated |enumitem| options. One may say +then that again the user has to memorize some customizing! +indeed, but the syntax and option names to memorize are in no +way related only to matters of tables of contents, hence an +economy of use of the poor brain. + +Still a different sort of example, +less elementary and not making use at all of list-making +environments, is built-in in \etoc own ``line styles''. They +are activated by the command \csb{etoctoclines}... and do +come with their own set of customizing macros! + +\section{Line styles and global 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... + +\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. + +\subsubsection{Multiple columns, ruled title, framed contents} + +\etoc provides four (customizable...) toc styles which are +variants on the use of the |multicol| package: +\csb{etocmulticolstyle}, \csb{etoctocstyle}, +\csb{etocruledstyle}, and \csb{etocframed\-style}. 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). + +\subsection{\csbhyp{etocsetstyle} for the line styles} + +The command to inform \etoc of what to do with \cs{etocname}, +\cs{etocnumber}, and \cs{etocpage} is called +\csb{etocsetstyle}. It has five mandatory arguments. The first +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 +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.} + +\subsection{Compatibility mode} + +Both for the ``line styles'' and the ``global style'', it is +possible to switch into a compatibility mode which uses the +document class default style.\footnote{for the ``global 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 +\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}, and if the document class does things in a +manner analogous as the standard classes, then the +\cs{etocstandardlines} compatibility switch should be +functional. 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 +course be changed in-between. Furthermore +\cs{localtableofcontents} will print local tables of +contents\footnote{Up to version |1.04| we called this + \starit{tableofcontents}, but for reasons of compatibility + with the |memoir| class, we have decided to drop this + usage.}: \emph{i.e.} all sections and sub-units inside a +given chapter, or all subsubsections and lower inside a given +subsection, etc . . . + +\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\\ \hbox to \linewidth{\hss - \tocstarb\space\csbi{label\string{my\_nice\_toc\string}}\hss} - -Then, elsewhere in the document, doing:\\ -\hbox to \linewidth{\hss \tocb\space\csbi{ref\string{my\_nice\_toc\string}}\hss} -will display again the same contents. However, the line styles -and global style (including the title) will be the current one and the -current value of the |tocdepth| counter is obeyed. As an example here is -the table of contents of Part \ref{part:custom}: - + \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 +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: +\begin{verbatim} +\let\myclearpage\clearpage +\tableofcontents +\let\myclearpage\relax +\end{verbatim} +The |memoir| class has the command \cs{settocdepth} which +writes a \cs{changetoc\-depth} command inside the |.toc| file. +This will impact the typesetting by \etoc of \emph{all} tables +of contents, with possibly unexpected results: imagine the +document has \cs{settocdepth}|{chapter}| at some point to +avoid having the sections from subsequent chapters be listed +in the main table of contents. Then a local table of contents +in one of these chapters will print a title but will be +without any entry. A solution is to do \cs{begingroup} +|\renewcommand*\changetocdepth[1]{}| \cs{localtableofcontents} +\cs{endgroup}, and to set the desired level for the local +table of contents with the other |memoir| command \cs{maxtocdepth}. +\footnote{The |memoir| class allows multiple calls to the \toc + command, so these issues already arise there, + independently of \etoc, see page 170 of the |memoir| + manual.} + + +\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\}}. 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 @@ -303,7 +456,7 @@ the table of contents of Part \ref{part:custom}: \renewcommand{\etocbkgcolorcmd}{\color{green!5}} \fboxsep1ex -\etocframed[1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone I am from +\etocframed*[1]{\fbox{\makebox[.5\linewidth]{\etocfontminusone I am from \hyperref[toc:c]{far away}}}} \label{toc:d} \ref{toc:c} @@ -313,44 +466,54 @@ the table of contents of Part \ref{part:custom}: 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{green!50!blue!50}the present location} -can itself now be referred to via |\ref{toc:d}|: this gives -the number of this TOC (\emph{i.e} -{\color{green!50!blue!50}\ref{toc:d}}) in the sequence of -document TOCs, will be a link if package |hyperref| is used, -and can be used elsewhere as \toc|\ref{toc:d}| (which now has -exactly the same effect as \toc|\ref{toc:c}|). - -For info, the \hyperref[toc:c]{\color{green!50!blue!50}toc with label |toc:c|} -is the one which has number {\color{green!50!blue!50}\ref{toc:c}}... - -The \cs{label} command should come before the reference via -\cs{ref} to the other TOC. A \cs{label} detected by \etoc -immediately (skipping spaces) after the command \toc will be -activated right after the update to the toc counter. A +\hyperref[toc:d]{\color{green!35!blue!75}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{green!35!blue!75}\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}|. The +reason is that the doubly cloned TOC has no way of knowing that +it is a clone of a clone, and what `local' means will +erroneously be construed as being decided by the location of +the first clone, not the original. 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 +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 inside the TOC). +line styles, even some counter modified inside the TOC. -As another example let us now display a table of contents for +As another example let us display a table of contents for this first part of the document. Indeed, immediately after the line in the source file starting with the first \cs{part} we wrote: + +\vspace{-.25cm} \begin{verbatim} \setcounter{tocdepth}{-2} -\tableofcontents* \label{toc:partone} -\setcounter{tocdepth}{3} +\localtableofcontents \label{toc:partone} +\setcounter{tocdepth}{2} \end{verbatim} -The |tocdepth| being -2, nothing at -all was inserted in the page, but now that |tocdepth| has -been reset to 3, we can display the TOC with the simple -command: +The |tocdepth| being set to -2, nothing at all was inserted in the +page (for the same effect one must use -3 in the |memoir| +class; and -3 works in all classes) but +now that it has been reset to 2, we can display the TOC with +the simple command: \begin{verbatim} \tableofcontents \ref{toc:partone} \end{verbatim} -\clearpage + +\subsection{Local table of contents for this part} + +This sub-section heading was manually added to the +document source, it is not part of the TOC style. \setcounter{tocdepth}{3} @@ -365,7 +528,7 @@ command: \renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}} \renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}} -\renewcommand{\etocleftrule}{\vrule width 2.5cm} +\renewcommand{\etocleftrule}{\vrule width 3cm} \renewcommand{\etocrightrule}{\vrule width 1cm} \renewcommand{\etocbottomrule}{\hrule height 12pt} \renewcommand{\etoctoprule}{\hrule height 12pt} @@ -418,21 +581,25 @@ command: \etocframedstyle[1]{} -\tableofcontents \ref{toc:partone} +\tableofcontents* \ref{toc:partone} \endgroup -The actual design is not pre-built in \etoc: it -combines the \etoc `framed' style (with a dummy empty title, the actual title -having been put inside the frame as part of the \marg{start} code of the section -`line style'). The frame borders have been set to have the same color as the one -which serves as background for the entire thing. This design (with other colors) -is used also for \hyperref[toc:clone]{\color{green!50!blue!50}this other toc} -(the coding used is reproduced there). +The actual design is not pre-built in \etoc; it uses the \etoc +`framed' style with a background color and a dummy empty +title, the actual title having been put inside the frame as +part of the \meta{start} code of the section `line style'. The +frame borders have been set to have the same color as the one +which serves as background for the entire thing. This design +(with other colors) is in use also for +\hyperref[toc:clone]{\color{green!35!blue!75}this other toc}, +and the coding used has been included in its subsection. \part{Package commands for line styles} +\setcounter{tocdepth}{3} + \etocsetstyle{section} {\begin{enumerate}[leftmargin=0pt,label=]} {\normalsize\bfseries\rmfamily\item} @@ -449,45 +616,42 @@ is used also for \hyperref[toc:clone]{\color{green!50!blue!50}this other toc} \etocsetstyle{subsubsection} {\par\nobreak\begingroup\normalfont\footnotesize\itshape\etocskipfirstprefix} -{\unskip\allowbreak\,--\,} -{\etocname} -{\unskip.\hfil\par\endgroup\pagebreak[3]} +{\allowbreak\,--\,} +{\etocname\unskip} +{.\hfil\par\endgroup\pagebreak[3]} \etocruledstyle[1]{\etocfontminusone\color{green} \fboxrule1pt\fboxsep1ex \framebox[\linewidth] {\normalcolor\hss Contents of this second part\hss}} -\tableofcontents* \label{toc:a} +\localtableofcontents \label{toc:a} -\section{The \csb{etocsetstyle} command} +\section{The \csbhyp{etocsetstyle} command} \subsection{An example} Let us explain how \etoc was used to produce the table of -contents displayed at the beginning of this second part (this -is a local table of contents, we used the command \tocstar). +contents displayed at the beginning of this second part. +This +is a local table of contents, and we used the command \localtoc. We shall distinguish between the \emph{line styles} and the -\emph{global style}. First we describe how to set-up the -line styles. Essentially they were obtained in the following -manner% +\emph{toc display style}. The line styles were (essentially) +obtained in the following manner:% \footnote{the present document has {\ttfamily\string\renewcommand\string{% \string\familydefault\string}\string{\string\sfdefault\string}} - in its preamble, hence \csa{normalfont} switches to the + in its preamble, hence \cs{normalfont} switches to the |sans| typeface; so in the section line-style, I wrote - \csa{rmfamily} instead.} \footnote{\etoc uses the |xspace| - package, and there is no need to write - \csa{etocname\string{\string} text} rather than just - \csa{etocname text} for example. However, this forced us to - add the two mysterious \csa{unskip} in the - subsubsection style.} + \cs{rmfamily} instead.} \begingroup\small \begin{verbatim} +\setcounter{tocdepth}{3} + \etocsetstyle{section} {\begin{enumerate}} {\normalsize\bfseries\rmfamily\item} @@ -503,38 +667,44 @@ manner% \etocsetstyle{subsubsection} {\par\nobreak\begingroup\normalfont \footnotesize\itshape\etocskipfirstprefix} -{\unskip\allowbreak\,--\,} -{\etocname} -{\unskip.\hfil\par\endgroup\pagebreak[3]} +{\allowbreak\,--\,} +{\etocname\unskip} +{.\hfil\par\endgroup\pagebreak[3]} \end{verbatim} \endgroup Each \csb{etocsetstyle} command has five mandatory arguments:\\ \hbox to \linewidth -{\hfil\csa{etocsetstyle}\color{blue}\marg{levelname}% +{\hfil\csb{etocsetstyle}\color{blue}\marg{levelname}% \marg{start}\marg{prefix}\marg{contents}\marg{finish}\hfil} -The initially recognized \marg{levelname}'s are the sectioning -levels of the standard document classes (from \emph{part} -down to \emph{subparagraph}). +The initially recognized \meta{levelname}'s are the sectioning +levels of the standard document classes: from \emph{part} (or +\emph{book} which is used by the |memoir| class) down to +\emph{subparagraph}. -The \marg{start} code is executed when a toc entry of that level is +The \meta{start} code is executed when a toc entry of that level is encountered and the previous one was at a higher level. The -\marg{finish} code is executed when one again encounters a higher +\meta{finish} code is executed when one again encounters a higher level toc entry. In the mean-time all entries for that level are -typeset by executing first the \marg{prefix} code and then the -\marg{contents} code. +typeset by executing first the \meta{prefix} code and then the +\meta{contents} code. -\subsubsection{\csb{etocname} and \csb{etocpage}} +\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. Temporarily, we relied on +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. -\subsubsection{The \csb{etocskipfirstprefix} command} +\subsubsection{The \csbhyp{etocskipfirstprefix} command} The chosen |subsubsection| style specifies to list the names of the subsubsections from a given subsection in an in-line @@ -555,19 +725,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{secnumdepth and tocdepth} +\subsubsection{secnum\-depth and tocdepth} The \LaTeX{} counter |secnumdepth| -decides (from part down to subparagraph) which levels are numbered and +decides which levels are numbered and automatically written to the |.toc| file. Its functioning is completely independent from the \etoc package. The counter |tocdepth| -decides the finest level displayed in the table of contents: it -is obeyed by \etoc, and as \toc can now be used arbitrarily +decides the finest level displayed in the table of contents: its +local value is obeyed by \etoc, and as \toc can now be used arbitrarily times, this is an important customization lever. -\subsection{The \csb{etocsetlevel} command} +\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 @@ -578,9 +748,10 @@ this in the following way: \etocsetlevel{atom}{2} \etocsetlevel{nucleus}{3} \end{verbatim} -The accepted numbers range from -1 to 5 inclusive. The package code +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} @@ -593,7 +764,7 @@ does: \subsection{Further informations and let's make this a very long title to see how it will look like} -\subsubsection{The \csb{etocnumber} command} +\subsubsection{The \csbhyp{etocnumber} command} So far, our specifications would use the numbering generated by the |enumerate| environments, but it would be nicer to use the actual numbers as found in the |.toc| file. This is @@ -607,15 +778,17 @@ syntax {\ttfamily label=\char32} from the package |enumitem|: {\etocname (page \etocpage)} {\end{enumerate}} \end{verbatim} -Rather than just\csa{etocnumber} we then used something like +Rather than just\cs{etocnumber} we then used something like |\fbox{\etocnumber}|. -\subsubsection{The \csb{etocifnumbered} switch} +\subsubsection{The \csbhyp{etocifnumbered} switch} -The \csa{fbox} would give an unaesthetic result in the case of an unnumbered -section (which ended up in the table of contents via an \csa{addcontentsline} -command). The \csa{etocifnumbered}\marg{A}\marg{B} command executes \meta{A} if +The \cs{fbox} would give an unaesthetic result in the case of an unnumbered +section (which ended up in the table of contents via an \cs{addcontentsline} +command). + +The \cs{etocifnumbered}\marg{A}\marg{B} command executes \meta{A} if the number exists, and \meta{B} if not. So our final code could be: \begin{verbatim} \etocsetstyle{section} @@ -644,15 +817,16 @@ We used, actually: If we had changed only the |section| level, and not the |subsection| level, an error on compilation would have occurred because the package style for subsections expects to start `in -vertical mode'. An additional \csa{par} token in the -\meta{contents} part of the |section| level would fixed +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 \csb{etocfontxxx...} commands} +\subsection{The \csbhyp{etocfontxxx...} commands} The package predefines for use in its default line styles: \begin{verbatim} +\newcommand\etocfontminustwo{\normalfont \LARGE \bfseries} \newcommand\etocfontminusone{\normalfont \large \bfseries} \newcommand\etocfontzero{\normalfont \normalsize \bfseries} \newcommand\etocfontone{\normalfont \normalsize \bfseries} @@ -661,10 +835,17 @@ The package predefines for use in its default line styles: \newcommand\etocfontfour{\normalfont \footnotesize} \newcommand\etocfontfive{\normalfont \footnotesize} \end{verbatim} -This only impacts the package default line styles and does -nothing under the \csa{etocstandardlines} regime. +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 not displayed by the package +(subparagraphs) are actually not displayed by the package default line styles. @@ -695,7 +876,7 @@ 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 \csa{normalsize} to the +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. @@ -703,6 +884,9 @@ a group, hence no font change therein can propagate to the outside. \section{Am I also in red?} +Well, actually no in this |scrartcl| class but I assure you I was in the +|article| class! + \begin{verbatim} \normalcolor \addtocontents{toc}{\string\normalcolor} @@ -732,14 +916,15 @@ section, and made it appear in the |.toc| file. \end{verbatim} -\part{Package commands for global styles} +\section{A comparison} -We shall illustrate the package functionalities through -comparing here various line styles: the standard formatting as -provided by the |article| class, the custom line styles we -defined above using enumerate environments, and the package -line styles. +The \hyperref[toc:main]{main table of contents} was done in +the \etoc style. Let us issue here again two \toc commands, +one with the document class style (with some special +centered title in place of the standard Contents heading) and +the other one with the style we defined in the previous part +on the basis of enumerate environments. \begin{verbatim} \setcounter{secnumdepth}{4} @@ -749,21 +934,53 @@ line styles. \setcounter{secnumdepth}{4} \setcounter{tocdepth}{4} -\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape - \fbox{\parbox{.8\linewidth}{This is the - table of contents using enumerate environments for part, - section and subsection, and an in-line italic style for - subsubsections.}}} +Let us use the standard formatting of entries, as is +provided by the document class, and a two-column layout: +\begin{verbatim} +\etocstandardlines +\etocruledstyle{% 2 is the default number of columns + \renewcommand{\etoctoprule}{\hrule height0pt}% + \normalfont\normalsize\rmfamily\itshape + \parbox{.8\linewidth}{\centering + This is the global table of contents with standard + (to the {\ttfamily scrartcl} class) entries + (and on two columns). Contrarily to + \hyperref[toc:test]{\color{green!35!blue!75}the next TOC} + it contains paragraph entries.}} +\tableofcontents +\end{verbatim} + +\etocstandardlines + +\etocruledstyle{% +\renewcommand{\etoctoprule}{\hrule height0pt}% +\normalfont\normalsize\rmfamily\itshape +\parbox{.8\linewidth}{\centering + This is the global table of contents with standard + (to the {\ttfamily scrartcl} class) entries + (and on two columns). Contrarily to + \hyperref[toc:test]{\color{green!35!blue!75}the next TOC} it + contains paragraph entries.}} -First let us use again our set-up from the previous part. We add to it +\tableofcontents + +We then switch to our set-up from the previous part and add to it: \begin{verbatim} \etocsetstyle{part} -{\begin{enumerate}[label=\etocnumber,leftmargin=1em]} +{\begin{enumerate}[label=\etocnumber,leftmargin=1.5em]} {\etocfontminusone\item} {\etocname} {\end{enumerate}} +\tableofcontents \label{toc:test} \ref{toc:main} \end{verbatim} + +\etocruledstyle[2]{\normalfont\normalsize\rmfamily\itshape + \fbox{\parbox{.8\linewidth}{This is the global table of + contents using quickly defined (and easily improvable) + enumerate environments for part, section and subsection, + and an ad hoc in-line italic style for subsubsection.}}} + \etocsetstyle{part} {\begin{enumerate}[label=\etocnumber,leftmargin=1.5em]} {\etocfontminusone\item} @@ -772,101 +989,23 @@ First let us use again our set-up from the previous part. We add to it \tableofcontents \label{toc:test} \ref{toc:main} -Then we switch to the standard formatting of entries, as is -provided by the document class, but displayed here on two columns: -\begin{verbatim} -\etocstandardlines -\tableofcontents -\end{verbatim} - -\etocstandardlines - -\etocruledstyle[2]{% -\renewcommand{\etoctoprule}{\hrule height0pt}% -\normalfont\normalsize\rmfamily\itshape -\parbox{.8\linewidth}{\centering -This is the table of contents with standard - entries (on 2 columns!).\\ Contrarily to - \hyperref[toc:test]{\color{green!50!blue!50}the previous TOC} it - displays the paragraph entries.}} -\tableofcontents - -For the third example, we will use the starred variant -\tocstar to restrict its contents to this document part. -Furthermore we opt for a ``framed'' style, and specify some -colors (including a background color). We modify various -things from the package defaults. - -\etocetoclines - -\begingroup -\renewcommand{\etocinnerleftsep}{2ex} -\renewcommand{\etocinnerrightsep}{2ex} -% specify a background color for the toc contents -\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}} -% set up the top and bottom rules -\renewcommand{\etoctoprule}{\hrule height 1pt} -\renewcommand{\etoctoprulecolorcmd}{\color{red!25}} -\renewcommand{\etocbottomrule}{\hrule height 1pt} -\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}} -% set up the left and right rules -\renewcommand{\etocleftrule}{\vrule width 5pt} -\renewcommand{\etocrightrule}{\vrule width 5pt} -\renewcommand{\etocleftrulecolorcmd}{\color{red!25}} -\renewcommand{\etocrightrulecolorcmd}{\color{red!25}} -% use \fcolorbox to set up a colored frame for the title -\fboxrule1pt -\etocframedstyle{\normalsize\rmfamily\itshape - \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering - This is a table of contents \`a la \etoc, but just for - the sections and subsections in this part. As it is put - 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 -\tableofcontents* \label{toc:b} -\endgroup +\part{Package commands for global styles} +\label{part:globalcmds} -\begingroup -\baselineskip10pt -\footnotesize \begin{verbatim} -\etocetoclines -\begingroup % we use a group to limit the scope of the next commands -\renewcommand{\etocinnerleftsep}{2ex} -\renewcommand{\etocinnerrightsep}{2ex} -% specify a background color for the toc contents -\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}} -% set up the top and bottom rules -\renewcommand{\etoctoprule}{\hrule height 1pt} -\renewcommand{\etoctoprulecolorcmd}{\color{red!25}} -\renewcommand{\etocbottomrule}{\hrule height 1pt} -\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}} -% set up the left and right rules -\renewcommand{\etocleftrule}{\vrule width 5pt} -\renewcommand{\etocrightrule}{\vrule width 5pt} -\renewcommand{\etocleftrulecolorcmd}{\color{red!25}} -\renewcommand{\etocrightrulecolorcmd}{\color{red!25}} -% use \fcolorbox to set up a colored frame for the title -\fboxrule1pt -\etocframedstyle{\normalsize\rmfamily\itshape - \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering - This is a table of contents \`a la \etoc, but just for - the sections and subsections in this part. As it is put - 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 -\tableofcontents* \label{toc:b} -\endgroup +\setcounter{tocdepth}{-2} +\localtableofcontents \label{toc:globalcmds} \end{verbatim} -\endgroup +\setcounter{tocdepth}{-2} +\localtableofcontents \label{toc:globalcmds} \setcounter{tocdepth}{3} -\section{Specifying the global style} +\section{Specifying the toc display style} -The \emph{global} style says whether the TOC appears with +The \emph{toc display} style says whether the TOC appears with multiple columns or just one, whether the title is typeset as in the |article| or |book| class, or should be centered above the entries, with rules on its sides, or if the entire TOC @@ -875,27 +1014,29 @@ heading and single column layout, one issues commands of the following type: \begin{verbatim} \etocruledstyle[1]{Title} -\tableofcontents (or \tableofcontents*) -or the shortcuts: - \etocruled[1]{Title} or \etocruled*[1]{Title} + \tableofcontents (or \localtableofcontents) +shortcuts: + \etocruled[1]{Title} (or \localetocruled[1]{Title}) \end{verbatim} -\subsection{The command \csb{etocruledstyle}} +\subsection{The command \csbhyp{etocruledstyle}} -The general format of \csa{etocruledstyle} is:\\ -\centerline{\color{blue}\csa{etocruledstyle}% +The general format of \cs{etocruledstyle} is:\\ +\centerline{\color{blue}\cs{etocruledstyle}% \oarg{number of columns}\marg{title of the toc}} -\noindent Note that the title is horizontal material, if it does not fit on one -line it can be put in a \csa{parbox} of a given width. We did this and even -enclosed the parboxes in \csa{fbox}es to get frames around them. For the example -with the standard formatting we did not use an \csa{fbox} and got rid of the -horizontal rules via: +\noindent Note that the title is horizontal material, if it +does not fit on one line it should be put in a \cs{parbox} of +a given width. We did this and even enclosed the parboxes in +\cs{fbox}es to get frames around them. For the example with +the standard formatting we did not use an \cs{fbox} and got +rid of the horizontal rules via: \begin{verbatim} \renewcommand{\etoctoprule}{\hrule height 0pt} \end{verbatim} -The green frame for the heading of the \hyperref[toc:a]{% -\color{green!50!blue!50}table of contents at the - start of the second part of this document} was obtained with: +The green frame for the heading of the table of contents at +the \hyperref[toc:a]{% + \color{green!35!blue!75} start of the second part of this + document} was obtained with: \begin{verbatim} \etocruledstyle[1]{\etocfontminusone\color{green} \fboxrule1pt\fboxsep1ex @@ -904,43 +1045,54 @@ The green frame for the heading of the \hyperref[toc:a]{% \end{verbatim} -\subsection{The command \csb{etocmulticolstyle}} +\subsection{The command \csbhyp{etocmulticolstyle}} This is also a command with one optional and one mandatory argument:\\ -\centerline{\color{blue}\csa{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}} -The \oarg{number\_of\_columns} can go from 1 to 10 (it defaults to 2, and from 2 -on is passed to a |multicols| environment). The \marg{heading} can be something like: +\centerline{\color{blue}\cs{etocmulticolstyle}% +\oarg{number\_of\_columns}\marg{heading}} +The \meta{number\_of\_columns} can go from 1 to 10 (it +defaults to 2, and from 2 on is passed to a |multicols| +environment). The \meta{heading} should be some `vertical' material like: \begin{center} - {\ttfamily\string\chapter\lowast}\marg{title},\\ - or\\ -\csa{etocstandardheading}\marg{title},\\ -or\\ - \csa{etocstandardheadingnomarks}\marg{title}. + \meta{heading} = {\ttfamily\string\section\lowast}\marg{title} \end{center} -These last two commands do either \starit{section} or -\starit{chapter} depending on the document class, and the -first one puts the marks for the page headings. To emulate the -standard formatting one can thus use:\\ -\centerline{\ttfamily\string\etocmulticolstyle[1]\string{% -\string\etocstandardheading\string{\string\contentsname\string}\string}} -After such a command, future \csa{tableofcontents} will use the +After such a command, future \cs{tableofcontents} will use the specified style. A shortcut for just one table of contents and not affecting the styles of later TOCs is:\\ -\centerline{\csa{etocmulticol}\oarg{number\_of\_columns}\marg{heading}} -And the starred form will be -\starit{etocmulticol}\oarg{number\_of\_columns}\marg{heading}. +\centerline{\cs{etocmulticol}\oarg{number\_of\_columns}\marg{heading}} +And there is also +\cs{localetocmulticol}\oarg{number\_of\_columns}\marg{heading}. + + +\subsubsection{The command \csbhyp{etoctocstyle}} + +\centerline{\color{blue}\cs{etoctocstyle}\oarg{kind}% +\marg{number\_of\_columns}\marg{title}} +\hbox to \linewidth{\hss= +\cs{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|% +|{\kind*{|\itshape title\upshape|}}|\hss} +where |kind| is one of |chapter|, |section|, . . . and defaults +to |chapter| or |section| depending on the document class. -\subsubsection{A point of some importance} +\paragraph{\texorpdfstring{\csb{etoc\-toc\-style\-with\-marks}}{etoctocstylewithmarks}}% +\leavevmode\unskip{\color{blue}\oarg{kind}\marg{number\_of\_columns}\marg{title}\marg{mark}}\\ +\hbox to \linewidth +{\hss=\cs{etocmulticolstyle}|[|{\itshape number\_of\_columns}|]|% +|{\kind*{|\itshape title \ttfamily\upshape\string\markboth% +|{\MakeUppercase{|{\rmfamily\itshape mark}|}}}}|\hss} +where |kind| is one of |chapter|, |section|, ... The +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 -\csa{etocmulticolstyle} and \csa{etocruledstyle} commands. The +\cs{etocmulticolstyle} and \cs{etocruledstyle} commands. The mandatory argument of the former can not be just some -\emph{naked text}. It should rather be something like -|\hbox{naked text}| or |\vbox{naked text}|. -% -More conveniently, one can use things such as:\\ -\hbox to \linewidth{\hss |\section*{some not so naked text}|\hss} -Else, you will get an error:\\ +\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 @@ -949,160 +1101,292 @@ it is possible to feed it with `|naked text\par|'. On the other hand, it is exactly the \emph{opposite} for -\csa{etocruledstyle} which expects things which fit inside a -horizontal box, hence it will gladly accepts a \emph{naked - text} as argument, but will choke on things such as \cs{par}. - +\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?} \paragraph{really?} -\subsection{The command \csb{etocruledstyle} (cont.)} - +\subsection{The command \csbhyp{etocruled}} -As a shortcut to set the style with this command and then make a -\csa{tableofcontents} or \tocstar call (in a group, so that the -style for future table of contents is not affected) we have: \\ +As a shortcut to set the style and issue a +\cs{tableofcontents}, all inside a group +so that future table of contents will not be +affected, there is:\\ \centerline{\csb{etocruled}\oarg{number\_of\_columns}\marg{title}} -And the starred form will be with \staritb{etocruled}. +And the local form will be \csb{localetocruled}. -\subsection{The command \csb{etocframedstyle}} +\subsection{The commands \csbhyp{etocframedstyle} and \csbhyp{etocframed}} Same mechanism:\\ -\centerline{\color{blue}\csa{etocframedstyle}\oarg{number\_of\_columns}\marg{title}} +\centerline{\color{blue}\cs{etocframedstyle}% + \oarg{number\_of\_columns}\marg{title}} and the accompanying shortcut:\\ \centerline{\csb{etocframed}\oarg{number\_of\_columns}\marg{title}} Here the entire table of contents is framed, hence this can only work if it fits on a page. Note that the title itself is -not framed, if one wants a frame one should use the commands inside the argument to \cs{etocframedstyle} or \cs{etocframed}. The starred -variant for the shortcut again begins with \staritb{etocframed}. +not framed, if one wants a frame one should set it up +inside the \meta{title} argument to \cs{etocframedstyle} or +\cs{etocframed}. There is also \cs{local\-etocframedstyle} and +\cs{localetocframed}. -\subsection{The command \csb{etocsettocstyle}} +\subsection{The command \csbhyp{etocsettocstyle}} This is a command with two mandatory arguments:\\ -\centerline{\color{blue}\csa{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}} +\centerline{\color{blue}\cs{etocsettocstyle}\marg{before\_toc}% +\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 -instructions to mark the page headings.\footnote{\etoc - provides the command \csa{etocmarkboth}\oarg{optional\_name}, with an - optional argument which defaults to \csa{contentsname}.} Or +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 -would then reenact the two-column mode.\footnote{In our - testing, we had some difficulties, when using the |multicol| - package in a book class document with the two-column global - option. So, as we use |multicol| by default we decided - against trying to automatize a check for such a possible - |twocolumn| class option. It is up to the user to decide (or - not) to switch back and forth from two-column to one-column - when typesetting table of contents.} - -The three commands \csa{etocmulticolstyle}, \csa{etocruledstyle}, and -\csa{etocframedstyle} actually call \csa{etocsettocstyle} as a -lower-level routine. - -\section{Summary of the main local and global style - commands} +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. + +\subsection{The compatibility mode \csbhyp{etocstandarddisplaystyle}} + +\etoc will then emulate what the document class would have +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} + etc... commands} + +The \toc, \localtoc, \cs{etocmulticol}, etc... have starred +variants (the star must be before the other arguments). For +all but the |memoir| class, they are like the original. For +the |memoir| class, the original prints an entry in the |.toc| +file, as is the usage for the original \toc command in that +class, whereas the starred variants do not, as is the habit in +that class. + +To customize what is written to the |.toc| file by the +non-starred variants there is the command +\csb{etocmemoirtoctotocfmt}\marg{kind}\marg{name}, where +\meta{kind} is |chapter|, or |section|, ... and \meta{name} +can be for example \cs{contentsname}. The default is |chapter| +and |\contentsname|. + +Note though that this concerns only what is written to the +|.toc| file: the unstarred commands have an interest only if +the heading of the TOC was typeset using a suitable +\emph{unnumbered} division command (\emph{e.g.} using +\cs{etoctocstyle}), which should be chosen by the user to be +identical to the \meta{kind} argument above. In compatibility +mode for the global style, the |memoir| class will use a +Chapter like heading if the user has not customized it to do +otherwise: this will not fit well with local table of contents in +sections, and even chapters. + +Generally speaking there is hook macro called +\csb{etocaftertitlehook} which is defined initially to do +nothing, except for the |memoir| class for which it does the +above, and which is inhibited by using the starred variants of +the displaying commands. + +\section{Table of contents for part \ref{part:globalcmds}} + +As a third example we now print the local table of contents +for this part. We 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}. + +\begingroup +\baselineskip10pt +\footnotesize +\begin{verbatim} +\etoctoclines +\begingroup % we use a group to limit the scope of the next commands +\renewcommand{\etoccolumnsep}{3em} +\renewcommand{\etocinnerleftsep}{2em} +\renewcommand{\etocinnerrightsep}{2em} +% specify a background color for the toc contents +\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}} +%\renewcommand{\etocbkgcolorcmd}{\relax} +% set up the top and bottom rules +\renewcommand{\etoctoprule}{\hrule height 1pt} +\renewcommand{\etoctoprulecolorcmd}{\color{red!25}} +\renewcommand{\etocbottomrule}{\hrule height 1pt} +\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}} +% set up the left and right rules +\renewcommand{\etocleftrule}{\vrule width 5pt} +\renewcommand{\etocrightrule}{\vrule width 5pt} +\renewcommand{\etocleftrulecolorcmd}{\color{red!25}} +\renewcommand{\etocrightrulecolorcmd}{\color{red!25}} +% use \fcolorbox to set up a colored frame for the title +\fboxrule1pt +\etocframedstyle{\normalsize\rmfamily\itshape + \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering + This is a table of contents \`a la \etoc, but just for + the sections and subsections in this part. As it is put + 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 +\tableofcontents \label{toc:b} \ref{toc:globalcmds} +\endgroup +\end{verbatim} +\endgroup + +\etoctoclines +\begingroup +\renewcommand{\etoccolumnsep}{3em} +\renewcommand{\etocinnerleftsep}{2em} +\renewcommand{\etocinnerrightsep}{2em} +% specify a background color for the toc contents +\renewcommand{\etocbkgcolorcmd}{\color{yellow!10}} +% set up the top and bottom rules +\renewcommand{\etoctoprule}{\hrule height 1pt} +\renewcommand{\etoctoprulecolorcmd}{\color{red!25}} +\renewcommand{\etocbottomrule}{\hrule height 1pt} +\renewcommand{\etocbottomrulecolorcmd}{\color{red!25}} +% set up the left and right rules +\renewcommand{\etocleftrule}{\vrule width 5pt} +\renewcommand{\etocrightrule}{\vrule width 5pt} +\renewcommand{\etocleftrulecolorcmd}{\color{red!25}} +\renewcommand{\etocrightrulecolorcmd}{\color{red!25}} +% use \fcolorbox to set up a colored frame for the title +\fboxrule1pt +\etocframedstyle{\normalsize\rmfamily\itshape + \fcolorbox{red}{white}{\parbox{.8\linewidth}{\centering + This is a table of contents \`a la \etoc, but just for + the sections and subsections in this part. As it is put + 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 +\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} + + +\etoctoclines +\renewcommand{\etoctoprule}{\hrule height2pt depth0pt} +\renewcommand{\etoctoprulecolorcmd}{\color{red}} + +\etocruledstyle{\normalfont\normalsize\rmfamily\fboxrule1pt\color{red}% + \fbox{\parbox{.8\linewidth}{\centering\normalcolor This is a table of + contents for the sections and + subsections in this part. It carries the label |toc:c|}}} + +\localtableofcontents* \label{toc:c} + + +\section{Summary of the main style commands} \subsection{Setting up local styles} \hbox{\color{green}\fboxrule1pt\fboxsep1em -\setbox0\hbox{\csa{etocname}, \csa{etocnumber}, \csa{etocpage}, -\csa{etocifnumbered}\marg{A}\marg{B}}% +\setbox0\hbox{\cs{etocname}, \cs{etocnumber}, \cs{etocpage}, +\cs{etocifnumbered}\marg{A}\marg{B}}% \framebox[\linewidth][c] {\vbox{\hsize\wd0\normalcolor\noindent -\csa{etocsetstyle}\marg{levelname}% +\cs{etocsetstyle}\marg{levelname}% \marg{start}\marg{prefix}\marg{contents}\marg{finish}\\ -\csa{etocname}, \csa{etocnumber}, \csa{etocpage}, -\csa{etocifnumbered}\marg{A}\marg{B}% +\cs{etocname}, \cs{etocnumber}, \cs{etocpage}, +\cs{etocifnumbered}\marg{A}\marg{B}% }}} \subsection{Setting up global styles} \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em -\setbox0\hbox{\csa{etocname}, \csa{etocnumber}, \csa{etocpage}, -\csa{etocifnumbered}\marg{A}\marg{B}}% +\setbox0\hbox{\cs{etoctocstylewithmarksnouc}\oarg{kind}% +\marg{number\_of\_columns}\marg{title}\marg{mark}}% \framebox[\linewidth][c] -{\vbox{\hsize\wd0\normalcolor\noindent -\csa{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}\\ -\csa{etocruledstyle}\oarg{number\_of\_columns}\marg{title}\\ -\csa{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\ -\csa{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}}} +{\vbox{\hsize\wd0 +\normalcolor\noindent +\cs{etocmulticolstyle}\oarg{number\_of\_columns}\marg{heading}\\ +\cs{etoctocstyle}\oarg{kind}\marg{number\_of\_columns}\marg{title}\\ +\cs{etoctocstylewithmarks}\oarg{kind}\marg{number\_of\_columns}% +\marg{title}\marg{mark}\\ +\cs{etoctocstylewithmarksnouc}\oarg{kind}\marg{number\_of\_columns}% +\marg{title}\marg{mark}\\ +\cs{etocruledstyle}\oarg{number\_of\_columns}\marg{title}\\ +\cs{etocframedstyle}\oarg{number\_of\_columns}\marg{title}\\ +\cs{etocsettocstyle}\marg{before\_toc}\marg{after\_toc}}}} \subsection{Displaying Tables of Contents} \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em - \setbox0\hbox{\csa{etocname}, \csa{etocnumber}, - \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}% + \setbox0\hbox{\cs{etocname}, \cs{etocnumber}, + \cs{etocpage}, \cs{etocifnumbered}\marg{A}\marg{B}}% \framebox[\linewidth][c] {\vbox{\hsize\wd0\normalcolor\noindent \toc\\ - \tocstar\\ - \csa{etocmulticol}\oarg{number\_of\_columns}\marg{heading}\\ - \csa{etocmulticol}\lowast\oarg{number\_of\_columns}\marg{heading}\\ - \csa{etocruled}\oarg{number\_of\_columns}\marg{title}\\ - \csa{etocruled}\lowast\oarg{number\_of\_columns}\marg{title}\\ - \csa{etocframed}\oarg{number\_of\_columns}\marg{title}\\ - \csa{etocframed}\lowast\oarg{number\_of\_columns}\marg{title}% + \localtoc\\ + \cs{etocmulticol}\oarg{number\_of\_columns}\marg{heading}\\ + \cs{localetocmulticol}\oarg{number\_of\_columns}\marg{heading}\\ + \cs{etocruled}\oarg{number\_of\_columns}\marg{title}\\ + \cs{localetocruled}\oarg{number\_of\_columns}\marg{title}\\ + \cs{etocframed}\oarg{number\_of\_columns}\marg{title}\\ + \cs{localetocframed}\oarg{number\_of\_columns}\marg{title}\\ + \hbox{}{\itshape\ttfamily\ \ \ \ and their starred variants} }}} \subsection{Labels and references} -The commands to actually display the table of contents +The commands (starred or not) to actually display the table of contents can be followed with optional labels or references:\par \medskip \hbox{\color{green}\fboxrule1pt\fboxsep1em - \setbox0\hbox{\csa{etocname}, \csa{etocnumber}, - \csa{etocpage}, \csa{etocifnumbered}\marg{A}\marg{B}}% + \setbox0\hbox{\cs{etocname}, \cs{etocnumber}, + \cs{etocpage}, \cs{etocifnumbered}\marg{A}\marg{B}}% \framebox[\linewidth][c] {\vbox{\hsize\wd0\normalcolor\noindent - \toc\\ \toc \cs{label}|\{toc:here\}|\\ \toc \cs{ref}|\{toc:far\}| \\ \toc \cs{label}|\{toc:here\}| \cs{ref}|\{toc:far\}| \\ - \tocstar\\ - \tocstar \cs{label}|\{toc:here\}| + \localtoc \cs{label}|\{toc:here\}|\\ + \hbox{}{\itshape\ttfamily\ \ \ \ similarly with\ }% + \cs{etocmulticol}{\itshape\ttfamily\ etc . . . } }}} -\medskip The starred form displaying a local table of -contents, it will not react to a \cs{ref} following it. When +\medskip The local table of +contents does not react to a \cs{ref} following it. When re-displaying another toc, only its contents are transferred: both the line styles and the global style are the ones currently defined, not the ones from the cloned toc. -The shortcuts for setting up and using in one go the multicol, -ruled, and framed global styles can be followed in the -similar manner by a label and/or a reference. - +\subsection{An example design} -% The command \csb{etocref} when given a label |toc:x| as -% argument produces the number of the corresponding TOC: -% \emph{i.e.} 1 for the first in the document etc... this is the -% same information as in \cs{ref}|{toc:x}| or \cs{ref*}|{toc:x}| -% but without any hyperlink or other extraneous data. It is -% mainly used internally by \etoc, but can be used as a perhaps -% more robust command than \cs{ref} or \cs{ref*} when -% typesetting the number of the TOC. -\subsection{Example of a cloned local TOC} - - -We try out |\tableofcontents \ref{toc:b}|. -First we have to specify the design. -I got motivated by a +I got motivated by a question\footnote{\href{http://tex.stackexchange.com/questions/83184/how-to-change-style-and-color-of-table-of-content}{tex.stackexchange.com/questions/83184}} I saw on the \TeX{} StackExchange site. I copied the color RGB specifications from an answer which had been provided to the -question. The \cs{etocframedstyle} puts the title -on the top rule in a centered position. This is not very -convenient for this example so we included the title as part of the +question. The \cs{etocframedstyle} puts the title on the top +rule in a centered position. This is not very convenient for +this example so we included the title as part of the \meta{start} code at section level, to get it \emph{inside} -the frame. +the frame. \begingroup \baselineskip10pt @@ -1120,7 +1404,7 @@ the frame. \renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}} \renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}} -\renewcommand{\etocleftrule}{\vrule width 1.5cm} +\renewcommand{\etocleftrule}{\vrule width 1cm} \renewcommand{\etocrightrule}{\vrule width .5cm} \renewcommand{\etocbottomrule}{\hrule height 12pt} \renewcommand{\etoctoprule}{\hrule height 12pt} @@ -1164,7 +1448,7 @@ the frame. \par\nointerlineskip} \etocsetstyle{section}{\coloredstuff{white} - {\hfil \hyperref[toc:b]{\bfseries\large I am a clone of + {\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}% @@ -1172,11 +1456,23 @@ the frame. \vskip6pt} {} \etocframedstyle[1]{} % title is not there! -\tableofcontents \label{toc:clone} \ref{toc:b} +\tableofcontents \label{toc:clone} \ref{toc:globalcmds} \endgroup \end{verbatim} \endgroup + +The coding is a bit involved 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 +color) can only deal with material short enough to fit on one +page. + +Regarding colors, generally speaking all color commands inside +\etoc are initially defined to do nothing, and the choice to +use or not colors is left to the user. + \setcounter{tocdepth}{3} \begingroup @@ -1190,7 +1486,7 @@ the frame. \renewcommand{\etocbottomrulecolorcmd}{\color{tocbackground}} \renewcommand{\etoctoprulecolorcmd}{\color{tocbackground}} -\renewcommand{\etocleftrule}{\vrule width 1.5cm} +\renewcommand{\etocleftrule}{\vrule width 1cm} \renewcommand{\etocrightrule}{\vrule width .5cm} \renewcommand{\etocbottomrule}{\hrule height 12pt} \renewcommand{\etoctoprule}{\hrule height 12pt} @@ -1240,7 +1536,7 @@ the frame. \par\nointerlineskip} \etocsetstyle{section}{\coloredstuff{white} - {\hfil \hyperref[toc:b]{\bfseries\large I am a clone of + {\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}% @@ -1250,42 +1546,24 @@ the frame. \etocframedstyle[1]{} -\tableofcontents \label{toc:clone} \ref{toc:b} +\tableofcontents \label{toc:clone} \ref{toc:globalcmds} \endgroup -The coding is a bit involved as it does not use any additional -package. The framed style allowed us to specify a background -color. Generally speaking all color commands inside \etoc are -initially defined to do nothing, so the choice to use or not -color packages is left to the user. - - - -\part{Customizing \etoc} -\label{part:custom} - - -\etocetoclines -\renewcommand{\etoctoprule}{\hrule height2pt depth0pt} -\renewcommand{\etoctoprulecolorcmd}{\color{red}} - -\etocruledstyle{\normalfont\normalsize\rmfamily\fboxrule1pt\color{red}% - \fbox{\parbox{.8\linewidth}{\centering\normalcolor This is a table of - contents for the sections and - subsections in this part. It carries the label |toc:c|}}} +\section{Customizing \etoc} -\tableofcontents* \label{toc:c} -\section{Customizing the \etoc line styles} +\subsection{Customizing the \etoc line styles} -We will simply list the relevant commands as defined in the package. Customizing -them goes through suitable \csa{renewcommand}s: +We will simply list the relevant commands as defined in the +package. Customizing them goes through suitable +\cs{renewcommand}s: \begin{verbatim} +\newcommand\etocfontminustwo{\normalfont \LARGE \bfseries} \newcommand\etocfontminusone{\normalfont \large \bfseries} \newcommand\etocfontzero{\normalfont \normalsize \bfseries} \newcommand\etocfontone{\normalfont \normalsize \bfseries} @@ -1294,13 +1572,19 @@ them goes through suitable \csa{renewcommand}s: \newcommand\etocfontfour{\normalfont \footnotesize} \newcommand\etocfontfive{\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\etocminusonelrmargins{1em} +\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} @@ -1311,29 +1595,41 @@ them goes through suitable \csa{renewcommand}s: {\hbox{\normalfont\normalsize\hbox to 2ex {\hss.\hss}}} \newcommand\etocabbrevpagename{p.~} +\newcommand\etocpartname{\partname} +\newcommand\etocbookname{Book} \end{verbatim} No customizing of the standard line styles is possible from within \etoc. As already explained, when -\csa{etocstandardlines} has been issued, the package just makes +\cs{etocstandardlines} has been issued, the package just makes itself very discrete and acts only at the global level, and the TOC entries are (hopefully) formatted as would have -happened in the absence of \etoc. In this mode the -\csa{etocsetstyle} commands will have an effect only after the -document encounters again an \csa{etocetoclines} command. +happened in the absence of \etoc.\footnote{with the + KOMA-script classes, we noticed that + \cs{etocstandarddisplaystyle} was apparently needed for the + KOMA options |toc=left| to be active at the level of the line entries.} + -The \csa{etocstandardlines} mechanism will work also with -sectioning commands made known to \etoc via \csa{etocsetlevel}, +The \cs{etocstandardlines} mechanism will work also with +sectioning commands made known to \etoc via \cs{etocsetlevel}, under the condition of course that these sectioning commands are accompanied with all the relevant definitions for typesetting toc entries in the \LaTeX{} default manner -(existence of the macros \csa{l@something} . . .). +(existence of the macros \cs{l@something} . . .). -\section{Customizing the global styles} +Using the \cs{etoctoclines} (obviously) or even just one +\cs{etocsetstyle} command turns off the compatibility mode +(all of this obey the scoping mecanism of \TeX/\LaTeX{} groups). +\subsection{Customizing the global styles} -Again we list the relevant macros, what they do should be legible from their -names: + +Again we list the relevant macros, what they do should be +legible from their names. Note that \cs{renewcommand}'s and +not \cs{setlength}'s have to be used for what appear to be +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} @@ -1342,9 +1638,8 @@ names: \newcommand\etocmulticolsep{0ex} \newcommand\etocmulticolpretolerance{-1} \newcommand\etocmulticoltolerance{200} - +\newcommand\etocdefaultnbcol{2} \newcommand\etocinnertopsep{2ex} - \newcommand\etoctoprule{\hrule} \newcommand\etoctoprulecolorcmd{\relax} @@ -1356,38 +1651,38 @@ names: \newcommand\etocleftrule{\vrule} \newcommand\etocrightrule{\vrule} \newcommand\etocbottomrule{\hrule} - \newcommand\etocleftrulecolorcmd{\relax} \newcommand\etocrightrulecolorcmd{\relax} \newcommand\etocbottomrulecolorcmd{\relax} \newcommand\etocbkgcolorcmd{\relax} +% hooks \newcommand\etocframedmphook{\relax} +\newcommand\etocaftertitlehook{\relax} \end{verbatim} -This last command is a hook, it is positioned immediately +\cs{etocaftertitlehook} was commented upon before, and +\cs{etocframedmphook} is positioned immediately after the beginning of a minipage environment where the contents of the framed TOC are typeset. The \cs{...colorcmd} things are initially set to be \cs{relax}, so there is no need to do \cs{usepackage}|{color}| -if the document does not use colors. Note that they should -evaluate to something like `\cs{color}|{green}|' and not just -`|green|'. If the scope of a change to the background color -command \cs{etocbkgcolorcmd} has not been limited to a group -and one then wishes to let it again be \cs{relax} one must use -a \cs{renewcommand} and not +if the document does not use colors. If the scope of a change +to a color command such as \cs{etocbkgcolorcmd} has not +been limited to a group and one then wishes to let it again be +\cs{relax} one must use a \cs{renewcommand} and not \cs{let}\cs{etocbkgcolorcmd}\cs{relax}. Regarding the dimensions of the top rule they can be specified -in |ex|'s or |em|'s as for example:\\ +in |ex|'s or |em|'s as in this example:\\ \hbox to \linewidth{\hss |\renewcommand{\etoctoprule}{\hrule height 1ex}|\hss} The package code is done in such a manner that it is the font size in instance at the end of typesetting -the title argument to \csa{etocruledtoc} or -\csa{etocframedtoc} which will be used for the meaning of the +the title argument to \cs{etocruledtoc} or +\cs{etocframedtoc} which will be used for the meaning of the `1ex'. Of course also the other rule commands can have their dimensions in font relative units, but their values are decided on the basis of the font in effect just before the @@ -1400,6 +1695,10 @@ used as (horizontal) leaders but as objects of a given specified width. Note that \emph{only} the Plain \TeX{} syntax for rules is accepted here. +\part{Tips} + +\section{... and tricks} + \subsection{Hacking framed parboxes} @@ -1411,10 +1710,9 @@ accepted here. {\normalfont This text is perfectly centered vertically with respect to the surrounding horizontal rules.}}}} -\ref{toc:b} +\ref{toc:globalcmds} \end{verbatim} -\clearpage \renewcommand\etoctoprule{\hrule height 2pt depth 2pt} \etocruled{\color{green}\fboxrule2pt\fboxsep1ex @@ -1423,7 +1721,7 @@ accepted here. {\normalfont This text is perfectly centered vertically with respect to the surrounding horizontal rules.}}}} - \ref{toc:b} + \ref{toc:globalcmds} \subsection{Interverting the levels} @@ -1440,74 +1738,128 @@ label=,leftmargin=0pt]} {\end{enumerate}} \renewcommand{\etoccolumnsep}{2.75em} \renewcommand{\columnseprule}{1pt} +\etocmarkbothnouc{List of all subsections} \etocmulticol[3]{\subsection{All subsections of this document}} \end{verbatim} \setcounter{tocdepth}{2} \begingroup +\etoctoclines +\etocstandarddisplaystyle +\etocsetlevel{book}{3} \etocsetlevel{part}{3} +\etocsetlevel{chapter}{3} \etocsetlevel{section}{3} \etocsetstyle{subsection}{% \begin{enumerate}[itemsep=0pt,label=,leftmargin=0pt]} {\normalfont\bfseries\item} {\roman{enumi}. \normalfont\etocname (\etocnumber, p.~\etocpage)} {\end{enumerate}} + \renewcommand{\etoccolumnsep}{2.75em} \renewcommand{\columnseprule}{1pt} +\etocmarkbothnouc{List of all subsections} \etocmulticol[3]{\subsection{All subsections of this document}} - \endgroup \subsection{Compatibility with other packages} \etoc uses the packages |multicol| and |xspace|. It is -|hyperref| aware and hopefully |hyperref| compatible! +|hyperref| aware and hopefully |hyperref| compatible! It +doesn't matter whether \etoc or |hyperref| is loaded first. The -macros \csa{etocname}, \csa{etocnumber}, and \csa{etocpage} +macros \cs{etocname}, \cs{etocnumber}, and \cs{etocpage} contain the |hyperref| links, 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 table of contents of the present document are fully linked. -\etoc has not been tested with other packages than those -cited. It has been tested to work as expected with the -|article|, |book| and |scrartcl| document classes. - - +The contents of the |.toc| file are read into memory by \etoc +once, at the \cs{begin\{document\}} (and not at the first +\toc). The input stream opened by \etoc for reading is then +closed but the |.toc| file is of course left opened for write +operations, with the exact same instructions as used by the +standard \LaTeX{} classes. + +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. This is the only kind of +data written by \etoc to the |.toc| file (of course it does +mean that if you remove usage of \etoc from the document, you +should trash the |.toc| file). The correct local table of +contents will be displayed only on the next |latex| run. + +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. If these macros are redefined after the +\cs{begin\{document\}} then \etoc will fail. However if they +are defined before and \etoc is instructed of their level by +commands such as \cs{etocsetlevel\{kind\}\{2\}} then +\cs{etocstandardlines} should be functional. You may customize +the standard styles throughout the document (with |tocloft| +for example) and \etoc should respond in compatibility mode as +expected. \subsection{\TeX nical matters} -The \csa{etocname}, \csa{etocnumber}, \csa{etocpage} and -\csa{etocifnumbered} macros are protected against premature -expansion. The macro \csa{etocsetstyle}, as well as -\csa{etocsetlevel} and the global style commands -\csa{etocmulticolstyle}, \csa{etocruledstyle} and -\csa{etocframedstyle} obey \LaTeX{}'s groups. - +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. + +When using multiple \toc commands in a document, one should +beware from adding typesetting instructions directly in the +|.toc| file, as they will be executed by \etoc for all TOCs: +even for a \localtoc it doesn't matter if that instruction +seems to concern material outside of its scope, it will get +executed nevertheless. If absolutely necessary these +instructions should be done in such a way that they can +be activated or deactivated easily from the document source, +as need be. \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. + 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{i.e.} after having removed the use of package -|hyperref| from the document), one must trash the previous -|.aux| and |.toc| files. +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). -\part{The code} +\part{The code} -This source file |etoc.dtx| produces the package file +This source file |etoc.dtx| produces |etoc.sty| when one does |latex etoc.dtx| or |pdflatex etoc.dtx| (an |etoc.ins| file is also produced, for distributions expecting it for installation). Two more runs are necessary to finish producing the documentation. The |etoc.sty| file should be moved to a suitable location within -the \TeX{} distribution. +the \TeX{} installation. \section{Implementation} @@ -1564,6 +1916,7 @@ release. % placeholder for comments % \begin{macrocode} \newtoks\Etoc@toctoks +\newif\ifEtoc@jj % book \newif\ifEtoc@j % part \newif\ifEtoc@ % chapter \newif\ifEtoc@i % section @@ -1573,7 +1926,7 @@ release. \newif\ifEtoc@v % subparagraph \newif\ifEtoc@number \newif\ifEtoc@hyperref -\newif\ifEtoc@star +\newif\ifEtoc@tocwithid \newif\ifEtoc@standard \newif\ifEtoc@part % \end{macrocode} @@ -1588,15 +1941,18 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} +\@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@@four@@4\relax -\chardef\Etoc@@five@@5\relax -\chardef\Etoc@@six@@6\relax -\let\Etoc@localtop\m@ne +\chardef\Etoc@@four@@ 4 +\chardef\Etoc@@five@@ 5 +\chardef\Etoc@@six@@ 6 +\let\Etoc@localtop\Etoc@@minustwo@@ +\def\Etoc@@minustwo@{minustwo} \def\Etoc@@minusone@{minusone} \def\Etoc@@zero@{zero} \def\Etoc@@one@{one} @@ -1622,13 +1978,14 @@ release. \Etoc@Lazarus@eltb#2}} \def\etocsetlevel#1#2{% \let\Etoc@next\@firstofone - \ifcase#2\or\or\or\or\or\else\ifnum#2=\m@ne\else + \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 -1, 0, 1, 2, 3, 4 or 5. Set to -1}% + 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 + \let\Etoc@next\@gobble\fi\fi\fi \if@noskipsec \else \expandafter\expandafter\expandafter @@ -1659,9 +2016,15 @@ release. \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@ \expandafter\def \csname Etoc@#1@\endcsname{five}% \else + \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@@minustwo@@ + \expandafter\def \csname Etoc@#1@\endcsname{minustwo}% + \fi \fi}} +\etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} \etocsetlevel{section}{1} @@ -1726,6 +2089,7 @@ release. \or \global\Etoc@vtrue \else + \ifnum#1=\m@ne \global\Etoc@vfalse \global\Etoc@ivfalse \global\Etoc@iiifalse @@ -1733,6 +2097,16 @@ release. \global\Etoc@ifalse \global\Etoc@false \global\Etoc@jtrue + \else + \global\Etoc@vfalse + \global\Etoc@ivfalse + \global\Etoc@iiifalse + \global\Etoc@iifalse + \global\Etoc@ifalse + \global\Etoc@false + \global\Etoc@jfalse + \global\Etoc@jjtrue + \fi \fi} % \end{macrocode} % placeholder for comments @@ -1804,6 +2178,7 @@ release. \gdef\Etoc@contents{\Etoc@contents@five}% \gdef\Etoc@prefix{\Etoc@prefix@five}% \else + \ifnum\Etoc@tmp=\m@ne \ifEtoc@v \Etoc@end@five\fi \ifEtoc@iv \Etoc@end@four\fi \ifEtoc@iii \Etoc@end@three\fi @@ -1814,6 +2189,18 @@ release. \global\Etoc@parttrue \gdef\Etoc@contents{\Etoc@contents@minusone}% \gdef\Etoc@prefix{\Etoc@prefix@minusone}% + \else + \ifEtoc@v \Etoc@end@five\fi + \ifEtoc@iv \Etoc@end@four\fi + \ifEtoc@iii \Etoc@end@three\fi + \ifEtoc@ii \Etoc@end@two\fi + \ifEtoc@i \Etoc@end@one\fi + \ifEtoc@ \Etoc@end@zero\fi + \ifEtoc@j \Etoc@end@minusone\fi + \ifEtoc@jj \else \def\Etoc@next{\Etoc@begin@minustwo}\fi + \gdef\Etoc@contents{\Etoc@contents@minustwo}% + \gdef\Etoc@prefix{\Etoc@prefix@minustwo}% + \fi \fi \Etoc@setflags{\Etoc@tmp}% \fi\fi @@ -1873,7 +2260,7 @@ release. % \begin{macrocode} \def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@{% \def\Etoc@getname ##1\hspace\relax\etoc@{% - \global\@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5}\xspace}% + \global\@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5\xspace}}% \def\Etoc@getnbr ##1\hspace##2##3\etoc@{% \ifx\relax##2\else \global\@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% @@ -1919,7 +2306,6 @@ release. \def\Etoc@starttoc{% \begingroup \makeatletter -\chardef\ET@endline\endlinechar \@ifpackageloaded{hyperref} {\ifx\hyper@last\@undefined \ltx@ifpackageloaded {parskip}{\parskip \z@ }{}% @@ -1933,10 +2319,9 @@ release. \Etoc@readtoc\Etoc@tf \closein\Etoc@tf} {\typeout{No file \jobname .toc.}}}% -\endlinechar\ET@endline \if@filesw \newwrite \tf@toc \immediate \openout \tf@toc \jobname .toc\relax \fi -\endgroup} +\@nobreakfalse \endgroup} % \end{macrocode} % placeholder for comments % \begin{macrocode} @@ -1949,17 +2334,22 @@ release. \global\Etoc@ifalse \global\Etoc@false \global\Etoc@jfalse + \global\Etoc@jjfalse \ifEtoc@standard \Etoc@Lazarus -\etocsetstyle{@minusone}{}{}{}{}% -\etocsetstyle{@zero}{}{}{}{}% -\etocsetstyle{@one}{}{}{}{}% -\etocsetstyle{@two}{}{}{}{}% -\etocsetstyle{@three}{}{}{}{}% -\etocsetstyle{@four}{}{}{}{}% -\etocsetstyle{@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 -\let\numberline\@gobble +\let\numberline\@gobble +\let\booknumberline\numberline +\let\partnumberline\numberline +\let\chapternumberline\numberline \fi \the\Etoc@toctoks \ifEtoc@notactive\else @@ -1970,6 +2360,7 @@ release. \ifEtoc@i \Etoc@end@one\fi \ifEtoc@ \Etoc@end@zero\fi \ifEtoc@j \Etoc@end@minusone\fi + \ifEtoc@jj \Etoc@end@minustwo\fi \fi} % \end{macrocode} % placeholder for comments @@ -1979,6 +2370,7 @@ release. \ifEtoc@localtoc \ifEtoc@notactive \ifnum #1=#2\relax + \ifEtoc@jj \global\let\Etoc@localtop\Etoc@@minusone@@ \fi \ifEtoc@j \global\let\Etoc@localtop\Etoc@@zero@@ \fi \ifEtoc@ \global\let\Etoc@localtop\Etoc@@one@@ \fi \ifEtoc@i \global\let\Etoc@localtop\Etoc@@two@@ \fi @@ -1993,7 +2385,8 @@ release. \global\Etoc@iifalse \global\Etoc@ifalse \global\Etoc@false - \global\Etoc@jfalse}% + \global\Etoc@jfalse + \global\Etoc@jjfalse}% \fi \fi\fi \Etoc@next} @@ -2001,16 +2394,6 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\Etoc@getrefno #1#2\etoc@{#1} -\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter - \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}} -\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}} -\def\Etoc@label#1{\label{#1}\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -{\def\1{\Etoc@again}\expandafter -\gdef\1 {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} \long\def\Etoc@localtableofcontents#1{% \edef\Etoc@tmp{#1}% \ifnum\Etoc@tmp<\@ne @@ -2023,8 +2406,8 @@ release. \edef\etoc@startlocaltoc##1{% \noexpand\etoc@@startlocaltoc{##1}{#1}} \Etoc@localtoctrue - \let\Etoc@localtop\m@ne - \Etoc@stoptocfalse + \let\Etoc@localtop\Etoc@@minustwo@@ + \global\Etoc@stoptocfalse \global\Etoc@notactivetrue \Etoc@tableofcontents \endgroup}% @@ -2032,12 +2415,24 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} +\def\Etoc@getrefno #1#2\etoc@{#1} +\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter + \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}} +\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}} +\def\Etoc@label#1{\label{#1}\ifEtoc@tocwithid\else\addtocontents{toc} + {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}\fi + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +{\def\1{\Etoc@again}\expandafter +\gdef\1 {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} \def\Etoc@t@bleofcontents{% \ifx\Etoc@nexttoken\label \def\Etoc@next{\expandafter\Etoc@label\@gobble}\else \ifx\Etoc@nexttoken\@sptoken \let\Etoc@next\Etoc@again\else - \ifEtoc@star + \ifEtoc@tocwithid \def\Etoc@next{\Etoc@localtableofcontents{\c@etoc@tocid}}% \else \ifx\Etoc@nexttoken\ref @@ -2053,23 +2448,33 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\tableofcontents{\par - \refstepcounter{etoc@tocid}% - \@ifstar {\addtocontents{toc} - {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% - \Etoc@startrue - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} - {\Etoc@starfalse - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} +\newcommand\etocaftertitlehook{} +\def\table@fcontents{\par + \refstepcounter{etoc@tocid}% + \Etoc@tocwithidfalse + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +\def\localtable@fcontents{\par + \refstepcounter{etoc@tocid}% + \addtocontents{toc} + {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% + \Etoc@tocwithidtrue + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +\def\tableofcontents{\@ifstar + {\let\Etoc@aftertitlehook\relax\table@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}} +\def\localtableofcontents{\@ifstar + {\let\Etoc@aftertitlehook\relax\localtable@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}} % \end{macrocode} % placeholder for comments % \begin{macrocode} \newcommand\etocsettocstyle[2]{% \long\def\Etoc@tableofcontents -{\ifnum\c@tocdepth>-2\let\Etoc@@next\@firstofone\else +{\ifnum\c@tocdepth>\Etoc@minf\let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble\fi -\Etoc@@next{#1\Etoc@toctoc\let\Etoc@n@xt\relax - \ifEtoc@star\else +\Etoc@@next{#1\Etoc@aftertitlehook + \Etoc@toctoc\let\Etoc@n@xt\relax + \ifEtoc@tocwithid\else \ifEtoc@localtoc \ifEtoc@notactive \def\Etoc@n@xt{\Etoc@localtocfalse @@ -2077,10 +2482,16 @@ release. \Etoc@toctoc}% \fi\fi\fi\Etoc@n@xt #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[5]{% +\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}% \long\expandafter\def @@ -2092,12 +2503,9 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\etocstandardlines{\Etoc@standardtrue} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} +\newcommand\etocfontminustwo{\normalfont \LARGE \bfseries} \newcommand\etocfontminusone{\normalfont \large \bfseries} -\newcommand\etocfontzero{\normalfont \normalsize \bfseries} +\newcommand\etocfontzero{\normalfont \large \bfseries} \newcommand\etocfontone{\normalfont \normalsize \bfseries} \newcommand\etocfonttwo{\normalfont \normalsize} \newcommand\etocfontthree{\normalfont \footnotesize} @@ -2106,6 +2514,7 @@ release. % \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} @@ -2114,6 +2523,7 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} +\newcommand\etocbaselinespreadminustwo{1} \newcommand\etocbaselinespreadminusone{1} \newcommand\etocbaselinespreadzero{1} \newcommand\etocbaselinespreadone{1} @@ -2122,31 +2532,48 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocminusonelrmargins{1em} +\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\hbox to 2ex {\hss.\hss}}} + {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}} \newcommand\etocabbrevpagename{p.~} +\newcommand\etocpartname{\partname} +\newcommand\etocbookname{Book} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\etocetoclines{\Etoc@standardfalse +\def\etoctoclines{\Etoc@standardfalse % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@minusone}{\addpenalty\@highpenalty}{} +\etoc@setstyle{@minustwo}{\etocskipfirstprefix}{\pagebreak[3]} +{\begingroup \etocfontminustwo + \addvspace{\etocsepminustwo}% + \parindent \z@ + \leftskip \etocminustwoleftmargin + \rightskip \etocminustworightmargin + \parfillskip \@flushglue + \vbox{\etocifnumbered{\etocbookname~\etocnumber:~}{}\etocname + \baselineskip\etocbaselinespreadminustwo\baselineskip\par}% + \addvspace{\etocsepminusone}\nobreak +\endgroup} +{}% +\etoc@setstyle{@minusone}{\etocskipfirstprefix}{\pagebreak[3]} {\begingroup \etocfontminusone \addvspace{\etocsepminusone}% \parindent \z@ - \leftskip \etocminusonelrmargins - \rightskip \etocminusonelrmargins + \leftskip \etocminusoneleftmargin + \rightskip \etocminusonerightmargin \parfillskip \@flushglue - \vbox{\etocifnumbered{\etocnumber.~}{}\etocname + \vbox{\etocpartname\etocifnumbered{ \etocnumber.~}{ }\etocname \baselineskip\etocbaselinespreadminusone\baselineskip\par}% \addvspace{\etocsepzero}\nobreak \endgroup} -{\addpenalty\@secpenalty}% -\etocsetstyle{@zero} -{\addpenalty\@highpenalty}{} +{}% +\etoc@setstyle{@zero} +{\addpenalty\@highpenalty\etocskipfirstprefix}{\pagebreak[2]} {\begingroup \etocfontzero \addvspace{\etocsepzero}% @@ -2159,9 +2586,8 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@one} -{\addpenalty\@medpenalty} -{} +\etoc@setstyle{@one} +{\addpenalty\@medpenalty\etocskipfirstprefix}{\pagebreak[1]} {\begingroup\etocfontone \addvspace{\etocsepone}% \parindent \z@ \parfillskip \z@ @@ -2172,8 +2598,8 @@ release. \setbox\z@=\etoctoclineleaders \advance\dimen\z@\wd\z@ \etocifnumbered -{\setbox\tw@\hbox{\etocfonttwo\etocnumber, \etocabbrevpagename\etocpage}} -{\setbox\tw@\hbox{\etocfonttwo\etocabbrevpagename\etocpage}}% +{\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}} +{\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}% \advance\dimen\z@\wd\tw@ \ifdim\dimen\z@ < \linewidth \vbox{\etocname\nobreak @@ -2191,9 +2617,9 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@two} -{\addpenalty\@medpenalty} -{} +\etoc@setstyle{@two} +{\addpenalty\@medpenalty\etocskipfirstprefix} +{\pagebreak[1]} {\begingroup\etocfonttwo \addvspace{\etocseptwo}% \parindent \z@ \parfillskip \z@ @@ -2223,67 +2649,41 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@three} -{\nobreak +\etoc@setstyle{@three} +{\nopagebreak \etocfontthree \addvspace{\etocsepthree}% \nointerlineskip\noindent \etocskipfirstprefix} {\allowbreak\,--\,} -{\etocname} -{\unskip.\hfil\begingroup +{\etocname\unskip} % \xspace in \etocname +{.\hfil\begingroup \baselineskip\etocbaselinespreadthree\baselineskip \par\endgroup \addpenalty{-\@highpenalty}}% % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@four}{}{}{}{}% +\etoc@setstyle{@four}{}{}{}{}% % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocsetstyle{@five}{}{}{}{}% +\etoc@setstyle{@five}{}{}{}{}% } % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocmarkboth[1][\contentsname]{% - \@mkboth {\MakeUppercase #1} - {\MakeUppercase #1}} -\def\etoc@article@tochead#1{\section *{#1\@mkboth - {\MakeUppercase{#1}} - {\MakeUppercase{#1}}}} -\def\etoc@article@tochead@nomarks#1{\section *{#1}} -\def\etoc@book@tochead#1{\chapter *{#1\@mkboth - {\MakeUppercase{#1}} - {\MakeUppercase{#1}}}} -\def\etoc@book@tochead@nomarks#1{\chapter *{#1}} -\let\etoc@standard@tochead\etoc@article@tochead -\let\etoc@standard@tochead@nomarks\etoc@article@tochead@nomarks -\@ifclassloaded{book}{% -\let\etoc@standard@tochead\etoc@book@tochead -\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{} -\@ifclassloaded{report}{% -\let\etoc@standard@tochead\etoc@book@tochead -\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{} -% \end{macrocode} -% placeholder for comments -% \begin{macrocode} -\newcommand\etocstandardheading[1]{% -\etoc@standard@tochead{#1}} -\newcommand\etocstandardheadingnomarks[1]{% -\etoc@standard@tochead@nomarks{#1}} -% \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} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocmulticolstyle[2][2]{% +\newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -2294,8 +2694,9 @@ release. \setlength{\columnsep}{\etoccolumnsep}% \setlength{\multicolsep}{\etocmulticolsep}% \begin{multicols}{#1}[#2\addvspace{\etocsepminusone}]} - {#2\addvspace{\etocsepminusone}\pretolerance\etocmulticolpretolerance - \tolerance\etocmulticoltolerance}} + {#2\addvspace{\etocsepminusone}% + \pretolerance\etocmulticolpretolerance + \tolerance\etocmulticoltolerance}} {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% @@ -2319,7 +2720,7 @@ release. % placeholder for comments % \begin{macrocode} \newcommand\etoc@ruledheading[1]{% - \hbox to \linewidth{\color@begingroup + \hb@xt@\linewidth{\color@begingroup \hss #1\hss\hskip-\linewidth \etoctoprulecolorcmd\leaders\etoctoprule\hfil \phantom{#1}% @@ -2328,7 +2729,7 @@ release. % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etocruledstyle[2][2]{% +\newcommand\etocruledstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -2354,13 +2755,13 @@ release. \newcommand\Etoc@relax{\relax} \newbox\etoc@framed@titlebox \newbox\etoc@framed@contentsbox -\newcommand\etocframedstyle[2][2]{% +\newcommand\etocframedstyle[2][\etocdefaultnbcol]{% \etocsettocstyle{% \addvspace{\etocabovetocskip}% - \setbox\z@\hbox{#2}% + \sbox\z@{#2}% \dimen\z@\dp\z@ \ifdim\wd\z@<\linewidth \dp\z@\z@ \else \dimen\z@\z@ \fi - \setbox\etoc@framed@titlebox=\hbox to \linewidth{\color@begingroup + \setbox\etoc@framed@titlebox=\hb@xt@\linewidth{\color@begingroup \hss \ifx\etocbkgcolorcmd\Etoc@relax\else \sbox\tw@{\color{white}% @@ -2399,14 +2800,15 @@ release. {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}\unskip}% - \end{minipage}%<- indispensable (horizontal mode here) + \end{minipage}% \egroup \vskip\etocinnerbottomsep \egroup + \vbox{\hsize\linewidth \ifx\etocbkgcolorcmd\Etoc@relax\else - \vskip\ht\etoc@framed@titlebox - \vskip\dp\etoc@framed@titlebox - \hbox to \linewidth{\color@begingroup + \kern\ht\etoc@framed@titlebox + \kern\dp\etoc@framed@titlebox + \hb@xt@\linewidth{\color@begingroup \etocleftrulecolorcmd\etocleftrule \etocbkgcolorcmd \leaders\vrule @@ -2422,69 +2824,223 @@ release. \vskip-\ht\etoc@framed@titlebox \fi \box\etoc@framed@titlebox\nointerlineskip - \hbox to \linewidth{\color@begingroup + \hb@xt@\linewidth{\color@begingroup {\etocleftrulecolorcmd\etocleftrule}% \hss\box\etoc@framed@contentsbox\hss \etocrightrulecolorcmd\etocrightrule\color@endgroup} \nointerlineskip \vskip\ht\etoc@framed@contentsbox \vskip\dp\etoc@framed@contentsbox - \hbox to \linewidth{\color@begingroup\etocbottomrulecolorcmd - \leaders\etocbottomrule\hss\color@endgroup} + \hb@xt@\linewidth{\color@begingroup\etocbottomrulecolorcmd + \leaders\etocbottomrule\hss\color@endgroup}} \addvspace{\etocbelowtocskip}}} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etoc@multicoltoc[2][2]{% -\begingroup +\newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{% \etocmulticolstyle[#1]{#2}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} +\tableofcontents} +\newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\tableofcontents*} +\newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\localtableofcontents} +\newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\localtableofcontents*} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\newcommand\etoc@ruledtoc[2][2]{% -\begingroup +\newcommand\etoc@ruledtoc[2][\etocdefaultnbcol]{% \etocruledstyle[#1]{#2}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} +\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][2]{% -\begingroup +\newcommand\etoc@framedtoc[2][\etocdefaultnbcol]{% \etocframedstyle[#1]{#2}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} +\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 + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@multicoltoci} + {\etoc@multicoltoc}} +\newcommand\etocruled{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@ruledtoci} + {\etoc@ruledtoc}} +\newcommand\etocframed{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@framedtoci} + {\etoc@framedtoc}} +\newcommand\localetocmulticol{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@multicoltoci} + {\etoc@local@multicoltoc}} +\newcommand\localetocruled{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@ruledtoci} + {\etoc@local@ruledtoc}} +\newcommand\localetocframed{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@framedtoci} + {\etoc@local@framedtoc}} +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} +\newcommand\etocarticlestyle{% + \etocsettocstyle + {\section *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}} + {}} +\newcommand\etocarticlestylenomarks{% + \etocsettocstyle + {\section *{\contentsname}} + {}} +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} +\newcommand\etocbookstyle{% + \etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \chapter *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}} + {\if@restonecol \twocolumn \fi}} +\newcommand\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 +% \begin{macrocode} +\newcommand\etocmemoirtoctotocfmt[2]{% + \renewcommand\etocaftertitlehook{\ifmem@em@starred@listof \else + \phantomsection \addcontentsline {toc}{#1}{#2}\fi}} +\newcommand\etocmemoirstyle{% + \etocsettocstyle + {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle} + \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax + \parskip \cftparskip \@nameuse {cfttocbeforelisthook}} + {\@nameuse {cfttocafterlisthook}\endgroup \restorefromonecol}} % \end{macrocode} % placeholder for comments % \begin{macrocode} -\def\etocmulticol{\@ifstar{\Etoc@startrue\etoc@multicoltoc} -{\Etoc@starfalse\etoc@multicoltoc}} -\def\etocruled{\@ifstar{\Etoc@startrue\etoc@ruledtoc} -{\Etoc@starfalse\etoc@ruledtoc}} -\def\etocframed{\@ifstar{\Etoc@startrue\etoc@framedtoc} -{\Etoc@starfalse\etoc@framedtoc}} +\newcommand\etocscrartclstyle{% + \etocsettocstyle + {\let\if@dynlist\if@tocleft + \iftocfeature {toc}{onecolumn} + {\iftocfeature {toc}{leveldown} + {} + {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }} + {}% + \tocbasic@listhead {\listoftocname}% + \begingroup \expandafter \expandafter \expandafter + \endgroup \expandafter + \ifx + \csname microtypesetup\endcsname \relax + \else + \iftocfeature {toc}{noprotrusion}{} + {\microtypesetup {protrusion=false}% + \PackageInfo {tocbasic}% + {character protrusion at toc deactivated}}% + \fi + \setlength {\parskip }{\z@ }% + \setlength {\parindent }{\z@ }% + \setlength {\parfillskip }{\z@ \@plus 1fil}% + \csname tocbasic@@before@hook\endcsname + \csname tb@toc@before@hook\endcsname} + {\csname tb@toc@after@hook\endcsname + \csname tocbasic@@after@hook\endcsname}} +\let\etocscrbookstyle\etocscrartclstyle +\let\etocscrreprtstyle\etocscrartclstyle % \end{macrocode} % placeholder for comments % \begin{macrocode} -\etocetoclines -\etocmulticolstyle{\etocstandardheading\contentsname} +\newcommand\etocnakedtocdisplaystyle{\etocsettocstyle{}{}} +\newcommand\etocstandarddisplaystyle{\etocarticlestyle} +\newcommand\etocmarkboth[1]{% + \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} +\newcommand\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} +\newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3}}} +\newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3\etocmarkboth{#4}}}} +\newcommand\etoctocstylewithmarksnouc[4][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3\etocmarkbothnouc{#4}}}} +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} +\def\Etoc@redefetocstyle#1{% + \renewcommand\etoctocstylewithmarks[4][#1] + {\etocmulticolstyle[##2]% + {\csname ##1\endcsname *{##3\etocmarkboth{##4}}}} + \renewcommand\etoctocstylewithmarksnouc[4][#1] + {\etocmulticolstyle[##2]% + {\csname ##1\endcsname *{##3\etocmarkbothnouc{##4}}}} + \renewcommand\etoctocstyle[3][#1]{% + \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}} +\@ifclassloaded{scrartcl} + {\renewcommand\etocstandarddisplaystyle{\etocscrartclstyle}}{} +\@ifclassloaded{book} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocbookstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{report} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocreportstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{scrbook} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocscrbookstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{scrreprt} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocscrreprtstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{memoir} + {\renewcommand\etocfontone{\normalfont\normalsize} + \etocmemoirtoctotocfmt{chapter}{\contentsname}% + \renewcommand\etocstandarddisplaystyle{\etocmemoirstyle} + \Etoc@redefetocstyle{chapter}}{} +% \end{macrocode} +% placeholder for comments +% \begin{macrocode} +\newcommand\etocstandardlines{\Etoc@standardtrue} +\etoctoclines +\etocstandardlines +\etocstandarddisplaystyle \endinput % \end{macrocode} % \MakePercentComment @@ -2505,7 +3061,7 @@ release. Grave accent \` Left brace \{ Vertical bar \| Right brace \} Tilde \~} -\CheckSum{2091} +\CheckSum{2536} \Finale %% diff --git a/Master/texmf-dist/source/latex/etoc/etoc.ins b/Master/texmf-dist/source/latex/etoc/etoc.ins index da3006bd47c..b7d5e068036 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.ins +++ b/Master/texmf-dist/source/latex/etoc/etoc.ins @@ -1,8 +1,9 @@ %% Package `etoc' by Jean-Francois Burnol %% Copyright (C) 2012 by Jean-Francois Burnol +\def\lasttimestamp{Time-stamp: <29-11-2012 19:26:40 CET jfb>} \def\pkgname{etoc} -\def\pkgdate{2012/11/24} -\def\pkgversion{v1.04} +\def\pkgdate{2012/11/28} +\def\pkgversion{v1.05} \def\pkgdescription{easily customizable TOCs (jfB)} %% %% This file `etoc.ins' is provided for compatibility with TeX distributions diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index c54f5c95a62..0fbedff0f51 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -22,7 +22,7 @@ %% in the same archive or directory.) %% \ProvidesPackage{etoc} - [2012/11/24 v1.04 easily customizable TOCs (jfB)] + [2012/11/28 v1.05 easily customizable TOCs (jfB)] %% Package `etoc' by Jean-Francois Burnol %% Copyright (C) 2012 by Jean-Francois Burnol \NeedsTeXFormat{LaTeX2e} @@ -31,6 +31,7 @@ \DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} \ProcessOptions\relax \newtoks\Etoc@toctoks +\newif\ifEtoc@jj % book \newif\ifEtoc@j % part \newif\ifEtoc@ % chapter \newif\ifEtoc@i % section @@ -40,7 +41,7 @@ \newif\ifEtoc@v % subparagraph \newif\ifEtoc@number \newif\ifEtoc@hyperref -\newif\ifEtoc@star +\newif\ifEtoc@tocwithid \newif\ifEtoc@standard \newif\ifEtoc@part \newif\ifEtoc@localtoc @@ -49,15 +50,18 @@ \newif\ifEtoc@notactive \newcounter{etoc@tocid} \newif\ifEtoc@mustclosegroup +\@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@@four@@4\relax -\chardef\Etoc@@five@@5\relax -\chardef\Etoc@@six@@6\relax -\let\Etoc@localtop\m@ne +\chardef\Etoc@@four@@ 4 +\chardef\Etoc@@five@@ 5 +\chardef\Etoc@@six@@ 6 +\let\Etoc@localtop\Etoc@@minustwo@@ +\def\Etoc@@minustwo@{minustwo} \def\Etoc@@minusone@{minusone} \def\Etoc@@zero@{zero} \def\Etoc@@one@{one} @@ -77,13 +81,14 @@ \Etoc@Lazarus@eltb#2}} \def\etocsetlevel#1#2{% \let\Etoc@next\@firstofone - \ifcase#2\or\or\or\or\or\else\ifnum#2=\m@ne\else + \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 -1, 0, 1, 2, 3, 4 or 5. Set to -1}% + 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 + \let\Etoc@next\@gobble\fi\fi\fi \if@noskipsec \else \expandafter\expandafter\expandafter @@ -114,9 +119,15 @@ \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@five@@ \expandafter\def \csname Etoc@#1@\endcsname{five}% \else + \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@@minustwo@@ + \expandafter\def \csname Etoc@#1@\endcsname{minustwo}% + \fi \fi}} +\etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} \etocsetlevel{section}{1} @@ -172,6 +183,7 @@ \or \global\Etoc@vtrue \else + \ifnum#1=\m@ne \global\Etoc@vfalse \global\Etoc@ivfalse \global\Etoc@iiifalse @@ -179,6 +191,16 @@ \global\Etoc@ifalse \global\Etoc@false \global\Etoc@jtrue + \else + \global\Etoc@vfalse + \global\Etoc@ivfalse + \global\Etoc@iiifalse + \global\Etoc@iifalse + \global\Etoc@ifalse + \global\Etoc@false + \global\Etoc@jfalse + \global\Etoc@jjtrue + \fi \fi} \def\Etoc@etoccontentsline#1{% \global\expandafter\let\expandafter\Etoc@tmp\csname Etoc@#1@@\endcsname @@ -247,6 +269,7 @@ \gdef\Etoc@contents{\Etoc@contents@five}% \gdef\Etoc@prefix{\Etoc@prefix@five}% \else + \ifnum\Etoc@tmp=\m@ne \ifEtoc@v \Etoc@end@five\fi \ifEtoc@iv \Etoc@end@four\fi \ifEtoc@iii \Etoc@end@three\fi @@ -257,6 +280,18 @@ \global\Etoc@parttrue \gdef\Etoc@contents{\Etoc@contents@minusone}% \gdef\Etoc@prefix{\Etoc@prefix@minusone}% + \else + \ifEtoc@v \Etoc@end@five\fi + \ifEtoc@iv \Etoc@end@four\fi + \ifEtoc@iii \Etoc@end@three\fi + \ifEtoc@ii \Etoc@end@two\fi + \ifEtoc@i \Etoc@end@one\fi + \ifEtoc@ \Etoc@end@zero\fi + \ifEtoc@j \Etoc@end@minusone\fi + \ifEtoc@jj \else \def\Etoc@next{\Etoc@begin@minustwo}\fi + \gdef\Etoc@contents{\Etoc@contents@minustwo}% + \gdef\Etoc@prefix{\Etoc@prefix@minustwo}% + \fi \fi \Etoc@setflags{\Etoc@tmp}% \fi\fi @@ -298,7 +333,7 @@ \Etoc@getname #3\etoc@\fi} \def\Etoc@getit@hyp #1#2#3#4#5#6\etoc@{% \def\Etoc@getname ##1\hspace\relax\etoc@{% - \global\@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5}\xspace}% + \global\@namedef{etocname }{\leavevmode #1{#2}{#3}{##1}#5\xspace}}% \def\Etoc@getnbr ##1\hspace##2##3\etoc@{% \ifx\relax##2\else \global\@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}% @@ -329,7 +364,6 @@ \def\Etoc@starttoc{% \begingroup \makeatletter -\chardef\ET@endline\endlinechar \@ifpackageloaded{hyperref} {\ifx\hyper@last\@undefined \ltx@ifpackageloaded {parskip}{\parskip \z@ }{}% @@ -343,10 +377,9 @@ \Etoc@readtoc\Etoc@tf \closein\Etoc@tf} {\typeout{No file \jobname .toc.}}}% -\endlinechar\ET@endline \if@filesw \newwrite \tf@toc \immediate \openout \tf@toc \jobname .toc\relax \fi -\endgroup} +\@nobreakfalse \endgroup} \AtBeginDocument{\Etoc@starttoc} \def\Etoc@toctoc{% \global\Etoc@vfalse @@ -356,17 +389,22 @@ \global\Etoc@ifalse \global\Etoc@false \global\Etoc@jfalse + \global\Etoc@jjfalse \ifEtoc@standard \Etoc@Lazarus -\etocsetstyle{@minusone}{}{}{}{}% -\etocsetstyle{@zero}{}{}{}{}% -\etocsetstyle{@one}{}{}{}{}% -\etocsetstyle{@two}{}{}{}{}% -\etocsetstyle{@three}{}{}{}{}% -\etocsetstyle{@four}{}{}{}{}% -\etocsetstyle{@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 \let\numberline\@gobble +\let\booknumberline\numberline +\let\partnumberline\numberline +\let\chapternumberline\numberline \fi \the\Etoc@toctoks \ifEtoc@notactive\else @@ -377,12 +415,14 @@ \ifEtoc@i \Etoc@end@one\fi \ifEtoc@ \Etoc@end@zero\fi \ifEtoc@j \Etoc@end@minusone\fi + \ifEtoc@jj \Etoc@end@minustwo\fi \fi} \def\etoc@@startlocaltoc#1#2{% \let\Etoc@next\relax \ifEtoc@localtoc \ifEtoc@notactive \ifnum #1=#2\relax + \ifEtoc@jj \global\let\Etoc@localtop\Etoc@@minusone@@ \fi \ifEtoc@j \global\let\Etoc@localtop\Etoc@@zero@@ \fi \ifEtoc@ \global\let\Etoc@localtop\Etoc@@one@@ \fi \ifEtoc@i \global\let\Etoc@localtop\Etoc@@two@@ \fi @@ -397,18 +437,12 @@ \global\Etoc@iifalse \global\Etoc@ifalse \global\Etoc@false - \global\Etoc@jfalse}% + \global\Etoc@jfalse + \global\Etoc@jjfalse}% \fi \fi\fi \Etoc@next} \def\etoc@startlocaltoc#1{\etoc@@startlocaltoc{#1}{\c@etoc@tocid}} -\def\Etoc@getrefno #1#2\etoc@{#1} -\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter - \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}} -\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}} -\def\Etoc@label#1{\label{#1}\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -{\def\1{\Etoc@again}\expandafter -\gdef\1 {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} \long\def\Etoc@localtableofcontents#1{% \edef\Etoc@tmp{#1}% \ifnum\Etoc@tmp<\@ne @@ -421,18 +455,27 @@ \edef\etoc@startlocaltoc##1{% \noexpand\etoc@@startlocaltoc{##1}{#1}} \Etoc@localtoctrue - \let\Etoc@localtop\m@ne - \Etoc@stoptocfalse + \let\Etoc@localtop\Etoc@@minustwo@@ + \global\Etoc@stoptocfalse \global\Etoc@notactivetrue \Etoc@tableofcontents \endgroup}% \ifEtoc@mustclosegroup\expandafter\endgroup\fi} +\def\Etoc@getrefno #1#2\etoc@{#1} +\def\Etoc@getref #1{\@ifundefined{r@#1}{0}{\expandafter\expandafter\expandafter + \Etoc@getrefno\csname r@#1\endcsname\relax\etoc@}} +\def\Etoc@ref#1{\Etoc@localtableofcontents{\Etoc@getref{#1}}} +\def\Etoc@label#1{\label{#1}\ifEtoc@tocwithid\else\addtocontents{toc} + {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}\fi + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +{\def\1{\Etoc@again}\expandafter +\gdef\1 {\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} \def\Etoc@t@bleofcontents{% \ifx\Etoc@nexttoken\label \def\Etoc@next{\expandafter\Etoc@label\@gobble}\else \ifx\Etoc@nexttoken\@sptoken \let\Etoc@next\Etoc@again\else - \ifEtoc@star + \ifEtoc@tocwithid \def\Etoc@next{\Etoc@localtableofcontents{\c@etoc@tocid}}% \else \ifx\Etoc@nexttoken\ref @@ -445,20 +488,30 @@ \endgroup}% \fi \fi\fi\fi\Etoc@next} -\def\tableofcontents{\par - \refstepcounter{etoc@tocid}% - \@ifstar {\addtocontents{toc} - {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% - \Etoc@startrue - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} - {\Etoc@starfalse - \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} +\newcommand\etocaftertitlehook{} +\def\table@fcontents{\par + \refstepcounter{etoc@tocid}% + \Etoc@tocwithidfalse + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +\def\localtable@fcontents{\par + \refstepcounter{etoc@tocid}% + \addtocontents{toc} + {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% + \Etoc@tocwithidtrue + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} +\def\tableofcontents{\@ifstar + {\let\Etoc@aftertitlehook\relax\table@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}} +\def\localtableofcontents{\@ifstar + {\let\Etoc@aftertitlehook\relax\localtable@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}} \newcommand\etocsettocstyle[2]{% \long\def\Etoc@tableofcontents -{\ifnum\c@tocdepth>-2\let\Etoc@@next\@firstofone\else +{\ifnum\c@tocdepth>\Etoc@minf\let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble\fi -\Etoc@@next{#1\Etoc@toctoc\let\Etoc@n@xt\relax - \ifEtoc@star\else +\Etoc@@next{#1\Etoc@aftertitlehook + \Etoc@toctoc\let\Etoc@n@xt\relax + \ifEtoc@tocwithid\else \ifEtoc@localtoc \ifEtoc@notactive \def\Etoc@n@xt{\Etoc@localtocfalse @@ -466,7 +519,12 @@ \Etoc@toctoc}% \fi\fi\fi\Etoc@n@xt #2}}} -\newcommand\etocsetstyle[5]{% +\newcommand\etocextendtocstyle[2]{% +\toks0=\expandafter{\Etoc@tableofcontents #2}% +\toks2={#1}% +\long\edef\Etoc@tableofcontents{\the\toks2 \the\toks0}} +\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}% \long\expandafter\def @@ -475,43 +533,62 @@ \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}% \long\expandafter\def \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname {#5}} -\def\etocstandardlines{\Etoc@standardtrue} +\newcommand\etocfontminustwo{\normalfont \LARGE \bfseries} \newcommand\etocfontminusone{\normalfont \large \bfseries} -\newcommand\etocfontzero{\normalfont \normalsize \bfseries} +\newcommand\etocfontzero{\normalfont \large \bfseries} \newcommand\etocfontone{\normalfont \normalsize \bfseries} \newcommand\etocfonttwo{\normalfont \normalsize} \newcommand\etocfontthree{\normalfont \footnotesize} \newcommand\etocfontfour{\normalfont \footnotesize} \newcommand\etocfontfive{\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\etocminusonelrmargins{1em} +\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\hbox to 2ex {\hss.\hss}}} + {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}} \newcommand\etocabbrevpagename{p.~} -\def\etocetoclines{\Etoc@standardfalse -\etocsetstyle{@minusone}{\addpenalty\@highpenalty}{} +\newcommand\etocpartname{\partname} +\newcommand\etocbookname{Book} +\def\etoctoclines{\Etoc@standardfalse +\etoc@setstyle{@minustwo}{\etocskipfirstprefix}{\pagebreak[3]} +{\begingroup \etocfontminustwo + \addvspace{\etocsepminustwo}% + \parindent \z@ + \leftskip \etocminustwoleftmargin + \rightskip \etocminustworightmargin + \parfillskip \@flushglue + \vbox{\etocifnumbered{\etocbookname~\etocnumber:~}{}\etocname + \baselineskip\etocbaselinespreadminustwo\baselineskip\par}% + \addvspace{\etocsepminusone}\nobreak +\endgroup} +{}% +\etoc@setstyle{@minusone}{\etocskipfirstprefix}{\pagebreak[3]} {\begingroup \etocfontminusone \addvspace{\etocsepminusone}% \parindent \z@ - \leftskip \etocminusonelrmargins - \rightskip \etocminusonelrmargins + \leftskip \etocminusoneleftmargin + \rightskip \etocminusonerightmargin \parfillskip \@flushglue - \vbox{\etocifnumbered{\etocnumber.~}{}\etocname + \vbox{\etocpartname\etocifnumbered{ \etocnumber.~}{ }\etocname \baselineskip\etocbaselinespreadminusone\baselineskip\par}% \addvspace{\etocsepzero}\nobreak \endgroup} -{\addpenalty\@secpenalty}% -\etocsetstyle{@zero} -{\addpenalty\@highpenalty}{} +{}% +\etoc@setstyle{@zero} +{\addpenalty\@highpenalty\etocskipfirstprefix}{\pagebreak[2]} {\begingroup \etocfontzero \addvspace{\etocsepzero}% @@ -521,9 +598,8 @@ \addvspace{\etocsepone}\addpenalty\@itempenalty \endgroup} {\addpenalty\@secpenalty}% -\etocsetstyle{@one} -{\addpenalty\@medpenalty} -{} +\etoc@setstyle{@one} +{\addpenalty\@medpenalty\etocskipfirstprefix}{\pagebreak[1]} {\begingroup\etocfontone \addvspace{\etocsepone}% \parindent \z@ \parfillskip \z@ @@ -534,8 +610,8 @@ \setbox\z@=\etoctoclineleaders \advance\dimen\z@\wd\z@ \etocifnumbered -{\setbox\tw@\hbox{\etocfonttwo\etocnumber, \etocabbrevpagename\etocpage}} -{\setbox\tw@\hbox{\etocfonttwo\etocabbrevpagename\etocpage}}% +{\setbox\tw@\hbox{\etocnumber, \etocabbrevpagename\etocpage}} +{\setbox\tw@\hbox{\etocabbrevpagename\etocpage}}% \advance\dimen\z@\wd\tw@ \ifdim\dimen\z@ < \linewidth \vbox{\etocname\nobreak @@ -550,9 +626,9 @@ \addvspace{\etocseptwo}\addpenalty\@itempenalty \endgroup} {\addpenalty\@secpenalty}% -\etocsetstyle{@two} -{\addpenalty\@medpenalty} -{} +\etoc@setstyle{@two} +{\addpenalty\@medpenalty\etocskipfirstprefix} +{\pagebreak[1]} {\begingroup\etocfonttwo \addvspace{\etocseptwo}% \parindent \z@ \parfillskip \z@ @@ -579,51 +655,29 @@ \addvspace{\etocsepthree}\addpenalty\@itempenalty \endgroup} {\addpenalty\@secpenalty}% -\etocsetstyle{@three} -{\nobreak +\etoc@setstyle{@three} +{\nopagebreak \etocfontthree \addvspace{\etocsepthree}% \nointerlineskip\noindent \etocskipfirstprefix} {\allowbreak\,--\,} -{\etocname} -{\unskip.\hfil\begingroup +{\etocname\unskip} % \xspace in \etocname +{.\hfil\begingroup \baselineskip\etocbaselinespreadthree\baselineskip \par\endgroup \addpenalty{-\@highpenalty}}% -\etocsetstyle{@four}{}{}{}{}% -\etocsetstyle{@five}{}{}{}{}% +\etoc@setstyle{@four}{}{}{}{}% +\etoc@setstyle{@five}{}{}{}{}% } -\newcommand\etocmarkboth[1][\contentsname]{% - \@mkboth {\MakeUppercase #1} - {\MakeUppercase #1}} -\def\etoc@article@tochead#1{\section *{#1\@mkboth - {\MakeUppercase{#1}} - {\MakeUppercase{#1}}}} -\def\etoc@article@tochead@nomarks#1{\section *{#1}} -\def\etoc@book@tochead#1{\chapter *{#1\@mkboth - {\MakeUppercase{#1}} - {\MakeUppercase{#1}}}} -\def\etoc@book@tochead@nomarks#1{\chapter *{#1}} -\let\etoc@standard@tochead\etoc@article@tochead -\let\etoc@standard@tochead@nomarks\etoc@article@tochead@nomarks -\@ifclassloaded{book}{% -\let\etoc@standard@tochead\etoc@book@tochead -\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{} -\@ifclassloaded{report}{% -\let\etoc@standard@tochead\etoc@book@tochead -\let\etoc@standard@tochead@nomarks\etoc@book@tochead@nomarks}{} -\newcommand\etocstandardheading[1]{% -\etoc@standard@tochead{#1}} -\newcommand\etocstandardheadingnomarks[1]{% -\etoc@standard@tochead@nomarks{#1}} \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\etocmulticolstyle[2][2]{% +\newcommand\etocdefaultnbcol{2} +\newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -634,8 +688,9 @@ \setlength{\columnsep}{\etoccolumnsep}% \setlength{\multicolsep}{\etocmulticolsep}% \begin{multicols}{#1}[#2\addvspace{\etocsepminusone}]} - {#2\addvspace{\etocsepminusone}\pretolerance\etocmulticolpretolerance - \tolerance\etocmulticoltolerance}} + {#2\addvspace{\etocsepminusone}% + \pretolerance\etocmulticolpretolerance + \tolerance\etocmulticoltolerance}} {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% @@ -653,13 +708,13 @@ \newcommand\etocleftrulecolorcmd{\relax} \newcommand\etocrightrulecolorcmd{\relax} \newcommand\etoc@ruledheading[1]{% - \hbox to \linewidth{\color@begingroup + \hb@xt@\linewidth{\color@begingroup \hss #1\hss\hskip-\linewidth \etoctoprulecolorcmd\leaders\etoctoprule\hfil \phantom{#1}% \leaders\etoctoprule\hss\color@endgroup}% \nointerlineskip\vskip\etocinnertopsep} -\newcommand\etocruledstyle[2][2]{% +\newcommand\etocruledstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\addvspace{\etocabovetocskip}% \ifnum #1>\@ne\let\Etoc@next\@firstoftwo @@ -682,13 +737,13 @@ \newcommand\Etoc@relax{\relax} \newbox\etoc@framed@titlebox \newbox\etoc@framed@contentsbox -\newcommand\etocframedstyle[2][2]{% +\newcommand\etocframedstyle[2][\etocdefaultnbcol]{% \etocsettocstyle{% \addvspace{\etocabovetocskip}% - \setbox\z@\hbox{#2}% + \sbox\z@{#2}% \dimen\z@\dp\z@ \ifdim\wd\z@<\linewidth \dp\z@\z@ \else \dimen\z@\z@ \fi - \setbox\etoc@framed@titlebox=\hbox to \linewidth{\color@begingroup + \setbox\etoc@framed@titlebox=\hb@xt@\linewidth{\color@begingroup \hss \ifx\etocbkgcolorcmd\Etoc@relax\else \sbox\tw@{\color{white}% @@ -727,14 +782,15 @@ {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}\unskip}% - \end{minipage}%<- indispensable (horizontal mode here) + \end{minipage}% \egroup \vskip\etocinnerbottomsep \egroup + \vbox{\hsize\linewidth \ifx\etocbkgcolorcmd\Etoc@relax\else - \vskip\ht\etoc@framed@titlebox - \vskip\dp\etoc@framed@titlebox - \hbox to \linewidth{\color@begingroup + \kern\ht\etoc@framed@titlebox + \kern\dp\etoc@framed@titlebox + \hb@xt@\linewidth{\color@begingroup \etocleftrulecolorcmd\etocleftrule \etocbkgcolorcmd \leaders\vrule @@ -750,54 +806,190 @@ \vskip-\ht\etoc@framed@titlebox \fi \box\etoc@framed@titlebox\nointerlineskip - \hbox to \linewidth{\color@begingroup + \hb@xt@\linewidth{\color@begingroup {\etocleftrulecolorcmd\etocleftrule}% \hss\box\etoc@framed@contentsbox\hss \etocrightrulecolorcmd\etocrightrule\color@endgroup} \nointerlineskip \vskip\ht\etoc@framed@contentsbox \vskip\dp\etoc@framed@contentsbox - \hbox to \linewidth{\color@begingroup\etocbottomrulecolorcmd - \leaders\etocbottomrule\hss\color@endgroup} + \hb@xt@\linewidth{\color@begingroup\etocbottomrulecolorcmd + \leaders\etocbottomrule\hss\color@endgroup}} \addvspace{\etocbelowtocskip}}} -\newcommand\etoc@multicoltoc[2][2]{% -\begingroup +\newcommand\etoc@multicoltoc[2][\etocdefaultnbcol]{% \etocmulticolstyle[#1]{#2}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} -\newcommand\etoc@ruledtoc[2][2]{% -\begingroup +\tableofcontents} +\newcommand\etoc@multicoltoci[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\tableofcontents*} +\newcommand\etoc@local@multicoltoc[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\localtableofcontents} +\newcommand\etoc@local@multicoltoci[2][\etocdefaultnbcol]{% +\etocmulticolstyle[#1]{#2}% +\localtableofcontents*} +\newcommand\etoc@ruledtoc[2][\etocdefaultnbcol]{% \etocruledstyle[#1]{#2}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} -\newcommand\etoc@framedtoc[2][2]{% -\begingroup +\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}% - \ifEtoc@star - \def\Etoc@next{\tableofcontents*}% - \else - \def\Etoc@next{\tableofcontents}% - \fi -\Etoc@mustclosegrouptrue -\Etoc@next} -\def\etocmulticol{\@ifstar{\Etoc@startrue\etoc@multicoltoc} -{\Etoc@starfalse\etoc@multicoltoc}} -\def\etocruled{\@ifstar{\Etoc@startrue\etoc@ruledtoc} -{\Etoc@starfalse\etoc@ruledtoc}} -\def\etocframed{\@ifstar{\Etoc@startrue\etoc@framedtoc} -{\Etoc@starfalse\etoc@framedtoc}} -\etocetoclines -\etocmulticolstyle{\etocstandardheading\contentsname} +\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 + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@multicoltoci} + {\etoc@multicoltoc}} +\newcommand\etocruled{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@ruledtoci} + {\etoc@ruledtoc}} +\newcommand\etocframed{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@framedtoci} + {\etoc@framedtoc}} +\newcommand\localetocmulticol{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@multicoltoci} + {\etoc@local@multicoltoc}} +\newcommand\localetocruled{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@ruledtoci} + {\etoc@local@ruledtoc}} +\newcommand\localetocframed{\begingroup + \Etoc@mustclosegrouptrue + \@ifstar + {\etoc@local@framedtoci} + {\etoc@local@framedtoc}} +\newcommand\etocarticlestyle{% + \etocsettocstyle + {\section *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}} + {}} +\newcommand\etocarticlestylenomarks{% + \etocsettocstyle + {\section *{\contentsname}} + {}} +\newcommand\etocbookstyle{% + \etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \chapter *{\contentsname + \@mkboth {\MakeUppercase \contentsname} + {\MakeUppercase \contentsname}}} + {\if@restonecol \twocolumn \fi}} +\newcommand\etocbookstylenomarks{% + \etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \chapter *{\contentsname}} + {\if@restonecol \twocolumn \fi}} +\let\etocreportstyle\etocbookstyle +\let\etocreportstylenomarks\etocbookstylenomarks +\newcommand\etocmemoirtoctotocfmt[2]{% + \renewcommand\etocaftertitlehook{\ifmem@em@starred@listof \else + \phantomsection \addcontentsline {toc}{#1}{#2}\fi}} +\newcommand\etocmemoirstyle{% + \etocsettocstyle + {\ensureonecol \par \begingroup \@nameuse {@tocmaketitle} + \Etoc@aftertitlehook\let\Etoc@aftertitlehook\relax + \parskip \cftparskip \@nameuse {cfttocbeforelisthook}} + {\@nameuse {cfttocafterlisthook}\endgroup \restorefromonecol}} +\newcommand\etocscrartclstyle{% + \etocsettocstyle + {\let\if@dynlist\if@tocleft + \iftocfeature {toc}{onecolumn} + {\iftocfeature {toc}{leveldown} + {} + {\if@twocolumn \aftergroup \twocolumn \onecolumn \fi }} + {}% + \tocbasic@listhead {\listoftocname}% + \begingroup \expandafter \expandafter \expandafter + \endgroup \expandafter + \ifx + \csname microtypesetup\endcsname \relax + \else + \iftocfeature {toc}{noprotrusion}{} + {\microtypesetup {protrusion=false}% + \PackageInfo {tocbasic}% + {character protrusion at toc deactivated}}% + \fi + \setlength {\parskip }{\z@ }% + \setlength {\parindent }{\z@ }% + \setlength {\parfillskip }{\z@ \@plus 1fil}% + \csname tocbasic@@before@hook\endcsname + \csname tb@toc@before@hook\endcsname} + {\csname tb@toc@after@hook\endcsname + \csname tocbasic@@after@hook\endcsname}} +\let\etocscrbookstyle\etocscrartclstyle +\let\etocscrreprtstyle\etocscrartclstyle +\newcommand\etocnakedtocdisplaystyle{\etocsettocstyle{}{}} +\newcommand\etocstandarddisplaystyle{\etocarticlestyle} +\newcommand\etocmarkboth[1]{% + \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} +\newcommand\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} +\newcommand\etoctocstyle[3][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3}}} +\newcommand\etoctocstylewithmarks[4][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3\etocmarkboth{#4}}}} +\newcommand\etoctocstylewithmarksnouc[4][section]{\etocmulticolstyle[#2]% + {\csname #1\endcsname *{#3\etocmarkbothnouc{#4}}}} +\def\Etoc@redefetocstyle#1{% + \renewcommand\etoctocstylewithmarks[4][#1] + {\etocmulticolstyle[##2]% + {\csname ##1\endcsname *{##3\etocmarkboth{##4}}}} + \renewcommand\etoctocstylewithmarksnouc[4][#1] + {\etocmulticolstyle[##2]% + {\csname ##1\endcsname *{##3\etocmarkbothnouc{##4}}}} + \renewcommand\etoctocstyle[3][#1]{% + \etocmulticolstyle[##2]{\csname ##1\endcsname *{##3}}}} +\@ifclassloaded{scrartcl} + {\renewcommand\etocstandarddisplaystyle{\etocscrartclstyle}}{} +\@ifclassloaded{book} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocbookstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{report} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocreportstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{scrbook} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocscrbookstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{scrreprt} + {\renewcommand\etocfontone{\normalfont\normalsize} + \renewcommand\etocstandarddisplaystyle{\etocscrreprtstyle} + \Etoc@redefetocstyle{chapter}}{} +\@ifclassloaded{memoir} + {\renewcommand\etocfontone{\normalfont\normalsize} + \etocmemoirtoctotocfmt{chapter}{\contentsname}% + \renewcommand\etocstandarddisplaystyle{\etocmemoirstyle} + \Etoc@redefetocstyle{chapter}}{} +\newcommand\etocstandardlines{\Etoc@standardtrue} +\etoctoclines +\etocstandardlines +\etocstandarddisplaystyle \endinput %% %% End of file `etoc.sty'. -- cgit v1.2.3