From b9796f07afb63ea44bdf7109294476668d4d1c5f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 7 Aug 2011 22:51:21 +0000 Subject: tocvsec2 1.3 (7aug11) git-svn-id: svn://tug.org/texlive/trunk@23444 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty | 88 +++++++++++++++++++---- 1 file changed, 74 insertions(+), 14 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tocvsec2') diff --git a/Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty b/Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty index be19c89994d..8c90735738a 100644 --- a/Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty +++ b/Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty @@ -23,7 +23,7 @@ %% This work consists of the files listed in the README file. %% ----------------------------------------------------------------- \ProvidesPackage{tocvsec2} - [2010/02/27 v1.2b variable ToC section entries] + [2011/08/07 v1.3 variable ToC section entries] \RequirePackage{ifthen} \newif\ift@cchapter \t@cchapterfalse @@ -69,35 +69,35 @@ \newcommand{\settocdepth}[1]{% \@knownsect@cfalse \ifthenelse{\equal{#1}{none}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{-10}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-10}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{part}}{% \ift@cchapter - \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-1}} \else - \addtocontents{toc}{\protect\setcounter{tocdepth}{0}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}} \fi \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{chapter}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{0}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{section}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{1}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{1}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{subsection}}{ - \addtocontents{toc}{\protect\setcounter{tocdepth}{2}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{2}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{subsubsection}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{3}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{3}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{paragraph}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{4}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{4}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{subparagraph}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{5}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{5}} \@knownsect@ctrue}{} \ifthenelse{\equal{#1}{all}}{% - \addtocontents{toc}{\protect\setcounter{tocdepth}{100}} + \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{100}} \@knownsect@ctrue}{} \if@knownsect@c\else \PackageError{tocvsec2}{% @@ -105,12 +105,72 @@ {I'll ignore it. Type \space and I'll continue.} \fi } -\newcommand{\maxtocdepth}[1]{ - \@setseccntt@c{#1}{tocdepth}} +\newcounter{max@tocdepth} +\setcounter{max@tocdepth}{\value{tocdepth}} +\newcommand{\maxtocdepth}[1]{% + \save@tocdepth + \@setseccntt@c{#1}{max@tocdepth}% + \@setseccntt@c{#1}{tocdepth}% +} +\g@addto@macro\tableofcontents{% + \setcounter{tocdepth}{\value{max@tocdepth}}% +} \newcommand{\setsecnumdepth}[1]{% + \save@secnumdepth \@setseccntt@c{#1}{secnumdepth}} +\newcounter{max@secnumdepth} +\setcounter{max@secnumdepth}{\value{secnumdepth}} \newcommand{\maxsecnumdepth}[1]{% - \@setseccntt@c{#1}{secnumdepth}} + \save@secnumdepth + \@setseccntt@c{#1}{max@secnumdepth}% + \@setseccntt@c{#1}{secnumdepth}% +} +\let\stack@secnumdepth\@empty +\newcommand\save@secnumdepth{% + \edef\stack@secnumdepth{\the\c@secnumdepth\relax\stack@secnumdepth}% +} +\def\gobble@secnumdepth#1\@nil{\edef\stack@secnumdepth{#1}} +\newcommand\resetsecnumdepth{% + \@ifstar{% + \setcounter{secnumdepth}{\value{max@secnumdepth}}% + \edef\stack@secnumdepth{\the\c@secnumdepth\relax}% + }{% + \ifx\stack@secnumdepth\@empty + \PackageWarning{tocvsec2}{There is no previous value for secnumdepth}% + \else + \afterassignment\gobble@secnumdepth + \expandafter\c@secnumdepth\expandafter\numexpr\stack@secnumdepth\@nil + \fi + } +} +\let\stack@tocdepth\@empty +\protected\def\save@tocdepth{% + \edef\stack@tocdepth{\the\c@tocdepth\relax\stack@tocdepth}% +} +\def\gobble@tocdepth#1\@nil{\edef\stack@tocdepth{#1}} +\newcommand\resettocdepth{\@ifstar + {\addtocontents{toc}{\remax@tocdepth}} + {\addtocontents{toc}{\reset@tocdepth}}% +} +\protected\def\remax@tocdepth{% + \setcounter{tocdepth}{\value{max@tocdepth}}% + \edef\stack@secnumdepth{\the\c@tocdepth\relax}% +} +\protected\def\reset@tocdepth{% + \ifx\stack@tocdepth\@empty + \PackageWarning{tocvsec2}{There is no previous value for tocdepth}% + \else + \afterassignment\gobble@tocdepth + \expandafter\c@tocdepth\expandafter\numexpr\stack@tocdepth\@nil + \fi +} +\addtocontents{toc}{% + \@ifundefined{save@tocdepth}{% + \let\save@tocdepth\relax + \let\reset@tocdepth\relax + \let\remax@tocdepth\relax + }{}% +} \endinput %% %% End of file `tocvsec2.sty'. -- cgit v1.2.3