| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% tocvsec2.dtx |
| 4 |
% Author: Peter Wilson, Herries Press |
| 5 |
% Maintainer: Will Robertson (will dot robertson at latex-project dot org) |
| 6 |
% Copyright 1999-2004 Peter R. Wilson |
| 7 |
% Copyright 2010-2011 Will Robertson |
| 8 |
% |
| 9 |
% This work may be distributed and/or modified under the |
| 10 |
% conditions of the LaTeX Project Public License, either |
| 11 |
% version 1.3c of this license or (at your option) any |
| 12 |
% later version: <http://www.latex-project.org/lppl.txt> |
| 13 |
% |
| 14 |
% This work has the LPPL maintenance status "maintained". |
| 15 |
% The Current Maintainer of this work is Will Robertson. |
| 16 |
% |
| 17 |
% This work consists of the files listed in the README file. |
| 18 |
% |
| 19 |
% |
| 20 |
%<*driver> |
| 21 |
\ProvidesFile{tocvsec2.dtx} |
| 22 |
%</driver> |
| 23 |
%<usc>\ProvidesPackage{tocvsec2} |
| 24 |
%<*usc> |
| 25 |
[2014/03/10 v1.3a variable ToC section entries] |
| 26 |
%</usc> |
| 27 |
% |
| 28 |
%<*driver> |
| 29 |
\documentclass{ltxdoc} |
| 30 |
\EnableCrossrefs |
| 31 |
\CodelineIndex |
| 32 |
\setcounter{StandardModuleDepth}{1} |
| 33 |
\begin{document} |
| 34 |
\DocInput{tocvsec2.dtx} |
| 35 |
\end{document} |
| 36 |
%</driver> |
| 37 |
% |
| 38 |
% \fi |
| 39 |
% |
| 40 |
% \CheckSum{142} |
| 41 |
% |
| 42 |
% \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath} |
| 43 |
% \DoNotIndex{\@centercr,\@cite} |
| 44 |
% \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue} |
| 45 |
% \DoNotIndex{\@input,\@ixpt,\@m} |
| 46 |
% \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint} |
| 47 |
% \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb} |
| 48 |
% \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt} |
| 49 |
% \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt} |
| 50 |
% \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace} |
| 51 |
% \DoNotIndex{\advance,\Alph,\alph} |
| 52 |
% \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box} |
| 53 |
% \DoNotIndex{\bullet} |
| 54 |
% \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption} |
| 55 |
% \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass} |
| 56 |
% \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist} |
| 57 |
% \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup} |
| 58 |
% \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter} |
| 59 |
% \DoNotIndex{\fbox} |
| 60 |
% \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef} |
| 61 |
% \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule} |
| 62 |
% \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi} |
| 63 |
% \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi} |
| 64 |
% \DoNotIndex{\input} |
| 65 |
% \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark} |
| 66 |
% \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright} |
| 67 |
% \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment} |
| 68 |
% \DoNotIndex{\NeedsTeXFormat,\newdimen} |
| 69 |
% \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number} |
| 70 |
% \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@} |
| 71 |
% \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip} |
| 72 |
% \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions} |
| 73 |
% \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright} |
| 74 |
% \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font} |
| 75 |
% \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman} |
| 76 |
% \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength} |
| 77 |
% \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space} |
| 78 |
% \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase} |
| 79 |
% \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt} |
| 80 |
% \DoNotIndex{\viipt,\vipt,\vskip,\vspace} |
| 81 |
% \DoNotIndex{\wd,\xiipt,\year,\z@} |
| 82 |
% |
| 83 |
% \changes{v1.0}{1999/01/17}{First public release} |
| 84 |
% \changes{v1.1}{1999/01/24}{Added none and all `sections'} |
| 85 |
% \changes{v1.1}{1999/01/24}{Added maxsecnumdepth command} |
| 86 |
% \changes{v1.1a}{2004/05/10}{Changed license from LPPL v1.0 to v1.3} |
| 87 |
% \changes{v1.2}{2004/05/24}{Eliminated requirement for stdclsdv package} |
| 88 |
% \changes{v1.2a}{2009/09/04}{New maintainer (Will Robertson)} |
| 89 |
% \changes{v1.3a}{2011/03/10}{Some missing comment chars causing space issues} |
| 90 |
% |
| 91 |
% \def\dtxfile{tocvsec2.dtx} |
| 92 |
% \GetFileInfo{\dtxfile} |
| 93 |
% \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package |
| 94 |
% \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option |
| 95 |
% \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file |
| 96 |
% \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter |
| 97 |
% \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle |
| 98 |
% \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment |
| 99 |
% |
| 100 |
% \title{The \Lpack{tocvsec2} package\thanks{This |
| 101 |
% file (\texttt{\dtxfile}) has version number \fileversion, last revised |
| 102 |
% \filedate.}} |
| 103 |
% |
| 104 |
% \author{ |
| 105 |
% Author: Peter Wilson, Herries Press \\ |
| 106 |
% Maintainer: Will Robertson \\ |
| 107 |
% \texttt{will dot robertson at latex-project dot org} |
| 108 |
% } |
| 109 |
% \date{\filedate} |
| 110 |
% \maketitle |
| 111 |
% \begin{abstract} |
| 112 |
% The \Lpack{tocvsec2} package provides means of controlling the sectional |
| 113 |
% numbering and/or the entries |
| 114 |
% in the Table of Contents on a section by section basis. |
| 115 |
% It is a replacement for the \Lpack{tocvsec} package, which should |
| 116 |
% not be used. |
| 117 |
% Use of the package requires e\TeX\ and the \Lpack{ifthen} package to be available. |
| 118 |
% \end{abstract} |
| 119 |
% \tableofcontents |
| 120 |
% |
| 121 |
% ^^A \StopEventually{} |
| 122 |
% |
| 123 |
% |
| 124 |
% |
| 125 |
% \section{Introduction} |
| 126 |
% |
| 127 |
% In the standard classes two commands are used to control the numbering |
| 128 |
% of sectional divisions in a document, and which level of sectional |
| 129 |
% headings will be included in the Table of Contents (the ToC). Sometimes |
| 130 |
% finer control of these aspects of \LaTeX{} is required. The \Lpack{tocvsec2} |
| 131 |
% provides for control over the entries into the ToC on a section by section |
| 132 |
% basis. It also provides a means of locally controlling sectional numbering |
| 133 |
% without having to resort to the starred version of the sectional commands. |
| 134 |
% The package requires the \Lpack{ifthen} package |
| 135 |
% to be available. |
| 136 |
% |
| 137 |
% Portions of the package were developed as part of a class |
| 138 |
% and package bundle for typesetting ISO standards~\cite{PRW96i}. |
| 139 |
% This manual is typeset according to the conventions of the |
| 140 |
% \LaTeX{} \textsc{docstrip} utility which enables the automatic |
| 141 |
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}. |
| 142 |
% |
| 143 |
% Section~\ref{sec:usc} describes the usage of the package. |
| 144 |
% Commented source code for the package is in Section~\ref{sec:code}. |
| 145 |
% |
| 146 |
% \DescribeMacro{secnumdepth} |
| 147 |
% The \LaTeX{} \Lcount{secnumdepth} counter specifies the level number |
| 148 |
% for the least significant |
| 149 |
% sectional heading that will be numbered. In all the standard classes |
| 150 |
% |\section| has a level number of 1, |\subsection| has a level number |
| 151 |
% of 2, and so on. In the \Lpack{article} class (and its derivatives), |
| 152 |
% |\part| has a level number of 0. In the \Lpack{book} and \Lpack{report} |
| 153 |
% classes, |\chapter| is level number 0 and |\part| has level number -1. |
| 154 |
% |
| 155 |
% The \Lcount{secnumdepth} counter is normally set in the preamble and |
| 156 |
% remains constant thereafter. For example: |
| 157 |
% \begin{verbatim} |
| 158 |
% \setcounter{secnumdepth}{2} |
| 159 |
% \end{verbatim} |
| 160 |
% specifies that |\subsection|s and above should be numbered and |
| 161 |
% |\subsubsections| and below should not be numbered. It turns out |
| 162 |
% that \Lcount{secnumdepth} can be changed at any point in a document, not |
| 163 |
% just in the preamble, to make a (temporary) change to the section numbering |
| 164 |
% level. This is possible because the heading commands check the value |
| 165 |
% of \Lcount{secnumdepth} to decide whether or not to number the heading. |
| 166 |
% |
| 167 |
% \DescribeMacro{tocdepth} |
| 168 |
% The \Lcount{tocdepth} counter specifies the level number of the least |
| 169 |
% significant sectional unit that will be listed in the printed Table of |
| 170 |
% Contents (ToC). For example: |
| 171 |
% \begin{verbatim} |
| 172 |
% \setcounter{tocdepth}{1} |
| 173 |
% \end{verbatim} |
| 174 |
% specifies that the printed ToC should only list sectional headings down |
| 175 |
% to the |\section| level. The value of \Lcount{tocdepth} has to be set |
| 176 |
% before the |\tableofcontents| command is used. Each sectioning command |
| 177 |
% puts an entry into the \file{.toc} file, irrespective of the \Lcount{tocdepth} |
| 178 |
% value. The code implementing the typesetting of the ToC uses |
| 179 |
% \Lcount{tocdepth} to determine whether or not an entry should be printed. |
| 180 |
% Thus, unlike \Lcount{secnumdepth} which can be altered at any time and have |
| 181 |
% an effect, it is only the value of \Lcount{tocdepth} at the time of |
| 182 |
% printing the entries in the |\tableofcontents| that is used --- |
| 183 |
% any subsequent changes to |
| 184 |
% \Lcount{tocdepth} are immaterial. |
| 185 |
% |
| 186 |
% Note that \Lcount{tocdepth} only controls what appears in the ToC, |
| 187 |
% and \Lcount{secnumdepth} only controls which sectional headings are |
| 188 |
% numbered. The effect of changing one has no bearing on the other. |
| 189 |
% |
| 190 |
% \section{The \Lpack{tocvsec2} package} \label{sec:usc} |
| 191 |
% |
| 192 |
% The \Lpack{tocvsec} package changed the way in which entries were written |
| 193 |
% to the \file{.toc} file, enabling effective changes to be made to |
| 194 |
% \Lcount{tocdepth} at any point in a document. |
| 195 |
% |
| 196 |
% The basis of that package was to ensure that only those sectional elements |
| 197 |
% that were required to appear in the printed ToC were written to the \file{.toc} |
| 198 |
% file. The sectional commands call the |\addcontentsline| command to |
| 199 |
% write an entry to the \file{.toc} file. |
| 200 |
% There were two methods to achieve the desired functionality, both of which |
| 201 |
% required |
| 202 |
% modifications to the internal \LaTeX{} macros. |
| 203 |
% \begin{enumerate} |
| 204 |
% \item Modify the sectional commands so that they check the value of |
| 205 |
% \Lcount{tocdepth} in order to decide whether or not to put an entry |
| 206 |
% into the \file{.toc} file (i.e., call |\addcontentsline|). |
| 207 |
% \item Modify |\addcontentsline| so that it decides whether or not to write |
| 208 |
% to the \file{.toc} file. This is less efficient in terms of processing |
| 209 |
% time than changing the sectional commands. |
| 210 |
% \end{enumerate} |
| 211 |
% |
| 212 |
% Both approaches had disadvantages. If the \Lpack{tocvsec} package |
| 213 |
% changed the sectional commands and it was used in conjunction with |
| 214 |
% another package that also changes these definitions, then one or the other |
| 215 |
% package would not work as expected. On the other hand, changing the |
| 216 |
% |\addcontentsline| command may have had unexpected results if |\addcontentsline| |
| 217 |
% was either modified or used in a different manner elsewhere in the document. |
| 218 |
% |
| 219 |
% The \Lpack{tocvsec2} package takes a different approach which does |
| 220 |
% not have these disadvantages. It provides a means of inserting commands |
| 221 |
% into the \file{.toc} file that change the current value of |
| 222 |
% \Lcount{tocdepth} within the body of the file. |
| 223 |
% |
| 224 |
% |
| 225 |
% The package also provides some utility commands so you don't have to remember |
| 226 |
% the level numbers of the sectioning commands. |
| 227 |
% |
| 228 |
% \subsection{Changing ToC appearances} |
| 229 |
% |
| 230 |
% \DescribeMacro{\maxtocdepth} |
| 231 |
% The |\maxtocdepth{|\meta{sec}|}| command can be used after the preamble |
| 232 |
% (and before the |\tableofcontents| command) to set the global value |
| 233 |
% for the \Lcount{tocdepth}. \meta{sec} is the name of a sectioning |
| 234 |
% division (e.g., |part| or |paragraph|). You can also use |all|, |
| 235 |
% meaning all sectioning divisions, or |none|, meaning no sectioning divisions. |
| 236 |
% |
| 237 |
% \textbf{Note well}: after \cs{tableofcontents}, the \Lcount{tocdepth} |
| 238 |
% is reset to the value specified by \cs{maxtocdepth} in case that counter is |
| 239 |
% used by a subsequent `List of Figures' or `List of Tables', as in the |
| 240 |
% standard \LaTeX\ classes. |
| 241 |
% |
| 242 |
% |
| 243 |
% \DescribeMacro{\settocdepth} |
| 244 |
% The |\settocdepth{|\meta{sec}|}| command can be used to change the value of |
| 245 |
% the \Lcount{tocdepth} counter within the \file{.toc} file, |
| 246 |
% where \meta{sec} is the name of a sectional |
| 247 |
% division (e.g., \texttt{chapter} or \texttt{subsection}), or |all| or |
| 248 |
% |none|. For example, |
| 249 |
% |\settocdepth{section}| will set \Lcount{tocdepth} to be 1 within the |
| 250 |
% \file{.toc} file, until it is altered by another |\settocdepth| |
| 251 |
% command. The command |
| 252 |
% cannot be used in the preamble (i.e., before |\begin{document}|), but |
| 253 |
% can be used any point thereafter. |
| 254 |
% |
| 255 |
% \Lcount{tocdepth} should be set in the preamble, or immediately after, |
| 256 |
% to the least |
| 257 |
% significant sectional unit |
| 258 |
% that should be in the printed ToC. |
| 259 |
% Later, after the |\tableofcontents| command, it is possible to |
| 260 |
% to use |\settocdepth| to change \Lcount{tocdepth} to a different |
| 261 |
% sectional level. |
| 262 |
% |
| 263 |
% \DescribeMacro{\resettocdepth} |
| 264 |
% After \Lcount{tocdepth} has been changed with |\settocdepth|, it is |
| 265 |
% possible to reset it to its previous value with |\resettocdepth|. |
| 266 |
% In fact, you may use |\resettocdepth| multiple times |
| 267 |
% to reset multiple uses of |\settocdepth|. (It behaves like a stack, for |
| 268 |
% you computer-science-types.) |
| 269 |
% If you wish to reset \Lcount{tocdepth} to its original value completely, |
| 270 |
% use |\resettocdepth*|. |
| 271 |
% |
| 272 |
% As an example, assume that |
| 273 |
% the ToC should list subsections and above, but there is one particular |
| 274 |
% section in the document which consists of a set of definitions, each of |
| 275 |
% which is presented as a subsection, but these should not appear in the |
| 276 |
% printed ToC. |
| 277 |
% \begin{verbatim} |
| 278 |
% \documentclass{...} |
| 279 |
% \usepackage{tocvsec2} |
| 280 |
% ... |
| 281 |
% \begin{document} |
| 282 |
% \maxtocdepth{subsection} |
| 283 |
% ... |
| 284 |
% \tableofcontents |
| 285 |
% ... |
| 286 |
% \section{Definitions} |
| 287 |
% \settocdepth{section} |
| 288 |
% \subsection{Definition 1} |
| 289 |
% ... |
| 290 |
% \resettocdepth %% equivalent to "\settocdepth{subsection}" |
| 291 |
% \section{After definitions} |
| 292 |
% ... |
| 293 |
% \end{verbatim} |
| 294 |
% |
| 295 |
% \section{Changing section numbering} |
| 296 |
% |
| 297 |
% \DescribeMacro{\setsecnumdepth} |
| 298 |
% The |\setsecnumdepth{|\meta{sec}|}| command is similar to |\settocdepth| |
| 299 |
% except |
| 300 |
% that it changes the value of \Lcount{secnumdepth} at the point in |
| 301 |
% the document where it is called. Like the |\settocdepth| |
| 302 |
% command, it cannot be used in the preamble, but can be used as often as |
| 303 |
% necessary after that. |
| 304 |
% |
| 305 |
% \DescribeMacro{\maxsecnumdepth} |
| 306 |
% The |\maxsecnumdepth{|\meta{sec}|}| command is similar to |\maxtocdepth| |
| 307 |
% except that it is for setting the default value for \Lcount{secnumdepth} |
| 308 |
% after the preamble. |
| 309 |
% In previous versions of the package if you used |\setsecnumdepth| for this |
| 310 |
% purpose you might find an extra blank page in the typeset manuscript, but |
| 311 |
% nowadays the two commands are interchangeable. |
| 312 |
% |
| 313 |
% \DescribeMacro{\resetsecnumdepth} |
| 314 |
% Similarly to |\resettocdepth|, this command cycles back through previous |
| 315 |
% values for \Lcount{secnumdepth} so you don't have to keep track of them |
| 316 |
% yourself if you need to change its value for only a short component of a |
| 317 |
% manuscript. By writing |\resetsecnumdepth*|, you can reset entirely back |
| 318 |
% to a clean state with \Lcount{secnumdepth} set to its original value. |
| 319 |
% |
| 320 |
% For example, assume that in a document the sectional divisions are |
| 321 |
% normally numbered down to the sub-subsection level, but within a particular |
| 322 |
% section, they should only be numbered to the subsection level. Also, |
| 323 |
% all sectional divisions within the appendices are to be numbered. |
| 324 |
% This can be accomplished like: |
| 325 |
% \begin{verbatim} |
| 326 |
% \documentclass{...} |
| 327 |
% \usepackage{tocvsec2} |
| 328 |
% ... |
| 329 |
% \begin{document} |
| 330 |
% \maxsecnumdepth{subsubsection} |
| 331 |
% ... |
| 332 |
% \tableofcontents |
| 333 |
% ... |
| 334 |
% \section{Normal section} |
| 335 |
% ... |
| 336 |
% \section{Reduce numbering} |
| 337 |
% \setsecnumdepth{subsection} |
| 338 |
% ... |
| 339 |
% \resetsecnumdepth %% equivalent to "\setsecnumdepth{subsubsection}" |
| 340 |
% \section{Another normal section} |
| 341 |
% ... |
| 342 |
% \appendix |
| 343 |
% \setsecnumdepth{all} |
| 344 |
% ... |
| 345 |
% \end{verbatim} |
| 346 |
% |
| 347 |
% |
| 348 |
% |
| 349 |
% |
| 350 |
% \section{The package code} \label{sec:code} |
| 351 |
% |
| 352 |
% \begin{macrocode} |
| 353 |
%<*usc> |
| 354 |
\RequirePackage{ifthen} |
| 355 |
% \end{macrocode} |
| 356 |
% |
| 357 |
% In order to try and avoid name clashes with other packages, each internal |
| 358 |
% name will include the character string \texttt{t@c}. |
| 359 |
% |
| 360 |
% Issue warning if there are no recognized sectional divisions. |
| 361 |
% \begin{macrocode} |
| 362 |
\newif\ift@cchapter |
| 363 |
\t@cchapterfalse |
| 364 |
\@ifundefined{chapter}{% |
| 365 |
\@ifundefined{section}{% |
| 366 |
\PackageWarning{tocvsec2}{% |
| 367 |
I don't recognize any divisions but I'll do my best}}{}}% |
| 368 |
{\t@cchaptertrue} |
| 369 |
|
| 370 |
% \end{macrocode} |
| 371 |
% |
| 372 |
% \begin{macro}{\if@knownsect@c} |
| 373 |
% \begin{macro}{\@setseccntt@c} |
| 374 |
% A helper macro to set a sectioning-related counter. Call as |
| 375 |
% |\@setseccntt@c{|\meta{sec}|}{|\meta{counter}|}| to set |
| 376 |
% \Lcount{counter} to the level of \meta{sec}. |
| 377 |
% \begin{macrocode} |
| 378 |
\newif\if@knownsect@c |
| 379 |
\newcommand{\@setseccntt@c}[2]{% |
| 380 |
\@knownsect@cfalse |
| 381 |
\ifthenelse{\equal{#1}{none}}{\setcounter{#2}{-10} |
| 382 |
\@knownsect@ctrue}{}% |
| 383 |
\ifthenelse{\equal{#1}{part}}{\ift@cchapter |
| 384 |
\setcounter{#2}{-1} |
| 385 |
\else |
| 386 |
\setcounter{#2}{0} |
| 387 |
\fi |
| 388 |
\@knownsect@ctrue}{}% |
| 389 |
\ifthenelse{\equal{#1}{chapter}}{\setcounter{#2}{0} |
| 390 |
\@knownsect@ctrue}{}% |
| 391 |
\ifthenelse{\equal{#1}{section}}{\setcounter{#2}{1} |
| 392 |
\@knownsect@ctrue}{}% |
| 393 |
\ifthenelse{\equal{#1}{subsection}}{\setcounter{#2}{2} |
| 394 |
\@knownsect@ctrue}{}% |
| 395 |
\ifthenelse{\equal{#1}{subsubsection}}{\setcounter{#2}{3} |
| 396 |
\@knownsect@ctrue}{}% |
| 397 |
\ifthenelse{\equal{#1}{paragraph}}{\setcounter{#2}{4} |
| 398 |
\@knownsect@ctrue}{}% |
| 399 |
\ifthenelse{\equal{#1}{subparagraph}}{\setcounter{#2}{5} |
| 400 |
\@knownsect@ctrue}{}% |
| 401 |
\ifthenelse{\equal{#1}{all}}{\setcounter{#2}{100} |
| 402 |
\@knownsect@ctrue}{}% |
| 403 |
\if@knownsect@c\else |
| 404 |
\PackageError{tocvsec2}{% |
| 405 |
Unknown sectioning command name (#1) |
| 406 |
}{% |
| 407 |
I'll ignore it. Type \space <return> and I'll continue.\MessageBreak |
| 408 |
If you haven't mistyped the name then use \protect\setcounter\space instead.}% |
| 409 |
\fi |
| 410 |
} |
| 411 |
% \end{macrocode} |
| 412 |
% \end{macro} |
| 413 |
% \end{macro} |
| 414 |
% |
| 415 |
% |
| 416 |
% \begin{macro}{\settocdepth} |
| 417 |
% |\settocdepth{|\meta{sec}|}| is the user command for setting |
| 418 |
% \Lcount{tocdepth} in the \file{.toc} file to the value corresponding |
| 419 |
% to \meta{sec}. |
| 420 |
% \begin{macrocode} |
| 421 |
\newcommand{\settocdepth}[1]{% |
| 422 |
\@knownsect@cfalse |
| 423 |
\ifthenelse{\equal{#1}{none}}{% |
| 424 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-10}} |
| 425 |
\@knownsect@ctrue}{}% |
| 426 |
\ifthenelse{\equal{#1}{part}}{% |
| 427 |
\ift@cchapter |
| 428 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{-1}} |
| 429 |
\else |
| 430 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}} |
| 431 |
\fi |
| 432 |
\@knownsect@ctrue}{}% |
| 433 |
\ifthenelse{\equal{#1}{chapter}}{% |
| 434 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{0}} |
| 435 |
\@knownsect@ctrue}{}% |
| 436 |
\ifthenelse{\equal{#1}{section}}{% |
| 437 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{1}} |
| 438 |
\@knownsect@ctrue}{}% |
| 439 |
\ifthenelse{\equal{#1}{subsection}}{% |
| 440 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{2}} |
| 441 |
\@knownsect@ctrue}{}% |
| 442 |
\ifthenelse{\equal{#1}{subsubsection}}{% |
| 443 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{3}} |
| 444 |
\@knownsect@ctrue}{}% |
| 445 |
\ifthenelse{\equal{#1}{paragraph}}{% |
| 446 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{4}} |
| 447 |
\@knownsect@ctrue}{}% |
| 448 |
\ifthenelse{\equal{#1}{subparagraph}}{% |
| 449 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{5}} |
| 450 |
\@knownsect@ctrue}{}% |
| 451 |
\ifthenelse{\equal{#1}{all}}{% |
| 452 |
\addtocontents{toc}{\save@tocdepth\protect\setcounter{tocdepth}{100}} |
| 453 |
\@knownsect@ctrue}{}% |
| 454 |
\if@knownsect@c\else |
| 455 |
\PackageError{tocvsec2}{% |
| 456 |
Unknown sectioning command name (#1)}% |
| 457 |
{I'll ignore it. Type \space <return> and I'll continue.}% |
| 458 |
\fi |
| 459 |
} |
| 460 |
% \end{macrocode} |
| 461 |
% \end{macro} |
| 462 |
% |
| 463 |
% \begin{macro}{\maxtocdepth} |
| 464 |
% |\maxtocdepth{|\meta{sec}|}| can be used to initialise \Lcount{tocdepth} |
| 465 |
% between the end of the preamble and the |\tableofcontents| command. |
| 466 |
% \begin{macrocode} |
| 467 |
\newcounter{max@tocdepth} |
| 468 |
\setcounter{max@tocdepth}{\value{tocdepth}} |
| 469 |
\newcommand{\maxtocdepth}[1]{% |
| 470 |
\save@tocdepth |
| 471 |
\@setseccntt@c{#1}{max@tocdepth}% |
| 472 |
\@setseccntt@c{#1}{tocdepth}% |
| 473 |
} |
| 474 |
% \end{macrocode} |
| 475 |
% \end{macro} |
| 476 |
% |
| 477 |
% |
| 478 |
% \begin{macro}{\tableofcontents} |
| 479 |
% \changes{v1.3}{2011/08/07}{Patch to reset \Lcount{tocdepth}} |
| 480 |
% \begin{macrocode} |
| 481 |
\g@addto@macro\tableofcontents{% |
| 482 |
\setcounter{tocdepth}{\value{max@tocdepth}}% |
| 483 |
} |
| 484 |
% \end{macrocode} |
| 485 |
% \end{macro} |
| 486 |
% |
| 487 |
% |
| 488 |
% \begin{macro}{\setsecnumdepth} |
| 489 |
% \changes{v1.2b}{2010/02/27}{Remove occasional extraneous vertical space} |
| 490 |
% |\setsecnumdepth{|\meta{sec}|}| is the user command for setting |
| 491 |
% \Lcount{secnumdepth} to the value corresponding to \meta{sec}. |
| 492 |
% \begin{macrocode} |
| 493 |
\newcommand{\setsecnumdepth}[1]{% |
| 494 |
\save@secnumdepth |
| 495 |
\@setseccntt@c{#1}{secnumdepth}% |
| 496 |
} |
| 497 |
% \end{macrocode} |
| 498 |
% \end{macro} |
| 499 |
% |
| 500 |
% \begin{macro}{\maxsecnumdepth} |
| 501 |
% |\maxsecnumdepth{|\meta{sec}|}| is the user command to initialise |
| 502 |
% \Lcount{secnumdepth} after the preamble |
| 503 |
% to the value corresponding to \meta{sec}. |
| 504 |
% \begin{macrocode} |
| 505 |
\newcounter{max@secnumdepth} |
| 506 |
\setcounter{max@secnumdepth}{\value{secnumdepth}} |
| 507 |
\newcommand{\maxsecnumdepth}[1]{% |
| 508 |
\save@secnumdepth |
| 509 |
\@setseccntt@c{#1}{max@secnumdepth}% |
| 510 |
\@setseccntt@c{#1}{secnumdepth}% |
| 511 |
} |
| 512 |
% \end{macrocode} |
| 513 |
% \end{macro} |
| 514 |
% |
| 515 |
% |
| 516 |
% \subsection{Resetting and returning to previous values} |
| 517 |
% |
| 518 |
% |
| 519 |
% \begin{macro}{\resetsecnumdepth} |
| 520 |
% \changes{v1.3}{2011/08/07}{New command} |
| 521 |
% It would be nice to be able to `reset' the tocdepth or secnumdepth |
| 522 |
% to a previous value. |
| 523 |
% Unfortunately this can't be done with grouping so we use a stack-based |
| 524 |
% approach. |
| 525 |
% \begin{macrocode} |
| 526 |
\let\stack@secnumdepth\@empty |
| 527 |
\newcommand\save@secnumdepth{% |
| 528 |
\edef\stack@secnumdepth{\the\c@secnumdepth\relax\stack@secnumdepth}% |
| 529 |
} |
| 530 |
\def\gobble@secnumdepth#1\@nil{\edef\stack@secnumdepth{#1}} |
| 531 |
% \end{macrocode} |
| 532 |
% The idea of the stack is |
| 533 |
% |{|$x_n$|\relax| $x_{n-1}$|\relax| \dots$x_0$|\relax}|; |
| 534 |
% prepending new values with \cs{edef} and using assignment and |
| 535 |
% \cs{afterassignment} to push an entry off the front. |
| 536 |
% \begin{macrocode} |
| 537 |
\newcommand\resetsecnumdepth{% |
| 538 |
\@ifstar{% |
| 539 |
\setcounter{secnumdepth}{\value{max@secnumdepth}}% |
| 540 |
\edef\stack@secnumdepth{\the\c@secnumdepth\relax}% |
| 541 |
}{% |
| 542 |
\ifx\stack@secnumdepth\@empty |
| 543 |
\PackageWarning{tocvsec2}{There is no previous value for secnumdepth}% |
| 544 |
\else |
| 545 |
\afterassignment\gobble@secnumdepth |
| 546 |
\expandafter\c@secnumdepth\expandafter\numexpr\stack@secnumdepth\@nil |
| 547 |
\fi |
| 548 |
}% |
| 549 |
} |
| 550 |
% \end{macrocode} |
| 551 |
% \end{macro} |
| 552 |
% |
| 553 |
% \begin{macro}{\resettocdepth} |
| 554 |
% \changes{v1.3}{2011/08/07}{New command} |
| 555 |
% The idea the same is as above but because it all happens inside an auxiliary |
| 556 |
% file there's a couple of extra steps. |
| 557 |
% \begin{macrocode} |
| 558 |
\let\stack@tocdepth\@empty |
| 559 |
\protected\def\save@tocdepth{% |
| 560 |
\edef\stack@tocdepth{\the\c@tocdepth\relax\stack@tocdepth}% |
| 561 |
} |
| 562 |
\def\gobble@tocdepth#1\@nil{\edef\stack@tocdepth{#1}} |
| 563 |
% \end{macrocode} |
| 564 |
% Resetting is done in the \verb|.toc| file: |
| 565 |
% \begin{macrocode} |
| 566 |
\newcommand\resettocdepth{\@ifstar |
| 567 |
{\addtocontents{toc}{\remax@tocdepth}} |
| 568 |
{\addtocontents{toc}{\reset@tocdepth}}% |
| 569 |
} |
| 570 |
% \end{macrocode} |
| 571 |
% Reset back to the initial state (and clear the stack): |
| 572 |
% \begin{macrocode} |
| 573 |
\protected\def\remax@tocdepth{% |
| 574 |
\setcounter{tocdepth}{\value{max@tocdepth}}% |
| 575 |
\edef\stack@secnumdepth{\the\c@tocdepth\relax}% |
| 576 |
} |
| 577 |
% \end{macrocode} |
| 578 |
% Reset to the previous state on the stack: |
| 579 |
% \begin{macrocode} |
| 580 |
\protected\def\reset@tocdepth{% |
| 581 |
\ifx\stack@tocdepth\@empty |
| 582 |
\PackageWarning{tocvsec2}{There is no previous value for tocdepth}% |
| 583 |
\else |
| 584 |
\afterassignment\gobble@tocdepth |
| 585 |
\expandafter\c@tocdepth\expandafter\numexpr\stack@tocdepth\@nil |
| 586 |
\fi |
| 587 |
} |
| 588 |
% \end{macrocode} |
| 589 |
% Ensure errant commands in the ToC won't cause problems: |
| 590 |
% \begin{macrocode} |
| 591 |
\addtocontents{toc}{% |
| 592 |
\@ifundefined{save@tocdepth}{% |
| 593 |
\let\save@tocdepth\relax |
| 594 |
\let\reset@tocdepth\relax |
| 595 |
\let\remax@tocdepth\relax |
| 596 |
}{}% |
| 597 |
} |
| 598 |
% \end{macrocode} |
| 599 |
% \end{macro} |
| 600 |
% |
| 601 |
% |
| 602 |
% The end of this package. |
| 603 |
% \begin{macrocode} |
| 604 |
%</usc> |
| 605 |
% \end{macrocode} |
| 606 |
% |
| 607 |
% |
| 608 |
% \bibliographystyle{alpha} |
| 609 |
% |
| 610 |
% \begin{thebibliography}{GMS94} |
| 611 |
% |
| 612 |
% \bibitem[GMS94]{GOOSSENS94} |
| 613 |
% Michel Goossens, Frank Mittelbach, and Alexander Samarin. |
| 614 |
% \newblock {\em The LaTeX Companion}. |
| 615 |
% \newblock Addison-Wesley Publishing Company, 1994. |
| 616 |
% |
| 617 |
% \bibitem[Wil96]{PRW96i} |
| 618 |
% Peter~R. Wilson. |
| 619 |
% \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}. |
| 620 |
% \newblock NIST Report NISTIR, June 1996. |
| 621 |
% |
| 622 |
% \end{thebibliography} |
| 623 |
% |
| 624 |
% |
| 625 |
% \Finale |
| 626 |
% \PrintIndex |
| 627 |
% |
| 628 |
\endinput |
| 629 |
|
| 630 |
%% \CharacterTable |
| 631 |
%% {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 |
| 632 |
%% 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 |
| 633 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 634 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 635 |
%% Dollar \$ Percent \% Ampersand \& |
| 636 |
%% Acute accent \' Left paren \( Right paren \) |
| 637 |
%% Asterisk \* Plus \+ Comma \, |
| 638 |
%% Minus \- Point \. Solidus \/ |
| 639 |
%% Colon \: Semicolon \; Less than \< |
| 640 |
%% Equals \= Greater than \> Question mark \? |
| 641 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 642 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 643 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 644 |
%% Right brace \} Tilde \~} |
| 645 |
|
| 646 |
|