diff options
author | Karl Berry <karl@freefriends.org> | 2012-11-23 22:45:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-11-23 22:45:17 +0000 |
commit | 1bcc012dc9ee137c9349ef3925bd98c933567a33 (patch) | |
tree | 7c6fb69d4813259ee3e6045d200d38559f1419f9 /Master/texmf-dist/tex/latex/etoc | |
parent | 53ef995986cf28c61e47d976d1a2b681ef9e1d7b (diff) |
etoc (23nov12)
git-svn-id: svn://tug.org/texlive/trunk@28343 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoc')
-rw-r--r-- | Master/texmf-dist/tex/latex/etoc/etoc.sty | 233 |
1 files changed, 151 insertions, 82 deletions
diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty index 321b9036933..c269282b0e8 100644 --- a/Master/texmf-dist/tex/latex/etoc/etoc.sty +++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty @@ -22,7 +22,8 @@ %% in the same archive or directory.) %% \ProvidesPackage{etoc} - [2012/11/18 v1.02 easily customizable TOCs (jfB)] + [2012/11/23 v1.03 easily customizable TOCs (jfB)] +%% Package `etoc' by Jean-Francois Burnol %% Copyright (C) 2012 by Jean-Francois Burnol \NeedsTeXFormat{LaTeX2e} \RequirePackage{multicol} @@ -46,7 +47,8 @@ \newif\ifEtoc@skipthisone \newif\ifEtoc@stoptoc \newif\ifEtoc@notactive -\newcounter{etoc@localtocid} +\newcounter{etoc@tocid} +\newif\ifEtoc@mustclosegroup \let\Etoc@@minusone@@\m@ne \chardef\Etoc@@zero@@\z@ \chardef\Etoc@@one@@\@ne @@ -141,30 +143,6 @@ {\Etoc@savedcontentsline{#1}} {\Etoc@contents}} \let\etocskipfirstprefix\@thirdofthree -\def\etoc@startlocaltoc#1{% -\let\Etoc@next\relax - \ifEtoc@localtoc - \ifEtoc@notactive - \ifnum #1<\c@etoc@localtocid\relax - \else - \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 - \ifEtoc@ii \global\let\Etoc@localtop\Etoc@@three@@ \fi - \ifEtoc@iii \global\let\Etoc@localtop\Etoc@@four@@ \fi - \ifEtoc@iv \global\let\Etoc@localtop\Etoc@@five@@ \fi - \ifEtoc@v \global\let\Etoc@localtop\Etoc@@six@@ \fi - \def\Etoc@next{\global\Etoc@notactivefalse - \global\Etoc@vfalse - \global\Etoc@ivfalse - \global\Etoc@iiifalse - \global\Etoc@iifalse - \global\Etoc@ifalse - \global\Etoc@false - \global\Etoc@jfalse}% - \fi - \fi\fi -\Etoc@next} \def\Etoc@setflags #1{% \ifcase #1\relax \global\Etoc@vfalse @@ -400,24 +378,88 @@ \global\Etoc@ifalse \global\Etoc@false \global\Etoc@jfalse} -\def\tableofcontents{\@ifstar{% -\stepcounter{etoc@localtocid}% -\global\Etoc@localtoctrue -\global\let\Etoc@localtop\m@ne -\global\Etoc@stoptocfalse -\global\Etoc@notactivetrue -\addtocontents{toc}{\string\etoc@startlocaltoc -\string{\arabic{etoc@localtocid}\string}}% -\Etoc@tableofcontents -\global\Etoc@notactivefalse -\global\Etoc@stoptocfalse -\global\Etoc@localtocfalse} -{\Etoc@tableofcontents}} +\def\etoc@@startlocaltoc#1#2{% +\let\Etoc@next\relax + \ifEtoc@localtoc + \ifEtoc@notactive + \ifnum #1=#2\relax + \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 + \ifEtoc@ii \global\let\Etoc@localtop\Etoc@@three@@ \fi + \ifEtoc@iii \global\let\Etoc@localtop\Etoc@@four@@ \fi + \ifEtoc@iv \global\let\Etoc@localtop\Etoc@@five@@ \fi + \ifEtoc@v \global\let\Etoc@localtop\Etoc@@six@@ \fi + \def\Etoc@next{\global\Etoc@notactivefalse + \global\Etoc@vfalse + \global\Etoc@ivfalse + \global\Etoc@iiifalse + \global\Etoc@iifalse + \global\Etoc@ifalse + \global\Etoc@false + \global\Etoc@jfalse}% + \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@localtoctrue + \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}} +\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@localtoc + \def\Etoc@next{\Etoc@localtableofcontents{\c@etoc@tocid}}% + \else + \ifx\Etoc@nexttoken\ref + \def\Etoc@next{\expandafter\Etoc@ref\@gobble}% + \else + \def\Etoc@next{\begingroup\Etoc@tableofcontents + \ifEtoc@mustclosegroup\expandafter\endgroup\fi + \endgroup\Etoc@mustclosegroupfalse}% + \fi + \fi\fi\fi\Etoc@next} +\long\def\Etoc@localtableofcontents#1{% + \edef\Etoc@tmp{#1}% + \ifnum\Etoc@tmp<\@ne + \PackageWarning{etoc} + {Unknown toc id: run LaTeX to get references right}% + \leavevmode --unknown etoc ref: run latex again--\par + \let\Etoc@next\@gobble\else\let\Etoc@next\@firstofone\fi + \Etoc@next + {\begingroup + \edef\etoc@startlocaltoc##1{% + \noexpand\etoc@@startlocaltoc{##1}{#1}} + \Etoc@localtoctrue + \let\Etoc@localtop\m@ne + \Etoc@stoptocfalse + \Etoc@notactivetrue + \Etoc@tableofcontents + \endgroup}% + \ifEtoc@mustclosegroup\expandafter\endgroup\fi + \Etoc@mustclosegroupfalse} +\def\tableofcontents{\par\refstepcounter{etoc@tocid}% + \@ifstar {\addtocontents{toc} + {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}% + \Etoc@localtoctrue + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents} + {\Etoc@localtocfalse + \futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}} \newcommand\etocsettocstyle[2]{% \long\def\Etoc@tableofcontents {\ifnum\c@tocdepth>-2\let\Etoc@@next\@firstofone\else \let\Etoc@@next\@gobble\fi -\Etoc@@next{\begingroup #1\Etoc@toctoc #2\endgroup}}} +\Etoc@@next{#1\Etoc@toctoc + \Etoc@localtocfalse + \ifEtoc@notactive \expandafter\Etoc@toctoc\fi + #2}}} \newcommand\etocsetstyle[5]{% \long\expandafter\def \csname Etoc@begin@\csname Etoc@#1@\endcsname\endcsname {#2}% @@ -447,7 +489,7 @@ \newcommand\etocbaselinespreadthree{.9} \newcommand\etocminusonelrmargins{1em} \newcommand\etoctoclineleaders -{\hbox{\normalfont\normalsize\hbox to 2ex {\hfil.\hfil}}} +{\hbox{\normalfont\normalsize\hbox to 2ex {\hss.\hss}}} \newcommand\etocabbrevpagename{p.~} \def\etocetoclines{\Etoc@standardfalse \etocsetstyle{@minusone}{\addpenalty\@highpenalty}{} @@ -605,11 +647,11 @@ \newcommand\etocleftrulecolorcmd{\relax} \newcommand\etocrightrulecolorcmd{\relax} \newcommand\etoc@ruledheading[1]{% - \hbox to \linewidth{% - \hfil #1\hfil\hskip-\linewidth - {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}% + \hbox to \linewidth{\color@begingroup + \hss #1\hss\hskip-\linewidth + \etoctoprulecolorcmd\leaders\etoctoprule\hfil \phantom{#1}% - {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}}% + \leaders\etoctoprule\hss\color@endgroup}% \nointerlineskip\vskip\etocinnertopsep} \newcommand\etocruledstyle[2][2]{% \etocsettocstyle @@ -629,30 +671,36 @@ \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}}% \addvspace{\etocbelowtocskip}}} +\newcommand\etocframedmphook{\relax} +\newcommand\etocframedbkgcolorcmd{\relax} +\newbox\etoc@framed@titlebox +\newbox\etoc@framed@contentsbox \newcommand\etocframedstyle[2][2]{% \etocsettocstyle{% \addvspace{\etocabovetocskip}% - \sbox\z@{#2}\dimen\z@\dp\z@ - \ifdim\wd\z@<\linewidth\dp\z@\z@\else\dimen\z@\z@\fi - \hbox to \linewidth{% - \hfil\copy\z@\hfil\hskip-\linewidth - {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}% - \phantom{\box\z@}% - {\etoctoprulecolorcmd\leaders\etoctoprule\hfil}}% - \nointerlineskip\nobreak - \hbox to \linewidth - \bgroup - {\etocleftrulecolorcmd\etocleftrule}% - \kern\etocinnerleftsep - \vbox\bgroup + \setbox\z@\hbox{#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 + \hss{\etocframedbkgcolorcmd + \vrule\@width\wd\z@\@height\ht\z@\@depth\dp\z@}% + \hskip-\wd\z@ + \copy\z@\hss + \hskip-\linewidth + \etoctoprulecolorcmd\leaders\etoctoprule\hss% + \hskip\wd\z@ + \etoctoprulecolorcmd\leaders\etoctoprule\hss\color@endgroup}% + \setbox\z@\hbox{\etocleftrule\etocrightrule}% + \dimen\tw@\linewidth\advance\dimen\tw@-\wd\z@ + \advance\dimen\tw@-\etocinnerleftsep + \advance\dimen\tw@-\etocinnerrightsep + \setbox\etoc@framed@contentsbox=\vbox\bgroup + \hsize\dimen\tw@ \kern\dimen\z@ \vskip\etocinnertopsep \hbox\bgroup - \setbox\z@\hbox{\etocleftrule\etocrightrule}% - \dimen\z@\linewidth\advance\dimen\z@-\wd\z@ - \advance\dimen\z@-\etocinnerleftsep - \advance\dimen\z@-\etocinnerrightsep - \begin{minipage}{\dimen\z@} + \begin{minipage}{\hsize}% + \etocframedmphook \ifnum #1>\@ne\let\Etoc@next\@firstoftwo \else \let\Etoc@next\@secondoftwo\fi \Etoc@next @@ -666,52 +714,73 @@ {\ifnum #1>\@ne\let\Etoc@next\@firstofone \else \let\Etoc@next\@gobble\fi \Etoc@next{\end{multicols}\unskip}% - \end{minipage}\egroup + \end{minipage}%<- indispensable (horizontal mode here) + \egroup \vskip\etocinnerbottomsep - \egroup\kern\etocinnerrightsep - \etocrightrulecolorcmd\etocrightrule\egroup - \nointerlineskip\nobreak - \hbox to \linewidth{\etocbottomrulecolorcmd - \leaders\etocbottomrule\hfill} + \egroup + \vskip\ht\etoc@framed@titlebox + \vskip\dp\etoc@framed@titlebox + \hbox to \linewidth{\color@begingroup + \etocleftrulecolorcmd\etocleftrule + \etocframedbkgcolorcmd + \leaders\vrule + \@height\ht\etoc@framed@contentsbox + \@depth\dp\etoc@framed@contentsbox + \hss + \etocrightrulecolorcmd\etocrightrule + \color@endgroup} + \nointerlineskip + \vskip-\dp\etoc@framed@contentsbox + \vskip-\ht\etoc@framed@contentsbox + \vskip-\dp\etoc@framed@titlebox + \vskip-\ht\etoc@framed@titlebox + \box\etoc@framed@titlebox\nointerlineskip + \hbox to \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} \addvspace{\etocbelowtocskip}}} \newcommand\etoc@multicoltoc[2][2]{% \begingroup -\ifnum\c@tocdepth>-2\relax \etocmulticolstyle[#1]{#2}% \ifEtoc@star \def\Etoc@next{\tableofcontents*}% - \else\def\Etoc@next{\tableofcontents}% + \else + \def\Etoc@next{\tableofcontents}% \fi -\Etoc@next -\fi\endgroup} +\Etoc@mustclosegrouptrue +\Etoc@next} \newcommand\etoc@ruledtoc[2][2]{% \begingroup -\ifnum\c@tocdepth>-2\relax \etocruledstyle[#1]{#2}% \ifEtoc@star \def\Etoc@next{\tableofcontents*}% \else \def\Etoc@next{\tableofcontents}% \fi -\Etoc@next -\fi\endgroup} +\Etoc@mustclosegrouptrue +\Etoc@next} \newcommand\etoc@framedtoc[2][2]{% \begingroup -\ifnum\c@tocdepth>-2\relax \etocframedstyle[#1]{#2}% \ifEtoc@star \def\Etoc@next{\tableofcontents*}% \else \def\Etoc@next{\tableofcontents}% \fi -\Etoc@next -\fi\endgroup} +\Etoc@mustclosegrouptrue +\Etoc@next} \def\etocmulticol{\@ifstar{\global\Etoc@startrue\etoc@multicoltoc} -{\global\Etoc@starfalse\etoc@multicoltoc}} +{\Etoc@starfalse\etoc@multicoltoc}} \def\etocruled{\@ifstar{\global\Etoc@startrue\etoc@ruledtoc} -{\global\Etoc@starfalse\etoc@ruledtoc}} +{\Etoc@starfalse\etoc@ruledtoc}} \def\etocframed{\@ifstar{\global\Etoc@startrue\etoc@framedtoc} -{\global\Etoc@starfalse\etoc@framedtoc}} +{\Etoc@starfalse\etoc@framedtoc}} \etocetoclines \etocmulticolstyle{\etocstandardheading\contentsname} \endinput |