Debian Codegraph @

texmf-dist/source/latex/elocalloc/elocalloc.dtx

raw
1 % \iffalse
2 %% Source File: textcase.dtx
3 %% Copyright 2015-2016 David Carlisle
4 %%
5 %% This file may be distributed under the terms of the LPPL.
6 %% See README for details.
7 %
8 %<*dtx>
9 \ProvidesFile{elocalloc.dtx}
10 %</dtx>
11 %<package>\NeedsTeXFormat{LaTeX2e}
12 %<package>\ProvidesPackage{elocalloc}
13 %<driver> \ProvidesFile{elocalloc.drv}
14 % \fi
15 % \ProvidesFile{elocalloc.dtx}
16 [2016/12/15 v0.03 local allocation for LaTeX 2015+ (DPC)]
17 %
18 % \iffalse
19 %<*driver>
20 \documentclass{ltxdoc}
21 \begin{document}
22 \DocInput{elocalloc.dtx}
23 \end{document}
24 %</driver>
25 % \fi
26 %
27 % \GetFileInfo{elocalloc.dtx}
28 %
29 % \title{The \textsf{elocalloc} Package\thanks{This file
30 % has version number \fileversion, last
31 % revised \filedate.
32 % Please report any issues at https://github.com/davidcarlisle/dpctex/issues}}
33 % \author{David Carlisle}
34 % \maketitle
35 %
36 % \section{Introduction}
37 %
38 % Prior to the 2015/01/01 \LaTeX\ release, access to extended registers was
39 % usually provided by the \textsf{etex} package. From 2015 on the base
40 % \LaTeX\ format ``knows'' the register ranges for tex, etex, xetex and
41 % luatex, and so for most purposes the \textsf{etex} package is not
42 % required.
43 %
44 % For existing documents \textsf{etex} may still be loaded and will work
45 % as before, however in general it is best not to load \textsf{etex} as it
46 % will over-write the new allocation scheme with its own.
47 %
48 % Standard allocation macros such as |\newbox| and extended versions of
49 % tracing commands are now defined in the format for suitable engines however
50 % there were some features of \textsf{etex} not copied into the format,
51 % notably the ``local'' allocation macros. A search of CTAN showed that
52 % these were almost never used, and their use can often be avoided, however
53 % there are occasions when they may be useful. This package provides
54 % implementations based on the new allocation system in \LaTeX\ 2015/01/01.
55 %
56 % Within a local group a command such as |\locbox\tmpbox| defines |\tmpbox|
57 % to be a box register, but unlike |\newbox| the definition is local, and
58 % at the end of the group, |\tmpbox| loses its definition, and the box
59 % allocation number is restored.
60 %
61 % The package defines: |\loccount|, |\locdimen|, |\locskip|, |\locmuskip|,
62 % |\locbox|, |\loctoks| and |\locmarks|.
63 %
64 %
65 % \section{Implementation}
66 %
67 % \begin{macrocode}
68 %<*package>
69 % \end{macrocode}
70 % On old \LaTeX, load |etex.sty| and stop.
71 % \begin{macrocode}
72 \ifx\e@alloc\@undefined
73 \RequirePackage{etex}
74 \expandafter\endinput
75 \fi
76 % \end{macrocode}
77 %
78 % If something else defined |\locbox|, stop with a warning.
79 %
80 % \begin{macrocode}
81 \ifx\locbox\@undefined\else
82 \PackageWarning{elocalloc}{%
83 \string\locbox\space already defined, stopping}
84 \expandafter\endinput
85 \fi
86 % \end{macrocode}
87 %
88 % Don't allow |\extrafloats| while a local allocation is in force.
89 % It is however OK to use |\extrafloats| with this package and to
90 % use floats within a group with a local allocation.
91 %
92 % For local allocations, reduce the top of the range available for global
93 % allocations by one, and locally allocate the register from that top
94 % position.
95 %
96 % Note that this means that (unlike the \textsf{etex} package originals)
97 % locally allocating one register affects the top of the other registers
98 % that share the same top of range, but doing otherwise would mean storing
99 % separate values for each type, and would make it harder to make
100 % |\extrafloats| work, should such an extension ever be needed.
101 % \begin{macrocode}
102 \def\eloc@lloc#1#2#3#4#5{%
103 \def\extrafloats##1{%
104 \PackageWarning{elocalloc}{\string\extrafloats\space ignored}}%
105 \e@ch@ck{#1}#2\z@#3%
106 \expandafter\e@alloc@chardef\expandafter#2%
107 \the\numexpr#2-1\relax
108 \allocationnumber=#2%
109 #3#5#2}
110 % \end{macrocode}
111 %
112 % The top level local allocation commands.
113 % \begin{macrocode}
114 \def\loccount {\eloc@lloc{\count 10}\float@count\countdef\count}
115 \def\locdimen {\eloc@lloc{\count 11}\float@count\dimendef\dimen}
116 \def\locskip {\eloc@lloc{\count 12}\float@count\skipdef\skip}
117 \def\locmuskip{\eloc@lloc{\count 13}\e@alloc@top\muskipdef\muskip}
118 \def\locbox {\eloc@lloc{\count 14}\float@count\e@alloc@chardef\box}
119 \def\loctoks {\eloc@lloc{\count 15}\e@alloc@top\toksdef\toks}
120 \def\locmarks {\eloc@lloc{\count256}\e@alloc@top\e@alloc@chardef\marks}
121 % \end{macrocode}
122 %
123 % \begin{macrocode}
124 %</package>
125 % \end{macrocode}
126 %
127 % \Finale
128 %