summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-08-07 22:51:21 +0000
committerKarl Berry <karl@freefriends.org>2011-08-07 22:51:21 +0000
commitb9796f07afb63ea44bdf7109294476668d4d1c5f (patch)
treee5f4683338fd567cc11ef84f67dbf2fa587a5537 /Master
parentbcdd4b5d66feaf11bd0ef448645957cb6f14f372 (diff)
tocvsec2 1.3 (7aug11)
git-svn-id: svn://tug.org/texlive/trunk@23444 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/tocvsec2/README20
-rw-r--r--Master/texmf-dist/doc/latex/tocvsec2/tocvsec2-example.tex56
-rw-r--r--Master/texmf-dist/doc/latex/tocvsec2/tocvsec2.pdfbin287553 -> 301276 bytes
-rw-r--r--Master/texmf-dist/source/latex/tocvsec2/tocvsec2.dtx197
-rw-r--r--Master/texmf-dist/tex/latex/tocvsec2/tocvsec2.sty88
5 files changed, 312 insertions, 49 deletions
diff --git a/Master/texmf-dist/doc/latex/tocvsec2/README b/Master/texmf-dist/doc/latex/tocvsec2/README
index cf07be57538..a3e5ad6338f 100644
--- a/Master/texmf-dist/doc/latex/tocvsec2/README
+++ b/Master/texmf-dist/doc/latex/tocvsec2/README
@@ -8,6 +8,18 @@ NB. The package also requires the ifthen package.
______________
Change history
+version 1.3 (2011/08/07)
+- New commands \resettocdepth and \resetsecnumdepth
+ used for resetting to previous values of the tocdepth
+ and secnumdepth counters (using a stack-based approach).
+ With optional star argument can reset to the original
+ `max' values.
+
+- Bug fix that resets "tocdepth" to its original value after
+ the \tableofcontents -- els it will adversely affect
+ subsequent List of Figures/Tables (or cause no harm,
+ either way).
+
version 1.2b (2010/02/27)
- Bug fix for extraneous vertical space before sections
(This may change the typesetting of documents that use
@@ -22,7 +34,8 @@ version 1.2 (2004/05/24)
-----------------------------------------------------------------
Author: Peter Wilson, Herries Press
Maintainer: Will Robertson (will dot robertson at latex-project dot org)
- Copyright 1999 -- 2004 Peter R. Wilson
+ Copyright 1999-2004 Peter R. Wilson
+ Copyright 2010-2011 Will Robertson
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
@@ -55,7 +68,6 @@ tocvsec2.pdf (user manual)
http://www.tug.ac.uk/faq for more information on this.
To regenerate the user manual:
-- run: latex tocvsec2.dtx
+- run: pdflatex tocvsec2.dtx
- run: makeindex -s gind.ist tocvsec2
-- run: latex tocvsec2.dtx
-- Print tocvsec2.dvi for a hardcopy of the package manual
+- run: pdflatex tocvsec2.dtx
diff --git a/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2-example.tex b/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2-example.tex
new file mode 100644
index 00000000000..0dea71304b8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2-example.tex
@@ -0,0 +1,56 @@
+
+\documentclass{article}
+
+\usepackage{tocvsec2}
+\maxtocdepth{subsubsection}
+\maxsecnumdepth{subsubsection}
+
+\def\x{%
+ \subsection{sone} xyz
+ \subsubsection{ssone} abc
+ \subsubsection{sstwo} def
+ \subsection{stwo} 123
+ \paragraph{foo} here
+}
+
+\begin{document}
+\makeatletter
+
+\tableofcontents
+\section{Normal section}
+\x
+
+\setsecnumdepth{subsection}
+\settocdepth{subsection}
+\section{Reduce numbering}
+\x
+
+\setsecnumdepth{section}
+\settocdepth{section}
+\section{Reduce numbering again}
+\x
+
+\resetsecnumdepth
+\resettocdepth
+\section{Reset numbering once}
+\x
+
+\setsecnumdepth{section}
+\settocdepth{section}
+\section{Reduce numbering again}
+\x
+
+\resetsecnumdepth*
+\resettocdepth*
+\section{Another normal section after resetting completely}
+\x
+
+\appendix
+
+\settocdepth{all}
+\setsecnumdepth{all}
+\section{Appendix with all numbering}
+\x
+
+
+\end{document}
diff --git a/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2.pdf b/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2.pdf
index a9dd02c3c32..7977c890f8d 100644
--- a/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2.pdf
+++ b/Master/texmf-dist/doc/latex/tocvsec2/tocvsec2.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/tocvsec2/tocvsec2.dtx b/Master/texmf-dist/source/latex/tocvsec2/tocvsec2.dtx
index 244ad2750ef..5d47eb29e29 100644
--- a/Master/texmf-dist/source/latex/tocvsec2/tocvsec2.dtx
+++ b/Master/texmf-dist/source/latex/tocvsec2/tocvsec2.dtx
@@ -3,8 +3,8 @@
% tocvsec2.dtx
% Author: Peter Wilson, Herries Press
% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
-% Copyright 1999--2004 Peter R. Wilson
-% Copyright 2010 Will Robertson
+% Copyright 1999-2004 Peter R. Wilson
+% Copyright 2010-2011 Will Robertson
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -22,7 +22,7 @@
%</driver>
%<usc>\ProvidesPackage{tocvsec2}
%<*usc>
- [2010/02/27 v1.2b variable ToC section entries]
+ [2011/08/07 v1.3 variable ToC section entries]
%</usc>
%
%<*driver>
@@ -113,7 +113,7 @@
% in the Table of Contents on a section by section basis.
% It is a replacement for the \Lpack{tocvsec} package, which should
% not be used.
-% Use of the package requires the \Lpack{ifthen} package to be available.
+% Use of the package requires e\TeX\ and the \Lpack{ifthen} package to be available.
% \end{abstract}
% \tableofcontents
%
@@ -139,8 +139,6 @@
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
-% \clearpage
-%
% Section~\ref{sec:usc} describes the usage of the package.
% Commented source code for the package is in Section~\ref{sec:code}.
%
@@ -226,13 +224,20 @@
% The package also provides some utility commands so you don't have to remember
% the level numbers of the sectioning commands.
%
+% \subsection{Changing ToC appearances}
+%
% \DescribeMacro{\maxtocdepth}
% The |\maxtocdepth{|\meta{sec}|}| command can be used after the preamble
% (and before the |\tableofcontents| command) to set the global value
% for the \Lcount{tocdepth}. \meta{sec} is the name of a sectioning
% division (e.g., |part| or |paragraph|). You can also use |all|,
% meaning all sectioning divisions, or |none|, meaning no sectioning divisions.
-%
+%
+% \textbf{Note well}: after \cs{tableofcontents}, the \Lcount{tocdepth}
+% is reset to the value specified by \cs{maxtocdepth} in case that counter is
+% used by a subsequent `List of Figures' or `List of Tables', as in the
+% standard \LaTeX\ classes.
+%
%
% \DescribeMacro{\settocdepth}
% The |\settocdepth{|\meta{sec}|}| command can be used to change the value of
@@ -250,9 +255,20 @@
% to the least
% significant sectional unit
% that should be in the printed ToC.
-% Later, after the |\tableofcontents| command, it is possible to
-% to use |\settocdepth| to reset \Lcount{tocdepth} to a more significant
-% sectional level (and to reset it back again). As an example, assume that
+% Later, after the |\tableofcontents| command, it is possible to
+% to use |\settocdepth| to change \Lcount{tocdepth} to a different
+% sectional level.
+%
+% \DescribeMacro{\resettocdepth}
+% After \Lcount{tocdepth} has been changed with |\settocdepth|, it is
+% possible to reset it to its previous value with |\resettocdepth|.
+% In fact, you may use |\resettocdepth| multiple times
+% to reset multiple uses of |\settocdepth|. (It behaves like a stack, for
+% you computer-science-types.)
+% If you wish to reset \Lcount{tocdepth} to its original value completely,
+% use |\resettocdepth*|.
+%
+% As an example, assume that
% the ToC should list subsections and above, but there is one particular
% section in the document which consists of a set of definitions, each of
% which is presented as a subsection, but these should not appear in the
@@ -270,11 +286,13 @@
% \settocdepth{section}
% \subsection{Definition 1}
% ...
-% \settocdepth{subsection}
+% \resettocdepth %% equivalent to "\settocdepth{subsection}"
% \section{After definitions}
% ...
% \end{verbatim}
%
+% \section{Changing section numbering}
+%
% \DescribeMacro{\setsecnumdepth}
% The |\setsecnumdepth{|\meta{sec}|}| command is similar to |\settocdepth|
% except
@@ -286,10 +304,19 @@
% \DescribeMacro{\maxsecnumdepth}
% The |\maxsecnumdepth{|\meta{sec}|}| command is similar to |\maxtocdepth|
% except that it is for setting the default value for \Lcount{secnumdepth}
-% after the preamble. If you used |\setsecnumdepth| for this purpose
-% you might find an extra blank page in the typeset manuscript.
-%
-% For example, assume that in a document the sectional divisions are
+% after the preamble.
+% In previous versions of the package if you used |\setsecnumdepth| for this
+% purpose you might find an extra blank page in the typeset manuscript, but
+% nowadays the two commands are interchangeable.
+%
+% \DescribeMacro{\resetsecnumdepth}
+% Similarly to |\resettocdepth|, this command cycles back through previous
+% values for \Lcount{secnumdepth} so you don't have to keep track of them
+% yourself if you need to change its value for only a short component of a
+% manuscript. By writing |\resetsecnumdepth*|, you can reset entirely back
+% to a clean state with \Lcount{secnumdepth} set to its original value.
+%
+% For example, assume that in a document the sectional divisions are
% normally numbered down to the sub-subsection level, but within a particular
% section, they should only be numbered to the subsection level. Also,
% all sectional divisions within the appendices are to be numbered.
@@ -308,7 +335,7 @@
% \section{Reduce numbering}
% \setsecnumdepth{subsection}
% ...
-% \setsecnumdepth{subsubsection}
+% \resetsecnumdepth %% equivalent to "\setsecnumdepth{subsubsection}"
% \section{Another normal section}
% ...
% \appendix
@@ -393,35 +420,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}{%
@@ -436,28 +463,136 @@
% |\maxtocdepth{|\meta{sec}|}| can be used to initialise \Lcount{tocdepth}
% between the end of the preamble and the |\tableofcontents| command.
% \begin{macrocode}
-\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}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\tableofcontents}
+% \changes{v1.3}{2011/08/07}{Patch to reset \Lcount{tocdepth}}
+% \begin{macrocode}
+\g@addto@macro\tableofcontents{%
+ \setcounter{tocdepth}{\value{max@tocdepth}}%
+}
% \end{macrocode}
% \end{macro}
%
+%
% \begin{macro}{\setsecnumdepth}
% \changes{v1.2b}{2010/02/27}{Remove occasional extraneous vertical space}
-% |\setsecnumdepth{|\meta{sec}|}| is the user command for setting
+% |\setsecnumdepth{|\meta{sec}|}| is the user command for setting
% \Lcount{secnumdepth} to the value corresponding to \meta{sec}.
% \begin{macrocode}
\newcommand{\setsecnumdepth}[1]{%
+ \save@secnumdepth
\@setseccntt@c{#1}{secnumdepth}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\maxsecnumdepth}
% |\maxsecnumdepth{|\meta{sec}|}| is the user command to initialise
-% \Lcount{secnumdepth} after the preamble
+% \Lcount{secnumdepth} after the preamble
% to the value corresponding to \meta{sec}.
% \begin{macrocode}
+\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}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Resetting and returning to previous values}
+%
+%
+% \begin{macro}{\resetsecnumdepth}
+% \changes{v1.3}{2011/08/07}{New command}
+% It would be nice to be able to `reset' the tocdepth or secnumdepth
+% to a previous value.
+% Unfortunately this can't be done with grouping so we use a stack-based
+% approach.
+% \begin{macrocode}
+\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}}
+% \end{macrocode}
+% The idea of the stack is
+% |{|$x_n$|\relax| $x_{n-1}$|\relax| \dots$x_0$|\relax}|;
+% prepending new values with \cs{edef} and using assignment and
+% \cs{afterassignment} to push an entry off the front.
+% \begin{macrocode}
+\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
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\resettocdepth}
+% \changes{v1.3}{2011/08/07}{New command}
+% The idea the same is as above but because it all happens inside an auxiliary
+% file there's a couple of extra steps.
+% \begin{macrocode}
+\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}}
+% \end{macrocode}
+% Resetting is done in the \verb|.toc| file:
+% \begin{macrocode}
+\newcommand\resettocdepth{\@ifstar
+ {\addtocontents{toc}{\remax@tocdepth}}
+ {\addtocontents{toc}{\reset@tocdepth}}%
+}
+% \end{macrocode}
+% Reset back to the initial state (and clear the stack):
+% \begin{macrocode}
+\protected\def\remax@tocdepth{%
+ \setcounter{tocdepth}{\value{max@tocdepth}}%
+ \edef\stack@secnumdepth{\the\c@tocdepth\relax}%
+}
+% \end{macrocode}
+% Reset to the previous state on the stack:
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% Ensure errant commands in the ToC won't cause problems:
+% \begin{macrocode}
+\addtocontents{toc}{%
+ \@ifundefined{save@tocdepth}{%
+ \let\save@tocdepth\relax
+ \let\reset@tocdepth\relax
+ \let\remax@tocdepth\relax
+ }{}%
+}
% \end{macrocode}
% \end{macro}
%
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 <return> 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'.