diff options
author | Karl Berry <karl@freefriends.org> | 2016-09-10 21:11:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-09-10 21:11:01 +0000 |
commit | 5c3da0da8a472ce2b35b66cf2050bf74aea5bd33 (patch) | |
tree | 49327865362b087477452f6e2094d333d04da98e /Master/texmf-dist/source/latex/etoc | |
parent | 69853360e6612dd8c9939367f987e675f8f78462 (diff) |
etoc (10sep16)
git-svn-id: svn://tug.org/texlive/trunk@42033 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/etoc')
-rw-r--r-- | Master/texmf-dist/source/latex/etoc/etoc.dtx | 709 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/etoc/etoc.ins | 6 |
2 files changed, 665 insertions, 50 deletions
diff --git a/Master/texmf-dist/source/latex/etoc/etoc.dtx b/Master/texmf-dist/source/latex/etoc/etoc.dtx index eeecf1a0c0c..a7ebf849b55 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.dtx +++ b/Master/texmf-dist/source/latex/etoc/etoc.dtx @@ -1,13 +1,13 @@ -% -*- coding: utf-8; -*- +% -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- +% N.B.: this dtx file is NOT for use with \DocInput. The latex source of the +% user manual isn't prefixed with percent signs. %<*none> -{\def\doctimestamp {Time-stamp: <12-11-2015 15:44:31 CET>}% - \def\getdtxtimestamp #1 <#2 #3 #4>{#2 at #3 #4}% - \xdef\etocdtxtimestamp {\expandafter\getdtxtimestamp\doctimestamp }}% +\def\etocdtxtimestamp {Time-stamp: <09-09-2016 at 21:49:18 CEST>}% %</none> %<*!readme> %% %% Package: etoc -%% Version: 1.08g (2015/08/29 -- doc 2015/11/12) +%% Version: 1.08g (2015/08/29 -- doc 2016/09/09) %% License: LPPL 1.3c or later (see etoc.dtx) %% Copyright (C) 2012-2015 Jean-Francois Burnol %% <jfbu at free dot fr> @@ -18,9 +18,9 @@ %</!readme> %<*insfile> \def\etocpkgdate {2015/08/29} -\def\etocdocdate {2015/11/12} +\def\etocdocdate {2016/09/09} \def\etocpkgversion {v1.08g} -\def\etocpkgdescription {Completely customisable TOCs (jfB)} +\def\etocpkgdescription {Completely customisable TOCs (JFB)} %</insfile> %<*none> % Now the date and version which are specific to the German translation. @@ -36,7 +36,7 @@ \catcode32=13\catcode`\\=12^^Brelax^^A ^^Bfirstofone{^^Bendgroup^^Bdef^^BetocLicense^^A {% Package: etoc -% Version: 1.08g (2015/08/29 -- doc 2015/11/12) +% Version: 1.08g (2015/08/29 -- doc 2016/09/09) % License: LPPL 1.3c or later % Copyright (C) 2012-2015 Jean-Francois Burnol <jfbu at free dot fr> % Copyright (C) 2014-2015 Christine Roemer <Christine_Roemer at t-online dot de> @@ -71,13 +71,13 @@ %<*readme> <!-- --> - Source: etoc.dtx (v1.08g 2015/08/29 -- doc 2015/11/12) + Source: etoc.dtx (v1.08g 2015/08/29 -- doc 2016/09/09) Author: Jean-Francois Burnol Author: Christine Roemer et al. (German tranlation) Info: Completely customisable TOCs License: LPPL 1.3c or later - Copyright (C) 2012-2015 Jean-Francois Burnol. - Copyright (C) 2014-2015 Christine Roemer and collaborators for + Copyright (C) 2012-2016 Jean-Francois Burnol. + Copyright (C) 2014-2016 Christine Roemer and collaborators for the translation into German of the documentation. <jfbu at free dot fr> <Christine_Roemer at t-online dot de> @@ -1035,11 +1035,39 @@ pdfpagemode=UseOutlines} \def\tikzmycustomgrowth {% \pgftransformreset \ifnum\tikztreelevel=1 - \pgftransformrotate{55+((\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild)}% +% \pgftransformrotate{55+((\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild)}% + \pgftransformrotate{-55+((\pgfkeysvalueof{/tikz/sibling angle})*(\tikznumberofcurrentchild)}% \pgftransformxshift{\the\tikzleveldistance}% \fi \ifnum\tikztreelevel=2 +% modifications le Vendredi 09 septembre 2016 à 11:23:42 + % \pgfmathsetmacro\tikzoffsetofcurrentchild{(\tikzsiblingdistance)*(\tikznumberofcurrentgrandchild)}% + % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelwidth pt + % \pgftransformxshift{\tikzlevelwidth/2-\tikzoffsetofcurrentchild} + % \pgftransformyshift{\tikzlevelheight/2} + % \else + % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelwidth}% + % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt + % \pgftransformxshift{-\tikzlevelwidth/2} + % \pgftransformyshift{\tikzlevelheight/2-\tikzoffsetofcurrentchild} + % \else + % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelheight}% + % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelwidth pt + % \pgftransformxshift{-\tikzlevelwidth/2+\tikzoffsetofcurrentchild} + % \pgftransformyshift{-\tikzlevelheight/2} + % \else + % \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelwidth}% + % \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt + % \pgftransformxshift{\tikzlevelwidth/2} + % \pgftransformyshift{-\tikzlevelheight/2+\tikzoffsetofcurrentchild} + % \fi\fi\fi\fi + % \global\advance\tikznumberofcurrentgrandchild by1 \pgfmathsetmacro\tikzoffsetofcurrentchild{(\tikzsiblingdistance)*(\tikznumberofcurrentgrandchild)}% + \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt + \pgftransformxshift{\tikzlevelwidth/2} + \pgftransformyshift{-\tikzlevelheight/2+\tikzoffsetofcurrentchild} + \else + \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelheight}% \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelwidth pt \pgftransformxshift{\tikzlevelwidth/2-\tikzoffsetofcurrentchild} \pgftransformyshift{\tikzlevelheight/2} @@ -1055,9 +1083,10 @@ pdfpagemode=UseOutlines} \pgftransformyshift{-\tikzlevelheight/2} \else \pgfmathsetmacro\tikzoffsetofcurrentchild{\tikzoffsetofcurrentchild-\tikzlevelwidth}% - \ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt + %\ifdim\tikzoffsetofcurrentchild pt<\tikzlevelheight pt \pgftransformxshift{\tikzlevelwidth/2} \pgftransformyshift{-\tikzlevelheight/2+\tikzoffsetofcurrentchild} + %\fi \fi\fi\fi\fi \global\advance\tikznumberofcurrentgrandchild by1 \fi @@ -1315,7 +1344,8 @@ etoc-framed-mp-hook % % distance par rapport au CENTRE ! (avec le code tel qu'en ce moment) % 39 hard coded mais je pourrais aussi le calculer % pour version rectangulaire, par tâtonnements: - level 2/.append style={level width=21cm,level height=30cm, sibling distance=2.57cm}, + level 2/.append style={level width=21cm,level height=30cm, sibling + distance=2.25cm},% was 2.57cm ] \the\treetok \end{tikzpicture}}\endgroup } @@ -1352,6 +1382,9 @@ etoc-framed-mp-hook \tableofcontents \label{toc:main} \endgroup +% ATTENTION Vendredi 09 septembre 2016 à 21:46:51 +\clearpage + \phantomsection\addcontentsline{toc}{section}{\abstractname} \begin{abstract} The \etoc package gives to the user complete control on how @@ -1587,7 +1620,7 @@ the second is executed after the TOC contents. These commands must be followed either by \toc or \localtoc. -\subsection{Compatibility mode}\label{ssub:compat} +\subsection{Compatibility mode}\label{subs:compat} \label{etoctoclines} \label{etocstandardlines} @@ -1845,6 +1878,215 @@ The code: \endgroup \end{verbatim} +\section{A third example: emulating the book class}\label{sec:thirdexample} + +As explained in \autoref{subs:compat}: without explicit use of an +\csb{etocsetstyle} command the package will leave to the document class the +hand regarding the ``toc line styles''. It is sometimes asked by users (for +example those using \etoc for its \csb{localtableofcontents}) how to stay +close to but not completely identical with the design implemented by the +standard classes, such as |book|. I can recommend package |tocloft| for this, +as it is compatible with \etoc (see \autoref{subs:tocloft}) and thus \etoc will +obey the |tocloft| customizations (as long as no use has been made of +\csa{etocsetstyle}). It is also possible to modify only the style for, say, +sections and leave the parts, chapters, subsections as in the document class, +via the technique from \autoref{sec:anothercompat}. + +But for complete control, here is a translation of the |book| class code into +\etoc lingua. It is then easy to modify the relevant lengths or adjust the +used fonts. I thank \textsc{Denis Bitouzé} for prompting me to include this in +the \etoc manual, as it resulted from some conversation we had about this. The +code is not 100\% faithful to the |book| class, and particularly its rendering +of (multi-line) non-numbered units differs (... I think, as I copied pasted as +is the code from where I had stored it and did not do much thinking about it +again). Some proficiency in low-level \TeX\ and \LaTeX\ macros is needed to +understand what the code says, but for modifying fonts or some lengths such +in-depth understanding is not needed. + +With some extra code one can \emph{automatically adjust the widths} assigned +to typesetting sectioning numbers in order to prevent overflows, even with for +example \MakeUppercase{\romannumeral 38}; but this is a more advanced feature +which I have moved to \autoref{sec:thirdexampleextra}. + +First we set up some lengths. I use macro registers, not real \LaTeX\ lengths. +When using |em|'s however, this means that one must pay attention to when the +actual dimension assignment is made, as this will then depend upon the current +font settings. In the code below, at the location where the \csa{TOCnumwidthB} +and \csa{TOCnumwidthC} will be used, the |1em| from their specification will +be matched to the normal medium series font, not the bold font; this is +deliberate so that one can compare more readily with the other dimensions; +besides, with the \csa{TOCcomputenumwidths} from +\autoref{sec:thirdexampleextra} these macros will actually hold a dimension +using |pt| as dimensional unit. +\begin{verbatim} +% it will be easy to globally shift the TOC horizontally if needed +\def\TOCleftmargin {0pt} +\def\TOCrightmargin {2.55em}% like LaTeX's \@tocrmarg + +% this is for dotted leaders +\newbox\TOCleaderbox +\def\TOCleaderboxwidth {0.7777em}% about like what standard classes do + +% vertical spacing +\def\TOCverysmallvskip {0pt plus .2pt} +\def\TOCmedvskip {1em plus 1pt} +\def\TOCbigvskip {2.25em plus 1pt} + +% the ``numwidths'' for typesetting the numbering of division units. +% I don't recall exactly how (and for which fonts) these figures were chosen. +% They quickly prove too small if using Roman numerals (as do too the book +% class defaults even though they are a bit larger). +\def\TOCnumwidthB {1.5em} % chapter +\def\TOCnumwidthC {2.278em}% section, I think default is 2.3em +\def\TOCnumwidthD {3.056em}% analog in standard class is 3.2em +\def\TOCnumwidthE {3.833em}% analog in standard class is 4.1em +\def\TOCnumwidthF {4.611em}% analog in standard class is 5em +\def\TOCnumwidthG {5.389em}% analog in standard class is 6em +\end{verbatim} +The code for the ``global toc style''. +\begin{verbatim} +\makeatletter +\etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \parindent\z@ \leftskip\z@skip \rightskip \z@skip + \setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}% + \chapter *{\noindent\kern\TOCleftmargin\relax % uses "pt"... + \contentsname + \@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}}% + \rightskip \TOCrightmargin\relax + \parfillskip -\rightskip % or a smaller value if desired + \leftskip \TOCleftmargin \relax } + {\if@restonecol \twocolumn \fi\cleardoublepage}% +\makeatother +\end{verbatim} +The code for the |part| and |chapter| line styles: +\begin{verbatim} +\makeatletter +\etocsetstyle{part} + {} + {\addpenalty {-\@highpenalty}% + \addvspace \TOCbigvskip + \leavevmode + {\large \bfseries % use a group to limit font change + \interlinepenalty\@M + \etocifnumbered{\etocnumber\hspace{1em}}{}% + \etocname + \nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}}\par + \nobreak + } + {} + {} +\etocsetstyle{chapter} + {\advance\leftskip\TOCnumwidthB\relax} + {\addpenalty {-\@highpenalty }% + \vskip \TOCmedvskip\relax + \leavevmode + {\interlinepenalty\@M + \etocifnumbered + {\llap{\makebox[\TOCnumwidthB][l]{\bfseries\etocnumber}}} + {\advance\leftskip-\TOCnumwidthB\relax}% + \bfseries\etocname + \nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }% + \penalty \@highpenalty + } + {} + {\advance\leftskip-\TOCnumwidthB\relax} +\makeatother +\end{verbatim} +The remaining divisions share the same code, here abstracted into a macro: +\begin{verbatim} +\makeatletter +\newcommand\TOCsetlinestyle [2]{% #1= unit, #2= numwidth as macro +\etocsetstyle{#1} + {\advance\leftskip#2\relax} + {\vskip \TOCverysmallvskip\relax + \leavevmode + {\interlinepenalty\@M + \etocifnumbered + {\llap{\makebox[#2][l]{\etocnumber}}}{\advance\leftskip-#2\relax}% + \etocname + \nobreak\leaders \copy\TOCleaderbox + \hfil\makebox[-\parfillskip][r]{\etocpage}% + \par }% + } + {} + {\advance\leftskip-#2\relax}% +} +\makeatother +\TOCsetlinestyle {section} {\TOCnumwidthC} +\TOCsetlinestyle {subsection} {\TOCnumwidthD} +\TOCsetlinestyle {subsubsection}{\TOCnumwidthE} +\TOCsetlinestyle {paragraph} {\TOCnumwidthF} +\TOCsetlinestyle {subparagraph} {\TOCnumwidthG} +\end{verbatim} +Note Bene: the code deliberately handles the non-numbered sectioning units +unlike the way of the standard document classes (particularly regarding the +alignment of multi-line headings.) + +In practice, typically one will want to use \csb{localtableofcontents}, hence +we need to change a bit the global toc style for using |\section*| rather than +|\chapter*| for example. When the time comes for these local ``minitocs'' one +can do something like the following (of course all of that can be stored +inside a macro, whose definition can be located in the preamble.) + +For some reason this code has some hard-coded |2.25em| and |4.5em| which were +not abstracted into macros or lengths. + +The code inserts horizontal rules above and below the TOC contents in a +non-separable by pagebreak way. +\begin{verbatim} +\makeatletter +\etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}% + \parindent\z@ + \dimen@ 2.25em % soon to be \leftskip + \section *{\kern\dimen@ % \dimen@ works here by sheer luck + \contentsname + \@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}}% + \parskip \z@skip + \vspace{-1.25\baselineskip}% somewhat ad hoc + \leftskip 2.25em + \rightskip 4.5em + \advance\rightskip-\TOCrightmargin\relax + \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par + \rightskip 4.5em + \parfillskip -\TOCrightmargin\relax } + {\nobreak\vskip-.5\baselineskip + \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par + \bigskip + \if@restonecol \twocolumn \fi } +\makeatother +\end{verbatim} +We then need to specify the line styles: +\begin{verbatim} +\makeatletter +\etocsetstyle{section} + {\advance\leftskip\TOCnumwidthC\relax} + {\addpenalty \@secpenalty + \etociffirst{}{\addvspace{\TOCmedvskip}}% + \leavevmode + {\interlinepenalty\@M + \bfseries\etocifnumbered + {\llap{\makebox[\TOCnumwidthC][l]{\etocnumber}}} + {\advance\leftskip-\TOCnumwidthC}% + \etocname\nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }% + \penalty \@highpenalty } + {} + {\advance\leftskip-\TOCnumwidthC\relax} +\makeatother +\TOCsetlinestyle {subsection} {\TOCnumwidthD} +\TOCsetlinestyle {subsubsection}{\TOCnumwidthE} +\TOCsetlinestyle {paragraph} {\TOCnumwidthF} +\TOCsetlinestyle {subparagraph} {\TOCnumwidthG} +\end{verbatim} +As mentioned previously, this handles non-numbered (multi-line) sectioning +units somewhat differently from what happens in the standard document classes. + +See \autoref{sec:thirdexampleextra} for more. + +% ATTENTION Vendredi 09 septembre 2016 à 21:48:15 +\clearpage \section{Linked list of the main package commands} \begingroup\raggedcolumns @@ -1896,6 +2138,8 @@ The code: \csb{etocthepage}\par \csb{etoctoccontentsline}\par \csb{etoctoclines}\par + \csb{localtableofcontents}\par + \csb{tableofcontents}\par %\vspace{5\baselineskip}\hrule height 0pt \end{multicols} \endgroup @@ -1915,6 +2159,8 @@ The code: \localtableofcontents \section{Labeling and reusing elsewhere} +\label{tableofcontents} +\label{localtableofcontents} \etoc allows arbitrarily many \csa{tableofcontents} commands in your document. The line styles and the toc display style may of @@ -2937,9 +3183,9 @@ Another technique for doing this kind of things is explained in \repeat \endgroup -\section{Another compatibility mode} +\section{Another compatibility mode}\label{sec:anothercompat} -As explained in \autoref{ssub:compat}, the commands +As explained in \autoref{subs:compat}, the commands \csa{etocstandardlines} and \csa{etocstandarddisplaystyle} tell \etoc to, essentially, act as an observer. The document class layout for the table of contents is then perfectly obeyed. There is no way to customize this standard @@ -3677,9 +3923,9 @@ appears \vpageref{toc:mindmap}. nodes={concept}, concept color=orange!60, root concept/.append style={text width=4cm, font=\Large}, - level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, - level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, - level 1 concept/.append style={font=\normalsize}, + level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, + level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, + level 1 concept/.append style={font=\normalsize}, ] \the\treetok \end{tikzpicture}}} @@ -3987,6 +4233,82 @@ of contents to be empty (for that run) and thus printed nothing (not even a |\par|). +\section{A TOC self-adjusting widths for its typesetting} +\label{sec:thirdexampleextra} + +This is a continuation of \autoref{sec:thirdexample}. The goal is to adjust +automatically the ``numwidths'' used for typesetting the unit numbers in the +(local) tables of contents. +\begin{verbatim} +\newcommand*\TOCcomputenumwidths [1][]{% #1=empty or "local" + \begingroup + \def\TOCnumwidthB {0pt}% + \def\TOCnumwidthC {0pt}% + \def\TOCnumwidthD {0pt}% + \def\TOCnumwidthE {0pt}% + \def\TOCnumwidthF {0pt}% + \def\TOCnumwidthG {0pt}% + \etocsetstyle{part}{}{}{}{}% + \etocsetstyle{chapter}{} + {\setbox0\hbox{\bfseries\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthB\edef\TOCnumwidthB{\the\wd0}\fi}{}% + \etocsetstyle{section}{} + {\setbox0\hbox{\bfseries\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthC\edef\TOCnumwidthC{\the\wd0}\fi}{}% + \etocsetstyle{subsection}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthD\edef\TOCnumwidthD{\the\wd0}\fi}{}% + \etocsetstyle{subsubsection}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthE\edef\TOCnumwidthE{\the\wd0}\fi}{}% + \etocsetstyle{paragraph}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthF\edef\TOCnumwidthF{\the\wd0}\fi}{}% + \etocsetstyle{subparagraph}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthG\edef\TOCnumwidthG{\the\wd0}\fi}{}% + % + \etocsettocstyle{} + {\global\let\TOCnumwidthB\TOCnumwidthB + \global\let\TOCnumwidthC\TOCnumwidthC + \global\let\TOCnumwidthD\TOCnumwidthD + \global\let\TOCnumwidthE\TOCnumwidthE + \global\let\TOCnumwidthF\TOCnumwidthF + \global\let\TOCnumwidthG\TOCnumwidthG}% + \etocnopar + \csname #1tableofcontents\endcsname +\typeout{Next TOCs will use \TOCnumwidthB\space for chapter number width}% +\typeout{Next TOCs will use \TOCnumwidthC\space for section number width}% +\typeout{Next TOCs will use \TOCnumwidthD\space for subsection number width}% +\typeout{Next TOCs will use \TOCnumwidthE\space for subsubsection number width}% +\typeout{Next TOCs will use \TOCnumwidthF\space for paragraph number width}% +\typeout{Next TOCs will use \TOCnumwidthG\space for subparagraph number width}% + \endgroup +}% +\end{verbatim} +One invokes either only once \csa{TOCcomputenumwidths} (with +a prior |\etocsetnexttocdepth{all}|) or, alternatively multiple times, +using the optional argument: +\begin{verbatim} +\bgroup + \etocsettocdepth{paragraph}% for example + \TOCcomputenumwidths [local]% + \localtableofcontents +\egroup +\end{verbatim} +Then each local table of contents will compute the various ``numwidths'' to +match exactly (with an extra |0.5em|), for each sectioning unit (apart from +|\part| as it has no associated ``numwidth'' in the table of contents code of +the |book| class), the widest number found. As the code makes global +assignments, it is either to be used only once, or for each local table of +contents. Notice that the bold font serves for both chapter and section +styles, but the code from \autoref{sec:thirdexample} does not use bold for +sections in the global TOC, only in local TOCs. Thus the +\csa{TOCcomputenumwidth} will set the parameter \csa{TOCnumwidthC} to a value +slightly larger than needed in the main TOC. Hence the section style in +\csa{TOCcomputenumwidths} should possibly insert the |\bfseries| in the box +only after testing for the optional parameter |local|. + \clearpage \etocdepthtag.toc {linestyles} @@ -5469,9 +5791,9 @@ use or not colors is left to the user. \etocstandardlines \localtableofcontents -\section{... and tricks} +%\section{... and tricks} -\subsection{Hacking framed parboxes} +\section{Hacking framed parboxes} \begin{verbatim} @@ -5499,7 +5821,7 @@ use or not colors is left to the user. \ref{toc:globalcmds} -\subsection{Interverting the levels} +\section{Interverting the levels} \label{subsec:interverting} Let us display and count all subsections occurring in this @@ -5547,7 +5869,7 @@ this technique): \endgroup -\subsection{Displaying statistics}\label{ssec:statistics} +\section{Displaying statistics}\label{ssec:statistics} Each part of this document starts with a paragraph telling how many sections and subsections it has. Well, each one of this paragraph is a @@ -5643,7 +5965,7 @@ stands here is for using within a section). \makeatother \end{verbatim} -\subsection{Using depth tags} +\section{Using depth tags} \label{ssec:tocwithdepthtags} We want a TOC which will have a heading for each |\part| (except @@ -5798,7 +6120,7 @@ get: \end{verbatim} \endgroup -\subsection{Typesetting the TOC as a table (the old way)} +\section{Typesetting the TOC as a table (the old way)} \label{ssec:tocastableold} Due to, among other things, the fact that alignment cells create and close @@ -5983,7 +6305,7 @@ first. \etoc loads the package |multicol|. -\subsection{Compatibility with \texttt{tocloft}} +\subsection{Compatibility with \texttt{tocloft}}\label{subs:tocloft} Release |1.07k| added compatibility with package |tocloft|:\footnote{\url{http://ctan.org/pkg/tocloft}} steps are @@ -6189,11 +6511,11 @@ version is \texttt{\etocpkgversion}, of \texttt{\etocpkgdate}. concept color=orange!60, root concept/.append style={font=\huge, text width = 6cm}, % geändert 2015/11/12 6cm->7cm - level 1/.append style={level distance=7cm, sibling angle=360/9}, - level 1 concept/.append style={font=\Large, text width = - 3cm}, + level 1/.append style={level distance=7cm, sibling angle=360/9}, + level 1 concept/.append style={font=\Large, text width = 3cm}, % geändert 2015/11/12 20cm->21cm - level 2/.append style={level width=21cm,level height=30cm, sibling distance=2.57cm}, + level 2/.append style={level width=21cm,level height=30cm, sibling + distance=2.25cm},% 2.57cm ] \the\treetok \end{tikzpicture}}\endgroup } @@ -6230,6 +6552,9 @@ version is \texttt{\etocpkgversion}, of \texttt{\etocpkgdate}. \tableofcontents \label{toc:main} \endgroup +% Attention Vendredi 09 septembre 2016 à 21:49:17 +\clearpage + \phantomsection\addcontentsline{toc}{section}{\abstractname} \begin{abstract} Das \etoc"=Paket gibt dem Nutzer lückenlose Möglichkeiten, die Einträge des @@ -6452,7 +6777,7 @@ Spalten (Einspaltenmodus kann durch das optionale Argument Diese Befehle müssen entweder von \toc oder \localtoc gefolgt sein. -\subsection{Kompatibilismus}\label{ssub:compat} +\subsection{Kompatibilismus}\label{subs:compat} \label{etoctoclines} \label{etocstandardlines} @@ -6710,6 +7035,216 @@ Der Code: \endgroup \end{verbatim} +\begin{otherlanguage}{english} +\section{Ein drittes Beispiel: emulating the book class}\label{sec:thirdexample} + +As explained in \autoref{subs:compat}: without explicit use of an +\csb{etocsetstyle} command the package will leave to the document class the +hand regarding the ``toc line styles''. It is sometimes asked by users (for +example those using \etoc for its \csb{localtableofcontents}) how to stay +close to but not completely identical with the design implemented by the +standard classes, such as |book|. I can recommend package |tocloft| for this, +as it is compatible with \etoc (see \autoref{sec:kompatmitanderen}) and thus \etoc will +obey the |tocloft| customizations (as long as no use has been made of +\csa{etocsetstyle}). It is also possible to modify only the style for, say, +sections and leave the parts, chapters, subsections as in the document class, +via the technique from \autoref{sec:anothercompat}. + +But for complete control, here is a translation of the |book| class code into +\etoc lingua. It is then easy to modify the relevant lengths or adjust the +used fonts. I thank \textsc{Denis Bitouzé} for prompting me to include this in +the \etoc manual, as it resulted from some conversation we had about this. The +code is not 100\% faithful to the |book| class, and particularly its rendering +of (multi-line) non-numbered units differs (... I think, as I copied pasted as +is the code from where I had stored it and did not do much thinking about it +again). Some proficiency in low-level \TeX\ and \LaTeX\ macros is needed to +understand what the code says, but for modifying fonts or some lengths such +in-depth understanding is not needed. + +With some extra code one can \emph{automatically adjust the widths} assigned +to typesetting sectioning numbers in order to prevent overflows, even with for +example \MakeUppercase{\romannumeral 38}; but this is a more advanced feature +which I have moved to \autoref{sec:thirdexampleextra}. + +First we set up some lengths. I use macro registers, not real \LaTeX\ lengths. +When using |em|'s however, this means that one must pay attention to when the +actual dimension assignment is made, as this will then depend upon the current +font settings. In the code below, at the location where the \csa{TOCnumwidthB} +and \csa{TOCnumwidthC} will be used, the |1em| from their specification will +be matched to the normal medium series font, not the bold font; this is +deliberate so that one can compare more readily with the other dimensions; +besides, with the \csa{TOCcomputenumwidths} from +\autoref{sec:thirdexampleextra} these macros will actually hold a dimension +using |pt| as dimensional unit. +\begin{verbatim} +% it will be easy to globally shift the TOC horizontally if needed +\def\TOCleftmargin {0pt} +\def\TOCrightmargin {2.55em}% like LaTeX's \@tocrmarg + +% this is for dotted leaders +\newbox\TOCleaderbox +\def\TOCleaderboxwidth {0.7777em}% about like what standard classes do + +% vertical spacing +\def\TOCverysmallvskip {0pt plus .2pt} +\def\TOCmedvskip {1em plus 1pt} +\def\TOCbigvskip {2.25em plus 1pt} + +% the ``numwidths'' for typesetting the numbering of division units. +% I don't recall exactly how (and for which fonts) these figures were chosen. +% They quickly prove too small if using Roman numerals (as do too the book +% class defaults indicated below which although a bit larger). +\def\TOCnumwidthB {1.5em} % chapter +\def\TOCnumwidthC {2.278em}% section, I think default is 2.3em +\def\TOCnumwidthD {3.056em}% analog in standard class is 3.2em +\def\TOCnumwidthE {3.833em}% analog in standard class is 4.1em +\def\TOCnumwidthF {4.611em}% analog in standard class is 5em +\def\TOCnumwidthG {5.389em}% analog in standard class is 6em +\end{verbatim} +The code for the ``global toc style''. +\begin{verbatim} +\makeatletter +\etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \parindent\z@ \leftskip\z@skip \rightskip \z@skip + \setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}% + \chapter *{\noindent\kern\TOCleftmargin\relax % uses "pt"... + \contentsname + \@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}}% + \rightskip \TOCrightmargin\relax + \parfillskip -\rightskip % or a smaller value if desired + \leftskip \TOCleftmargin \relax } + {\if@restonecol \twocolumn \fi\cleardoublepage}% +\makeatother +\end{verbatim} +The code for the |part| and |chapter| line styles: +\begin{verbatim} +\makeatletter +\etocsetstyle{part} + {} + {\addpenalty {-\@highpenalty}% + \addvspace \TOCbigvskip + \leavevmode + {\large \bfseries % use a group to limit font change + \interlinepenalty\@M + \etocifnumbered{\etocnumber\hspace{1em}}{}% + \etocname + \nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}}\par + \nobreak + } + {} + {} +\etocsetstyle{chapter} + {\advance\leftskip\TOCnumwidthB\relax} + {\addpenalty {-\@highpenalty }% + \vskip \TOCmedvskip\relax + \leavevmode + {\interlinepenalty\@M + \etocifnumbered + {\llap{\makebox[\TOCnumwidthB][l]{\bfseries\etocnumber}}} + {\advance\leftskip-\TOCnumwidthB\relax}% + \bfseries\etocname + \nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }% + \penalty \@highpenalty + } + {} + {\advance\leftskip-\TOCnumwidthB\relax} +\makeatother +\end{verbatim} +The remaining divisions share the same code, here abstracted into a macro: +\begin{verbatim} +\makeatletter +\newcommand\TOCsetlinestyle [2]{% #1= unit, #2= numwidth as macro +\etocsetstyle{#1} + {\advance\leftskip#2\relax} + {\vskip \TOCverysmallvskip\relax + \leavevmode + {\interlinepenalty\@M + \etocifnumbered + {\llap{\makebox[#2][l]{\etocnumber}}}{\advance\leftskip-#2\relax}% + \etocname + \nobreak\leaders \copy\TOCleaderbox + \hfil\makebox[-\parfillskip][r]{\etocpage}% + \par }% + } + {} + {\advance\leftskip-#2\relax}% +} +\makeatother +\TOCsetlinestyle {section} {\TOCnumwidthC} +\TOCsetlinestyle {subsection} {\TOCnumwidthD} +\TOCsetlinestyle {subsubsection}{\TOCnumwidthE} +\TOCsetlinestyle {paragraph} {\TOCnumwidthF} +\TOCsetlinestyle {subparagraph} {\TOCnumwidthG} +\end{verbatim} +Note Bene: the code deliberately handles the non-numbered sectioning units +unlike the way of the standard document classes (particularly regarding the +alignment of multi-line headings.) + +In practice, typically one will want to use \csb{localtableofcontents}, hence +we need to change a bit the global toc style for using |\section*| rather than +|\chapter*| for example. When the time comes for these local ``minitocs'' one +can do something like the following (of course all of that can be stored +inside a macro, whose definition can be located in the preamble.) + +For some reason this code has some hard-coded |2.25em| and |4.5em| which were +not abstracted into macros or lengths. + +The code inserts horizontal rules above and below the TOC contents in a +non-separable by pagebreak way. +\begin{verbatim} +\makeatletter +\etocsettocstyle + {\if@twocolumn \@restonecoltrue \onecolumn \else \@restonecolfalse \fi + \setbox\TOCleaderbox\hbox to \TOCleaderboxwidth{\hss.\hss}% + \parindent\z@ + \dimen@ 2.25em % soon to be \leftskip + \section *{\kern\dimen@ % \dimen@ works here by sheer luck + \contentsname + \@mkboth {\MakeUppercase \contentsname}{\MakeUppercase \contentsname}}% + \parskip \z@skip + \vspace{-1.25\baselineskip}% somewhat ad hoc + \leftskip 2.25em + \rightskip 4.5em + \advance\rightskip-\TOCrightmargin\relax + \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par + \rightskip 4.5em + \parfillskip -\TOCrightmargin\relax } + {\nobreak\vskip-.5\baselineskip + \leavevmode\leaders\hrule\@height\p@\hfill\kern\z@\par + \bigskip + \if@restonecol \twocolumn \fi } +\makeatother +\end{verbatim} +We then need to specify the line styles: +\begin{verbatim} +\makeatletter +\etocsetstyle{section} + {\advance\leftskip\TOCnumwidthC\relax} + {\addpenalty \@secpenalty + \etociffirst{}{\addvspace{\TOCmedvskip}}% + \leavevmode + {\interlinepenalty\@M + \bfseries\etocifnumbered + {\llap{\makebox[\TOCnumwidthC][l]{\etocnumber}}} + {\advance\leftskip-\TOCnumwidthC}% + \etocname\nobreak\hfil\makebox[-\parfillskip][r]{\etocpage}\par }% + \penalty \@highpenalty } + {} + {\advance\leftskip-\TOCnumwidthC\relax} +\makeatother +\TOCsetlinestyle {subsection} {\TOCnumwidthD} +\TOCsetlinestyle {subsubsection}{\TOCnumwidthE} +\TOCsetlinestyle {paragraph} {\TOCnumwidthF} +\TOCsetlinestyle {subparagraph} {\TOCnumwidthG} +\end{verbatim} +As mentioned previously, this handles non-numbered (multi-line) sectioning +units somewhat differently from what happens in the standard document classes. + +See \autoref{sec:thirdexampleextra} for more. + +\end{otherlanguage} + % \clearpage % ATTENTION 28 mars 2015 \section{Verlinkte Liste der Hauptbefehle} @@ -6764,6 +7299,8 @@ Der Code: \csb{etocthepage}\par \csb{etoctoccontentsline}\par \csb{etoctoclines}\par + \csb{localtableofcontents}\par + \csb{tableofcontents}\par %\vspace{5\baselineskip}\hrule height 0pt \end{multicols} \endgroup @@ -6783,6 +7320,8 @@ Der Code: \localtableofcontents \section{Beschriften und anderswo wieder benutzen} +\label{tableofcontents} +\label{localtableofcontents} \etoc erlaubt beliebig viele \csa{tableofcontents}"=Befehle in ihrem Dokument. Die Zeilen- und Inhaltsangabenstile können @@ -7771,9 +8310,9 @@ Eine andere Technik für diese Art der Dinge erläutert \repeat \endgroup -\section{Ein weiterer Kompatibilitätsmodus} +\section{Ein weiterer Kompatibilitätsmodus}\label{sec:anothercompat} -Wie in \autoref{ssub:compat} erläutert, sagen die Befehle +Wie in \autoref{subs:compat} erläutert, sagen die Befehle \csa{etocstandardlines} und \csa{etocstandarddisplaystyle} \etoc im Wesentlichen, wie man als Beobachter fungiert. Das Dokumentenklasse"=Layout für das Inhaltsverzeichnis wird dann gehorchen. Es gibt keine Möglichkeit, dieses @@ -8394,9 +8933,9 @@ page}.} nodes={concept}, concept color=orange!60, root concept/.append style={text width=4cm, font=\Large}, - level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, - level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, - level 1 concept/.append style={font=\normalsize}, + level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, + level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, + level 1 concept/.append style={font=\normalsize}, ] \the\treetok \end{tikzpicture}}} @@ -8517,9 +9056,9 @@ hier \vpageref{toc:mindmap}. nodes={concept}, concept color=orange!60, root concept/.append style={text width=4cm, font=\Large}, - level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, - level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, - level 1 concept/.append style={font=\normalsize}, + level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm}, + level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm}, + level 1 concept/.append style={font=\normalsize}, ] \the\treetok \end{tikzpicture}}} @@ -8834,6 +9373,82 @@ empty, this does mean that \etoc considered the just encountered local table of contents to be empty (for that run) and thus printed nothing (not even a |\par|). +\section{A TOC self-adjusting widths for its typesetting} +\label{sec:thirdexampleextra} + +This is a continuation of \autoref{sec:thirdexample}. The goal is to adjust +automatically the ``numwidths'' used for typesetting the unit numbers in the +(local) tables of contents. +\begin{verbatim} +\newcommand*\TOCcomputenumwidths [1][]{% #1=empty or "local" + \begingroup + \def\TOCnumwidthB {0pt}% + \def\TOCnumwidthC {0pt}% + \def\TOCnumwidthD {0pt}% + \def\TOCnumwidthE {0pt}% + \def\TOCnumwidthF {0pt}% + \def\TOCnumwidthG {0pt}% + \etocsetstyle{part}{}{}{}{}% + \etocsetstyle{chapter}{} + {\setbox0\hbox{\bfseries\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthB\edef\TOCnumwidthB{\the\wd0}\fi}{}% + \etocsetstyle{section}{} + {\setbox0\hbox{\bfseries\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthC\edef\TOCnumwidthC{\the\wd0}\fi}{}% + \etocsetstyle{subsection}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthD\edef\TOCnumwidthD{\the\wd0}\fi}{}% + \etocsetstyle{subsubsection}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthE\edef\TOCnumwidthE{\the\wd0}\fi}{}% + \etocsetstyle{paragraph}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthF\edef\TOCnumwidthF{\the\wd0}\fi}{}% + \etocsetstyle{subparagraph}{} + {\setbox0\hbox{\etocthenumber\kern0.5em}} + {\ifdim\wd0>\TOCnumwidthG\edef\TOCnumwidthG{\the\wd0}\fi}{}% + % + \etocsettocstyle{} + {\global\let\TOCnumwidthB\TOCnumwidthB + \global\let\TOCnumwidthC\TOCnumwidthC + \global\let\TOCnumwidthD\TOCnumwidthD + \global\let\TOCnumwidthE\TOCnumwidthE + \global\let\TOCnumwidthF\TOCnumwidthF + \global\let\TOCnumwidthG\TOCnumwidthG}% + \etocnopar + \csname #1tableofcontents\endcsname +\typeout{Next TOCs will use \TOCnumwidthB\space for chapter number width}% +\typeout{Next TOCs will use \TOCnumwidthC\space for section number width}% +\typeout{Next TOCs will use \TOCnumwidthD\space for subsection number width}% +\typeout{Next TOCs will use \TOCnumwidthE\space for subsubsection number width}% +\typeout{Next TOCs will use \TOCnumwidthF\space for paragraph number width}% +\typeout{Next TOCs will use \TOCnumwidthG\space for subparagraph number width}% + \endgroup +}% +\end{verbatim} +One invokes either only once \csa{TOCcomputenumwidths} (with +a prior |\etocsetnexttocdepth{all}|) or, alternatively multiple times, +using the optional argument: +\begin{verbatim} +\bgroup + \etocsettocdepth{paragraph}% for example + \TOCcomputenumwidths [local]% + \localtableofcontents +\egroup +\end{verbatim} +Then each local table of contents will compute the various ``numwidths'' to +match exactly (with an extra |0.5em|), for each sectioning unit (apart from +|\part| as it has no associated ``numwidth'' in the table of contents code of +the |book| class), the widest number found. As the code makes global +assignments, it is either to be used only once, or for each local table of +contents. Notice that the bold font serves for both chapter and section +styles, but the code from \autoref{sec:thirdexample} does not use bold for +sections in the global TOC, only in local TOCs. Thus the +\csa{TOCcomputenumwidth} will set the parameter \csa{TOCnumwidthC} to a value +slightly larger than needed in the main TOC. Hence the section style in +\csa{TOCcomputenumwidth} should insert the |\bfseries| in the box only after +testing that optional parameter |local| was used, but well. + \end{otherlanguage} \clearpage @@ -10282,9 +10897,9 @@ Farben nutzen will oder nicht. \etocstandardlines \localtableofcontents -\section{\ldots\ und Tricks} +%\section{\ldots\ und Tricks} -\subsection{Hacken "`framed parboxes"'} +\section{Hacken "`framed parboxes"'} \begin{verbatim} @@ -10310,7 +10925,7 @@ Farben nutzen will oder nicht. \ref{toc:globalcmds} -\subsection{Umstellen der Ebenen} +\section{Umstellen der Ebenen} \label{subsec:interverting} Lasst uns alle Unterabschnitte zeigen und aufzählen, die in diesem Dokument @@ -10357,7 +10972,7 @@ vorkommen (Siehe \autoref{part:surprising} für andere Verwendungen dieser Techn \endgroup -\subsection{Statistiken anzeigen}\label{ssec:statistics} +\section{Statistiken anzeigen}\label{ssec:statistics} Jeder Teil dieses Dokuments beginnt mit einem Paragraphen, der sagt, wieviele Kapitel und Unterkapitel er hat. Nun, jeder von diesen Paragraphen ist ein @@ -10466,7 +11081,7 @@ steht hier für die Verwendung in einem Kapitel). \makeatother \end{verbatim} -\subsection{Tiefe Tags nehmen} +\section{Tiefe Tags nehmen} \label{ssec:tocwithdepthtags} Wir wollen ein TOC, das für jeden |\part| eine Überschrift hat (außer der letzte @@ -10620,7 +11235,7 @@ es kann leicht recycelt) erhalten wir: \end{verbatim} \endgroup -\subsection{Das TOC als eine Tabelle setzend (die alte Weise)} +\section{Das TOC als eine Tabelle setzend (die alte Weise)} \label{ssec:tocastableold} Aufgrund, unter anderem, der Tatsache, dass die Ausrichtung Zellen @@ -10720,7 +11335,7 @@ zum Beispiel \autoref{sec:mindmap}. \part{\etoc und die Außenwelt} -\section{Kompatibilität mit anderen Paketen} +\section{Kompatibilität mit anderen Paketen}\label{sec:kompatmitanderen} % JFBU modifiziert Januar 23, 2015 Die Inhalte der |.toc|-Datei (falls bereits vorhanden) werden einmal in den diff --git a/Master/texmf-dist/source/latex/etoc/etoc.ins b/Master/texmf-dist/source/latex/etoc/etoc.ins index 76a0130f5c3..8a22f09b8a6 100644 --- a/Master/texmf-dist/source/latex/etoc/etoc.ins +++ b/Master/texmf-dist/source/latex/etoc/etoc.ins @@ -1,6 +1,6 @@ %% %% Package: etoc -%% Version: 1.08g (2015/08/29 -- doc 2015/11/12) +%% Version: 1.08g (2015/08/29 -- doc 2016/09/09) %% License: LPPL 1.3c or later (see etoc.dtx) %% Copyright (C) 2012-2015 Jean-Francois Burnol %% <jfbu at free dot fr> @@ -9,9 +9,9 @@ %% and collaborators for the translation into German of the documentation %% \def\etocpkgdate {2015/08/29} -\def\etocdocdate {2015/11/12} +\def\etocdocdate {2016/09/09} \def\etocpkgversion {v1.08g} -\def\etocpkgdescription {Completely customisable TOCs (jfB)} +\def\etocpkgdescription {Completely customisable TOCs (JFB)} %% Run etex on this file to extract from etoc.dtx: %% etoc.sty, etoc.tex, etoc-DE.tex and README.md %% |