From 74e3ca017b02a77b352d7696a8ca4e253e843d2b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Oct 2013 22:29:17 +0000 Subject: etoc (14oct13) git-svn-id: svn://tug.org/texlive/trunk@31904 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/etoc/etoc.sty | 270 ++++++++++++++++++++---------- 1 file changed, 178 insertions(+), 92 deletions(-) (limited to 'Master/texmf-dist/tex/latex/etoc') diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index 6296a45dde2..a84b3be14fc 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -22,19 +22,19 @@ %% in the same archive or directory.) %% \ProvidesPackage{etoc} - [2013/03/07 v1.07f Completely customisable TOCs (jfB)] + [2013/10/13 v1.07g Completely customisable TOCs (jfB)] %% -%% Package `etoc' by Jean-Francois Burnol -%% Copyright (C) 2012, 2013 by Jean-Francois Burnol +%% Package: etoc +%% Version: 2013/10/13 v1.07g +%% Copyright (C) 2012-2013 by Jean-Francois Burnol %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{multicol} -%% \RequirePackage{xspace} %% REMOVED (1.07b) \DeclareOption*{\PackageWarning{etoc}{Option `\CurrentOption' is unknown.}} \ProcessOptions\relax \newtoks\Etoc@toctoks \def\Etoc@par{\par} -\newcommand*{\etocinline}{\def\Etoc@par{}} +\def\etocinline{\def\Etoc@par{}} \let\etocnopar\etocinline \newif\ifEtoc@jj % book \newif\ifEtoc@j % part @@ -56,13 +56,14 @@ \newif\ifEtoc@notactive \newcounter{etoc@tocid} \newif\ifEtoc@mustclosegroup -\def\etoc@{\etoc@} % Delimiter in \Etoc@getnb etc.. macros. This def added 1.07f +\def\etoc@{\etoc@} +\newcounter{etoc@tocdepth}% 1.07g \@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}} \def\Etoc@@minustwo@@{-\tw@} \let\Etoc@@minusone@@\m@ne -\chardef\Etoc@@zero@@ 0 -\let\Etoc@@one@@ \@ne -\let\Etoc@@two@@ \tw@ +\let\Etoc@@zero@@ \z@ +\let\Etoc@@one@@ \@ne +\let\Etoc@@two@@ \tw@ \let\Etoc@@three@@ \thr@@ \chardef\Etoc@@four@@ 4 \chardef\Etoc@@five@@ 5 @@ -76,6 +77,18 @@ \def\Etoc@@three@{three} \def\Etoc@@four@{four} \def\Etoc@@five@{five} +\expandafter\def\csname Etoc@-3@@\endcsname {-\thr@@} +\expandafter\let\csname Etoc@-2@@\endcsname \Etoc@@minustwo@@ +\expandafter\let\csname Etoc@-1@@\endcsname \Etoc@@minusone@@ +\expandafter\let\csname Etoc@0@@\endcsname \Etoc@@zero@@ +\expandafter\let\csname Etoc@1@@\endcsname \Etoc@@one@@ +\expandafter\let\csname Etoc@2@@\endcsname \Etoc@@two@@ +\expandafter\let\csname Etoc@3@@\endcsname \Etoc@@three@@ +\expandafter\let\csname Etoc@4@@\endcsname \Etoc@@four@@ +\expandafter\let\csname Etoc@5@@\endcsname \Etoc@@five@@ +\expandafter\let\csname Etoc@6@@\endcsname \Etoc@@six@@ +\let\Etoc@all@@ \Etoc@@five@@ +\let\Etoc@none@@ \Etoc@minf \def\Etoc@levellist{} \def\Etoc@newlevel#1{% \def\Etoc@levellist@elt{\noexpand\Etoc@levellist@elt\noexpand}% @@ -110,12 +123,16 @@ \ifnum#2=-\tw@ \expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@minustwo@@ \expandafter\let \csname Etoc@#1@\endcsname\Etoc@@minustwo@ + \else + \ifnum#2=-\thr@@ + \expandafter\let \csname Etoc@#1@@\expandafter\endcsname + \csname Etoc@-3@@\endcsname \else \PackageWarning{etoc} {unexpected value `#2' in \string\etocsetlevel.^^J% Should be -2,-1, 0, 1, 2, 3, 4, 5, or 6. Set to 6 (=ignored)}% \expandafter\let\csname Etoc@#1@@\endcsname\Etoc@@six@@ -\fi\fi\fi} +\fi\fi\fi\fi} \etocsetlevel{book}{-2} \etocsetlevel{part}{-1} \etocsetlevel{chapter}{0} @@ -410,13 +427,13 @@ }% \Etoc@getnbr #4\hspace\relax\etoc@ } -\newcommand*\etocthename {} -\newcommand*\etocthenumber {} -\newcommand*\etocthepage {} -\newcommand*\etocthelinkedname {} -\newcommand*\etocthelinkednumber {} -\newcommand*\etocthelinkedpage {} -\newcommand*\etocthelink {} +\let\etocthename \@empty +\let\etocthenumber \@empty +\let\etocthepage \@empty +\let\etocthelinkedname \@empty +\let\etocthelinkednumber \@empty +\let\etocthelinkedpage \@empty +\let\etocthelink \@empty \DeclareRobustCommand*{\etocname} {} \DeclareRobustCommand*{\etocnumber}{} \DeclareRobustCommand*{\etocpage} {} @@ -443,8 +460,7 @@ \Etoc@readtoc\Etoc@tf \closein\Etoc@tf}} {\typeout{No file \jobname .toc.}} -\def\Etoc@openouttoc{% formerly \Etoc@starttoc -%% 1.07d: parskip and \@nobreakfalse stuff moved to \Etoc@tableofcontents +\def\Etoc@openouttoc{% \ifEtoc@hyperref \ifx\hyper@last\@undefined \IfFileExists{\jobname .toc} @@ -459,7 +475,7 @@ \newwrite \tf@toc \immediate \openout \tf@toc \jobname .toc\relax \fi - \gdef\Etoc@openouttoc{}% 1.07d, rather than using a boolean + \gdef\Etoc@openouttoc{}% } \def\Etoc@toctoc{% \global\Etoc@vfalse @@ -528,7 +544,7 @@ \ifnum\Etoc@tmp<\@ne \PackageWarning{etoc} {Unknown toc id: run LaTeX to get references right}% - \leavevmode --unknown etoc ref: run latex again--\par +%%\leavevmode --unknown etoc ref: run latex again--\par (REMOVED IN 1.07g) \let\Etoc@next\@gobble\else\let\Etoc@next\@firstofone\fi \Etoc@next {\edef\etoc@startlocaltoc##1{% @@ -538,7 +554,9 @@ \global\Etoc@stoptocfalse \global\Etoc@notactivetrue \Etoc@tableofcontents}% - \endgroup\ifEtoc@mustclosegroup\endgroup\fi} + \endgroup\ifEtoc@mustclosegroup\endgroup\fi + \etocaftertochook % 1.07g +} \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@}} @@ -560,59 +578,65 @@ \global\Etoc@notactivefalse \Etoc@tableofcontents \endgroup - \ifEtoc@mustclosegroup\endgroup\fi}% + \ifEtoc@mustclosegroup\endgroup\fi + \etocaftertochook % 1.07g + }% \fi \fi\fi\fi\Etoc@next} -\def\table@fcontents{% +\def\Etoc@table@fcontents{% \refstepcounter{etoc@tocid}% \Etoc@tocwithidfalse \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\def\localtable@fcontents{% +\def\Etoc@localtable@fcontents{% \refstepcounter{etoc@tocid}% \addtocontents{toc} {\string\etoc@startlocaltoc{\arabic{etoc@tocid}}}% \Etoc@tocwithidtrue \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} -\newcommand*\etocaftertitlehook{} -\newcommand*\etocaftercontentshook{} -\renewcommand*\tableofcontents{% +\let\etocaftertitlehook \@empty +\let\etocaftercontentshook \@empty +\def\etoctableofcontents{% \Etoc@openouttoc \Etoc@par \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}% \@ifstar - {\def\Etoc@aftertitlehook{}\table@fcontents} - {\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}} + {\def\Etoc@aftertitlehook{}\Etoc@table@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@table@fcontents}} +\let\tableofcontents\etoctableofcontents \newcommand*\localtableofcontents{% \Etoc@openouttoc \Etoc@par \begingroup % closed in \Etoc@t@bleofcontents or \Etoc@localtableofcontents \@ifstar - {\def\Etoc@aftertitlehook{}\localtable@fcontents} - {\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}} + {\def\Etoc@aftertitlehook{}\Etoc@localtable@fcontents} + {\let\Etoc@aftertitlehook\etocaftertitlehook\Etoc@localtable@fcontents}} \newcommand\etocsettocstyle[2]{% \def\Etoc@tableofcontents {\ifnum\c@tocdepth>\Etoc@minf \let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble \fi -\Etoc@@next{#1\ifEtoc@parskip\parskip\z@skip\fi %1.07d +\Etoc@@next{\Etoc@storetocdepth % 1.07g + #1\ifEtoc@parskip\parskip\z@skip\fi %1.07d \Etoc@aftertitlehook \let\Etoc@savedcontentsline\contentsline \let\contentsline\Etoc@etoccontentsline \Etoc@toctoc \let\Etoc@@next\relax - \ifEtoc@tocwithid\else + \ifEtoc@tocwithid\else \ifEtoc@localtoc \ifEtoc@notactive \def\Etoc@@next{\Etoc@localtocfalse \global\Etoc@notactivefalse \Etoc@toctoc}% - \fi\fi\fi - \Etoc@@next - \etocaftercontentshook - #2\@nobreakfalse}}} % 1.07d: \@nobreakfalse moved here -\newcommand*\etocsetstyle{\Etoc@standardfalse\etoc@setstyle} + \fi\fi + \fi + \Etoc@@next + \Etoc@resettocdepth % 1.07g + \etocaftercontentshook + #2\@nobreakfalse}}} % 1.07d: \@nobreakfalse moved here +\def\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}% @@ -622,35 +646,35 @@ \csname Etoc@contents@\csname Etoc@#1@\endcsname\endcsname {#4}% \long\expandafter\def \csname Etoc@end@\csname Etoc@#1@\endcsname\endcsname {#5}} -\newcommand*\etocfontminustwo {\normalfont \LARGE \bfseries} -\newcommand*\etocfontminusone {\normalfont \large \bfseries} -\newcommand*\etocfontzero {\normalfont \large \bfseries} -\newcommand*\etocfontone {\normalfont \normalsize \bfseries} -\newcommand*\etocfonttwo {\normalfont \normalsize} -\newcommand*\etocfontthree {\normalfont \footnotesize} -\newcommand*\etocsepminustwo {4ex \@plus .5ex \@minus .5ex} -\newcommand*\etocsepminusone {4ex \@plus .5ex \@minus .5ex} -\newcommand*\etocsepzero {2.5ex \@plus .4ex \@minus .4ex} -\newcommand*\etocsepone {1.5ex \@plus .3ex \@minus .3ex} +\def\etocfontminustwo {\normalfont \LARGE \bfseries} +\def\etocfontminusone {\normalfont \large \bfseries} +\def\etocfontzero {\normalfont \large \bfseries} +\def\etocfontone {\normalfont \normalsize \bfseries} +\def\etocfonttwo {\normalfont \normalsize} +\def\etocfontthree {\normalfont \footnotesize} +\def\etocsepminustwo {4ex \@plus .5ex \@minus .5ex} +\def\etocsepminusone {4ex \@plus .5ex \@minus .5ex} +\def\etocsepzero {2.5ex \@plus .4ex \@minus .4ex} +\def\etocsepone {1.5ex \@plus .3ex \@minus .3ex} %%\newcommand*\etocseptwo{1ex \@plus .15ex \@minus .15ex} % modified in 1.07e -\newcommand*\etocseptwo {.5ex \@plus .1ex \@minus .1ex} -\newcommand*\etocsepthree {.25ex \@plus .05ex \@minus .05ex} -\newcommand*\etocbaselinespreadminustwo {1} -\newcommand*\etocbaselinespreadminusone {1} -\newcommand*\etocbaselinespreadzero {1} -\newcommand*\etocbaselinespreadone {1} -\newcommand*\etocbaselinespreadtwo {1} -\newcommand*\etocbaselinespreadthree {.9} -\newcommand*\etocminustwoleftmargin {1.5em plus 0.5fil} -\newcommand*\etocminustworightmargin {1.5em plus -0.5fil} -\newcommand*\etocminusoneleftmargin {1em} -\newcommand*\etocminusonerightmargin {1em} -\newcommand*\etoctoclineleaders +\def\etocseptwo {.5ex \@plus .1ex \@minus .1ex} +\def\etocsepthree {.25ex \@plus .05ex \@minus .05ex} +\def\etocbaselinespreadminustwo {1} +\def\etocbaselinespreadminusone {1} +\def\etocbaselinespreadzero {1} +\def\etocbaselinespreadone {1} +\def\etocbaselinespreadtwo {1} +\def\etocbaselinespreadthree {.9} +\def\etocminustwoleftmargin {1.5em plus 0.5fil} +\def\etocminustworightmargin {1.5em plus -0.5fil} +\def\etocminusoneleftmargin {1em} +\def\etocminusonerightmargin {1em} +\def\etoctoclineleaders {\hbox{\normalfont\normalsize\hb@xt@2ex {\hss.\hss}}} -\newcommand*\etocabbrevpagename {p.~} -\newcommand*\etocpartname {\partname} -\newcommand*\etocbookname {Book} -\def\etocdefaultlines{\Etoc@standardfalse +\def\etocabbrevpagename {p.~} +\def\etocpartname {\partname} +\def\etocbookname {Book} +\def\etocdefaultlines{\Etoc@standardfalse % %% `book' in memoir class: \etoc@setstyle{@minustwo} {\addpenalty\@M\etocskipfirstprefix} @@ -780,15 +804,15 @@ \addpenalty{-\@highpenalty}}% \etoc@setstyle{@four}{}{}{}{}% \etoc@setstyle{@five}{}{}{}{}% -} -\newcommand*\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand*\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} -\newcommand*\etoccolumnsep{2em} -\newcommand*\etocmulticolsep{0ex} -\newcommand*\etocmulticolpretolerance{-1} -\newcommand*\etocmulticoltolerance{200} -\newcommand*\etocdefaultnbcol{2} -\newcommand*\etocinnertopsep{2ex} +} % end of \etocdefaultlines! +\def\etocabovetocskip{3.5ex \@plus 1ex \@minus .2ex} +\def\etocbelowtocskip{3.5ex \@plus 1ex \@minus .2ex} +\def\etoccolumnsep{2em} +\def\etocmulticolsep{0ex} +\def\etocmulticolpretolerance{-1} +\def\etocmulticoltolerance{200} +\def\etocdefaultnbcol{2} +\def\etocinnertopsep{2ex} \newcommand\etocmulticolstyle[2][\etocdefaultnbcol]{% \etocsettocstyle {\let\etocoldpar\par @@ -808,17 +832,17 @@ \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% \addvspace{\etocbelowtocskip}}} -\newcommand*\etocinnerbottomsep{3.5ex} -\newcommand*\etocinnerleftsep{2em} -\newcommand*\etocinnerrightsep{2em} -\newcommand*\etoctoprule{\hrule} -\newcommand*\etocleftrule{\vrule} -\newcommand*\etocrightrule{\vrule} -\newcommand*\etocbottomrule{\hrule} -\newcommand*\etoctoprulecolorcmd{\relax} -\newcommand*\etocbottomrulecolorcmd{\relax} -\newcommand*\etocleftrulecolorcmd{\relax} -\newcommand*\etocrightrulecolorcmd{\relax} +\def\etocinnerbottomsep{3.5ex} +\def\etocinnerleftsep{2em} +\def\etocinnerrightsep{2em} +\def\etoctoprule{\hrule} +\def\etocleftrule{\vrule} +\def\etocrightrule{\vrule} +\def\etocbottomrule{\hrule} +\def\etoctoprulecolorcmd{\relax} +\def\etocbottomrulecolorcmd{\relax} +\def\etocleftrulecolorcmd{\relax} +\def\etocrightrulecolorcmd{\relax} \def\etoc@ruledheading #1{% \hb@xt@\linewidth{\color@begingroup \hss #1\hss\hskip-\linewidth @@ -844,8 +868,8 @@ \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% \addvspace{\etocbelowtocskip}}} -\newcommand\etocframedmphook{\relax} -\newcommand*\etocbkgcolorcmd{\relax} +\long\def\etocframedmphook{\relax} +\def\etocbkgcolorcmd{\relax} \def\Etoc@relax{\relax} \newbox\etoc@framed@titlebox \newbox\etoc@framed@contentsbox @@ -1056,7 +1080,7 @@ \csname tocbasic@@after@hook\endcsname}} \let\etocscrbookstyle\etocscrartclstyle \let\etocscrreprtstyle\etocscrartclstyle -\newcommand*\etocstandarddisplaystyle{\etocarticlestyle} +\def\etocstandarddisplaystyle{\etocarticlestyle} \newcommand*\etocmarkboth[1]{% \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}} \newcommand*\etocmarkbothnouc[1]{\@mkboth{#1}{#1}} @@ -1112,11 +1136,73 @@ \addcontentsline {toc}{#1}{#2}} \DeclareRobustCommand*{\etoctoccontentsline} {\@ifstar{\Etoc@addcontentsline@}{\Etoc@addtocontents}} -\newcommand*\etocstandardlines{\Etoc@standardtrue} -\newcommand*\etoctoclines{\Etoc@standardfalse} % 1.07b -\etocdefaultlines % for initialization +\def\Etoc@storetocdepth {\global\c@etoc@tocdepth\c@tocdepth } +\def\Etoc@resettocdepth {\global\c@tocdepth\c@etoc@tocdepth } +\def\etocobeytoctocdepth + {\def\Etoc@settocdepth {\afterassignment\Etoc@@settocdepth\global\c@tocdepth}} +\def\Etoc@@settocdepth {\ifnum\c@tocdepth>\c@etoc@tocdepth + \global\c@tocdepth\c@etoc@tocdepth\fi } +\def\etocignoretoctocdepth {\let\Etoc@settocdepth\count@ } +\def\etocsettocdepth {\futurelet\Etoc@nexttoken\Etoc@set@tocdepth } +\def\Etoc@set@tocdepth {\ifx\Etoc@nexttoken\bgroup + \expandafter\Etoc@set@tocdepth@ + \else\expandafter\Etoc@set@toctocdepth@ + \fi } +\def\Etoc@set@tocdepth@ #1{\@ifundefined {Etoc@#1@@} + {\PackageWarning{etoc} + {Unknown sectioning unit #1, \protect\etocsettocdepth\space ignored}} + {\global\c@tocdepth\csname Etoc@#1@@\endcsname}% +} +\def\Etoc@set@toctocdepth@ #1#{\Etoc@set@toctocdepth@@ }% +\def\Etoc@set@toctocdepth@@ #1{% + \@ifundefined{Etoc@#1@@} + {\PackageWarning{etoc} + {Unknown sectioning unit #1, \protect\etocsettocdepth.toc ignored}} + {\addtocontents {toc} + {\protect\Etoc@settocdepth\expandafter\protect\csname Etoc@#1@@\endcsname}}% +} +\def\Etoc@tocvsec@err #1{\PackageError {etoc} + {the command \protect#1\space is incompatible with etoc} + {use \protect\etocsettocdepth.toc as replacement (check the manual)}% +}% +\AtBeginDocument {% + \@ifpackageloaded {tocvsec2} + {\def\maxtocdepth #1{\Etoc@tocvsec@err \maxtocdepth }% + \def\settocdepth #1{\Etoc@tocvsec@err \settocdepth }% + \def\resettocdepth {\@ifstar {\Etoc@tocvsec@err \resettocdepth }% + {\Etoc@tocvsec@err \resettocdepth }% + }% + \def\save@tocdepth #1#2#3{}% % if etoc is added to file previously + \let\reset@tocdepth\relax % using tocvsec2 + \let\remax@tocdepth\relax + \let\tableofcontents\etoctableofcontents + \PackageWarning {etoc} + {package tocvsec2 detected and its modification of^^J + \protect\tableofcontents\space reverted. Use + \protect\etocsettocdepth.toc as a replacement^^J + for the tocvsec2 toc-related commands}}{}% +}% +\addtocontents {toc}{\protect\@ifundefined{etocsetstyle}% + {\let\protect\Etoc@settocdepth\count@ + \let\protect\etoc@startlocaltoc\protect\@gobble }{}}% +\def\invisibletableofcontents {\etocsetnexttocdepth {-3}\tableofcontents }% +\def\invisiblelocaltableofcontents + {\etocsetnexttocdepth {-3}\localtableofcontents }% +\def\etocsetnexttocdepth #1{% + \@ifundefined{Etoc@#1@@} + {\PackageWarning{etoc} + {Unknown sectioning unit #1, \protect\etocsetnextocdepth\space ignored}} + {\edef\etocaftertochook {\global\c@tocdepth\the\c@tocdepth\space + \let\noexpand\etocaftertochook\noexpand\@empty }% + \global\c@tocdepth\csname Etoc@#1@@\endcsname}% +}% +\def\etocstandardlines {\Etoc@standardtrue} +\def\etoctoclines {\Etoc@standardfalse} +\etocdefaultlines \etocstandardlines \etocstandarddisplaystyle +\etocobeytoctocdepth +\let\etocaftertochook\@empty \endinput %% %% End of file `etoc.sty'. -- cgit v1.2.3