I'm aware that some "temporary" LaTeX dimensions etc. exist. I would, however, like to know all of them.
I know \reserved@a (macro), \@tempdima (dimension) and \@tempcnta (counter).
|
I'm aware that some "temporary" LaTeX dimensions etc. exist. I would, however, like to know all of them. I know |
||||
|
The use of scratch registers and macros in TeX/LaTeX date back to the time when it was absolutely essential to conserve memory consumption, because TeX's memory (both in terms of token/macro memory as well as number of available registers) was very limited and one could easily run out of space just by loading a few packages on top of the main format. Traces of this can be still found all over the place in the code, e.g., you see things like However, using sratch registers and macros to overcome these limitations always came with a price: there is always the danger that the register or macro got reused while your code is still assuming that it holds your value! And despite a lot of precautions (like using them only within a group or ensure that setting and use would be really really next to each other) time and time again it caused bugs and issues because macros got called within arguments of others (both assuming that they could safely use the same scratch object) or through the fact that the output routine is visited in unexpected situations changing the context. With LaTeX2e which was born 1994 or so the size limitation got even worse because the core code got extended. So we had to use scratch registers all over the place and conserve memory as best as we could. But knowing the issues with them we split the scratch registers into two: those that we wanted to see only being used within kernel code and those that had been used in the past by third party packages already (and which we couldn't take away without breaking those package). Therefore we introduced Bottom line: use of scratch registers and macros is not advisable unless there is a very good reason and these days the original reason (the memory limitation) is no longer valid. All modern TeX installations (younger than a decade or so) these days are based on eTeX and all offer enough space and registers that it is much better and simpler if packages use their own private commands and registers and therefore can rely on living side by side without any headache. With LaTeX3 ( |
|||||||||||||||
|
|
The LaTeX kernel allocates some scratch registers and defines a scratch conditional. The complete list is
Notice that for the first two The register allocation mechanism always leaves free the first ten register numbers, so also
and box registers 0 to 9 are free for scratch usage. An agreed upon convention (that unfortunately some packages don't follow) is that even numbered scratch registers should be used locally, and odd numbered ones should be used globally. Also for local usage are
but not box register 255; The kernel uses also Also registers Usage of scratch conditional and registers should follow some simple rules.
Any register can be used as scratch register, provided this is done inside a group and following the rules above (but with more care about possible value clobbering). So it's fairly common to find A very common pitfall is in the usage of box registers which do follow the group structure, with the peculiarity that
the box register 0 will be void. On the other hand,
will result in box register 0 still containing |
||||
|
|
|
This might only be a partial answer, depending on your view of other packages that might also define scratch registers/variables. Searching
There's also |
|||||||||||||||||
|
\reserved@...set are not really 'temporary' in the same sense as\@tempaor\@tempdima: thereservedis there for a reason (team use only)! – Joseph Wright♦ Dec 26 '12 at 21:23