Update
Recent LaTeX kernels have incorporated the greater part of etex
, so it's quite unlikely that one needs to load it nowadays.
Original answer
TeX, as designed by Knuth, has various registers addressable with an eight bit number (that is, from 0 to 255). Registers are of type
\count
\dimen
\skip
\muskip
\toks
\insert
\box
Let's consider the \dimen
registers, for the others the allocation mechanism is similar. Each register is addressable by its number, for instance
\dimen34=42pt
\kern\dimen34
are legal example of setting a \dimen
register or retrieving its value. However, calling registers by number is a problem, because packages couldn't cooperate with each other. So all formats provide an allocation mechanism: one says
\newdimen\foo
and TeX sets up things so that \foo
is the same as calling \dimen<n>
where <n>
represents a number that we don't need to know. Note that \newdimen
is not a documented LaTeX command, but it is documented in source2e
and is very useful when writing packages.
TeX/LaTeX keeps track of the most recent allocated number for each register type; since the maximum number is 255, when a \newdimen
command hits the limit, the dreaded
No room for a new \dimen
error message appears. There is a slight complication because allocation of \insert
registers starts from 254 down and each \newinsert
also allocates the \count
, \dimen
, \skip
and \box
registers with the same number, so the upper limit is usually something less than 255, but it's not the main problem.
In case we hit the limit, there is nothing to do: we are forced to load less packages or do nasty tricks that will almost certainly bite us later on.
In order to solve this problem that became apparent several years ago when PicTeX was released, a different implementation of TeX was prepared that defines 32768 registers of each type. This is part of e-TeX, that is incorporated in pdftex
, the engine used when we run LaTeX on a document.
However, the kernel of LaTeX has not been modified, because it's basically frozen apart from bug fixes. Changing the allocation mechanism might break documents or packages that have been written under the assumption that only 256 registers of each type are available.
The etex
package modifies the allocation mechanism; when \newdimen
would issue the No room for a new \dimen
error message, it insteads jumps beyond 255 and allocates the register number 256 and goes forward from there.
Here is a simulation, where we assume that \newdimen\foo
allocates the last available eight bit slot and \newdimen\baz
needs to go up to fifteen bits; in the log file you'd find
\foo=\dimen233
Normal \dimen register pool exhausted, switching to extended pool.
\baz=\dimen256
provided you have \usepackage{etex}
in your preamble.
Why 233 is the last? Because LaTeX allocates \insert
classes from 254 to 234; they are connected with marginal notes, footnotes, figures and tables.
\newdimen
). The code of the\newdimen
macro reflects this by checking that not too many registers are allocated. The current eTeX engine extends this fixed number to 32768, but the code of\newdimen
needs to be adapted to the new maximum number by theetex
package.