The newclude LaTeX package

A new system for including files (Frankenstein’s backbone)

          Matt Swift <swift@alum.mit.edu>

Version: 1.0 Date: 1996/01/24

Documentation revision: 1997/10/07

Abstract

Newclude is a backwards-compatible reimplementation of \include and \includeonly. The restriction that \clearpage’s must surround an included file are removed, as is the restriction that \include s cannot be nested. An optional argument to \include is executed before the included file, whenever it is processed.

Newclude and includex are both attempts to provide similar features. Newclude is more ambitious, but includex is still more successful in certain ways.

This package is useful but may have problems and is unsupported.

Contents

I Discussion 3

1 Introduction 3 1.1 Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Allocate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Usage 4

II Implementation 6

3 Version control 6

4 Review of the old system 6

5 Simple 8 6 Allocate and Group 9

6.1 Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.2 Writing to \@auxout . . . . . . . . . . . . . . . . . . . . . . . . . . 10 6.3 Kernel redefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 6.4 Checkpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.5 Including . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.6 Allocate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

6.6.1 Wheels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.6.2 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.6.3 Static allocation . . . . . . . . . . . . . . . . . . . . . . . . 19 6.6.4 Dynamic allocation . . . . . . . . . . . . . . . . . . . . . . . 20 6.6.5 Including . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6.6.6 Checkpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 6.6.7 Wheels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

6.7 Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Warning: This code is unfinished. I feel the package is not robust enough for

general distribution. Because I have not found time to improve it for a long time, and because some others expressed interest in solving the problems this package attempts to solve, I have decided to release it to these people. If it makes its way to the general public, that is OK because I have attached all the appropriate copyright notices.

Here are my personal notes on the state of this package:

• Add an end-hook to \include

• Add \includedoc and subordinates from includex.

• Efficiency!

• What about nesting \includeonly?

• \includeall should erase all things from \includeonly so it can be used both before and after \includeonly.

• Explain that when you quit under tag, you loose all aux info from then forward. In the old system, if you processed it twice more, you would recover it. It would not be there the next pass, because the main aux would not include the \inputpart.aux. The next pass would recover it.

• We could rewrite x.tex to write out unwritten auxinfos in their last order; and also to possibly fix a broken aux file.

• We could possibly adjust the page number of the new checkpoint according to how much a pre-checkpoint differed from a stored pre-checkpoint.

Part I

Discussion

1 Introduction

For brevity, I call included files parts.

The first new feature is implemented in three different ways, each with their own advantages and disadvantages. The user may select any of these with an option to the newclude package. The default is the tag option.

1.1 Simple

If the simple option is given, only the second new feature mentioned in the abstract is provided.

1.2 Tag

The tag option causes L^{A}TEX to use just one aux file. It redefines all the kernel’s commands that write to \@auxout. This solution works perfectly if you do not use a package or class which redefines any of these commands. If you do use such a package or class, it is very simple to adapt it for use with newclude, see section 6.2 below. A list of affected commands is given there.

1.3 Allocate

The allocate option is probably the next best choice. This option causes L^{A}TEX to dynamically allocate TEX output streams to each part as they are needed. Streams are allocated when processing of the part begins, and are reclaimed after the ejection of the last page to which the part has contributed. Like the old system, a separate aux file is created for each part. The limitation of this implementation is that TEX only possesses 16 output streams. Each of the commands \tableofcontents,

\listoffigures, \listoftables, \makeglossary, and \makeindex causes L^{A}TEX

to use one output stream. The remainder (minus any streams required by packages and classes) are available for the including system. If n streams are available, the level of nesting possible is n − 1 minus the maximum number of parts that occur on the same page. For example, if 10 streams are available and the parts never appear on the same page (the old behavior required by the \clearpages), then 8 levels of nesting are possible (which is 8, not 7 more than with the old system). The maximum number of parts that may contribute the to same page is calculated with the same equation.^{1}

1TEX’s page-breaking algorithm looks ahead until it has more than enough material to fill one page. You must count all the new aux files that are opened during a look-ahead as contributing to the page in question, even if some of the later ones do not actually contribute to the page after the break is chosen.

The allocate solution is itself implemented in two ways. The system either reserves a fixed number of output streams from the start, or will dynamically claim and free them as needed. The dynamic solution is the default. I do not see much use for the static solution at present. If the dynamic system claims streams that are later required, then it is simply a question of whether newclude or the other feature is going to signal an error about having no more streams to allocate.

1.4 Group

The group option causes L^{A}TEX to use just one aux file for the entire LaTeX job. This solution works the same way as the tag solution, except that it does redefines only the commands FIX. If redefinitions in other packages prevent you from using the tag solution, and the limitations of the allocate solution are not acceptable, try the group solution.

The following problem occurs with the group solution: if a L^{A}TEX job is interrupted prematurely during the processing of a part, the aux file will be “broken” and cause an error during the next pass. A broken aux file must be deleted before processing of the main source can continue. The degree of inconvenience of this situation depends on several things: the importance of the information in the aux file, the difficulty of regenerating it, and the mechanism by which L^{A}TEX is invoked.

The information that will be lost when a broken aux file must be deleted is:

1. backward references (which then require an extra pass), and

2. references generated by parts compiled at least once in the past but presently excluded by an \includeonly declaration.

If L^{A}TEX is always invoked in \nonstopmode (e.g., by AUC-TEX), the aux file is much less likely to break, but it is possible. A broken aux file can usually be repaired by appending a single closing brace. Sophisticated user interfaces to L^{A}TEX may well be able to either delete or repair a broken aux file automatically.

2 Usage

\includeonly The \includeonly macro is reimplemented, but its usage is the same as before.

\include \include {⟨file⟩}[⟨tokens⟩] behaves like the kernel’s \include except it can be nested and takes an optional argument, whose contents will be processed before the included file, whenever the file is included. Right square braces (]s) in the optional argument must be surrounded by curly braces to avoid confusing the argument parser.

For example, putting the \chapter declaration in the optional argument allows the chapter name, and perhaps a corresponding L^{A}TEX label, to be kept in the including file, rather than the included file.

\include* \include*{⟨file⟩}[⟨tokens⟩] is like \include but furthermore omits the usual

\IncludeSurround
\DefaultIncludeSurround

\clearpage s that surround an included file, replacing them with \IncludeSurround,

which defaults to \DefaultIncludeSurround. The contents of \IncludeSurround

are inserted before the tokens in the optional argument of \include.

A space gets inserted after an \include* unless it is suppressed by a % immediately following. Combined with trailing spaces in the included file, this may lead to extra unwanted spaces. For this reason, \DefaultIncludeSurround is initialized to \par. When the user must explicitly change \IncludeSurround to achieve totally smooth flow from main file to included file, they are more likely to consult the documentation if they spot a problem. Package and class writers should take this difficulty into account when changing \DefaultIncludeSurround.

Part II

Implementation

3 Version control

\fileinfo \DoXUsepackagE \HaveECitationS \fileversion \filedate \docdate \PPOptArg These definitions must be the first ones in the file.
 1 \def\fileinfo{A new system for including files (Frankenstein's backbone)}
 2 \def\DoXPackageS {}
 3 \def\fileversion{v1.0}
 4 \def\filedate{1996/01/24}
 5 \def\docdate{1997/10/07}
 6 \edef\PPOptArg {%
 7 \filedate\space \fileversion\space \fileinfo
 8 }

If we’re loading this file from a \ProcessDTXFile command (see the compsci package), then \JusTLoaDInformatioN will be defined; othewise we assume it is not (that’s why the FunkY NamE).

If we’re loading from \ProcessDTXFile, we want to load the packages listed in \DoXPackageS (needed to typeset the documentation for this file) and then bail out. Otherwise, we’re using this file in a normal way as a package, so do nothing. \DoXPackageS, if there are any, are declared in the dtx file, and, if you’re reading the typeset documentation of this package, would appear just above. (It’s OK to call \usepackage with an empty argument or \relax, by the way.)

 9 \makeatletter% A special comment to help create bst files.  Don't change!
10 \@ifundefined{JusTLoaDInformatioN} {%
11 }{% ELSE (we know the compsci package is already loaded, too)
12 \UndefineCS\JusTLoaDInformatioN
13 \SaveDoXVarS
14 \eExpand\csname DoXPackageS\endcsname\In {%use \csname in case it's undefined
15  \usepackage{#1}%
16 }%
17 \RestoreDoXVarS
18 \makeatother
19 \endinput
20 }% A special comment to help create bst files.  Don't change!

Now we check for L^{A}TEX2e and declare the LaTeX package.

21 \NeedsTeXFormat{LaTeX2e}
22 \ProvidesPackage{newclude}[\PPOptArg]

4 Review of the old system

One aux file is written to disk for the principle source and each of the included parts. To do this, the kernel uses two of TEX’s output streams. When a routine writes to an auxiliary file, it writes to \@auxout, which is \let to either \@mainaux, the aux file for the principle source, or \@partaux the aux file for all the parts in turn.

In removing the \clearpages that usually surround the part, a problem arises involving the delayed action of \write commands. Suppose a part ending with a \write command ends halfway down a page, and another \write occurs in the principle source immediately after the inclusion. The first must be written to \@partaux and the second to \@mainaux. If we close \@partaux while the first \write is still pending, that is, before the current page has been shipped out, then the \write will be destined for a closed stream and therefore go to the log file and terminal. The \clearpages solve this by flushing all pending \writes before closing \@partaux immediately. Then \@mainaux is reopened.

When encountering an \include command, but before deciding whether or not to actually load the part, the kernel writes a command to \@mainaux that will load the part’s aux file. The main aux file is loaded by \document, so that all aux files are read in every time the principle source is processed.

If a part is actually loaded, a checkpoint is written to the part’s aux file consisting of a snapshot of the counters (a record of the values of all L^{A}TEX counters). On the next run, if the part is not actually loaded, the information in its aux file (e.g., references and labels) has nevertheless already been processed by \document. Processing the checkpoint causes a macro to be defined that when invoked restores the counter state. If the part is not actually loaded this time, \include calls this checkpoint macro instead.

This system has pitfalls as well as benefits. It is useful to keep the bibliography, bibliographic references, cross references, and page numbers up to date in certain situations, but the results can be confusing sometimes, because checkpoints are not documented. (Perhaps this is remedied in the 2d edition of the L^{A}TEX manual.) How, besides reading the code, or finding out the hard way, is anyone supposed to guess that rearranging two “deactivated” \include statements in a principle source will bring havoc on the page numbers?

23 \RequirePackage{moredefs}
24 \InitCS\sc@t@a
25 \DeclareOption{simple} {%
26 \input{simple.sto}
27 \let\sc@t@a\endinput

28 }

29 \DeclareOption{group} {%
30 \AtEndOfPackage {\input{group.sto}}

31 }

32 \DeclareOption{tag} {%
33 \AtEndOfPackage {\input{tag.sto}}

34 }

35 \DeclareOption{allocate} {%
36 \AtEndOfPackage {\input{allocate.sto}}

37 }

38 \DeclareBooleanOptions{dynamic}{static}
39 \ExecuteOptions{tag}

40 \ProcessOptions
41 \sc@t@a

5 Simple

The above option processing causes the file simple.sto to be loaded when the simple is given. After it is loaded, processing stops. If the simple option is not given, skip this section and go to section 6.

The simple option adds the optional argument to \include, and does nothing else.

\include I’m not really sure why the \relax is there; I’m imitating the kernel’s command.

42 \defcommand\include {%
43 \relax
44 \ifnum\@auxout=\@partaux
45  \@latex@error{\string\include\space cannot be nested}\@eha
46 \else
47  \expandafter\@include
48 \fi

49 }

\@include
50 \defcommand\@include [2][] {%
51 \clearpage
52 \if@filesw
53  \immediate\write\@mainaux{\string\@input{#2.aux}}%
54 \fi
55 \@tempswatrue
56 \if@partsw
57  \@tempswafalse
58  \edef\reserved@b{#2}%
59  \@for\reserved@a:=\@partlist\do
60  {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
61 \fi
62 \if@tempswa
63  \let\@auxout\@partaux
64  \if@filesw
65  \immediate\openout\@partaux #2.aux
66  \immediate\write\@partaux{\relax}%
67  \fi

All we did was change #1 to #2 and add the next line.

68  #1%
69  \@input@{#2.tex}%
70  \clearpage
71  \@writeckpt{#2}%
72  \if@filesw
73  \immediate\closeout\@partaux
74  \fi

75 \else
76  \@nameuse{cp@#2}%
77 \fi
78 \let\@auxout\@mainaux

79 }

6 Allocate and Group

The code here is common to the allocate and group solutions.

\nc@t@a \nc@t@b \nc@t@c \nc@toks@a Scratch variables.
80 \ReserveCS\nc@t@a
81 \ReserveCS\nc@t@b
82 \ReserveCS\nc@t@c
83 \newtokens\nc@toks@a
\IncludeSurround
\DefaultIncludeSurround
84 \newcommand\DefaultIncludeSurround {%
85 \par

86 }

87 \newlet\IncludeSurround\DefaultIncludeSurround

\c@IncludeDepth With nested \include s, we need some way for the various ones to distinguish themselves, so we keep track of the nested depth with this the IncludeDepth counter.

88 \newcounter{IncludeDepth} % starts at 0

\IfAllowed \includeonly \IfAllowed {⟨part name⟩}{⟨true⟩}{⟨false⟩} executes ⟨true⟩ if ⟨part-name⟩ is on the list of files to be included and ⟨false⟩ otherwise. If there is no list, executes ⟨true⟩.

I think it’s more efficient to define a macro for each included part on the list than it is to search through the list possibly twice for each one. Other opinions on making this whole thing more efficient?

We are using the usual L^{A}TEX trick of undefined control sequences comparing equally with \relax. Empty control sequences are not the same. Should be followed by ⟨true clause⟩ then ⟨false clause⟩.

89 \newcommand\IfAllowed [1] {%
90 \@firstoftwo

91 }

92 \newcommand\includeall {%
93 \let\includeonly\Gobble

94 }

95 \defcommand\includeonly [1] {%
96 \@partswtrue
97 %  \typeout{INCLUDEONLY}%
98 \edef\@partlist {\zap@space#1 \@empty}%
99 \@for\nc@t@a:=\@partlist \do {%

100  \InitName*{nc@part@\nc@t@a}%

101 }%

102 \defcommand\IfAllowed [1] {% args: part-name
103  \@ifundefined{nc@part@##1} {%
104 %        \typeout{##1 NOTALLOWED}%
105  \let\nc@t@c\@secondoftwo
106  }{% ELSE
107 %      \typeout{##1 ALLOWED}%
108  \let\nc@t@c\@firstoftwo

109 }%

110  \nc@t@c

111 }%

112 %  \typeout{ENDINCLUDEONLY}%

113 }

\include \include* This is the principle user command. The scratch variable \nc@t@b contains what really surrounds the included file.

114 \def\include {%
115 \@ifstar {%
116  \let\nc@t@b\IncludeSurround
117  \nc@include
118  }{% ELSE
119  \let\nc@t@b\clearpage
120  \nc@include

121 }% 122 }

6.1 Tag

The code in this section is processing if the tag option is given, or if none of tag,

 group, or allocate is given.

6.2 Writing to \@auxout

To adapt a package or class for use with the tag option of newclude:

   1. replace \immediate\write\@auxout with \@writeaux
   2. replace \protected@write\@auxout with \protected@writeaux

3. add

       \providecommand\@writeaux {%
         \immediate\write\@auxout
       }
       \providecommand\protected@writeaux {%
         \protected@write\@auxout
       }

   Warning: Might I need to do \let\protect\@unexpandable@protect in-
stead of \noexpand, in the def of \\protected@writeaux?
\nc@writeaux@main \nc@protected@writeaux@main The main versions are exactly the same as what they replaced.
123 \newcommand\nc@writeaux@main {%
124 \immediate\write\@auxout

125 }

126 \newcommand\nc@protected@writeaux@main {%
127 \protected@write\@auxout

128 }

\nc@writeaux@aux \nc@protected@writeaux@aux When you remove the \immediate, you have to expand whatever’s in the argument

at the time you invoke \write. \IncludeName and \@percentchar, and other

exandables in #2 will get expanded now. The \@percentchar and the ^^Js are there because lines written to \@auxout must be on lines by themselves to satisfy BibTEX. The ^^Js write newlines, and the \@percentchar eliminates a newline when the aux file is read in again later. Accommodating BibTEXrequires special consideration several times below as well.

129 \newcommand\nc@writeaux@aux [1] {% args: write-text
130 \eExecute {%
131  \write\@auxout{\string\@auxtag{\IncludeName}{\@percentchar^^J#1^^J}}%

132 }% 133 }

134 \newcommand\nc@protected@writeaux@aux [2] {% args: init-hook write-text
135 \protected@write\@auxout{#1}{\string\@auxtag{\IncludeName}{\@percentchar^^J#2^^J}}%

136 }

\@writeaux \@protected@writeaux We start with the main versions. We don’t reserve the control sequences \@writeaux and \protected@writeaux because the hack to adapt other packages might have already defined it with \providecommand.

137 \let\@writeaux\nc@writeaux@main
138 \let\protected@writeaux\nc@protected@writeaux@main

6.3 Kernel redefinitions

\@bibitem \@lbibitem \label \@citex \bibliography \nocite \addtocontents These are simple redefinitions of kernel functions. The changes are the substitutions for the writing commands described above.

139 \defcommand*\@bibitem [1] {%
140 \item
141 \if@filesw
142  \@writeaux{\string\bibcite{#1}{\the\value{\@listctr}}}%
143 \fi
144 \ignorespaces

145 }

146 \DefName*{@lbibitem} {[#1]#2} {%
147 \item[\@biblabel{#1}\hfill]%
148 \if@filesw
149  \begingroup

150  \let\protect\noexpand
151  \@writeaux{\string\bibcite{#2}{#1}}%
152  \endgroup
153 \fi
154 \ignorespaces

155 }

156 \defcommand*\label [1] {%
157 \@bsphack
158 \protected@writeaux{}{\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
159 \@esphack

160 }

161 \defcommand\addtocontents [2] {%
162 \protected@writeaux

163 {

164  \let\label\Gobble
165  \let\index\Gobble
166  \let\glossary\Gobble

167 }

168  {\string\@writefile{#1}{#2}}%

169 }

170 \DefName*{@citex} {[#1]#2} {%
171 \let\@citea\@empty
172 \@cite {%
173  \@for\@citeb:=#2\do {%
174  \@citea
175  \def\@citea{,\penalty\@m\ }%
176  \edef\@citeb{\expandafter\@firstofone\@citeb}%
177  \if@filesw
178  \@writeaux{\string\citation{\@citeb}}%
179  \fi
180  \@ifundefined{b@\@citeb} {%
181 \mbox{\reset@font\bfseries ?}%
182 \G@refundefinedtrue
183 \@latex@warning
184  {Citation `\@citeb' on page \thepage \space undefined}%
185 }{% ELSE
186  \hbox{\csname b@\@citeb\endcsname}%

187 }% 188 }%

189 }{#1}% second arg to \@cite

190 }

191 \defcommand*\bibliography [1] {%
192 \if@filesw
193  \@writeaux{\string\bibdata{#1}}%
194 \fi
195 \@input@{\jobname.bbl}%

196 }

197 \defcommand*\bibliographystyle [1] {%
198 \ifx\@begindocumenthook\@undefined\else
199  \expandafter\AtBeginDocument

200 \fi
201 {\if@filesw
202  \@writeaux{\string\bibstyle{#1}}%
203 \fi}%

204 }

205 \defcommand*\nocite [1] {%
206 \@bsphack
207 \@for\@citeb:=#1\do {%
208  \edef\@citeb{\expandafter\@firstofone\@citeb}%
209  \if@filesw
210  \@writeaux{\string\citation{\@citeb}}%
211  \fi
212  \@ifundefined{b@\@citeb} {%
213 \G@refundefinedtrue
214  \@latex@warning{Citation `\@citeb' undefined}%
215  }{}%

216 }%

217 \@esphack

218 }

6.4 Checkpoints

\@writeckpt \@wckptelt The \@charlb, \@charrb, and \@percentchar stuff is to satisfy BibTEX (see

above).

219 \defcommand*\@writeckpt [1] {%
220 \if@filesw
221  \write\@auxout{\string\@setckpt{#1}\@charlb\@percentchar}%
222  {\let\@elt\@wckptelt
223  \cl@@ckpt}%
224  \write\@auxout{\@charrb}%
225 \fi

226 }

227 \defcommand\@wckptelt [1] {%
228 \write\@auxout{\string\setcounter{#1}{\the\@nameuse{c@#1}}}%

229 }

6.5 Including

\IncludeName \ParentName \nc@includename@<N> FIX
230 \newcommand\IncludeName {%
231 \@nameuse{nc@includename@\theIncludeDepth}%

232 }

233 \newcommand\ParentName {%
234 \ifnum\value{IncludeDepth}= 0
235  \jobname
236  \MonsterWarning{newclude}{Requested name of parent of principle source}%
237 \else

The incrementation of the IncludeDepth counter is local to the group.

238  \begingroup
239  \advance\c@IncludeDepth by \m@one
240  \@nameuse{nc@includename@\theIncludeDepth}%
241  \endgroup
242 \fi

243 }

244 \NewName {nc@includename@0} {} {\jobname}
\nc@include FIX
245 \newcommand\nc@include [2][] {% args: hook filename
246 \IfAllowed{#2} {%
247  \nc@t@b           % surround the \include with something
248  \stepcounter{IncludeDepth}%
249  \DefName*{nc@includename@\theIncludeDepth} {} {#2}%
250  \let\@writeaux\nc@writeaux@aux
251  \let\protected@writeaux\nc@protected@writeaux@aux

Now execute the text of the optional argument to \include.

252  #1%
253  \@input@{#2.tex}%
254  \@writeckpt{#2}%
255  \let\@writeaux\nc@writeaux@main
256  \let\protected@writeaux\nc@protected@writeaux@main

We mustn’t restore the counter before we have finished using it.

257  \addtocounter{IncludeDepth}{\m@ne}%
258  \nc@t@b           % surround the \include with something
259  }{% ELSE

If the file is not allowed, we don’t load it and do two things instead. We execute the part’s checkpoint, then we write out the part’s auxcommands and checkpoint again. We must handle the case when the auxcommands isn’t defined; but the checkpoint will always be defined.

260  \@ifundefined{cp@#2} {%
261 %        \typeout{No information on part [#2]!}%
262  }{% ELSE
263  \@nameuse{cp@#2}%
264  \if@filesw%
265  \nc@write@auxcommands{#2}%
266  \nc@write@ckpt{#2}%
267  \fi%                                                  if@filesw
268  }%                                                      if@undefined
269 }%                                                        IfAllowed

270 }%

\nc@write@auxcommands \nc@write@ckpt FIX dox

\meaning produces catcode 12’s for all chars except spaces which are 10. Begin making definitions with \catcode`\^^M=12 (other).

271 \begingroup
272 \catcode`\^^M=12 %% double percents mean they're there only because of the catcode

273 %%

274 \Global\DefName*{nc@write@auxcommands} {#1} {% args: partname
275 \@ifundefined{nc@auxcommands@#1} {%
276  }{% ELSE
277  \write\@auxout{\string\@auxtag{#1}\@charlb\@percentchar}%
278  \EExpand*\csname nc@auxcommands@#1\endcsname\In {%
279  \edef\nc@t@a {%
280  \expandafter\strip@prefix\meaning ##1%

281 }% 282 }%

283  \edef\nc@t@a {\expandafter\nc@strip@M\nc@t@a\@nil}%
284 %    \typeout{The auxcommands: \meaning\nc@t@a}%
285  \begingroup %%
286  \catcode`\^^M=12 % other
287  \nc@for\nc@t@b:=\nc@t@a\do {%
288 %  \typeout{auxcommand ITEM: \meaning\nc@t@b}%
289 \EExpand\nc@t@b\In {%
290 \write\@auxout{##1}%

291 }% 292 }%

293  \endgroup %%
294  \write\@auxout{\@charrb}%

295 }%

296 }%%
297 \Global\DefName*{nc@write@ckpt} {#1} {% args: partname
298 \write\@auxout{\string\@setckpt{#1}\@charlb\@percentchar}%
299 \EExpand*\csname cp@#1\endcsname\In {%
300  \edef\nc@t@a {%
301  \expandafter\strip@prefix\meaning ##1%

302 }% 303 }%

304 \edef\nc@t@a {\expandafter\nc@strip@M\nc@t@a\@nil}%
305 \begingroup %%
306  \catcode`\^^M=12 % other
307  \nc@for\nc@t@b:=\nc@t@a\do {%
308 %      \typeout{checkpoint ITEM: \meaning\nc@t@b}%
309  \EExpand\nc@t@b\In {%
310 \write\@auxout{##1}%

311 }% 312 }%

313 \endgroup %%
314 \write\@auxout{\@charrb}%
315 }%%

\nc@for \nc@forloop \nc@iforloop \nc@for is like the kernel’s \@for but divides its list at ^^M_{12} instead of ,.

316 \Global\NewName{nc@for} {#1:=#2\do#3} {% FIX
317 \expandafter   \def %%
318  \expandafter \@fortmp %%
319  \expandafter {#2}%
320 \ifx\@fortmp\@empty \else %%

321  \expandafter\nc@forloop#2^^M\@nil^^M\@nil\@@#1{#3}%
322 \fi %%
323 }%%
324 \Global\NewName{nc@forloop} {#1^^M#2^^M#3\@@#4#5} {%
325 \def#4{#1}%
326 \ifx #4\@nnil \else %%
327  #5%
328  \def#4{#2}%
329  \ifx #4\@nnil \else %%
330  #5%
331  \nc@iforloop #3\@@#4{#5}%
332  \fi %%
333 \fi %%
334 }%%
335 \Global\NewName{nc@iforloop} {#1^^M#2\@@#3#4} {%
336 \def#3{#1}%
337 \ifx #3\@nnil %%
338  \expandafter\@fornoop %%
339 \else %%
340  #4%
341  \relax %%
342  \expandafter\nc@iforloop %%
343 \fi %%
344 #2\@@#3{#4}%
345 }%%

\nc@strip@M This strips a final ^^M_{12} from its argument. FIX: this could be built in to \nc@for, I think.

346 \Global\NewName{nc@strip@M} {#1^^M\@nil} {#1}%%

Finish making definitions with \catcode`\^^M=12.

347 \endgroup

\@auxtag \@@auxtag We both execute and save. FIX: efficiency? check only once, then redefine auxtag?

FIX: dox.

I could use \EExpand\In for clarity, but I go for efficiency on this crucial macro.

Begin making definitions with \catcode`\^^M=12 (other).

348 \begingroup
349 \catcode`\^^M\active %% double percents mean they're there only because of the catcode

350 %%

351 \Global\NewName*{@auxtag} {#1} {% args: partname
352 \begingroup %%
353  \catcode`\^^M\active %%
354  \@@auxtag{#1}%
355 }%%
356 \Global\NewName*{@@auxtag} {#1#2} {% args: partname auxcommands
357  \@ifundefined {nc@auxcommands@#1} {%
358 \nc@toks@a={#2}%
359  }{% ELSE
360  \expandafter   \nc@toks@a %%

361 \expandafter \expandafter %%
362 \expandafter {\csname nc@auxcommands@#1\endcsname#2}%

363 }%

364  \expandafter\xdef\csname nc@auxcommands@#1\endcsname{\the\nc@toks@a}%
365  #2%
366 \endgroup %%
367 }%%
\@setckpt \@@setckpt FIX dox
368 \Global\DefName*{@setckpt} {#1} {% args: partname
369 \begingroup %%
370  \catcode`\^^M\active %%
371  \@@setckpt{#1}%
372 }%%

Finish making definitions with \catcode`\^^M=12.

373 \endgroup

The \endgroup terminates the change in catcode.

374 \newcommand*\@@setckpt [2] {% args: partname checkpoint
375  \expandafter\gdef\csname cp@#1\endcsname{#2}%
376 \endgroup

377 }

What this does is effectively remove all the tags. The end of document hook is processed before the closing processing of the aux files, during which checking for things like undefined references is done. At this point we do not need the tags.

378 \AtEndDocument {%
379 \let\@auxtag\@secondoftwo

380 }

6.6 Allocate

The code in this section is processing if the allocate option is given.

Warning: This code has not been well tested yet. The output routine of L^{A}TEX is very complicated, and unforseen problems might arise.

\NextAux The macro \NextAux changes \@auxout to a new stream if one is available, and

\DynamicAux
\StaticAux

gives an error otherwise. The macro is implemented in dynamic and static ways which can be selected with \DynamicAux and \StaticAux{⟨number of streams⟩}. The number of streams can be from 2 to 16. The dynamic implementation is the default; I do not see much use for the static implementation at present. The static option is the equivalent of the declaration \StaticAux{10}. The dynamic selects the dynamic implementation.

\StaticAux can be invoked after \DynamicAux, but not the other way around (at least, the streams allocated by \StaticAux are not recovered). Macros which use \NextAux do not have to know whether the implementation is static or dynamic.

6.6.1 Wheels

The output streams are manipulated with the help of a data structure I call a wheel.

A wheel has 0 or more spokes and can be rolled. Each spoke is a TEX token, probably a control sequence name, and has an internal name. You can access the spoke at the 12 o’clock or “top” position of a wheel. In computerese, a wheel is a circularly linked list of tokens, and the operation of rolling moves a pointer along it in a certain direction by one element.

Wheels and operations on wheels are local.

\InitWheel You make a wheel either with \InitWheel {⟨\csname⟩}, which makes \DefWheel ⟨\csname⟩ a wheel with no spokes, or \DefWheel {⟨\csname⟩}{⟨spokes⟩}, which

makes a wheel with ⟨spokes⟩ for spokes. The first spoke in ⟨spokes⟩ is the top, the second will be top after one roll, and the first will be top again after n rolls, if there are n spokes.

\Roll Wheels are rolled by \Roll {⟨wheel⟩}. Spokes can be added to a wheel with

\Top
\AddSpokes

\AddSpokes{⟨wheel⟩}{⟨spokes⟩}. When n spokes are added, the previous top will be at the top after n rolls. \Top {⟨wheel⟩} expands eventually to the top spoke, which then can further expand, and so on.

\IfTop \IfTop{⟨wheel⟩}{⟨spoke⟩}{⟨true clause⟩}{⟨false clause⟩} compares the top of ⟨wheel⟩ with ⟨spoke⟩ using \ifx, and executes either ⟨true clause⟩ or ⟨false clause⟩ as appropriate. (The newclude package doesn’t actually use this command; it’s provided to “round out” the wheel data structure.)

Warning: Don’t put more than one token as the second argument to \IfTop.

6.6.2 Preliminaries

We require the afterpage package. The intuitive justification is that \writes are delayed until the current page is shipped out. We need to keep an output stream open until its last \write has been actually handled; after that, the stream can be made available again.

381 \RequirePackage{afterpage}

\nc@aux@wheel We use the wheel structure to handle both the static case and the dynamic case. The spokes of the wheel are macros \nc@auxout@⟨n⟩. Their first-level expansion is ⟨n⟩, a positive integer from 0 to 15. Each spoke has two corresponding macros. \nc@auxout@⟨n⟩@stream is a stream name allocated by \newwrite. \nc@auxout@⟨n⟩@inuse is a global boolean which is true iff the corresponding stream is currently in use.

382 \InitWheel\nc@aux@wheel

\nc@count We need an internal counter. Notice that the stream numbers used in the auxwheel start at 0, so the stream associated with with the numeral 4 is the fifth stream.

383 \newcounter{nc@count}

\nc@aux@wheel@size \nc@aux@wheel@size is a pseudo-counter that holds the present size of the aux wheel. In the static case it never changes and is set only for consistency.

384 \ReserveCS\nc@aux@wheel@size
\NextAux
385 \ReserveCS\NextAux

The kernel allocates two streams for the include system, \@mainaux and \@partaux. The auxwheel is initialized with these two streams. The first, corresponding to the principle source, is always marked in use.

FIX: Reserve the stream names. FIX: have verified up to here

386 \newboolean{@nc@auxout@1@inuse@}

387

388 \ReserveName{nc@auxout@1}
389 \NewName*{nc@auxout@1} {} {1}

390

391 \ReserveName{nc@auxout@1@stream}
392 \expandafter\let\csname nc@auxout@1@stream\endcsname\@partaux

\nc@init@aux@wheel We initialize the wheel with the first spoke.

393 \newcommand\nc@init@aux@wheel {%
394 \EExpand\csname nc@auxout@1\endcsname\In {%
395  \AddSpokes\nc@aux@wheel##1%

396 } 397 }

6.6.3 Static allocation

\StaticAux nonpositive numbers are treated the same as 1.: FIX: bounds check; the counter’s max should be one less than the number, since we have stream 0.

398 \newcommand\StaticAux [1] {%
399 \def\nc@aux@wheel@size {#1}
400 \setcounter{nc@count}{2}
401 \nc@init@aux@wheel
402 \@whilenum \value{nc@count} <= \nc@aux@wheel@size
403  \do {%

First define the macros that make up the wheel itself to be their spoke numbers.

404  \eExpand*\thenc@count\In {%
405  \NewName*{nc@auxout@\thenc@count} {} {%
406  ##1%

407 }% 408 }

Next allocate the corresponding stream.

409  \EExpand\csname nc@auxout@\thenc@count@stream\endcsname\In {%
410  \@nameuse{newwrite}##1%

411 }

Next create the corresponding flag (they start false).

412  \provideboolean{@nc@auxout@\thenc@count @inuse@}

Now add the spoke itself.

413  \EExpand\csname nc@auxout@\thenc@count\endcsname\In {%
414  \ReserveCS#1%
415  \AddSpokes\nc@aux@wheel##1%

416 }

417  \stepcounter{nc@count}

418 }

419 \def\NextAux {%
420  \Roll\nc@aux@wheel
421  \@nameuse{if@nc@auxout@\Top\nc@aux@wheel @inuse@}%
422  \MonsterError{newclude} {%
423  You can't nest \protect\include this deeply!%

424 }%

425  \else
426  \Elet\@auxout\csname nc@auxout@\Top\nc@aux@wheel @stream\endcsname
427  \fi

428 }% 429 }

6.6.4 Dynamic allocation

\DynamicAux
\nc@addnewauxstream
430 \newcommand\DynamicAux {%
431 \def\nc@aux@wheel@size {1}
432 \nc@init@aux@wheel
433 \def\NextAux {%
434  \Roll\nc@aux@wheel
435  \@nameuse{if@nc@auxout@\Top\nc@aux@wheel @inuse@}%
436  \nc@addnewauxstream
437  \fi

Either the top spoke was not in use, or we have added a fresh spoke at the top – so the top spoke represents what we want.

438  \Elet\@auxout\csname nc@auxout@\Top\nc@aux@wheel @stream\endcsname
439  \typeout{NextAux has just set auxout to stream
440  \the\csname nc@auxout@\Top\nc@aux@wheel @stream\endcsname.
441  We are using spoke number
442  \csname nc@auxout@\Top\nc@aux@wheel\endcsname.}

443 }% 444 }

It works out that the new spoke should have a spoke number one greater than the current wheel size. We use the nc@count counter to find this number.

445 \newcommand\nc@addnewauxstream {%
446 \setcounter{nc@count}{\nc@aux@wheel@size}%
447 \stepcounter{nc@count}%
448 \typeout{Allocating another spoke (spoke number \thenc@count)}%

First we add the spoke itself, then initialize the corresponding objects.

449 \EExpand*\csname nc@auxout@\thenc@count\endcsname\In {%

450  \AddSpokes\nc@aux@wheel##1%

451 }%

452 \EExpand*\thenc@count\In {%
453  \DefName*{nc@auxout@##1} {} {##1}%
454  \provideboolean{@nc@auxout@##1@inuse@}%
455  \def\nc@aux@wheel@size {##1}%
456  \EExpand*\csname nc@auxout@##1@stream\endcsname\In {%
457  \@nameuse{newwrite}####1%

458 }% 459 }% 460 }

461 \DynamicAux

6.6.5 Including

\nc@include The only way I see how to set the inuse flag to false at the proper time is to use the afterpage package. What I would really like is to \write something with side effects.

462 \newcommand\nc@include [2][] {%
463 \if@filesw
464  \immediate\write\@mainaux{\string\@input{#2.aux}}%
465 \fi
466 \@tempswatrue
467 \if@partsw
468  \@tempswafalse
469  \edef\reserved@b{#2}%
470  \@for\reserved@a:=\@partlist\do
471  {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
472 \fi
473 \if@tempswa
474  \stepcounter{IncludeDepth}%

\nc@t@c is going to preserve the current aux stream number to restore \@auxout, in case there is a nested \include.

475  \edef\nc@t@c {%
476  \the\@auxout

477 }%

478  \if@filesw
479  \NextAux
480  \openout\@auxout #2.aux
481  \write\@auxout{\relax}%
482  \expandafter\global
483  \csname @nc@auxout@\Top\nc@aux@wheel @inuse@true\endcsname

\nc@include@finish@<N> The next line defines the macro \nc@include@finish@⟨n⟩ to close the output stream that is presently open. We have an interesting task here of getting certain unique information to macros after the \@input when we might end up recursing during the \@input. To do this, we immediately expand the variables we need and store them in a macro which will not be altered by a recursion of \include. We have set up the IncludeDepth counter to allow us to define such a macro, which is unique to this instance of \include.

Warning: The macro names \nc@include@finish@⟨n⟩ where ⟨n⟩ is an integer are overwritten, that is, they are not allocated in a safe way.

The following lines are intended to make this definition, where <D> represents the current value of IncludeDepth, <P> represents the spoke number of the current top of \nc@aux@wheel, and <S> represents the stream number for the current part, i.e., the current value of \@auxout, and <X> represents the stream number that was current before \include got called (this is saved in \nc@t@c).

    \def\nc@include@finish@<D> {%
      \closeout<S>%
      \global\chardef\@auxout=<X>%
      \afterpage{\global\@nc@auxout@<P>@inuse@false}
    }
484  \EExpand\theIncludeDepth\In {%                   ##1
485  \EExpand\the\@auxout\In {%                       ####1
486  \DefName{nc@include@finish@##1} {} {%
487  \closeout####1%
488  \global\chardef\@auxout=\nc@t@c
489  \typeout{Restored auxout to stream number
490  \nc@t@c \space (old: \the\@auxout)}
491  \typeout{executing afterpage}%
492  \EExpand\csname @nc@auxout@\Top\nc@aux@wheel
493  @inuse@false\endcsname\In {% ########1
494  \afterpage{%
495  \typeout{Finishing.  auxout is now \the\@auxout;  current spoke
496  is \csname nc@auxout@\Top\nc@aux@wheel\endcsname\space
497  with stream number
498  \the\csname nc@auxout@\Top\nc@aux@wheel @stream\endcsname

499 }%

500  \global########1%
501  }%                                                 Afterpage
502  }%                                                   EExpand
503  }%                                                     DefName
504  }}%                                                      EExpand
505  \fi %                                                      \if@filesw
506  \nc@t@b           % surround the \include with something

Now execute the text of the optional argument to \include. Notice that if we change to a new aux file, we should do it before the optional argument. This is important so that sectioning commands will appear in the right order. If the sectioning command were to write to \@mainaux, then it would come after the whole included aux file, instead of before it.

507  #1%
508  \@input@{#2.tex}%
509  \@writeckpt{#2}%
510  \if@filesw

511  \csname nc@include@finish@\theIncludeDepth\endcsname
512  \fi
513  \nc@t@b           % surround the \include with something

We mustn’t restore the counter before we have finished using it.

514  \addtocounter{IncludeDepth}{\m@ne}%

If the file is excluded by the \includeonly command, we don’t load it and execute the file’s checkpoint instead.

515 \else
516  \@nameuse{cp@#2}%
517 \fi

518 }

6.6.6 Checkpoints

\@writeckpt \@wckptelt We must redefine the macros which write the checkpoints. \@auxout is substituted for \@partaux; I think this change should be in the kernel anyway! And we remove

 the \immediates.
519 \defcommand\@writeckpt [1] {%
520 \if@filesw
521  \write\@auxout{\string\@setckpt{#1}\@charlb}%
522  \begingroup
523  \let\@elt\@wckptelt
524  \cl@@ckpt
525  \endgroup
526  \write\@auxout{\@charrb}%
527 \fi

528 }

529 \defcommand\@wckptelt [1] {%
530 \protected@write\@auxout{}{\string\setcounter{#1}{\the\@nameuse{c@#1}}}%

531 }

6.6.7 Wheels

\InitWheel \Roll \IfTop \Top \AddSpokes A wheel is implemented as a macro. The tokens of its first-level expansion are the spokes, the top being the first.

532 \newcommand\InitWheel [1] {% args: wheel
533 \InitCS#1%

534 }

535 \newcommand\Roll [1] {% args: wheel
536 \edef #1{%
537  \expandafter\nc@roll #1\nc@llor

538 }% 539 }

540 \ReserveCS\nc@llor
541 \NewNameDef{nc@roll} {#1\nc@llor} {%
542 \@cdr#1\@nil\@car#1\@nil

543 }

544 \newcommand\Top [1] {% args: wheel

545 \E@car #1\@nil

546 }

547 \newcommand\IfTop [4] {% args: wheel token true false
548 \EExpand#1\In {%
549  \edef\nc@t@b {%
550  \expandafter\noexpand\@car##1\@nil

551 }% 552 }%

At this point, the first-level expansion of \nc@t@b is a single token, the top of the wheel. We \let \nc@t@a to this token.

553 \Elet\nc@t@a\nc@t@b
554 \let\nc@t@b #2%
555 \ifx\nc@t@a\nc@t@b
556  \expandafter\@firstoftwo
557 \else
558  \expandafter\@secondoftwo
559 \fi

560 }

561 \newcommand\AddSpokes [2] {% args: wheel spokes
562 \EExpand#1\In {%
563  \def #1{#2##1}%

564 }% 565 }

6.7 Group

The code in this section is processing if the group option is given.

The group solution uses just one aux file. The reason to have a separate ones for the parts is so that information from the last time the part was included is retained in subsequent runs even when the part is excluded by \includeonly. Suppose a part is processed once, and on a subsequent run its name is removed from the \includeonly list. This run will still read in the part’s aux file, since the aux file of any part that was \included during the last run is always read. But the information therein is not going to be regenerated in this run, since the part will not be processed. The main aux file is created anew with each run, so this information would be lost if it resided there.

We can use the same technique the kernel uses to manage checkpoints to obviate the need for separate aux files as follows.

When a part is actually included, we leave \@auxout as \@mainaux, but enclose what the part writes to \@mainaux by lines which make the text the second argument of a macro called \@aux@info (the first argument is the basename of the part, just like \@setckpt). We end the second argument before writing the checkpoint. In summary, for each part that is processed, we write the macro name \@aux@info followed by three arguments in braces to the main aux file. The three arguments are the part’s base name, the text written to \@auxout while processing the part, and the part’s checkpoint.

Now suppose we are on the next L^{A}TEX run after a part was processed. The definition of \@aux@info is such that it tests whether its part (named in the first argument) is allowed by \includeonly (that is, if the part would be included by an \include command below). (Notice that \includeonly is already required to appear in the preamble, that is, before the \document command which reads the main aux file and causes the execution of \@aux@info, so \@aux@info has the information it needs.) If the part is allowed, then the second argument is just executed. This is exactly what would have happened with the old system. If the part is not allowed, then \@aux@info saves both arguments in variables and executes nothing—again just like \@setckpt.

Below, if the part is not named in an \include command, the part is assumed not to be important any more and, just like in the old system, will be ignored during the next run (except for its innocuous appearance in the \includeonly list). This leaves two cases. 1) If the part is allowed and also \included, the process explained in the last two paragraphs is repeated and we are doing fine.

2) If the part is not allowed but is \included, then we wish to ensure that its information is preserved for the next L^{A}TEX run. In the past this was automatic, because the information was in its own file that was not going to be overwritten. It is not much more difficult now, since we have ensured that the same information is contained in two variables defined while executing \document. All we do is rewrite the contents of these variables to the (main) aux file, wrapped once again as the second and third arguments to \@aux@info.

One might worry that storing this information in macros might tax TEX’s memory. I tried defining some very long macros, and it didn’t seem to affect any of the memory parameters given in the log file. I also tried all the biggest L^{A}TEX jobs on my computer including my thesis and source2e and found that no more than 1/3 of available main memory was ever used. Since I am using a normal web2c TEX, this quick experiment convinces me that storing what was once the part’s aux file in a macro will tax the average TEX’s memory resources hardly at all.

\nc@toks@b Scratch variable.

566 \newtokens\nc@toks@b

\nc@include An undefined \ai@ macro means that we have no information on the part, it is new.

567 \newcommand\nc@include [2][] {% args: hook filename
568 \IfAllowed{#2} {%
569  \nc@t@b           % surround the \include with something
570  \stepcounter{IncludeDepth}%
571  \if@filesw
572  \write\@auxout{\string\@aux@info{#2}\@charlb}%
573  \fi

Now execute the text of the optional argument to \include.

574  #1%
575  \@input@{#2.tex}%

576  \if@filesw
577  \write\@auxout{\@charrb}%
578  \fi
579  \@writeckpt

We mustn’t restore the counter before we have finished using it.

580  \addtocounter{IncludeDepth}{\m@ne}%
581  \nc@t@b           % surround the \include with something
582  }{% ELSE

If the file is not allowed, we don’t load it and do two things instead. If the file’s checkpoint exists, we execute it and write out the dependent source’s information and checkpoint again, which are stored in ai@⟨DS filename⟩.

583  \@ifundefined{cp@#2} {%
584  \typeout{No information on part [#2]!}%
585  }{% ELSE
586  \@nameuse{cp@#2}%
587  \if@filesw
588  \EExpand*\csname ai@#2\endcsname\In {%
589  \nc@toks@a=\expandafter{##1}%

590 }%

591  \EExpand*\csname cp@#2\endcsname\In {%
592  \nc@toks@b=\expandafter{##1}%

593 }%

594  \write\@auxout{\string\@aux@info{#2}{\the\nc@toks@a}{\the\nc@toks@b}}%
595  \fi
596  }%                                                      ifundefined
597 }%                                                        IfAllowed

598 }

\@writeckpt \@wckptelt We must redefine the macros which write the checkpoints. \@auxout is substituted for \@partaux; I think this change should be in the kernel anyway! And we remove

 the \immediates.
599 \def\@writeckpt {%
600 \if@filesw
601  \write\@auxout{\@charlb}%
602  \begingroup
603  \let\@elt\@wckptelt
604  \cl@@ckpt
605  \endgroup
606  \write\@auxout{\@charrb}%
607 \fi

608 }

609 \defcommand\@wckptelt [1] {%
610 \protected@write\@auxout{}{\string\setcounter{#1}{\the\@nameuse{c@#1}}}%

611 }

\@aux@info If the dependent source is allowed, we execute its information and ignore its checkpoint. In either case we store its information and checkpoint in the macro \ai@⟨DS name⟩, and just its checkpoint in the macro \cp@⟨partfile⟩.

To do: Improve the efficiency.

612 \newcommand\@aux@info [3] {% args: part-name part-info checkpoint-info
613 \IfAllowed{#1} {%
614  #2%
615  }{}%
616 \Global\DefName{ai@#1} {} {#2}%
617 \Global\DefName{cp@#1} {} {#3}%

618 }

Index

Numbers written in italic refer to the page where the corresponding entry is described, the ones underlined to the code line of the definition, the rest to the code lines where the entry is used.

Symbols

\@@ 321, 324, 331, 335, 344 \@@auxtag . . . . . . . . \underline{348}

\@@setckpt . . . . . . . \underline{368}

\@aux@info 572, 594, \underline{612} \@auxout . 44, 63, 78,

124, 127, 131, 135, 221, 224, 228, 277, 290, 294, 298, 310, 314, 426, 438, 476, 480, 481, 485, 488, 490, 495, 521, 526, 530, 572, 577, 594, 601, 606, 610

\@auxtag . . . . . 131,

135, 277, \underline{348}, 379

\@begindocumenthook 198

\@bibitem . . . . . . . . \underline{139}

\@biblabel . . . . . . . 147

\@bsphack …. 157, 206 \@car . . . . . . . . 542, 550 \@cdr . . . . . . . . . . . . 542 \@charlb . . 221, 277,

298, 521, 572, 601 \@charrb . . 224, 294,

314, 526, 577, 606 \@cite . . . . . . . 172, 189 \@citea … 171, 174, 175 \@citeb . . . . . . 173,

176, 178, 180, 184, 186, 207, 208, 210, 212, 214

\@citex . . . . . . . . . . \underline{139}

\@currentlabel . . . . 158

\@eha . . . . . . . . . . . . 45 \@elt . . . . . 222, 523, 603 \@empty … 98, 171, 320 \@esphack …. 159, 217

\@firstofone . . 176, 208
\@firstoftwo 90, 108, 556

\@for 59, 99, 173, 207, 470 \@fornoop . . . . . . . . 338 \@fortmp . . . . . 318, 320 \@ifstar . . . . . . . . . 115

\@ifundefined . . 10,

103, 180, 212, 260, 275, 357, 583

\@include . . . . . . 47, \underline{50} \@input . . . . . . . 53, 464 \@input@ . . . . . . 69,

195, 253, 508, 575

\@latex@error . . . . . 45
\@latex@warning 183, 214
\@lbibitem . . . . . . . \underline{139}

\@listctr . . . . . . . . 142 \@m . . . . . . . . . . . . . 175 \@mainaux . . 53, 78, 464 \@nameuse 76, 228, 231,

240, 263, 410, 421, 435, 457, 516, 530, 586, 610

\@nil . 283, 304, 321,

346, 542, 545, 550 \@nnil …. 326, 329, 337

\@partaux . . . . . 44,

63, 65, 66, 73, 392 \@partlist 59, 98, 99, 470

\@partswtrue . . . . . . 96
\@percentchar . 131,

135, 221, 277, 298

\@protected@writeaux

. . . . . . . . . . . \underline{137}

\@secondoftwo . . . . .

…. 105, 379, 558

\@setckpt . . . . . . . .

. 221, 298, \underline{368}, 521

\@tempswafalse . 57, 468
\@tempswatrue . . . . .

. . 55, 60, 466, 471

\@undefined . . . . . . . 198

\@wckptelt \underline{219}, \underline{519}, \underline{599}

\@whilenum . . . . . . . 402

                          \@writeaux   \underline{137}, 142,

151, 178, 193, 202, 210, 250, 255

                          \@writeckpt . . . . . . .

. . 71, \underline{219}, 254, 509, \underline{519}, 579, \underline{599}

                          \@writefile . . . . . . . 168

\^. . . . . . . 272, 286, 306, 349, 353, 370

\␣ . . . . . . . . . . . . . . 175

A \active … 349, 353, 370

                          \AddSpokes . . . . 18,

395, 415, 450, \underline{532}

                          \addtocontents . . . . \underline{139}
                          \addtocounter . . . . .

…. 257, 514, 580 \advance . . . . . . . . . 239

                          \afterpage . . . . . . . 494
                          \AtBeginDocument . . 199
                          \AtEndDocument . . . . 378
                          \AtEndOfPackage . . .

. . . . . . . 30, 33, 36

B

                          \begingroup . . . . . . .

. 149, 238, 271, 285, 305, 348, 352, 369, 522, 602

\bfseries . . . . . . . . 181 \bibcite . . . . . 142, 151 \bibdata . . . . . . . . . 193

                          \bibliography . . . . . \underline{139}
                          \bibliographystyle . 197

\bibstyle . . . . . . . . 202

C

                          \c@IncludeDepth   \underline{88}, 239

\catcode . . 272, 286,

306, 349, 353, 370 \chardef . . . . . . . . . 488 \citation …. 178, 210 \cl@@ckpt . 223, 524, 604

\clearpage . 51, 70, 119

\closeout . . . . . 73, 487 \csname …. 14, 186,

278, 299, 362, 364, 375, 392, 394, 409, 413, 426, 438, 440, 442, 449, 456, 483, 492, 496, 498, 511, 588, 591

D

\DeclareBooleanOptions

. . . . . . . . . . . . 38

\DeclareOption . . . .

…. 25, 29, 32, 35 \def . . . . . . . . . . . 1–

5, 114, 175, 317, 325, 328, 336, 399, 419, 431, 433, 455, 563, 599

\DefaultIncludeSurround

. . . . . . . . . . 4, \underline{84}

\defcommand . . . . 42,

50, 95, 102, 139, 156, 161, 191, 197, 205, 219, 227, 519, 529, 609

\DefName 146, 170, 249, 274, 297, 368, 453, 486, 616, 617

\DefWheel . . . . . . . . 18 \do . . . . . . . . 59, 99,

173, 207, 287, 307, 316, 403, 470

\docdate . . . . . . . . . . \underline{1}

\DoXPackageS . . . . . . . 2
\DoXUsepackagE . . . . . \underline{1}
\DynamicAux . . . . 17, \underline{430}

E

\E@car . . . . . . . . . . . 545 \edef . . . . . 6, 58, 98,

176, 208, 279, 283, 300, 304, 469, 475, 536, 549

\eExecute . . . . . . . . 130 \EExpand . . . . . 278,

289, 299, 309, 394, 409, 413, 449, 452, 456, 484, 485, 492, 548, 562, 588, 591

\eExpand . . . . . . 14, 404 \Elet . . . . . 426, 438, 553 \else 46, 75, 198, 237,

320, 326, 329, 339, 425, 515, 557

\endcsname . 14, 186,

278, 299, 362, 364, 375, 392, 394, 409, 413, 426, 438, 440, 442, 449, 456, 483, 493, 496, 498, 511, 588, 591

\endgroup . . . . . . . .

. 152, 241, 293, 313, 347, 366, 373, 376, 525, 605

\endinput . . . . . . 19, 27

\ExecuteOptions . . . 39
\expandafter . . . . . .

. . 47, 176, 199, 208, 280, 283, 301, 304, 317– 319, 321, 338, 342, 360–362, 364, 375, 392, 482, 537, 550, 556, 558, 589, 592

F

\fi . . . . . 48, 54, 60, 61, 67, 74, 77, 143, 153, 179, 194, 200, 203, 211, 225, 242, 267, 322, 332, 333, 343, 427, 437, 465, 471, 472, 505, 512, 517, 527, 559, 573, 578, 595, 607

\filedate . . . . . . . . . \underline{1} \fileinfo . . . . . . . . . \underline{1}

\fileversion . . . . . . . \underline{1}

G

                   \G@refundefinedtrue

. . . . . . . . 182, 213 \gdef . . . . . . . . . . . . 375 \Global . . . . . . 274,

297, 316, 324, 335, 346, 351, 356, 368, 616, 617

\global … 482, 488, 500 \glossary . . . . . . . . 166 \Gobble …. 93, 164–166

H

                   \HaveECitationS . . . . \underline{1}

\hbox . . . . . . . . . . . . 186 \hfill . . . . . . . . . . . 147

I

                   \if@filesw . . . . . . .

52, 64, 72, 141, 148, 177, 192, 201, 209, 220, 264, 463, 478, 505, 510, 520, 571, 576, 587, 600

                   \if@partsw . . . . 56, 467
                   \if@tempswa . . . . 62, 473
                   \IfAllowed . . . . . . .

. \underline{89}, 246, 568, 613 \ifnum . . . . . . . . 44, 234 \IfTop . . . . . . . . 18, \underline{532} \ifx 60, 198, 320, 326,

329, 337, 471, 555

                   \ignorespaces . 144, 154
                   \immediate . . . . 53,

65, 66, 73, 124, 464 \In … 14, 278, 289,

299, 309, 394, 404, 409, 413, 449, 452, 456, 484, 485, 493, 548, 562, 588, 591

\include . 4, \underline{42}, \underline{114}, 247, 258, 423, 506, 513, 569, 581

\include* . . . . . . 4, \underline{114}

                   \includeall . . . . . . . 92
                   \IncludeName . . . . . .

…. 131, 135, \underline{230}

                   \includeonly . . . . . 4, \underline{89}

\IncludeSurround . .

. . . . . . . 4, \underline{84}, 116 \index . . . . . . . . . . . 165 \InitCS . . . . . . . 24, 533 \InitName . . . . . . . . 100

\InitWheel 18, 382, \underline{532}

\input … 26, 30, 33, 36 \item . . . . . . . . 140, 147

J

\jobname . . 195, 235, 244

\JusTLoaDInformatioN 12

L

\label . . . . . . . . . . . \underline{139} \let . . . . . . . . . . 27,

63, 78, 93, 105, 108, 116, 119, 137, 138, 150, 164–166, 171, 222, 250, 251, 255, 256, 379, 392, 523, 554, 603

M

\m@ne . . . . . 257, 514, 580 \m@one . . . . . . . . . . . 239

\makeatletter . . . . . . 9
\makeatother . . . . . . 18

\mbox . . . . . . . . . . . . 181 \meaning . . . . . 280,

284, 288, 301, 308

\MonsterError . . . . . 422
\MonsterWarning . . . 236

N

\nc@addnewauxstream  \underline{430}
\nc@aux@wheel . . . . .

. \underline{382}, 395, 415, 420, 421, 426, 434, 435, 438, 440, 442, 450, 483, 492, 496, 498

\nc@aux@wheel@size .

…. \underline{384}, 399, 402, 431, 446, 455

\nc@count . . . . . . . . \underline{383} \nc@for … 287, 307, \underline{316}

\nc@forloop . . . . . . . \underline{316}
\nc@iforloop . . . . . . \underline{316}

\nc@include . . . 117,

120, \underline{245}, \underline{462}, \underline{567}

\nc@init@aux@wheel .

…. \underline{393}, 401, 432 \nc@llor . . 537, 540, 541

\nc@protected@writeaux@aux

. . . . . . . . \underline{129}, 251

\nc@protected@writeaux@main

…. \underline{123}, 138, 256 \nc@roll . . . . . . . . . 537

\nc@strip@M 283, 304, \underline{346}

\nc@t@a . . . . . \underline{80}, 99, 100, 279, 283, 284, 287, 300, 304, 307, 553, 555

\nc@t@b \underline{80}, 116, 119, 247, 258, 287– 289, 307–309, 506, 513, 549, 553–555, 569, 581

\nc@t@c \underline{80}, 105, 108,

110, 475, 488, 490

\nc@toks@a . \underline{80}, 358,

360, 364, 589, 594 \nc@toks@b \underline{566}, 592, 594

\nc@write@auxcommands

. . . . . . . . 265, \underline{271}

\nc@write@ckpt 266, \underline{271}
\nc@writeaux@aux . .

. . . . . . . . \underline{129}, 250

\nc@writeaux@main .

…. \underline{123}, 137, 255

\NeedsTeXFormat . . . 21
\newboolean . . . . . . . 386
\newcommand . . . . . . .

84, 89, 92, 123, 126, 129, 134, 230, 233, 245, 374, 393, 398, 430, 445, 462, 532, 535, 544, 547, 561, 567, 612

\newcounter . . . . 88, 383

\newlabel . . . . . . . . 158 \newlet . . . . . . . . . . 87 \NewName . . 244, 316,

324, 335, 346, 351, 356, 389, 405

\NewNameDef . . . . . . . 541
\newtokens . . . . 83, 566

\NextAux . . . . . . 17,

\underline{385}, 419, 433, 479 \nocite . . . . . . . . . . \underline{139} \noexpand …. 150, 550

O

\openout . . . . . . 65, 480

P

\par . . . . . . . . . . . . . 85

\ParentName . . . . . . . \underline{230}

\penalty . . . . . . . . . 175 \PPOptArg . . . . . . . \underline{1}, 22

\ProcessOptions . . . 40

\protect . . . . . 150, 423

\protected@write . .

. 127, 135, 530, 610

\protected@writeaux

. . . . . . . . 138, 158, 162, 251, 256

\provideboolean 412, 454
\ProvidesPackage . . 22

R

\relax . . 43, 66, 341, 481

\RequirePackage 23, 381
\ReserveCS . . 80–82,

384, 385, 414, 540

\reserved@a . . . . . . .

. . 59, 60, 470, 471

\reserved@b . . . . . . .

. . 58, 60, 469, 471

\ReserveName . . 388, 391
\reset@font . . . . . . . 181
\RestoreDoXVarS . . . 17

\Roll . . 18, 420, 434, \underline{532}

S

\SaveDoXVarS . . . . . . 13

\sc@t@a . . . . . 24, 27, 41

\setcounter . . . 228,

400, 446, 530, 610 \space 7, 45, 184, 490, 496

\StaticAux . . . . 17, \underline{398}
\stepcounter . . 248,

417, 447, 474, 570 \string . 45, 53, 131,

135, 142, 151, 158, 168, 178, 193, 202, 210, 221, 228, 277, 298, 464, 521, 530, 572, 594, 610

\strip@prefix . 280, 301

T

\the . . . . . . 142, 228, 364, 440, 476, 485, 490, 495, 498, 530, 594, 610

\theIncludeDepth 231,

240, 249, 484, 511

\thenc@count . . . . . .

. 404, 405, 412, 413, 448, 449, 452

\thenc@count@stream 409

\thepage . . . . . 158, 184 \Top . . . . . . . 18, 421,

426, 435, 438, 440, 442, 483, 492, 496, 498, \underline{532}

\typeout . . . . . . 97, 104, 107, 112, 261, 284, 288, 308, 439, 448, 489, 491, 495, 584

U

                   \UndefineCS . . . . . . . 12
                   \usepackage . . . . . . . 15

V \value …. 142, 234, 402

W \write . . 53, 66, 124,

131, 221, 224, 228, 277, 290, 294, 298, 310, 314, 464, 481, 521, 526, 572, 577, 594, 601, 606

X \xdef . . . . . . . . . . . . 364

Z

                                             \zap@space . . . . . . . 98