summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/etoc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-12-10 01:31:54 +0000
committerKarl Berry <karl@freefriends.org>2012-12-10 01:31:54 +0000
commit7565eef64053e06881b3bc55e1a20bc7af0b15bb (patch)
treed526b457cd2e04d23a31b86528f375390d11896f /Master/texmf-dist/tex/latex/etoc
parenteb3f5f9a64a4553a16273f9ff5cfe99d10f27dd8 (diff)
etoc
git-svn-id: svn://tug.org/texlive/trunk@28483 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etoc')
-rw-r--r--Master/texmf-dist/tex/latex/etoc/etoc.sty193
1 files changed, 89 insertions, 104 deletions
diff --git a/Master/texmf-dist/tex/latex/etoc/etoc.sty b/Master/texmf-dist/tex/latex/etoc/etoc.sty
index dba9b9d17ae..837487b6d2f 100644
--- a/Master/texmf-dist/tex/latex/etoc/etoc.sty
+++ b/Master/texmf-dist/tex/latex/etoc/etoc.sty
@@ -22,9 +22,11 @@
%% in the same archive or directory.)
%%
\ProvidesPackage{etoc}
- [2012/12/01 v1.05 easily customizable TOCs (jfB)]
+ [2012/12/07 v1.06 easily customizable TOCs (jfB)]
+%%
%% Package `etoc' by Jean-Francois Burnol
%% Copyright (C) 2012 by Jean-Francois Burnol
+%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{multicol}
\RequirePackage{xspace}
@@ -50,6 +52,7 @@
\newif\ifEtoc@notactive
\newcounter{etoc@tocid}
\newif\ifEtoc@mustclosegroup
+\newif\ifEtoc@tocopenedforwrite
\@ifclassloaded{memoir}{\def\Etoc@minf{-\thr@@}}{\def\Etoc@minf{-\tw@}}
\def\Etoc@@minustwo@@{-\tw@}
\let\Etoc@@minusone@@\m@ne
@@ -69,16 +72,10 @@
\def\Etoc@@three@{three}
\def\Etoc@@four@{four}
\def\Etoc@@five@{five}
-\def\Etoc@Lazarus{%
-\def\Etoc@Lazarus@elta##1\Etoc@Lazarus@eltb##2{\let##1##2}%
-\Etoc@Lazaruslist}
-\def\Etoc@Lazaruslist{}
-\def\Etoc@newdisciple#1#2{%
- \def\Etoc@Lazarus@elta{\noexpand\Etoc@Lazarus@elta\noexpand}%
- \def\Etoc@Lazarus@eltb{\noexpand\Etoc@Lazarus@eltb\noexpand}%
- \edef\Etoc@Lazaruslist{\Etoc@Lazaruslist
- \Etoc@Lazarus@elta#1
- \Etoc@Lazarus@eltb#2}}
+\def\Etoc@levellist{}
+\def\Etoc@newlevel#1{%
+ \def\Etoc@levellist@elt{\noexpand\Etoc@levellist@elt\noexpand}%
+ \edef\Etoc@levellist{\Etoc@levellist\Etoc@levellist@elt#1}}
\def\etocsetlevel#1#2{%
\let\Etoc@next\@firstofone
\ifcase#2\or\or\or\or\or
@@ -89,16 +86,7 @@
\expandafter\def\csname Etoc@#1@\endcsname{minusone}%
\expandafter\let\csname Etoc@#1@@\endcsname\m@ne
\let\Etoc@next\@gobble\fi\fi\fi
- \if@noskipsec
- \else
- \expandafter\expandafter\expandafter
- \let\expandafter\expandafter\csname Etoc@savedl@#1\endcsname
- \csname l@#1\endcsname
- \expandafter\let \csname l@#1\endcsname\Etoc@lxyz
- \fi
- \expandafter\expandafter\expandafter\Etoc@newdisciple
- \expandafter\expandafter
- \csname l@#1\endcsname\csname Etoc@savedl@#1\endcsname
+ \expandafter\Etoc@newlevel\csname l@#1\endcsname
\Etoc@next
{\ifcase#2\relax
\expandafter\let \csname Etoc@#1@@\endcsname\Etoc@@zero@@
@@ -136,10 +124,6 @@
\etocsetlevel{paragraph}{4}
\etocsetlevel{subparagraph}{5}
\AtBeginDocument{%
-\def\Etoc@Lazarus@elta#1\Etoc@Lazarus@eltb#2{\let#2#1\let#1\Etoc@lxyz}%
-\Etoc@Lazaruslist
-\let\Etoc@savedcontentsline\contentsline
-\let\contentsline\Etoc@etoccontentsline
\@ifpackageloaded{hyperref}
{\Etoc@hyperreftrue
\def\Etoc@et@hop#1#2#3#4#5{#1{#3}{#4}{#5}#2}}
@@ -153,7 +137,7 @@
\Etoc@et@hop
{\Etoc@savedcontentsline{#1}}
{\Etoc@contents}}
- \let\etocskipfirstprefix\@thirdofthree
+\let\etocskipfirstprefix\@thirdofthree
\def\Etoc@setflags #1{%
\ifcase #1\relax
\global\Etoc@vfalse
@@ -204,7 +188,6 @@
\fi}
\def\Etoc@etoccontentsline#1{%
\global\expandafter\let\expandafter\Etoc@tmp\csname Etoc@#1@@\endcsname
- \global\Etoc@partfalse
\Etoc@skipthisonefalse
\ifEtoc@hyperref
\def\Etoc@next{\expandafter\@gobbletwo\@gobblefour}%
@@ -236,38 +219,38 @@
\ifEtoc@ii \Etoc@end@two\fi
\ifEtoc@i \Etoc@end@one\fi
\ifEtoc@ \else \def\Etoc@next{\Etoc@begin@zero}\fi
- \gdef\Etoc@contents{\Etoc@contents@zero}%
- \gdef\Etoc@prefix{\Etoc@prefix@zero}%
+ \def\Etoc@contents{\Etoc@contents@zero}%
+ \def\Etoc@prefix{\Etoc@prefix@zero}%
\or
\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 \else \def\Etoc@next{\Etoc@begin@one}\fi
- \gdef\Etoc@contents{\Etoc@contents@one}%
- \gdef\Etoc@prefix{\Etoc@prefix@one}%
+ \def\Etoc@contents{\Etoc@contents@one}%
+ \def\Etoc@prefix{\Etoc@prefix@one}%
\or
\ifEtoc@v \Etoc@end@five\fi
\ifEtoc@iv \Etoc@end@four\fi
\ifEtoc@iii \Etoc@end@three\fi
\ifEtoc@ii \else \def\Etoc@next{\Etoc@begin@two}\fi
- \gdef\Etoc@contents{\Etoc@contents@two}%
- \gdef\Etoc@prefix{\Etoc@prefix@two}%
+ \def\Etoc@contents{\Etoc@contents@two}%
+ \def\Etoc@prefix{\Etoc@prefix@two}%
\or
\ifEtoc@v \Etoc@end@five\fi
\ifEtoc@iv \Etoc@end@four\fi
\ifEtoc@iii \else \def\Etoc@next{\Etoc@begin@three}\fi
- \gdef\Etoc@contents{\Etoc@contents@three}%
- \gdef\Etoc@prefix{\Etoc@prefix@three}%
+ \def\Etoc@contents{\Etoc@contents@three}%
+ \def\Etoc@prefix{\Etoc@prefix@three}%
\or
\ifEtoc@v \Etoc@end@five\fi
\ifEtoc@iv \else \def\Etoc@next{\Etoc@begin@four}\fi
- \gdef\Etoc@contents{\Etoc@contents@four}%
- \gdef\Etoc@prefix{\Etoc@prefix@four}%
+ \def\Etoc@contents{\Etoc@contents@four}%
+ \def\Etoc@prefix{\Etoc@prefix@four}%
\or
\ifEtoc@v \else \def\Etoc@next{\Etoc@begin@five}\fi
- \gdef\Etoc@contents{\Etoc@contents@five}%
- \gdef\Etoc@prefix{\Etoc@prefix@five}%
+ \def\Etoc@contents{\Etoc@contents@five}%
+ \def\Etoc@prefix{\Etoc@prefix@five}%
\else
\ifnum\Etoc@tmp=\m@ne
\ifEtoc@v \Etoc@end@five\fi
@@ -277,9 +260,8 @@
\ifEtoc@i \Etoc@end@one\fi
\ifEtoc@ \Etoc@end@zero\fi
\ifEtoc@j \else \def\Etoc@next{\Etoc@begin@minusone}\fi
- \global\Etoc@parttrue
- \gdef\Etoc@contents{\Etoc@contents@minusone}%
- \gdef\Etoc@prefix{\Etoc@prefix@minusone}%
+ \def\Etoc@contents{\Etoc@contents@minusone}%
+ \def\Etoc@prefix{\Etoc@prefix@minusone}%
\else
\ifEtoc@v \Etoc@end@five\fi
\ifEtoc@iv \Etoc@end@four\fi
@@ -289,16 +271,17 @@
\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}%
+ \def\Etoc@contents{\Etoc@contents@minustwo}%
+ \def\Etoc@prefix{\Etoc@prefix@minustwo}%
\fi
\fi
+ \ifnum\Etoc@tmp=\m@ne\Etoc@parttrue\else\Etoc@partfalse\fi
\Etoc@setflags{\Etoc@tmp}%
\fi\fi
\Etoc@next
\@firstoftwo{\Etoc@swa{#1}}{\Etoc@swb{#1}}}
-\def\Etoc@lxyz #1#2{\global\@namedef{etocname }{\leavevmode #1\xspace}%
- \global\@namedef{etocpage }{\leavevmode #2\xspace}%
+\def\Etoc@lxyz #1#2{\@namedef{etocname }{\leavevmode #1\xspace}%
+ \@namedef{etocpage }{\leavevmode #2\xspace}%
\Etoc@getnb #1\relax\relax\etoc@
\ifEtoc@number\else\ifEtoc@part
\Etoc@getit #1\hspace\relax\etoc@\fi\fi}
@@ -310,34 +293,34 @@
\let\Etoc@next\Etoc@getit@hyp\fi\fi\Etoc@next #1}
\def\Etoc@getnb@nohyp #1#2#3\etoc@{%
\ifx #1\numberline
-\global\@namedef{etocnumber }{\leavevmode #2\xspace}\global\Etoc@numbertrue
+\@namedef{etocnumber }{\leavevmode #2\xspace}\Etoc@numbertrue
\else
-\global\@namedef{etocnumber }{\leavevmode\xspace}\global\Etoc@numberfalse
+\@namedef{etocnumber }{\leavevmode\xspace}\Etoc@numberfalse
\fi}
\def\Etoc@getnb@hyp #1#2#3#4#5#6\etoc@{%
\def\Etoc@getnbr ##1##2##3\etoc@{%
\ifx ##1\numberline
- \global\@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}%
- \global\Etoc@numbertrue
+ \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##2}#5\xspace}%
+ \Etoc@numbertrue
\else
- \global\@namedef{etocnumber }{\leavevmode\xspace}%
- \global\Etoc@numberfalse
+ \@namedef{etocnumber }{\leavevmode\xspace}%
+ \Etoc@numberfalse
\fi}%
\Etoc@getnbr #4\relax\relax\etoc@}
\def\Etoc@getit@nohyp #1\hspace#2#3\etoc@{%
\def\Etoc@getname ##1\hspace\relax\etoc@{%
- \global\@namedef{etocname }{\leavevmode ##1\xspace}}%
+ \@namedef{etocname }{\leavevmode ##1\xspace}}%
\ifx \relax#2\else
- \global\@namedef{etocnumber }{\leavevmode #1\xspace}%
- \global\Etoc@numbertrue
+ \@namedef{etocnumber }{\leavevmode #1\xspace}%
+ \Etoc@numbertrue
\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}}%
+ \@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}%
- \global\Etoc@numbertrue
+ \@namedef{etocnumber }{\leavevmode #1{#2}{#3}{##1}#5\xspace}%
+ \Etoc@numbertrue
\Etoc@getname ##3\etoc@\fi}%
\Etoc@getnbr #4\hspace\relax\etoc@}
\edef\etocpage{\noexpand\protect\expandafter\noexpand
@@ -353,34 +336,35 @@
\def\Etoc@readtoc#1{%
\ifeof #1
\let\Etoc@nextread\@gobble
+ \global\Etoc@toctoks=\expandafter{\the\Etoc@toctoks}%
\else
\let\Etoc@nextread\Etoc@readtoc
\read #1 to \Etoc@buffer
- \global\Etoc@toctoks=\expandafter\expandafter\expandafter
+ \Etoc@toctoks=\expandafter\expandafter\expandafter
{\expandafter\the\expandafter\Etoc@toctoks\Etoc@buffer}%
\fi
\Etoc@nextread{#1}%
}
+\IfFileExists{\jobname .toc}
+ {{\endlinechar=-1 \makeatletter
+ \newread\Etoc@tf
+ \openin\Etoc@tf\@filef@und
+ \Etoc@readtoc\Etoc@tf
+ \closein\Etoc@tf}}{\typeout{No file \jobname .toc.}}
\def\Etoc@starttoc{%
\begingroup
\makeatletter
-\@ifpackageloaded{hyperref}
- {\ifx\hyper@last\@undefined
+\ifEtoc@hyperref
+ \ifx\hyper@last\@undefined
\ltx@ifpackageloaded {parskip}{\parskip \z@ }{}%
- \IfFileExists {\jobname .toc}{\Hy@WarningNoLine {old toc file
- detected, not used; run LaTeX again (cheers from etoc)}}{}%
- \expandafter\@gobble\fi}{}%
-{\IfFileExists{\jobname .toc}
- {\endlinechar=-1\relax
- \newread\Etoc@tf
- \openin\Etoc@tf\@filef@und
- \Etoc@readtoc\Etoc@tf
- \closein\Etoc@tf}
- {\typeout{No file \jobname .toc.}}}%
-\if@filesw \newwrite \tf@toc \immediate
-\openout \tf@toc \jobname .toc\relax \fi
-\@nobreakfalse \endgroup}
-\AtBeginDocument{\Etoc@starttoc}
+ \IfFileExists {\jobname .toc}
+ {\Hy@WarningNoLine
+ {old toc file detected, not used; run LaTeX again (cheers from etoc)}%
+ \global\Etoc@toctoks={}}
+{}\fi\fi
+\if@filesw \newwrite \tf@toc
+\immediate \openout \tf@toc \jobname .toc\relax \fi \@nobreakfalse
+\endgroup}
\def\Etoc@toctoc{%
\global\Etoc@vfalse
\global\Etoc@ivfalse
@@ -391,7 +375,6 @@
\global\Etoc@jfalse
\global\Etoc@jjfalse
\ifEtoc@standard
-\Etoc@Lazarus
\etoc@setstyle{@minustwo}{}{}{}{}%
\etoc@setstyle{@minusone}{}{}{}{}%
\etoc@setstyle{@zero}{}{}{}{}%
@@ -401,6 +384,8 @@
\etoc@setstyle{@four}{}{}{}{}%
\etoc@setstyle{@five}{}{}{}{}%
\else
+\def\Etoc@levellist@elt##1{\let##1\Etoc@lxyz}%
+\Etoc@levellist
\let\numberline\@gobble
\let\booknumberline\numberline
\let\partnumberline\numberline
@@ -422,14 +407,14 @@
\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
- \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
+ \ifEtoc@jj \let\Etoc@localtop\Etoc@@minusone@@ \fi
+ \ifEtoc@j \let\Etoc@localtop\Etoc@@zero@@ \fi
+ \ifEtoc@ \let\Etoc@localtop\Etoc@@one@@ \fi
+ \ifEtoc@i \let\Etoc@localtop\Etoc@@two@@ \fi
+ \ifEtoc@ii \let\Etoc@localtop\Etoc@@three@@ \fi
+ \ifEtoc@iii \let\Etoc@localtop\Etoc@@four@@ \fi
+ \ifEtoc@iv \let\Etoc@localtop\Etoc@@five@@ \fi
+ \ifEtoc@v \let\Etoc@localtop\Etoc@@six@@ \fi
\def\Etoc@next{\global\Etoc@notactivefalse
\global\Etoc@vfalse
\global\Etoc@ivfalse
@@ -442,7 +427,7 @@
\fi
\fi\fi
\Etoc@next}
-\def\etoc@startlocaltoc#1{\etoc@@startlocaltoc{#1}{\c@etoc@tocid}}
+\let\etoc@startlocaltoc\@gobble
\long\def\Etoc@localtableofcontents#1{%
\edef\Etoc@tmp{#1}%
\ifnum\Etoc@tmp<\@ne
@@ -451,25 +436,19 @@
\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{%
+ {\edef\etoc@startlocaltoc##1{%
\noexpand\etoc@@startlocaltoc{##1}{#1}}
\Etoc@localtoctrue
\let\Etoc@localtop\Etoc@@minustwo@@
\global\Etoc@stoptocfalse
\global\Etoc@notactivetrue
- \Etoc@tableofcontents
- \endgroup}%
- \ifEtoc@mustclosegroup\expandafter\endgroup\fi}
+ \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}}
@@ -485,13 +464,12 @@
\def\Etoc@next{\expandafter\Etoc@ref\@gobble}%
\else
\def\Etoc@next{\Etoc@localtocfalse
- \global\Etoc@notactivefalse
- \begingroup\Etoc@tableofcontents
- \ifEtoc@mustclosegroup\expandafter\endgroup\fi
- \endgroup}%
+ \global\Etoc@notactivefalse
+ \Etoc@tableofcontents
+ \endgroup
+ \ifEtoc@mustclosegroup\expandafter\endgroup\fi}%
\fi
\fi\fi\fi\Etoc@next}
-\newcommand\etocaftertitlehook{}
\def\table@fcontents{\par
\refstepcounter{etoc@tocid}%
\Etoc@tocwithidfalse
@@ -499,13 +477,20 @@
\def\localtable@fcontents{\par
\refstepcounter{etoc@tocid}%
\addtocontents{toc}
- {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}
+ {\string\etoc@startlocaltoc\string{\arabic{etoc@tocid}\string}}%
\Etoc@tocwithidtrue
\futurelet\Etoc@nexttoken\Etoc@t@bleofcontents}
-\def\tableofcontents{\@ifstar
+\newcommand\etocaftertitlehook{}
+\def\tableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi
+ \global\Etoc@tocopenedforwritetrue
+ \begingroup
+ \def\etoc@startlocaltoc##1{\etoc@@startlocaltoc{##1}{\c@etoc@tocid}}%
+ \@ifstar
{\let\Etoc@aftertitlehook\relax\table@fcontents}
{\let\Etoc@aftertitlehook\etocaftertitlehook\table@fcontents}}
-\def\localtableofcontents{\@ifstar
+\def\localtableofcontents{\ifEtoc@tocopenedforwrite\else\Etoc@starttoc\fi
+ \global\Etoc@tocopenedforwritetrue
+ \begingroup\@ifstar
{\let\Etoc@aftertitlehook\relax\localtable@fcontents}
{\let\Etoc@aftertitlehook\etocaftertitlehook\localtable@fcontents}}
\newcommand\etocsettocstyle[2]{%
@@ -513,6 +498,8 @@
{\ifnum\c@tocdepth>\Etoc@minf\let\Etoc@@next\@firstofone\else
\let\Etoc@@next\@gobble\fi
\Etoc@@next{#1\Etoc@aftertitlehook
+ \let\Etoc@savedcontentsline\contentsline
+ \let\contentsline\Etoc@etoccontentsline
\Etoc@toctoc\let\Etoc@n@xt\relax
\ifEtoc@tocwithid\else
\ifEtoc@localtoc
@@ -542,8 +529,6 @@
\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}