summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tocvsec2
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/tocvsec2
Initial commit
Diffstat (limited to 'macros/latex/contrib/tocvsec2')
-rw-r--r--macros/latex/contrib/tocvsec2/README77
-rw-r--r--macros/latex/contrib/tocvsec2/tocvsec2-example.tex56
-rw-r--r--macros/latex/contrib/tocvsec2/tocvsec2.dtx646
-rw-r--r--macros/latex/contrib/tocvsec2/tocvsec2.ins75
-rw-r--r--macros/latex/contrib/tocvsec2/tocvsec2.pdfbin0 -> 300978 bytes
5 files changed, 854 insertions, 0 deletions
diff --git a/macros/latex/contrib/tocvsec2/README b/macros/latex/contrib/tocvsec2/README
new file mode 100644
index 0000000000..382611626f
--- /dev/null
+++ b/macros/latex/contrib/tocvsec2/README
@@ -0,0 +1,77 @@
+____________________
+The TOCVSEC2 package
+
+ The tocvsec2 package provides control over sectional numbering and/or the
+entries in the Table of Contents on a section by section basis.
+NB. The package also requires the ifthen package.
+
+______________
+Change history
+
+version 1.3a (2014/03/10)
+- Missing % in a definition was causing a spacing issue.
+ Thanks: http://tex.stackexchange.com/a/164612
+
+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 -- else 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
+ this package. The price of a bug fix, unfortunately.)
+
+version 1.2a (2009/09/04)
+- New maintainer (Will Robertson)
+
+version 1.2 (2004/05/24)
+- The stdclsdv package is no longer required
+
+-----------------------------------------------------------------
+ Author: Peter Wilson, Herries Press
+ Maintainer: Will Robertson (will dot robertson at latex-project dot org)
+ 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
+ version 1.3c of this license or (at your option) any
+ later version: <http://www.latex-project.org/lppl.txt>
+
+ This work has the LPPL maintenance status "maintained".
+ The Current Maintainer of this work is Will Robertson.
+
+ This work consists of the files:
+README (this file)
+tocvsec2.dtx
+tocvsec2.ins
+ and the derived files:
+tocvsec2.sty
+
+ The distribution consists of the files:
+README (this file)
+tocvsec2.dtx
+tocvsec2.ins
+tocvsec2.pdf (user manual)
+
+-----------------------------------------------------------------
+
+ To install the package:
+- run: latex tocvsec2.ins (which will generate tocvsec2.sty)
+- Move tocvsec2.sty to a location where LaTeX will find it.
+ (typically in a local texmf tree at tex/latex/tocvsec2) and refresh the
+ file database. See the FAQ on CTAN at help/uk-tex-faq or
+ http://www.tug.ac.uk/faq for more information on this.
+
+ To regenerate the user manual:
+- run: pdflatex tocvsec2.dtx
+- run: makeindex -s gind.ist tocvsec2
+- run: pdflatex tocvsec2.dtx
diff --git a/macros/latex/contrib/tocvsec2/tocvsec2-example.tex b/macros/latex/contrib/tocvsec2/tocvsec2-example.tex
new file mode 100644
index 0000000000..0dea71304b
--- /dev/null
+++ b/macros/latex/contrib/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/macros/latex/contrib/tocvsec2/tocvsec2.dtx b/macros/latex/contrib/tocvsec2/tocvsec2.dtx
new file mode 100644
index 0000000000..c40a36b018
--- /dev/null
+++ b/macros/latex/contrib/tocvsec2/tocvsec2.dtx
@@ -0,0 +1,646 @@
+% \iffalse meta-comment
+%
+% 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-2011 Will Robertson
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3c of this license or (at your option) any
+% later version: <http://www.latex-project.org/lppl.txt>
+%
+% This work has the LPPL maintenance status "maintained".
+% The Current Maintainer of this work is Will Robertson.
+%
+% This work consists of the files listed in the README file.
+%
+%
+%<*driver>
+\ProvidesFile{tocvsec2.dtx}
+%</driver>
+%<usc>\ProvidesPackage{tocvsec2}
+%<*usc>
+ [2014/03/10 v1.3a variable ToC section entries]
+%</usc>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\EnableCrossrefs
+\CodelineIndex
+\setcounter{StandardModuleDepth}{1}
+\begin{document}
+ \DocInput{tocvsec2.dtx}
+\end{document}
+%</driver>
+%
+% \fi
+%
+% \CheckSum{142}
+%
+% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
+% \DoNotIndex{\@centercr,\@cite}
+% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
+% \DoNotIndex{\@input,\@ixpt,\@m}
+% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
+% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
+% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
+% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
+% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
+% \DoNotIndex{\advance,\Alph,\alph}
+% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
+% \DoNotIndex{\bullet}
+% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
+% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
+% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
+% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
+% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
+% \DoNotIndex{\fbox}
+% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
+% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
+% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
+% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
+% \DoNotIndex{\input}
+% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
+% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
+% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
+% \DoNotIndex{\NeedsTeXFormat,\newdimen}
+% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
+% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
+% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
+% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
+% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
+% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
+% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
+% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
+% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
+% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
+% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
+% \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
+% \DoNotIndex{\wd,\xiipt,\year,\z@}
+%
+% \changes{v1.0}{1999/01/17}{First public release}
+% \changes{v1.1}{1999/01/24}{Added none and all `sections'}
+% \changes{v1.1}{1999/01/24}{Added maxsecnumdepth command}
+% \changes{v1.1a}{2004/05/10}{Changed license from LPPL v1.0 to v1.3}
+% \changes{v1.2}{2004/05/24}{Eliminated requirement for stdclsdv package}
+% \changes{v1.2a}{2009/09/04}{New maintainer (Will Robertson)}
+% \changes{v1.3a}{2011/03/10}{Some missing comment chars causing space issues}
+%
+% \def\dtxfile{tocvsec2.dtx}
+% \GetFileInfo{\dtxfile}
+% \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package
+% \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option
+% \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file
+% \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter
+% \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle
+% \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment
+%
+% \title{The \Lpack{tocvsec2} package\thanks{This
+% file (\texttt{\dtxfile}) has version number \fileversion, last revised
+% \filedate.}}
+%
+% \author{
+% Author: Peter Wilson, Herries Press \\
+% Maintainer: Will Robertson \\
+% \texttt{will dot robertson at latex-project dot org}
+% }
+% \date{\filedate}
+% \maketitle
+% \begin{abstract}
+% The \Lpack{tocvsec2} package provides means of controlling the sectional
+% numbering and/or the entries
+% 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 e\TeX\ and the \Lpack{ifthen} package to be available.
+% \end{abstract}
+% \tableofcontents
+%
+% ^^A \StopEventually{}
+%
+%
+%
+% \section{Introduction}
+%
+% In the standard classes two commands are used to control the numbering
+% of sectional divisions in a document, and which level of sectional
+% headings will be included in the Table of Contents (the ToC). Sometimes
+% finer control of these aspects of \LaTeX{} is required. The \Lpack{tocvsec2}
+% provides for control over the entries into the ToC on a section by section
+% basis. It also provides a means of locally controlling sectional numbering
+% without having to resort to the starred version of the sectional commands.
+% The package requires the \Lpack{ifthen} package
+% to be available.
+%
+% Portions of the package were developed as part of a class
+% and package bundle for typesetting ISO standards~\cite{PRW96i}.
+% This manual is typeset according to the conventions of the
+% \LaTeX{} \textsc{docstrip} utility which enables the automatic
+% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
+%
+% Section~\ref{sec:usc} describes the usage of the package.
+% Commented source code for the package is in Section~\ref{sec:code}.
+%
+% \DescribeMacro{secnumdepth}
+% The \LaTeX{} \Lcount{secnumdepth} counter specifies the level number
+% for the least significant
+% sectional heading that will be numbered. In all the standard classes
+% |\section| has a level number of 1, |\subsection| has a level number
+% of 2, and so on. In the \Lpack{article} class (and its derivatives),
+% |\part| has a level number of 0. In the \Lpack{book} and \Lpack{report}
+% classes, |\chapter| is level number 0 and |\part| has level number -1.
+%
+% The \Lcount{secnumdepth} counter is normally set in the preamble and
+% remains constant thereafter. For example:
+% \begin{verbatim}
+% \setcounter{secnumdepth}{2}
+% \end{verbatim}
+% specifies that |\subsection|s and above should be numbered and
+% |\subsubsections| and below should not be numbered. It turns out
+% that \Lcount{secnumdepth} can be changed at any point in a document, not
+% just in the preamble, to make a (temporary) change to the section numbering
+% level. This is possible because the heading commands check the value
+% of \Lcount{secnumdepth} to decide whether or not to number the heading.
+%
+% \DescribeMacro{tocdepth}
+% The \Lcount{tocdepth} counter specifies the level number of the least
+% significant sectional unit that will be listed in the printed Table of
+% Contents (ToC). For example:
+% \begin{verbatim}
+% \setcounter{tocdepth}{1}
+% \end{verbatim}
+% specifies that the printed ToC should only list sectional headings down
+% to the |\section| level. The value of \Lcount{tocdepth} has to be set
+% before the |\tableofcontents| command is used. Each sectioning command
+% puts an entry into the \file{.toc} file, irrespective of the \Lcount{tocdepth}
+% value. The code implementing the typesetting of the ToC uses
+% \Lcount{tocdepth} to determine whether or not an entry should be printed.
+% Thus, unlike \Lcount{secnumdepth} which can be altered at any time and have
+% an effect, it is only the value of \Lcount{tocdepth} at the time of
+% printing the entries in the |\tableofcontents| that is used ---
+% any subsequent changes to
+% \Lcount{tocdepth} are immaterial.
+%
+% Note that \Lcount{tocdepth} only controls what appears in the ToC,
+% and \Lcount{secnumdepth} only controls which sectional headings are
+% numbered. The effect of changing one has no bearing on the other.
+%
+% \section{The \Lpack{tocvsec2} package} \label{sec:usc}
+%
+% The \Lpack{tocvsec} package changed the way in which entries were written
+% to the \file{.toc} file, enabling effective changes to be made to
+% \Lcount{tocdepth} at any point in a document.
+%
+% The basis of that package was to ensure that only those sectional elements
+% that were required to appear in the printed ToC were written to the \file{.toc}
+% file. The sectional commands call the |\addcontentsline| command to
+% write an entry to the \file{.toc} file.
+% There were two methods to achieve the desired functionality, both of which
+% required
+% modifications to the internal \LaTeX{} macros.
+% \begin{enumerate}
+% \item Modify the sectional commands so that they check the value of
+% \Lcount{tocdepth} in order to decide whether or not to put an entry
+% into the \file{.toc} file (i.e., call |\addcontentsline|).
+% \item Modify |\addcontentsline| so that it decides whether or not to write
+% to the \file{.toc} file. This is less efficient in terms of processing
+% time than changing the sectional commands.
+% \end{enumerate}
+%
+% Both approaches had disadvantages. If the \Lpack{tocvsec} package
+% changed the sectional commands and it was used in conjunction with
+% another package that also changes these definitions, then one or the other
+% package would not work as expected. On the other hand, changing the
+% |\addcontentsline| command may have had unexpected results if |\addcontentsline|
+% was either modified or used in a different manner elsewhere in the document.
+%
+% The \Lpack{tocvsec2} package takes a different approach which does
+% not have these disadvantages. It provides a means of inserting commands
+% into the \file{.toc} file that change the current value of
+% \Lcount{tocdepth} within the body of the file.
+%
+%
+% 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
+% the \Lcount{tocdepth} counter within the \file{.toc} file,
+% where \meta{sec} is the name of a sectional
+% division (e.g., \texttt{chapter} or \texttt{subsection}), or |all| or
+% |none|. For example,
+% |\settocdepth{section}| will set \Lcount{tocdepth} to be 1 within the
+% \file{.toc} file, until it is altered by another |\settocdepth|
+% command. The command
+% cannot be used in the preamble (i.e., before |\begin{document}|), but
+% can be used any point thereafter.
+%
+% \Lcount{tocdepth} should be set in the preamble, or immediately after,
+% 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 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
+% printed ToC.
+% \begin{verbatim}
+% \documentclass{...}
+% \usepackage{tocvsec2}
+% ...
+% \begin{document}
+% \maxtocdepth{subsection}
+% ...
+% \tableofcontents
+% ...
+% \section{Definitions}
+% \settocdepth{section}
+% \subsection{Definition 1}
+% ...
+% \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
+% that it changes the value of \Lcount{secnumdepth} at the point in
+% the document where it is called. Like the |\settocdepth|
+% command, it cannot be used in the preamble, but can be used as often as
+% necessary after that.
+%
+% \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.
+% 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.
+% This can be accomplished like:
+% \begin{verbatim}
+% \documentclass{...}
+% \usepackage{tocvsec2}
+% ...
+% \begin{document}
+% \maxsecnumdepth{subsubsection}
+% ...
+% \tableofcontents
+% ...
+% \section{Normal section}
+% ...
+% \section{Reduce numbering}
+% \setsecnumdepth{subsection}
+% ...
+% \resetsecnumdepth %% equivalent to "\setsecnumdepth{subsubsection}"
+% \section{Another normal section}
+% ...
+% \appendix
+% \setsecnumdepth{all}
+% ...
+% \end{verbatim}
+%
+%
+%
+%
+% \section{The package code} \label{sec:code}
+%
+% \begin{macrocode}
+%<*usc>
+\RequirePackage{ifthen}
+% \end{macrocode}
+%
+% In order to try and avoid name clashes with other packages, each internal
+% name will include the character string \texttt{t@c}.
+%
+% Issue warning if there are no recognized sectional divisions.
+% \begin{macrocode}
+\newif\ift@cchapter
+ \t@cchapterfalse
+\@ifundefined{chapter}{%
+ \@ifundefined{section}{%
+ \PackageWarning{tocvsec2}{%
+ I don't recognize any divisions but I'll do my best}}{}}%
+ {\t@cchaptertrue}
+
+% \end{macrocode}
+%
+% \begin{macro}{\if@knownsect@c}
+% \begin{macro}{\@setseccntt@c}
+% A helper macro to set a sectioning-related counter. Call as
+% |\@setseccntt@c{|\meta{sec}|}{|\meta{counter}|}| to set
+% \Lcount{counter} to the level of \meta{sec}.
+% \begin{macrocode}
+\newif\if@knownsect@c
+\newcommand{\@setseccntt@c}[2]{%
+ \@knownsect@cfalse
+ \ifthenelse{\equal{#1}{none}}{\setcounter{#2}{-10}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{part}}{\ift@cchapter
+ \setcounter{#2}{-1}
+ \else
+ \setcounter{#2}{0}
+ \fi
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{chapter}}{\setcounter{#2}{0}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{section}}{\setcounter{#2}{1}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subsection}}{\setcounter{#2}{2}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subsubsection}}{\setcounter{#2}{3}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{paragraph}}{\setcounter{#2}{4}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subparagraph}}{\setcounter{#2}{5}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{all}}{\setcounter{#2}{100}
+ \@knownsect@ctrue}{}%
+ \if@knownsect@c\else
+ \PackageError{tocvsec2}{%
+ Unknown sectioning command name (#1)
+ }{%
+ I'll ignore it. Type \space <return> and I'll continue.\MessageBreak
+ If you haven't mistyped the name then use \protect\setcounter\space instead.}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\settocdepth}
+% |\settocdepth{|\meta{sec}|}| is the user command for setting
+% \Lcount{tocdepth} in the \file{.toc} file to the value corresponding
+% to \meta{sec}.
+% \begin{macrocode}
+\newcommand{\settocdepth}[1]{%
+ \@knownsect@cfalse
+ \ifthenelse{\equal{#1}{none}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-10}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{part}}{%
+ \ift@cchapter
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-1}}
+ \else
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}}
+ \fi
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{chapter}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{section}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{1}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subsection}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{2}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subsubsection}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{3}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{paragraph}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{4}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{subparagraph}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{5}}
+ \@knownsect@ctrue}{}%
+ \ifthenelse{\equal{#1}{all}}{%
+ \addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{100}}
+ \@knownsect@ctrue}{}%
+ \if@knownsect@c\else
+ \PackageError{tocvsec2}{%
+ Unknown sectioning command name (#1)}%
+ {I'll ignore it. Type \space <return> and I'll continue.}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\maxtocdepth}
+% |\maxtocdepth{|\meta{sec}|}| can be used to initialise \Lcount{tocdepth}
+% between the end of the preamble and the |\tableofcontents| command.
+% \begin{macrocode}
+\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
+% \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
+% to the value corresponding to \meta{sec}.
+% \begin{macrocode}
+\newcounter{max@secnumdepth}
+\setcounter{max@secnumdepth}{\value{secnumdepth}}
+\newcommand{\maxsecnumdepth}[1]{%
+ \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}
+%
+%
+% The end of this package.
+% \begin{macrocode}
+%</usc>
+% \end{macrocode}
+%
+%
+% \bibliographystyle{alpha}
+%
+% \begin{thebibliography}{GMS94}
+%
+% \bibitem[GMS94]{GOOSSENS94}
+% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
+% \newblock {\em The LaTeX Companion}.
+% \newblock Addison-Wesley Publishing Company, 1994.
+%
+% \bibitem[Wil96]{PRW96i}
+% Peter~R. Wilson.
+% \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}.
+% \newblock NIST Report NISTIR, June 1996.
+%
+% \end{thebibliography}
+%
+%
+% \Finale
+% \PrintIndex
+%
+\endinput
+
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+
+
diff --git a/macros/latex/contrib/tocvsec2/tocvsec2.ins b/macros/latex/contrib/tocvsec2/tocvsec2.ins
new file mode 100644
index 0000000000..2b93abe5f8
--- /dev/null
+++ b/macros/latex/contrib/tocvsec2/tocvsec2.ins
@@ -0,0 +1,75 @@
+%% tocvsec2.ins
+%% Author: Peter Wilson, Herries Press
+%% Maintainer: Will Robertson (will dot robertson at latex-project dot org)
+%% Copyright 1998 -- 2004 Peter R. Wilson
+%% Copyright 2010 Will Robertson
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any
+%% later version: <http://www.latex-project.org/lppl.txt>
+%%
+%% This work has the LPPL maintenance status "maintained".
+%% The Current Maintainer of this work is Will Robertson.
+%%
+%% This work consists of the files listed in the README file.
+%%
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this work when run through
+%% LaTeX.
+%%
+%%
+%% --------------- start of docstrip commands ------------------
+%%
+\def\batchfile{tocvsec2.ins}
+\input docstrip.tex
+\preamble
+
+-----------------------------------------------------------------
+ Author: Peter Wilson, Herries Press
+ Maintainer: Will Robertson (will dot robertson at latex-project dot org)
+ Copyright 1998 -- 2004 Peter R. Wilson
+ Copyright 2010 Will Robertson
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c of this license or (at your option) any
+ later version: <http://www.latex-project.org/lppl.txt>
+
+ This work has the LPPL maintenance status "maintained".
+ The Current Maintainer of this work is Will Robertson.
+
+ This work consists of the files listed in the README file.
+-----------------------------------------------------------------
+\endpreamble
+
+\askforoverwritefalse
+\keepsilent
+
+%%% \Msg{*** Generating the driver file ***}
+%%% \generate{\file{tocvsec2.drv}{\from{tocvsec2.dtx}{driver}}}
+
+\Msg{*** Generating the LaTeX2e package files ***}
+
+\generate{\file{tocvsec2.sty}{\from{tocvsec2.dtx}{usc}}}
+
+\Msg{***********************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the following}
+\Msg{* file(s) into a directory searched by TeX:}
+\Msg{*}
+\Msg{* \space\space tocvsec2.sty}
+\Msg{*}
+\Msg{*}
+\Msg{* To produce the documentation run the files ending with}
+\Msg{* `.dtx' through LaTeX.}
+\Msg{* Process any name.idx file by:}
+\Msg{* \space\space\space\space makeindex -s gind.ist name}
+\Msg{* Process any name.glo file by:}
+\Msg{* \space\space\space\space makeindex -s gglo.ist -o name.gls name.glo}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{***********************************************************}
+
+\endinput
diff --git a/macros/latex/contrib/tocvsec2/tocvsec2.pdf b/macros/latex/contrib/tocvsec2/tocvsec2.pdf
new file mode 100644
index 0000000000..fe6e8d87a9
--- /dev/null
+++ b/macros/latex/contrib/tocvsec2/tocvsec2.pdf
Binary files differ