| 1 |
% \iffalse |
| 2 |
% |
| 3 |
% Package `localloc' to use with LaTeX 2e/2.09 and plain-TeX |
| 4 |
% Copyright (C) 1991,1994,1995 Bernd Raichle. All rights reserved. |
| 5 |
% |
| 6 |
% |
| 7 |
% Copying of this file is authorized only if either |
| 8 |
% (1) you make absolutely no changes to your copy, including name, or |
| 9 |
% (2) if you do make changes, you name it something other than |
| 10 |
% localloc.dtx, localloc.doc, localloc.tex, or localloc.sty. |
| 11 |
% This restriction helps ensure that all styles developed here |
| 12 |
% remain identical. |
| 13 |
% |
| 14 |
% Error reports in case of UNCHANGED versions please to: |
| 15 |
% Bernd Raichle |
| 16 |
% Stettener Str. 73 |
| 17 |
% D-73732 Esslingen |
| 18 |
% Federal Republic of Germany |
| 19 |
% Email: [email protected] |
| 20 |
% |
| 21 |
% |
| 22 |
% ========== INSTALLATION GUIDE: ========== |
| 23 |
% |
| 24 |
% The complete distribution consists of a set of files, which are |
| 25 |
% packed and documented in _one_ `docstrip archive file' called |
| 26 |
% `localloc.dtx' (the file you are currently reading). This archive |
| 27 |
% file can be unpacked to create the necessary files containing the |
| 28 |
% macros, documentation, etc. |
| 29 |
% |
| 30 |
% To unpack the archive file you need: |
| 31 |
% |
| 32 |
% * `localloc.dtx' (it is the file you are currently reading) |
| 33 |
% |
| 34 |
% * `docstrip.tex' version 2.x or newer |
| 35 |
% (You can find this file in the LaTeX 2e release.) |
| 36 |
% |
| 37 |
% Then run `localloc.dtx' through plainTeX or LaTeX to unpack the |
| 38 |
% archive file: |
| 39 |
% |
| 40 |
% tex localloc.dtx |
| 41 |
% or |
| 42 |
% latex localloc.dtx |
| 43 |
% |
| 44 |
% This will create a set of file which contain the macro code or |
| 45 |
% code to produce the documentation of the `localloc' package. |
| 46 |
% |
| 47 |
% --------------- start of docstrip archive file ------------------ |
| 48 |
% \fi |
| 49 |
% |
| 50 |
% \CheckSum{369} |
| 51 |
% |
| 52 |
% \iffalse |
| 53 |
%<*install> |
| 54 |
\def\batchfile{localloc.dtx} |
| 55 |
\input docstrip.tex |
| 56 |
\preamble |
| 57 |
|
| 58 |
This is a file of the `localloc' package reimplementing |
| 59 |
plain-TeX's and LaTeX's basic allocation macros to allow |
| 60 |
local allocation of registers. |
| 61 |
|
| 62 |
-- Copyright (C) 1991-1995 Bernd Raichle. All rights reserved -- |
| 63 |
|
| 64 |
This package is distributed in the hope that it will be useful, |
| 65 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 66 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 67 |
|
| 68 |
|
| 69 |
IMPORTANT NOTICE: |
| 70 |
|
| 71 |
Copying of this file is authorized only if either |
| 72 |
(1) you make absolutely no changes to your copy, including name, or |
| 73 |
(2) if you do make changes, you name it something other than |
| 74 |
localloc.dtx, localloc.doc, localloc.tex, or localloc.sty. |
| 75 |
|
| 76 |
For error reports see original source file `localloc.dtx'. |
| 77 |
|
| 78 |
\endpreamble |
| 79 |
%\generateFile{localloc.ins}{t}{\from{localloc.dtx}{install}} |
| 80 |
\generateFile{localloc.sty}{t}{\from{localloc.dtx}{package}} |
| 81 |
\generateFile{localloc.drv}{t}{\from{localloc.dtx}{driver}} |
| 82 |
\generateFile{localtst.tex}{t}{\from{localloc.dtx}{test}} |
| 83 |
|
| 84 |
\Msg{***********************************************************} |
| 85 |
\Msg{*} |
| 86 |
\Msg{* To finish the installation you have to move the following} |
| 87 |
\Msg{* file into a directory searched by TeX:} |
| 88 |
\Msg{*} |
| 89 |
\Msg{* \space\space localloc.sty} |
| 90 |
\Msg{*} |
| 91 |
\Msg{* To produce the documentation of this archive file run the} |
| 92 |
\Msg{* file `localloc.drv' through LaTeX 2e:} |
| 93 |
\Msg{*} |
| 94 |
\Msg{* \space\space latex localloc.drv} |
| 95 |
\Msg{*} |
| 96 |
\Msg{* Happy TeXing} |
| 97 |
\Msg{***********************************************************} |
| 98 |
\relax\endinput |
| 99 |
%</install> |
| 100 |
% \fi |
| 101 |
% |
| 102 |
% \changes{v1.1b}{95/09/24}{Released after a long sleep in my |
| 103 |
% archives; prefixed some tokens with \cs{lcllc@}.} |
| 104 |
% \changes{v1.1a}{94/10/16}{English documentation; added support for |
| 105 |
% \LaTeXe; added self unpacking archive code.} |
| 106 |
% \changes{v1.0b}{91/09/06}{Error in \cs{newinsert}: consecutive calls |
| 107 |
% return the same insertion register number.} |
| 108 |
% \changes{v1.0a}{91/09/04}{All macros in {plain.tex} replaced.} |
| 109 |
% |
| 110 |
% \DoNotIndex{\fileversion,\filedate,\docdate,\filename} |
| 111 |
% \DoNotIndex{\begingroup,\endgroup,\def,\relax} |
| 112 |
% \DoNotIndex{\ifnum,\ifcase,\else,\fi} |
| 113 |
% \DoNotIndex{\expandafter,\the} |
| 114 |
% \DoNotIndex{\@ne,\m@ne,\next} |
| 115 |
% |
| 116 |
% |
| 117 |
% \newcommand{\PiCTeX}{\protect\pPiCTeX} |
| 118 |
% \newcommand{\pPiCTeX}{\relax |
| 119 |
% P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC\kern-.11em\TeX} |
| 120 |
% |
| 121 |
% |
| 122 |
% \title{An Enhanced Implementation of the Allocation Macros in \LaTeXe, |
| 123 |
% \LaTeX~2.09, and plain-\TeX} |
| 124 |
% \date{\filedate~(\fileversion)} |
| 125 |
% \author{Bernd Raichle\\ |
| 126 |
% Stettener Str.~73\\ |
| 127 |
% D-73732 Esslingen, FRG\\ |
| 128 |
% Email: {\tt [email protected]}} |
| 129 |
% |
| 130 |
% \maketitle |
| 131 |
% |
| 132 |
% \begin{abstract} |
| 133 |
% This style option reimplements the allocation command macros |
| 134 |
% provided by plain-\TeX\ and adds macros to allow allocation |
| 135 |
% of local registers inside groups. |
| 136 |
% \end{abstract} |
| 137 |
% |
| 138 |
%^^A \tableofcontents |
| 139 |
% |
| 140 |
% \section{Introduction} |
| 141 |
% |
| 142 |
% \subsection{Restrictions of {\tt plain.tex}'s Register Allocation Macros} |
| 143 |
% |
| 144 |
% In {\tt plain.tex}, Donald E.\ Knuth writes about the macros for |
| 145 |
% register allocation~\cite[lines 149ff]{plain.tex-3.14159}: |
| 146 |
% \begin{quote} |
| 147 |
% When a register is used only temporarily, it need not be |
| 148 |
% allocated; grouping can be used, making the value previously in |
| 149 |
% the register return after the close of the group. The main use |
| 150 |
% of these macros is for registers that are defined by one macro |
| 151 |
% and used by others, possibly at different nesting levels. All |
| 152 |
% such registers should be defined through these macros; otherwise |
| 153 |
% conflicts may occur, especially when two or more more macro |
| 154 |
% packages are being used at once. |
| 155 |
% \end{quote} |
| 156 |
% Additional remarks can be read in the TeXbook~\cite[p.~346]{DEK91}: |
| 157 |
% \begin{quote} |
| 158 |
% {\it Allocation of registers.\/} The second major part of the |
| 159 |
% {\tt plain.tex} file provides a foundation on which systems of |
| 160 |
% independently developed macros can coexist peacefully without |
| 161 |
% interfering in their usage of registers. The idea is that macro |
| 162 |
% writers should abide by the macro conventions following ground |
| 163 |
% rules: [\ldots] |
| 164 |
% (4)~Furthermore, it's possible to use any register in a group, if |
| 165 |
% you ensure that \TeX's grouping mechanism will restore the |
| 166 |
% register when you're done with the group, and if you are certain |
| 167 |
% that other macros will not make global assignments to that |
| 168 |
% register when you need it. \ |
| 169 |
% (5)~But when a register is used by several macros, or over long |
| 170 |
% spans of time, it should be allocated by \verb+\newcount+, |
| 171 |
% \verb+\newdimen+, \verb+\newbox+, etc. \ (6)~Similar remarks apply |
| 172 |
% [\ldots] |
| 173 |
% to insertions (which require \verb+\box+, \verb+\count+, |
| 174 |
% \verb+\dimen+, and \verb+\skip+ registers all having the same |
| 175 |
% number). |
| 176 |
% \end{quote} |
| 177 |
% |
| 178 |
% This means, that within plain-\TeX\ and all formats based on |
| 179 |
% plain-\TeX\ a user can not allocate a register for temporary use |
| 180 |
% using the given mechanisms. Nonetheless there is often the need |
| 181 |
% for a allocated register which is only used within a rather small |
| 182 |
% piece of document text and should be set free for reuse in the rest |
| 183 |
% of the formatting run: |
| 184 |
% |
| 185 |
% If a macro~\verb+\macroa+ needs a register which should never be |
| 186 |
% destroyed by another macro~\verb+\macrob+ which is called by |
| 187 |
% \verb+\macroa+, you either have to know about the realisation of |
| 188 |
% \verb+\macrob+ or you have to allocate a new register. |
| 189 |
% |
| 190 |
% The name of this newly allocated register is only known to the |
| 191 |
% macro package in which macro~\verb+\macroa+ resides. If you have |
| 192 |
% a lot of macros which needs registers by their own it is possible |
| 193 |
% that all of the 256~registers of one type will be allocated. In |
| 194 |
% most cases it would be possible to share some of these registers by |
| 195 |
% more than one macro because the register is only needed within (an |
| 196 |
% environment delimited by) a group. To share registers---if they are |
| 197 |
% used only locally---it will be necessary to provide a mechanism to |
| 198 |
% allocate registers locally. Unfortunately {\tt plain.tex} and all |
| 199 |
% derived formats, like \LaTeX, misses this mechanism leading to the |
| 200 |
% problem that some macro packages cannot be combined. |
| 201 |
% |
| 202 |
% In the following example it is necessary to call two macros |
| 203 |
% |\macroa| and |macrob| in the same group (e.g.\ because |\macroa| |
| 204 |
% performs special actions at the begin and |\macrob| at the end of |
| 205 |
% an environment). Further you do not have any knowledge about the |
| 206 |
% use of scratch register in |\macroa|, |\macrob| or the text in the |
| 207 |
% argument specified by the user. Therefore it is impossible to use |
| 208 |
% a scratch register to save the current value of |\hsize|; we have |
| 209 |
% to allocate a new register to save it. |
| 210 |
%\begin{verbatim} |
| 211 |
% \newdimen\savedhsize |
| 212 |
%\end{verbatim} |
| 213 |
%\begin{verbatim} |
| 214 |
% \def\callAandB#1{\begingroup |
| 215 |
% \savedhsize=\hsize |
| 216 |
% \hsize=0.8\hsize \macroa |
| 217 |
% #1\relax |
| 218 |
% \hsize=\savedhsize \macrob |
| 219 |
% \endgroup} |
| 220 |
%\end{verbatim} |
| 221 |
% If there will be a mechanism, e.g. by a macro |\lnewdimen|, to |
| 222 |
% allocate a local register it is possible to use this local register |
| 223 |
% inside the group without worrying about possible dependencies |
| 224 |
% between the macros and the user specified text. Additionally after |
| 225 |
% leaving the group, the dimen register will be free to be used by |
| 226 |
% other macros. |
| 227 |
%\begin{verbatim} |
| 228 |
% \def\callAandB#1{\begingroup |
| 229 |
% \lnewdimen\savedhsize \savedhsize=\hsize |
| 230 |
% \hsize=0.8\hsize \macroa |
| 231 |
% #1\relax |
| 232 |
% \hsize=\savedhsize \macrob |
| 233 |
% \endgroup} |
| 234 |
%\end{verbatim} |
| 235 |
% |
| 236 |
% |
| 237 |
% \subsection{Local Register Allocation Macros} |
| 238 |
% |
| 239 |
% \DescribeMacro{\newcount} |
| 240 |
% \DescribeMacro{\newdimen} |
| 241 |
% \DescribeMacro{\newskip} |
| 242 |
% \DescribeMacro{\newbox} |
| 243 |
% {\let\newinsert=\relax \DescribeMacro{\newinsert}}^^A |
| 244 |
% When using this reimplementation of the allocation macros, the {\tt |
| 245 |
% plain.tex} macros |\newcount|, |\newdimen|, |\newskip|, and |
| 246 |
% |\newbox| will have a changed behaviour in two aspects: |
| 247 |
% \begin{itemize} |
| 248 |
% \item Do not assume that registers which are allocated consecutively |
| 249 |
% have consecutive register numbers. In general you should not |
| 250 |
% make any assumption about the order of register numbers. |
| 251 |
% \item It is possible that a register was locally allocated and used |
| 252 |
% in the past. After leaving the group the register is set to free |
| 253 |
% and the old value---normally zero---is restored. Nonetheless |
| 254 |
% you should not assume that a newly allocated register is |
| 255 |
% initialised with the value zero. |
| 256 |
% \end{itemize} |
| 257 |
% |
| 258 |
% {\let\newmuskip=\relax \DescribeMacro{\newmuskip}} |
| 259 |
% {\let\newtoks=\relax \DescribeMacro{\newtoks}}^^A |
| 260 |
% The behaviour of the macros |\newmuskip| and |\newtoks| are not |
| 261 |
% changed because they are not used for insertions. Nonetheless this |
| 262 |
% can be changed in a future version. |
| 263 |
% |
| 264 |
% \DescribeMacro{\lnewcount} |
| 265 |
% \DescribeMacro{\lnewdimen} |
| 266 |
% \DescribeMacro{\lnewskip} |
| 267 |
% \DescribeMacro{\lnewmuskip} |
| 268 |
% \DescribeMacro{\lnewbox} |
| 269 |
% \DescribeMacro{\lnewtoks} |
| 270 |
% |\lnewcount|, |\lnewdimen|, |\lnewskip|, |\lnewmuskip|, |\lnewbox|, |
| 271 |
% and |\lnewtoks| are the set of new macros to allocate registers |
| 272 |
% within the scope of the current group. At the end of the current |
| 273 |
% group the allocated register is freed. |
| 274 |
% |
| 275 |
% As with their global counterparts you should not assume that the |
| 276 |
% registers are allocated in a consecutive order---neither increasing |
| 277 |
% nor decreasing---or that the allocated register is initialised with |
| 278 |
% zero. |
| 279 |
% |
| 280 |
% |
| 281 |
% \subsection{Usage Examples} |
| 282 |
% |
| 283 |
% \subsubsection{\LaTeX's Picture Environment} |
| 284 |
% |
| 285 |
% \LaTeX's picture environment uses the box register |\@picbox| and |
| 286 |
% the dimen register |\@picht| to save the contents of a picture and |
| 287 |
% the user specified height of this picture at the beginning of the |
| 288 |
% environment. These two registers are set at the beginning and used |
| 289 |
% at the end of the |picture| environment. Because the two registers |
| 290 |
% are used nowhere else, it is possible to share them by only |
| 291 |
% allocating them within the environment. |
| 292 |
% |
| 293 |
% This is the simplified code for the |\begin{picture}| and |
| 294 |
% |\end{picture}| commands; the macros |\begin| and |\end| start and |
| 295 |
% end a new group: |
| 296 |
%\begin{verbatim} |
| 297 |
%\newbox\@picbox |
| 298 |
%\newdimen\@picht |
| 299 |
%\end{verbatim} |
| 300 |
%\begin{verbatim} |
| 301 |
%\def\picture(#1,#2){% |
| 302 |
% \@picht = #2\unitlength % save picture height |
| 303 |
% \setbox\@picbox = \hbox to #1\unitlength\bgroup |
| 304 |
% \ignorespaces} |
| 305 |
%\end{verbatim} |
| 306 |
%\begin{verbatim} |
| 307 |
%\def\endpicture{% |
| 308 |
% \hss |
| 309 |
% \egroup % close picture box |
| 310 |
% \ht\@picbox = \@picht % set box height to save picture height |
| 311 |
% \dp\@picbox = 0pt % set box depth to 0pt |
| 312 |
% \mbox{\box\@picbox}} % output this box |
| 313 |
%\end{verbatim} |
| 314 |
% |
| 315 |
% Using the new local allocation macros the code changes is simple: |
| 316 |
% Move the |\newbox| and |\newdimen| command within the |\picture| |
| 317 |
% macro definition and rename them to |\lnewbox| and |\lnewdimen|: |
| 318 |
%\begin{verbatim} |
| 319 |
% %\newbox\@picbox |
| 320 |
% %\newdimen\@picht |
| 321 |
%\end{verbatim} |
| 322 |
%\begin{verbatim} |
| 323 |
%\def\picture(#1,#2){% |
| 324 |
% \lnewbox\@picbox |
| 325 |
% \lnewdimen\@picht |
| 326 |
% \@picht = #2\unitlength % save picture height |
| 327 |
% \setbox\@picbox = \hbox to #1\unitlength\bgroup |
| 328 |
% \ignorespaces} |
| 329 |
%\end{verbatim} |
| 330 |
% |
| 331 |
% Additionally we can use a property of the usage pattern of these |
| 332 |
% two registers: |
| 333 |
% Within a nested use of the |picture| environment---you can use |
| 334 |
% subpictures within a picture---these registers are allocated for |
| 335 |
% each nesting level. This is not really necessary because the box |
| 336 |
% and the dimen register is always used in a group and is never |
| 337 |
% changed globally. |
| 338 |
% It is possible to add tests to avoid a (local) reallocation of |
| 339 |
% these registers: |
| 340 |
%\begin{verbatim} |
| 341 |
%\let\@picbox=\relax % mark register as not yet allocated |
| 342 |
%\let\@picht =\relax % mark register as not yet allocated |
| 343 |
%\end{verbatim} |
| 344 |
%\begin{verbatim} |
| 345 |
%\def\picture(#1,#2){% |
| 346 |
% \ifx\@picbox\relax \lnewbox\@picbox \fi |
| 347 |
% \ifx\@picht\relax \lnewdimen\@picht \fi |
| 348 |
% \@picht = #2\unitlength % save picture height |
| 349 |
% \setbox\@picbox = \hbox to #1\unitlength\bgroup |
| 350 |
% \ignorespaces} |
| 351 |
%\end{verbatim} |
| 352 |
% |
| 353 |
% |
| 354 |
% \subsubsection{\LaTeX's {\tt\protect\bslash multiput} Macro} |
| 355 |
% |
| 356 |
% Another example of registers which are used only in one rarely |
| 357 |
% used macro, are the count register |\@multicnt| and the two dimen |
| 358 |
% registers |\@xdim| and |\@ydim| for the |\multiput| command. To |
| 359 |
% change it according to the scheme above you have to insert an |
| 360 |
% additional grouping. |
| 361 |
% |
| 362 |
% In \LaTeXe\ these three rarely used registers and some more are |
| 363 |
% shared with the |\bezier| command, whose definition has to be |
| 364 |
% changed accordingly. This shows the need---and advantage---of a |
| 365 |
% better allocation scheme. |
| 366 |
% |
| 367 |
% \subsubsection{\PiCTeX} |
| 368 |
% |
| 369 |
% The macro package \PiCTeX\ uses a lot of dimen registers. A subset |
| 370 |
% of these registers are only used within a picture or within a set |
| 371 |
% of drawing and parameter setting commands. |
| 372 |
% |
| 373 |
% As an example the dimen registers |\totalarclength| is only used in |
| 374 |
% a very restrictic set of commands, i.e., it can be allocated within |
| 375 |
% the scope of the higher level commands or within \PiCTeX's |
| 376 |
% |\beginpicture| \ldots\ |\endpicture| environment. |
| 377 |
% |
| 378 |
% |
| 379 |
% \StopEventually{^^A |
| 380 |
% \begin{thebibliography}{0} |
| 381 |
% \bibitem{DEK91} Donald E.\ Knuth, |
| 382 |
% {\it The \TeX{}book}, |
| 383 |
% Addison-Wesley Publ., Reading, Mass., Juni 1991. |
| 384 |
% \bibitem{plain.tex-3.14159} File {\tt plain.tex}, |
| 385 |
% version 3.14159, |
| 386 |
% March 1995. |
| 387 |
% \end{thebibliography} |
| 388 |
% } |
| 389 |
% |
| 390 |
% |
| 391 |
% |
| 392 |
% \section{Implementation} |
| 393 |
% |
| 394 |
% |
| 395 |
% \subsection{Prolog, \LaTeXe\ Package Declarations, etc.} |
| 396 |
% |
| 397 |
% The very first thing we do is to ensure that this file is not |
| 398 |
% read in twice. To this end we check whether the macro |
| 399 |
% |\lnewcount| is defined. If so, we just stop reading this file. |
| 400 |
% \begin{macrocode} |
| 401 |
%<+package>\expandafter\ifx\csname lnewcount\endcsname\relax |
| 402 |
%<+package>\else \expandafter\endinput \fi |
| 403 |
% \end{macrocode} |
| 404 |
% |
| 405 |
% For the sake of \LaTeXe\ users declarations for this package are |
| 406 |
% included. The additional group hack is needed to prevent the |
| 407 |
% definition of |\ProvidesPackage| as |\relax| if it is undefined. |
| 408 |
% \begin{macrocode} |
| 409 |
%<+package|test>\begingroup\expandafter\expandafter\expandafter\endgroup |
| 410 |
%<+package|test>\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 411 |
%<+package|test>\else |
| 412 |
\NeedsTeXFormat{LaTeX2e} |
| 413 |
%<+package> \ProvidesPackage{localloc}% |
| 414 |
%<+test> \ProvidesFile{localtst.tex}% |
| 415 |
%<*!package&!test> |
| 416 |
\ProvidesFile{localloc.dtx}% |
| 417 |
%</!package&!test> |
| 418 |
[1995/09/24 v1.1b % |
| 419 |
Additional LaTeX Kernel Macros (local allocation)] |
| 420 |
%<+package|test>\fi |
| 421 |
% \end{macrocode} |
| 422 |
% |
| 423 |
% \begin{macrocode} |
| 424 |
%<*package> |
| 425 |
% \end{macrocode} |
| 426 |
% |
| 427 |
% To allow the use of this file within a plain-\TeX\ job, we have |
| 428 |
% to change the category code of the `at' character~{\tt @}. |
| 429 |
% \begin{macrocode} |
| 430 |
\expandafter\chardef\csname lcllc@at\endcsname=\catcode`\@ |
| 431 |
\catcode`\@=11 % \makeatletter |
| 432 |
% \end{macrocode} |
| 433 |
% |
| 434 |
% |
| 435 |
% \subsection{Accessing the {\tt muskip} registers} |
| 436 |
% |
| 437 |
% Beside the well-known \TeX\ registers, like |\count| or |\box|, |
| 438 |
% there is another set of registers which are used only in few |
| 439 |
% macros. The |\muskip| registers are normally used in math mode |
| 440 |
% only and the coercion of the value in a |\muskip| register to an |
| 441 |
% integer (|\count|), dimension (|\dimen|), or glue (|\glue|) |
| 442 |
% produces an error. |
| 443 |
% |
| 444 |
% The unit of a |\muskip| value is~$1$\,mu---there are $18$\,mu in |
| 445 |
% $1$\,em of the current font in {\em math family~2}. If you |
| 446 |
% assign a value to a |\muskip| register, this value is represented |
| 447 |
% in the unit~mu, not in~pt. The dimension of the |\muskip| value |
| 448 |
% is computed, if this value is used by |\mskip| or |\mkern|. |
| 449 |
% |
| 450 |
% To use a |\muskip| register as a replacement for a |\count| |
| 451 |
% register, it is necessary to do assignments, additions, and other |
| 452 |
% operations in units of~mu. If you want to coerce an |
| 453 |
% integer to a |\muskip| register, you have to get the value with |
| 454 |
% |\the| and add the keyword~|mu| while scanning the number. To get |
| 455 |
% the integer value of a |\muskip| register, you can use the |
| 456 |
% following macro~|\lcllc@cnvmutocnt|. |
| 457 |
% |
| 458 |
% \begin{macro}{\lcllc@cnvmutocnt} |
| 459 |
% The macro |\lcllc@cnvmutocnt| ist called with a |\muskip| register |
| 460 |
% or a value in~|mu| units as its argument. It will expand to the |
| 461 |
% integer value. To get the value of a register, we first expand |
| 462 |
% the value of this register to a list of tokens with \TeX's |\the| |
| 463 |
% primitive. |
| 464 |
% Example: if the register has the value~$3.4$\,mu, the expansion of |
| 465 |
% |\the| produces the tokens $\mbox{\tt 3}_{12} \mbox{\tt .}_{12} |
| 466 |
% \mbox{\tt 4}_{12} \mbox{\tt m}_{12} \mbox{\tt u}_{12}$. |
| 467 |
% \begin{macrocode} |
| 468 |
\def\lcllc@cnvmutocnt#1{\expandafter\lcllc@delmukey\the#1} |
| 469 |
% \end{macrocode} |
| 470 |
% |
| 471 |
% After we have expanded the value of the register, it is necessary |
| 472 |
% to strip of the unit keyword~|mu| and the fraction of the value. |
| 473 |
% To do this, we have to use tokens with {\em category code}~12 to |
| 474 |
% match the expansion string produced by~|\the|. |
| 475 |
% \begin{macrocode} |
| 476 |
\begingroup \catcode`\M=12 \catcode`\U=12 \catcode`\.=12 |
| 477 |
\lowercase{\endgroup |
| 478 |
\def\lcllc@delmukey#1.#2MU{#1}} |
| 479 |
% \end{macrocode} |
| 480 |
% \end{macro} |
| 481 |
% |
| 482 |
% |
| 483 |
% \subsection{Allocation registers} |
| 484 |
% |
| 485 |
% \subsubsection{Registers defined in {\tt plain.tex}} |
| 486 |
% |
| 487 |
% Plain-\TeX's allocation macros use a fixed set of |count| |
| 488 |
% registers containing a set of numbers with the highest allocated |
| 489 |
% register number. To make the following macro code more readable, |
| 490 |
% alias names for these |count| registers are defined. |
| 491 |
% \begin{macrocode} |
| 492 |
\countdef\count@ptr = 10 |
| 493 |
\countdef\dimen@ptr = 11 |
| 494 |
\countdef\skip@ptr = 12 |
| 495 |
\countdef\muskip@ptr = 13 |
| 496 |
\countdef\box@ptr = 14 |
| 497 |
\countdef\toks@ptr = 15 |
| 498 |
\countdef\read@ptr = 16 |
| 499 |
\countdef\write@ptr = 17 |
| 500 |
\countdef\mathfam@ptr = 18 |
| 501 |
% \end{macrocode} |
| 502 |
% {\tt plain.tex} for \TeX~3 introduces a new allocation command |
| 503 |
% needing an additional allocation count register. To simplify the |
| 504 |
% code of this package with older versions of {\tt plain.tex}, a |
| 505 |
% dummy count register is allocated and used. |
| 506 |
% \begin{macrocode} |
| 507 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 508 |
\expandafter\ifx\csname newlanguage\endcsname\relax |
| 509 |
\csname newcount\endcsname\language@ptr |
| 510 |
\else |
| 511 |
\countdef\language@ptr = 19 |
| 512 |
\fi |
| 513 |
% \end{macrocode} |
| 514 |
% |
| 515 |
% The allocation command for insertion uses another register, which |
| 516 |
% is already aliased as |\insc@unt|. |
| 517 |
%\begin{verbatim} |
| 518 |
%\countdef\insc@unt = 20 % = 19 in older versions of `plain.tex' |
| 519 |
%\end{verbatim} |
| 520 |
% |
| 521 |
% |
| 522 |
% \subsubsection{Additional Registers} |
| 523 |
% |
| 524 |
% For the new local allocation macros additional registers are |
| 525 |
% needed containing the boundaries for all types of locally |
| 526 |
% allocated registers. Whereas all globally allocated registers |
| 527 |
% are located in the lower region of the register numbers (with the |
| 528 |
% exception of the set of registers needed for an insertion), |
| 529 |
% locally allocated registers are taken from the higher region of |
| 530 |
% the register numbers---from top towards the bottom. |
| 531 |
% |
| 532 |
% To avoid using six additional count registers we use |\muskip| |
| 533 |
% registers to save the current lower boundary of the allocatable |
| 534 |
% register region. These boundaries are initialised either |
| 535 |
% with~$256$ or the actual boundary of the insertion allocation |
| 536 |
% register. |
| 537 |
% \begin{macrocode} |
| 538 |
\newmuskip\count@limit \count@limit = \the\insc@unt mu |
| 539 |
\newmuskip\dimen@limit \dimen@limit = \the\insc@unt mu |
| 540 |
\newmuskip\skip@limit \skip@limit = \the\insc@unt mu |
| 541 |
\newmuskip\box@limit \box@limit = \the\insc@unt mu |
| 542 |
\newmuskip\muskip@limit \muskip@limit = 256mu |
| 543 |
\newmuskip\toks@limit \toks@limit = 256mu |
| 544 |
% \end{macrocode} |
| 545 |
% |
| 546 |
% To simplify the code of the following allocation macros and to |
| 547 |
% save macro space, two additional |\muskip| registers are |
| 548 |
% allocated and initialised with the constants $16$ and~$256$. |
| 549 |
% \begin{macrocode} |
| 550 |
\newmuskip\cclvi@mu \cclvi@mu = 256mu |
| 551 |
\newmuskip\xvi@mu \xvi@mu = 16mu |
| 552 |
% \end{macrocode} |
| 553 |
% |
| 554 |
% |
| 555 |
% \subsection{Allocation Macros for the ``End User''} |
| 556 |
% |
| 557 |
% \subsubsection{Global Allocation Macros} |
| 558 |
% |
| 559 |
% \begin{macro}{\newcount} \begin{macro}{\newdimen} |
| 560 |
% \begin{macro}{\newskip} \begin{macro}{\newmuskip} |
| 561 |
% \begin{macro}{\newbox} \begin{macro}{\newtoks} |
| 562 |
% \begin{macro}{\newread} \begin{macro}{\newwrite} |
| 563 |
% \begin{macro}{\newfam} \begin{macro}{\newlanguage} |
| 564 |
% We have to replace the original macros in {\tt plain.tex} by new |
| 565 |
% ones to allow locally allocated registers. Otherwise it will be |
| 566 |
% possible that the two regions, the lower one with globally |
| 567 |
% allocated registers and the higher one with locally allocated |
| 568 |
% registers, will overlap resulting in a double use of the same |
| 569 |
% register. |
| 570 |
% |
| 571 |
% With the new macros it will be unnecessary to un-outer the {\tt |
| 572 |
% plain.tex} macros, because the local allocation macros have to be |
| 573 |
% non outer. Nonetheless we want to use this package in |
| 574 |
% conjunction with \LaTeX\ and therefore we have to define some of |
| 575 |
% them as non outer. |
| 576 |
% |
| 577 |
% The top level macros use the low level macro |\alloc@| which has |
| 578 |
% the following parameters: |
| 579 |
% The boundaries of the lower and the higher region, the type of |
| 580 |
% the allocated register, a flag if we have to check on overlapping |
| 581 |
% with insertion registers, the \TeX\ primitive to be used to |
| 582 |
% define this register, and the user given control sequence. |
| 583 |
% \begin{macrocode} |
| 584 |
%\outer |
| 585 |
\def\newcount {\alloc@\count@ptr \count@limit \count 1\countdef } |
| 586 |
%\outer |
| 587 |
\def\newdimen {\alloc@\dimen@ptr \dimen@limit \dimen 1\dimendef } |
| 588 |
%\outer |
| 589 |
\def\newskip {\alloc@\skip@ptr \skip@limit \skip 1\skipdef } |
| 590 |
% \outer |
| 591 |
\def\newmuskip {\alloc@\muskip@ptr \muskip@limit\muskip 0\muskipdef} |
| 592 |
%\outer |
| 593 |
\def\newbox {\alloc@\box@ptr \box@limit \box 1\chardef } |
| 594 |
% \outer |
| 595 |
\def\newtoks {\alloc@\toks@ptr \toks@limit \toks 0\toksdef } |
| 596 |
% \outer |
| 597 |
\def\newread {\alloc@\read@ptr \xvi@mu \read 0\chardef } |
| 598 |
%\outer |
| 599 |
\def\newwrite {\alloc@\write@ptr \xvi@mu \write 0\chardef } |
| 600 |
%\outer |
| 601 |
\def\newfam {\alloc@\mathfam@ptr\xvi@mu \fam 0\chardef } |
| 602 |
% \outer |
| 603 |
\def\newlanguage{\alloc@\lang@ptr \cclvi@mu \language0\chardef } |
| 604 |
% \end{macrocode} |
| 605 |
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} |
| 606 |
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} |
| 607 |
% |
| 608 |
% |\newinsert| needs additional code because this macro has to |
| 609 |
% allocate a set of |\box|, |\count|, |\dimen|, and |\skip| |
| 610 |
% registers with the restriction that all registers have to have |
| 611 |
% the same number. |\newinsert| is redefined at the end of this |
| 612 |
% file. |
| 613 |
% |
| 614 |
% |
| 615 |
% \subsubsection{Local Allocation Macros} |
| 616 |
% |
| 617 |
% |
| 618 |
% \begin{macro}{\lnewcount} \begin{macro}{\lnewdimen} |
| 619 |
% \begin{macro}{\lnewskip} \begin{macro}{\lnewmuskip} |
| 620 |
% \begin{macro}{\lnewbox} \begin{macro}{\lnewtoks} |
| 621 |
% There is an equivalent set of macros to allocate registers |
| 622 |
% locally. Instead of using the low level macro |\alloc@| it uses |
| 623 |
% the macro |\lalloc@| with the same set of parameters. |
| 624 |
% \begin{macrocode} |
| 625 |
\def\lnewcount {\lalloc@\count@ptr \count@limit \count 1\countdef } |
| 626 |
\def\lnewdimen {\lalloc@\dimen@ptr \dimen@limit \dimen 1\dimendef } |
| 627 |
\def\lnewskip {\lalloc@\skip@ptr \skip@limit \skip 1\skipdef } |
| 628 |
\def\lnewmuskip{\lalloc@\muskip@ptr\muskip@limit\muskip 0\muskipdef} |
| 629 |
\def\lnewbox {\lalloc@\box@ptr \box@limit \box 1\chardef } |
| 630 |
\def\lnewtoks {\lalloc@\toks@ptr \toks@limit \toks 0\toksdef } |
| 631 |
% \end{macrocode} |
| 632 |
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro} |
| 633 |
% |
| 634 |
% Local allocation macros for |\read|, |\write| streams, math |
| 635 |
% |\fam|, |language| numbers, or insertions are possible but not |
| 636 |
% very useful because of the global nature of these resources. |
| 637 |
% |
| 638 |
% |
| 639 |
% \subsection{Low Level Allocation Macros} |
| 640 |
% |
| 641 |
% The allocation scheme used by the macros in {\tt plain.tex} is |
| 642 |
% simple: |
| 643 |
% \begin{itemize} |
| 644 |
% \item all allocations are global, |
| 645 |
% \item register, math family, language, input/output stream |
| 646 |
% numbers are allocated using the lowest possible number, i.e., |
| 647 |
% it is done from lower number to higher numbers, |
| 648 |
% \item the set of insertion registers (|box|, |count|, |skip|, and |
| 649 |
% |dimen|), which have to have the same register number, are |
| 650 |
% allocated beginning from~$255$ to lower numbers. |
| 651 |
% \end{itemize} |
| 652 |
% |
| 653 |
% Contrary to this simple scheme this package uses numbers for |
| 654 |
% locally allocated registers from top to bottom interfering with |
| 655 |
% the original insertion register allocation scheme {\it and\/} the |
| 656 |
% simple test for a register number overflow. |
| 657 |
% |
| 658 |
% \begin{macro}{\lcllc@insnums} |
| 659 |
% Insertion registers are now allocated in a non-monotonous order |
| 660 |
% using the lowest possible number (because the allocation of the |
| 661 |
% needed set of registers is done in a global way). To allow the |
| 662 |
% checking of overlapping of globally or locally allocated |
| 663 |
% registers with the registers used for insertions, the insertion |
| 664 |
% register numbers are saved as a list in |\lcllc@insnums|. |
| 665 |
% Each entry in this list is saved as \mbox{\tt\string\do$\langle |
| 666 |
% n\rangle$.}; the list is initialised as empty. |
| 667 |
% \begin{macrocode} |
| 668 |
\def\lcllc@insnums{} |
| 669 |
% \end{macrocode} |
| 670 |
% \end{macro} |
| 671 |
% |
| 672 |
% \begin{macro}{\lcllc@checkins} |
| 673 |
% Whenever a new |box|, |count|, |skip|, or |dimen| register is |
| 674 |
% allocated it has to be checked first, if the next possible |
| 675 |
% free register is already allocated for an insertion. |
| 676 |
% |
| 677 |
% To detect a collision between a possibly free register number and |
| 678 |
% the set of insertion registers, the macro |\lcllc@checkins| is |
| 679 |
% called with the register number to be tested in |
| 680 |
% |\allocationnumber|. The argument of this macro has to be either |
| 681 |
% $1$ or~$-1$ and is used to get the next register number to be |
| 682 |
% tested against the insertion number list if an additional |
| 683 |
% iteration is needed. The result is a register number in |
| 684 |
% |\allocationnumber| which is not used for an insertion. (Note: |
| 685 |
% Nonetheless it can be an out-of-region register number of an |
| 686 |
% already used register!) |
| 687 |
% \begin{macrocode} |
| 688 |
\def\lcllc@checkins#1{% |
| 689 |
\begingroup |
| 690 |
% \end{macrocode} |
| 691 |
% After opening a new group, the macro |\do| is defined to read the |
| 692 |
% next insertion number delimited by a simple dot. It then tests |
| 693 |
% this number against the current |\allocationnumber| and if the |
| 694 |
% register numbers are equal, |\allocationnumber| is advanced by the |
| 695 |
% given argument (which is $1$ or~$-1$). |
| 696 |
% |
| 697 |
% To avoid a global change of |\allocationnumber|, a group hack |
| 698 |
% with expansion is used: If the list |\lcllc@insnums| is expanded |
| 699 |
% with this definition of |\do|, the result is empty if the |
| 700 |
% register number is not used for an insertion. Otherwise it |
| 701 |
% expands to the |\advance| command followed by an additional |
| 702 |
% |lcllc@checkins| (which has to be protected by |\noexpand|) to |
| 703 |
% start another iteration with the changed |\allocationnumber|. |
| 704 |
% \begin{macrocode} |
| 705 |
\def\do##1.{% |
| 706 |
\ifnum##1=\allocationnumber |
| 707 |
\advance\allocationnumber#1\relax |
| 708 |
\noexpand\lcllc@checkins{#1}% |
| 709 |
\fi}% |
| 710 |
% \end{macrocode} |
| 711 |
% The following expanded definition text of |\x| contains code to |
| 712 |
% close the group and the expansion of |\lcllc@insnums|, which is |
| 713 |
% either empty or contains the change of |\allocationnumber| and an |
| 714 |
% iterative call of |\lcllc@checkins|. After the definition is |
| 715 |
% completed, the code is executed which closes the group. |
| 716 |
% \begin{macrocode} |
| 717 |
\edef\x{\endgroup \lcllc@insnums}% |
| 718 |
\x} |
| 719 |
% \end{macrocode} |
| 720 |
% \end{macro} |
| 721 |
% |
| 722 |
% |
| 723 |
% \begin{macro}{\alloc@} |
| 724 |
% |\alloc@| is the low level macro for global allocation, which is |
| 725 |
% called with six arguments. The macro itself only uses the first |
| 726 |
% four argument: The two boundaries, the item type to be allocated, |
| 727 |
% and a flag if this item is propably used for an insertion. The |
| 728 |
% remaining two arguments, the \TeX\ primitive and the control |
| 729 |
% sequence to assign the allocated number is used by |
| 730 |
% |\lcllc@def|. |
| 731 |
% \begin{macrocode} |
| 732 |
\def\alloc@#1#2#3#4{% |
| 733 |
% \end{macrocode} |
| 734 |
% In the first step we assign the boundary of the lower region for |
| 735 |
% this item type to |\allocationnumber| and increment it by one. |
| 736 |
% \begin{macrocode} |
| 737 |
\allocationnumber#1% |
| 738 |
\advance\allocationnumber\@ne |
| 739 |
% \end{macrocode} |
| 740 |
% If this item type is used by insertion, we have to check for |
| 741 |
% collision with the |\lcllc@checkins| macro. After the execution of |
| 742 |
% this macro, |\allocationnumber| contains the next free number to |
| 743 |
% be used for allocation. This number is assigned globally to the |
| 744 |
% register containing the boundary. |
| 745 |
% \begin{macrocode} |
| 746 |
\ifnum#4=\@ne \lcllc@checkins\@ne \fi |
| 747 |
\global#1\allocationnumber |
| 748 |
% \end{macrocode} |
| 749 |
% We now have found an unused register. Nonetheless it is possible |
| 750 |
% that the register number is either not in the range of existing |
| 751 |
% register number or it is used for a locally allocated register. |
| 752 |
% |\ch@ck| is used to test these things. |
| 753 |
% \begin{macrocode} |
| 754 |
\ch@ck#1#2#3% |
| 755 |
% \end{macrocode} |
| 756 |
% At the end the \meta{control sequence} is defined using the |
| 757 |
% found |\allocationnumber|. |
| 758 |
% \begin{macrocode} |
| 759 |
\lcllc@def\global{}#3} |
| 760 |
% \end{macrocode} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% |
| 764 |
% \begin{macro}{\lalloc@} |
| 765 |
% |\lalloc@| is the low level macro for local allocation. The |
| 766 |
% definition of this macro a copy of |\alloc@| with some small |
| 767 |
% changes. |
| 768 |
% \begin{macrocode} |
| 769 |
\def\lalloc@#1#2#3#4{% |
| 770 |
% \end{macrocode} |
| 771 |
% In the first step we assign the boundary of the {\it higher\/} |
| 772 |
% region and {\it decrement\/} it by one. Because the higher |
| 773 |
% boundary is saved in a |\muskip| register, we have to use |
| 774 |
% |\lcllc@cnvmutocnt| to get the boundary value. |
| 775 |
% \begin{macrocode} |
| 776 |
\allocationnumber\lcllc@cnvmutocnt#2% |
| 777 |
\advance\allocationnumber\m@ne |
| 778 |
% \end{macrocode} |
| 779 |
% The check for insertion number collisions is called with~$-1$ to |
| 780 |
% decrement the register number to get the next free register |
| 781 |
% number. The |\allocationnumber| is then assigned {\it locally\/} |
| 782 |
% to the |\muskip| register containing the boundary. |
| 783 |
% \begin{macrocode} |
| 784 |
\ifnum#4=\@ne \lcllc@checkins\m@ne \fi |
| 785 |
#2\the\allocationnumber mu % |
| 786 |
% \end{macrocode} |
| 787 |
% The check for an already used globally allocated register or a |
| 788 |
% range underflow is needed, too. |
| 789 |
% \begin{macrocode} |
| 790 |
\ch@ck#1#2#3% |
| 791 |
% \end{macrocode} |
| 792 |
% At the end the \meta{control sequence} is defined using the |
| 793 |
% found |\allocationnumber|. |
| 794 |
% \begin{macrocode} |
| 795 |
\lcllc@def\relax{(local)}#3} |
| 796 |
% \end{macrocode} |
| 797 |
% \end{macro} |
| 798 |
% |
| 799 |
% |
| 800 |
% \begin{macro}{\ch@ck} |
| 801 |
% The test macro |\ch@ck| for a collision of the globally and |
| 802 |
% locally allocated registers from {\tt plain.tex} has to be |
| 803 |
% changed because the higher boundary is given as a |\muskip| value |
| 804 |
% instead of a normal integer. |
| 805 |
% \begin{macrocode} |
| 806 |
\def\ch@ck#1#2#3{% |
| 807 |
\ifnum#1<\lcllc@cnvmutocnt#2\relax \else |
| 808 |
\errmessage{No room for a new #3}% |
| 809 |
% \allocationnumber\m@ne |
| 810 |
\fi} |
| 811 |
% \end{macrocode} |
| 812 |
% \end{macro} |
| 813 |
% |
| 814 |
% |
| 815 |
% \begin{macro}{\lcllc@def} |
| 816 |
% |\lcllc@def| is used to assign the found |\allocationnumber| |
| 817 |
% to the \meta{control sequence} using the \TeX\ primitive. |
| 818 |
% Additionally an entry is written to the {\tt log} file. |
| 819 |
% \begin{macrocode} |
| 820 |
\def\lcllc@def#1#2#3#4#5{% |
| 821 |
#1#4#5=\allocationnumber |
| 822 |
\wlog{\string#5#2=\string#3\the\allocationnumber}} |
| 823 |
% \end{macrocode} |
| 824 |
% \end{macro} |
| 825 |
% |
| 826 |
% |
| 827 |
% \subsubsection{Low Level Insertion Allocation Macros} |
| 828 |
% |
| 829 |
% Insertions need a set of registers with the same register number. |
| 830 |
% To find a new register number when allocating an insertion, we |
| 831 |
% have to get the maximum of all boundaries used for an insertion. |
| 832 |
% |
| 833 |
% \begin{macro}{\lcllc@getmax} |
| 834 |
% |\lcllc@getmax| is used to assign |\allocationnumber| to the |
| 835 |
% maximum of |\allocationnumber| and its argument. |
| 836 |
% \begin{macrocode} |
| 837 |
\def\lcllc@getmax#1{% |
| 838 |
\ifnum#1<\allocationnumber \else |
| 839 |
\allocationnumber#1\advance\allocationnumber\@ne |
| 840 |
\fi} |
| 841 |
% \end{macrocode} |
| 842 |
% \end{macro} |
| 843 |
% |
| 844 |
% \begin{macro}{\newinsert} |
| 845 |
% |\newinsert| globally allocates a set of registers used for an |
| 846 |
% insertion. |
| 847 |
% \begin{macrocode} |
| 848 |
\outer\def\newinsert{% |
| 849 |
% \end{macrocode} |
| 850 |
% First we have to find the maximum of all globally allocated |
| 851 |
% register number used for an insertion. We start |
| 852 |
% by setting |\allocationnumber| to~$-1$\,\ldots |
| 853 |
% \begin{macrocode} |
| 854 |
\allocationnumber\m@ne |
| 855 |
% \end{macrocode} |
| 856 |
% \ldots\,and get the maxmimum of the boundaries for |count|, |
| 857 |
% |dimen|, |skip|, and |box| registers. |
| 858 |
% \begin{macrocode} |
| 859 |
\lcllc@getmax\count@ptr \lcllc@getmax\dimen@ptr |
| 860 |
\lcllc@getmax\skip@ptr \lcllc@getmax\box@ptr |
| 861 |
% \end{macrocode} |
| 862 |
% Then we have to check if this |\allocationnumber| is already used |
| 863 |
% for another insertion. |
| 864 |
% \changes{v1.0b}{91/09/06}{\cs{lcllc@checkins} inserted} |
| 865 |
% \begin{macrocode} |
| 866 |
\lcllc@checkins\@ne |
| 867 |
% \end{macrocode} |
| 868 |
% At last we have to check if this |\allocationnumber| is used for |
| 869 |
% one of the locally allocated registers. |
| 870 |
% \begin{macrocode} |
| 871 |
\ch@ck\allocationnumber\count@limit\count |
| 872 |
\ch@ck\allocationnumber\dimen@limit\dimen |
| 873 |
\ch@ck\allocationnumber\skip@limit\skip |
| 874 |
\ch@ck\allocationnumber\box@limit\box |
| 875 |
% \end{macrocode} |
| 876 |
% The found register number for insertions is then (globally) |
| 877 |
% inserted into the list of insertion numbers. |
| 878 |
% \begin{macrocode} |
| 879 |
\begingroup |
| 880 |
\let\do\relax |
| 881 |
\xdef\lcllc@insnums{\do\the\allocationnumber.\lcllc@insnums}% |
| 882 |
\endgroup |
| 883 |
% \end{macrocode} |
| 884 |
% At the end the \meta{control sequence} is defined using the |
| 885 |
% found |\allocationnumber|. |
| 886 |
% \begin{macrocode} |
| 887 |
\lcllc@def\global{}\insert\chardef} |
| 888 |
% \end{macrocode} |
| 889 |
% \end{macro} |
| 890 |
% |
| 891 |
% The register |\insc@unt| which is used to contain the boundary |
| 892 |
% number for insertion registers in the original {\tt plain.tex} |
| 893 |
% macro is not used anymore. |
| 894 |
% |
| 895 |
% |
| 896 |
% Finally, the category code of the `at' character~{\tt @} is reset |
| 897 |
% to its original value. |
| 898 |
% \begin{macrocode} |
| 899 |
\catcode`\@=\lcllc@at |
| 900 |
% \end{macrocode} |
| 901 |
% |
| 902 |
% \begin{macrocode} |
| 903 |
%</package> |
| 904 |
% \end{macrocode} |
| 905 |
% |
| 906 |
% |
| 907 |
% \iffalse |
| 908 |
%<*driver> |
| 909 |
\NeedsTeXFormat{LaTeX2e} |
| 910 |
\documentclass[a4paper]{ltxdoc} |
| 911 |
\GetFileInfo{localloc.dtx} |
| 912 |
\begin{document} |
| 913 |
\DocInput{\filename} |
| 914 |
\end{document} |
| 915 |
%</driver> |
| 916 |
% \fi |
| 917 |
% |
| 918 |
% \iffalse |
| 919 |
% |
| 920 |
% \section{Test File} |
| 921 |
% |
| 922 |
% A first version of a test file which can be used for plain-TeX, |
| 923 |
% \LaTeX~2.09, and \LaTeXe. The result shows the allocated register |
| 924 |
% numbers. You should notice that the insertions and global box |
| 925 |
% registers are not contiguously allocated but interfere. Further |
| 926 |
% from one to the next line there is a new global register number |
| 927 |
% greater than the former one. Whereas the local register numbers |
| 928 |
% are set to zero when leaving a group and they are recycled in the |
| 929 |
% next lines. |
| 930 |
% |
| 931 |
% \begin{macrocode} |
| 932 |
%<*test> |
| 933 |
% This test file can be used with plain-TeX & LaTeX 2.09/2e. |
| 934 |
% |
| 935 |
\edef\FORMAT{% |
| 936 |
\expandafter\ifx\csname documentstyle\endcsname\relax 0% |
| 937 |
\else\expandafter\ifx\csname documentclass\endcsname\relax |
| 938 |
1\else 2\fi\fi} |
| 939 |
\immediate\write16{=====>>> You are using % |
| 940 |
\ifcase\FORMAT plainTeX\or LaTeX 2.09\or LaTeX 2e\else ??\fi} |
| 941 |
\ifcase\FORMAT |
| 942 |
\input localloc.sty\relax \or |
| 943 |
\documentstyle[localloc]{article}\begin{document}\or |
| 944 |
\documentclass{article}\usepackage{localloc}\begin{document}\fi |
| 945 |
\tracingstats=1 |
| 946 |
% some macros |
| 947 |
\def\Message#1{\immediate\write16{#1}} |
| 948 |
\def\RegVal#1{\the\csname test#1\endcsname} |
| 949 |
\def\ShowSet#1{\if l#1local\else global\fi: |
| 950 |
\RegVal{i#1} \RegVal{ii#1}/\RegVal{iii#1} |
| 951 |
\RegVal{iv#1}} |
| 952 |
\def\ShowAll#1{\Message{#1 -- \ShowSet{g} -- \ShowSet{l}}} |
| 953 |
\def\ShowIns{\Message{Insertions: |
| 954 |
\the\testinsi, \the\testinsii, \the\testinsiii}} |
| 955 |
% initialise |
| 956 |
\chardef\testig=0 \chardef\testil=0 |
| 957 |
\chardef\testiig=0 \chardef\testiil=0 |
| 958 |
\chardef\testiiig=0 \chardef\testiiil=0 |
| 959 |
\chardef\testivg=0 \chardef\testivl=0 |
| 960 |
\chardef\testinsii=0 \chardef\testinsiii=0 |
| 961 |
% allocate an insertion/set of registers |
| 962 |
\newinsert\testinsi |
| 963 |
% make sure that a collision boxes/insertions occurs |
| 964 |
{\count0=\testinsi \advance\count0 -2 |
| 965 |
\loop\csname newbox\endcsname\testig |
| 966 |
\ifnum\testig<\count0\repeat} |
| 967 |
% |
| 968 |
\newbox\testig \lnewbox\testil |
| 969 |
\ShowAll{Level 0} |
| 970 |
\begingroup |
| 971 |
\lnewbox\testiil \newbox\testiig |
| 972 |
\ShowAll{Level 1} |
| 973 |
\begingroup |
| 974 |
\newbox\testivg \lnewbox\testivl |
| 975 |
\ShowAll{Level 2}\ShowIns |
| 976 |
\endgroup |
| 977 |
\lnewbox\testiiil \newbox\testiiig |
| 978 |
\ShowAll{Level 1b} |
| 979 |
\csname newinsert\endcsname\testinsii |
| 980 |
\ShowIns |
| 981 |
\begingroup |
| 982 |
\newbox\testivg \lnewbox\testivl |
| 983 |
\ShowAll{Level 2} |
| 984 |
\endgroup |
| 985 |
\ShowAll{Level 1b} |
| 986 |
\endgroup |
| 987 |
\newinsert\testinsiii |
| 988 |
\ShowAll{Level 0}\ShowIns |
| 989 |
\begingroup |
| 990 |
\lnewbox\testiil \newbox\testiig |
| 991 |
\lnewbox\testiiil \newbox\testiiig |
| 992 |
\ShowAll{Level 1} |
| 993 |
\begingroup |
| 994 |
\newbox\testivg \lnewbox\testivl |
| 995 |
\newbox\testvg \lnewbox\testvl |
| 996 |
\ShowAll{Level 2}\ShowIns |
| 997 |
\endgroup |
| 998 |
\ShowAll{Level 1} |
| 999 |
\endgroup |
| 1000 |
\ShowAll{Level 0} |
| 1001 |
\end{document} |
| 1002 |
%</test> |
| 1003 |
% \end{macrocode} |
| 1004 |
% |
| 1005 |
% \fi |
| 1006 |
% |
| 1007 |
% \Finale |
| 1008 |
% |
| 1009 |
%% \CharacterTable |
| 1010 |
%% {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 |
| 1011 |
%% 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 |
| 1012 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 1013 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 1014 |
%% Dollar \$ Percent \% Ampersand \& |
| 1015 |
%% Acute accent \' Left paren \( Right paren \) |
| 1016 |
%% Asterisk \* Plus \+ Comma \, |
| 1017 |
%% Minus \- Point \. Solidus \/ |
| 1018 |
%% Colon \: Semicolon \; Less than \< |
| 1019 |
%% Equals \= Greater than \> Question mark \? |
| 1020 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 1021 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 1022 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 1023 |
%% Right brace \} Tilde \~} |
| 1024 |
%% |
| 1025 |
% |
| 1026 |
\endinput |