What macros should be used as 'scratch space'?
up vote
17
down vote
favorite
The LaTeX kernel provides the 'scratch' macros @tempa
, etc., and reserved@a
, etc. These are used for a variety of purposes. Which should be used as temporary space by general users/programmers?
macros latex-base
add a comment |
up vote
17
down vote
favorite
The LaTeX kernel provides the 'scratch' macros @tempa
, etc., and reserved@a
, etc. These are used for a variety of purposes. Which should be used as temporary space by general users/programmers?
macros latex-base
I have to admit I have been using the plain TeX conventions here, using,
1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.
– Harald Hanche-Olsen
Aug 24 at 21:07
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49
add a comment |
up vote
17
down vote
favorite
up vote
17
down vote
favorite
The LaTeX kernel provides the 'scratch' macros @tempa
, etc., and reserved@a
, etc. These are used for a variety of purposes. Which should be used as temporary space by general users/programmers?
macros latex-base
The LaTeX kernel provides the 'scratch' macros @tempa
, etc., and reserved@a
, etc. These are used for a variety of purposes. Which should be used as temporary space by general users/programmers?
macros latex-base
macros latex-base
asked Aug 24 at 18:38
Joseph Wright♦
200k21549874
200k21549874
I have to admit I have been using the plain TeX conventions here, using,
1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.
– Harald Hanche-Olsen
Aug 24 at 21:07
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49
add a comment |
I have to admit I have been using the plain TeX conventions here, using,
1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.
– Harald Hanche-Olsen
Aug 24 at 21:07
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49
I have to admit I have been using the plain TeX conventions here, using
, 1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.– Harald Hanche-Olsen
Aug 24 at 21:07
I have to admit I have been using the plain TeX conventions here, using
, 1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.– Harald Hanche-Olsen
Aug 24 at 21:07
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49
add a comment |
3 Answers
3
active
oldest
votes
up vote
16
down vote
The reserved@...
macros are reserved for use by the LaTeX team only: they should not be used by others. On the other hand, the macros @temp...
are available for general scratch use.
This is because low-level parts of the kernel need to have reliable storage for internal use. The reserved@...
series provide this, and using them may cause unexpected issues in apparently unrelated code. No such reliance takes place with the @temp...
series.
If you are patching a kernel macro and using the reserved names exactly as the kernel does, you might of course need to use one. This is however an extremely limited set of circumstances.
add a comment |
up vote
16
down vote
LaTeX2.09 used @tempa
, ... as scratch macros, but by the time LaTeX2e was being designed so many style files (packages) were using the same "scratch" macros they were not really "safe" any more so we used reserved@a
,... in the format code, documented as not to be used by other packages. So @tempa
and friends have no special status now, although they are commonly used because many common packages have a history that goes back to latex2.09 (ie before 1994).
But really for any package being written now there is no need to use these generic scratch macros at all. If your package is called wibble.sty
use wibble@a
, wibble@b
,... etc.
In 1994, on a 640K PC running emtex there were only about 50 command names left after loading latex2e+amsmath, and so it made sense for as much code as possible to re-use the same command names. With a modern texlive or miktex installation there are typically several hundred thousand command names available in the string pool and obfuscating the code and running the risk of clashes with other packages by re-using some generic command names is probably taking a risk with no actual potential gain.
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by@tempdima
being used both byrule
and byl@section
: I was hacking intol@section
and trying to use the@tempdima
configured by it in the parameters of an extrarule
, but to no avail of course asrule
itselfs resets@tempdima
.
– jfbu
Aug 25 at 9:59
add a comment |
up vote
5
down vote
When writing code from scratch that might be used by people other than me, then I tend to write everything within an own namespace where each macro-name has its own prefix formed by the name of the project/package, trailed by an @
and an acronym denoting the person who wrote that code. E.g., for project foobar I don't use @tempa
but I use foobar@UD@tempa
. If I could easily use digits within names of control sequences, I would in many places include version number / date of submission into the namespace-prefix also.
Exception: Macro-names for macros for the user-level.
Besides this I tend to redefine whatsoever "scratch" macros not introduced by me within local scopes only, where at the moment of finishing producing whatsoever boxes, these local scopes are already closed again so that my temporary redefinitions don't interfere during moments where the output-routine is in action. (One can have fun in situations where globaldefs
might have a positive value. ;-) )
Another issue are macros where hooks like everypar
or everyeof
get modified. Modifying somebody else's macros, e.g., scratch-macros from the kernel, might probably affect the way in which things triggered by those hooks are done. This in turn might cause problems.
E.g., recently there was a thread macros - inaccurate hyperlink to customly defined theorems where changing the kernel's box-register @labels
happened even without the user being aware of that:
The labels of the text of a theorem-like environment were to be nested into another itemize-like environment. First the material for typesetting both the theorem-like environment's label and for placing an anchor for hyperlinks was placed into the box-register @labels
. Theorem-like environments rely on everypar
for typesetting the content of that box-register. But the content of that box-register was replaced due to the itemize-like-environment before the everypar
-hook was carried out. This time with material where no anchor for hyperlinks was placed. Thus hyperref-functionality was broken.
So, problems with changing things belonging to the kernel can even happen without users knowing/intending that.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
16
down vote
The reserved@...
macros are reserved for use by the LaTeX team only: they should not be used by others. On the other hand, the macros @temp...
are available for general scratch use.
This is because low-level parts of the kernel need to have reliable storage for internal use. The reserved@...
series provide this, and using them may cause unexpected issues in apparently unrelated code. No such reliance takes place with the @temp...
series.
If you are patching a kernel macro and using the reserved names exactly as the kernel does, you might of course need to use one. This is however an extremely limited set of circumstances.
add a comment |
up vote
16
down vote
The reserved@...
macros are reserved for use by the LaTeX team only: they should not be used by others. On the other hand, the macros @temp...
are available for general scratch use.
This is because low-level parts of the kernel need to have reliable storage for internal use. The reserved@...
series provide this, and using them may cause unexpected issues in apparently unrelated code. No such reliance takes place with the @temp...
series.
If you are patching a kernel macro and using the reserved names exactly as the kernel does, you might of course need to use one. This is however an extremely limited set of circumstances.
add a comment |
up vote
16
down vote
up vote
16
down vote
The reserved@...
macros are reserved for use by the LaTeX team only: they should not be used by others. On the other hand, the macros @temp...
are available for general scratch use.
This is because low-level parts of the kernel need to have reliable storage for internal use. The reserved@...
series provide this, and using them may cause unexpected issues in apparently unrelated code. No such reliance takes place with the @temp...
series.
If you are patching a kernel macro and using the reserved names exactly as the kernel does, you might of course need to use one. This is however an extremely limited set of circumstances.
The reserved@...
macros are reserved for use by the LaTeX team only: they should not be used by others. On the other hand, the macros @temp...
are available for general scratch use.
This is because low-level parts of the kernel need to have reliable storage for internal use. The reserved@...
series provide this, and using them may cause unexpected issues in apparently unrelated code. No such reliance takes place with the @temp...
series.
If you are patching a kernel macro and using the reserved names exactly as the kernel does, you might of course need to use one. This is however an extremely limited set of circumstances.
answered Aug 24 at 18:41
Joseph Wright♦
200k21549874
200k21549874
add a comment |
add a comment |
up vote
16
down vote
LaTeX2.09 used @tempa
, ... as scratch macros, but by the time LaTeX2e was being designed so many style files (packages) were using the same "scratch" macros they were not really "safe" any more so we used reserved@a
,... in the format code, documented as not to be used by other packages. So @tempa
and friends have no special status now, although they are commonly used because many common packages have a history that goes back to latex2.09 (ie before 1994).
But really for any package being written now there is no need to use these generic scratch macros at all. If your package is called wibble.sty
use wibble@a
, wibble@b
,... etc.
In 1994, on a 640K PC running emtex there were only about 50 command names left after loading latex2e+amsmath, and so it made sense for as much code as possible to re-use the same command names. With a modern texlive or miktex installation there are typically several hundred thousand command names available in the string pool and obfuscating the code and running the risk of clashes with other packages by re-using some generic command names is probably taking a risk with no actual potential gain.
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by@tempdima
being used both byrule
and byl@section
: I was hacking intol@section
and trying to use the@tempdima
configured by it in the parameters of an extrarule
, but to no avail of course asrule
itselfs resets@tempdima
.
– jfbu
Aug 25 at 9:59
add a comment |
up vote
16
down vote
LaTeX2.09 used @tempa
, ... as scratch macros, but by the time LaTeX2e was being designed so many style files (packages) were using the same "scratch" macros they were not really "safe" any more so we used reserved@a
,... in the format code, documented as not to be used by other packages. So @tempa
and friends have no special status now, although they are commonly used because many common packages have a history that goes back to latex2.09 (ie before 1994).
But really for any package being written now there is no need to use these generic scratch macros at all. If your package is called wibble.sty
use wibble@a
, wibble@b
,... etc.
In 1994, on a 640K PC running emtex there were only about 50 command names left after loading latex2e+amsmath, and so it made sense for as much code as possible to re-use the same command names. With a modern texlive or miktex installation there are typically several hundred thousand command names available in the string pool and obfuscating the code and running the risk of clashes with other packages by re-using some generic command names is probably taking a risk with no actual potential gain.
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by@tempdima
being used both byrule
and byl@section
: I was hacking intol@section
and trying to use the@tempdima
configured by it in the parameters of an extrarule
, but to no avail of course asrule
itselfs resets@tempdima
.
– jfbu
Aug 25 at 9:59
add a comment |
up vote
16
down vote
up vote
16
down vote
LaTeX2.09 used @tempa
, ... as scratch macros, but by the time LaTeX2e was being designed so many style files (packages) were using the same "scratch" macros they were not really "safe" any more so we used reserved@a
,... in the format code, documented as not to be used by other packages. So @tempa
and friends have no special status now, although they are commonly used because many common packages have a history that goes back to latex2.09 (ie before 1994).
But really for any package being written now there is no need to use these generic scratch macros at all. If your package is called wibble.sty
use wibble@a
, wibble@b
,... etc.
In 1994, on a 640K PC running emtex there were only about 50 command names left after loading latex2e+amsmath, and so it made sense for as much code as possible to re-use the same command names. With a modern texlive or miktex installation there are typically several hundred thousand command names available in the string pool and obfuscating the code and running the risk of clashes with other packages by re-using some generic command names is probably taking a risk with no actual potential gain.
LaTeX2.09 used @tempa
, ... as scratch macros, but by the time LaTeX2e was being designed so many style files (packages) were using the same "scratch" macros they were not really "safe" any more so we used reserved@a
,... in the format code, documented as not to be used by other packages. So @tempa
and friends have no special status now, although they are commonly used because many common packages have a history that goes back to latex2.09 (ie before 1994).
But really for any package being written now there is no need to use these generic scratch macros at all. If your package is called wibble.sty
use wibble@a
, wibble@b
,... etc.
In 1994, on a 640K PC running emtex there were only about 50 command names left after loading latex2e+amsmath, and so it made sense for as much code as possible to re-use the same command names. With a modern texlive or miktex installation there are typically several hundred thousand command names available in the string pool and obfuscating the code and running the risk of clashes with other packages by re-using some generic command names is probably taking a risk with no actual potential gain.
edited Aug 25 at 11:21
GuM
16k2254
16k2254
answered Aug 24 at 20:17
David Carlisle
477k3811061841
477k3811061841
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by@tempdima
being used both byrule
and byl@section
: I was hacking intol@section
and trying to use the@tempdima
configured by it in the parameters of an extrarule
, but to no avail of course asrule
itselfs resets@tempdima
.
– jfbu
Aug 25 at 9:59
add a comment |
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by@tempdima
being used both byrule
and byl@section
: I was hacking intol@section
and trying to use the@tempdima
configured by it in the parameters of an extrarule
, but to no avail of course asrule
itselfs resets@tempdima
.
– jfbu
Aug 25 at 9:59
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
The 'throw away' temporaries are handy for ad hoc code, mainly: that was the context in which the initial query arose.
– Joseph Wright♦
Aug 24 at 20:22
5
5
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
@JosephWright yes but one person's ad hoc code ends up being someone else's go-to package 20 years later:-)
– David Carlisle
Aug 24 at 20:24
I just got bitten by
@tempdima
being used both by rule
and by l@section
: I was hacking into l@section
and trying to use the @tempdima
configured by it in the parameters of an extra rule
, but to no avail of course as rule
itselfs resets @tempdima
.– jfbu
Aug 25 at 9:59
I just got bitten by
@tempdima
being used both by rule
and by l@section
: I was hacking into l@section
and trying to use the @tempdima
configured by it in the parameters of an extra rule
, but to no avail of course as rule
itselfs resets @tempdima
.– jfbu
Aug 25 at 9:59
add a comment |
up vote
5
down vote
When writing code from scratch that might be used by people other than me, then I tend to write everything within an own namespace where each macro-name has its own prefix formed by the name of the project/package, trailed by an @
and an acronym denoting the person who wrote that code. E.g., for project foobar I don't use @tempa
but I use foobar@UD@tempa
. If I could easily use digits within names of control sequences, I would in many places include version number / date of submission into the namespace-prefix also.
Exception: Macro-names for macros for the user-level.
Besides this I tend to redefine whatsoever "scratch" macros not introduced by me within local scopes only, where at the moment of finishing producing whatsoever boxes, these local scopes are already closed again so that my temporary redefinitions don't interfere during moments where the output-routine is in action. (One can have fun in situations where globaldefs
might have a positive value. ;-) )
Another issue are macros where hooks like everypar
or everyeof
get modified. Modifying somebody else's macros, e.g., scratch-macros from the kernel, might probably affect the way in which things triggered by those hooks are done. This in turn might cause problems.
E.g., recently there was a thread macros - inaccurate hyperlink to customly defined theorems where changing the kernel's box-register @labels
happened even without the user being aware of that:
The labels of the text of a theorem-like environment were to be nested into another itemize-like environment. First the material for typesetting both the theorem-like environment's label and for placing an anchor for hyperlinks was placed into the box-register @labels
. Theorem-like environments rely on everypar
for typesetting the content of that box-register. But the content of that box-register was replaced due to the itemize-like-environment before the everypar
-hook was carried out. This time with material where no anchor for hyperlinks was placed. Thus hyperref-functionality was broken.
So, problems with changing things belonging to the kernel can even happen without users knowing/intending that.
add a comment |
up vote
5
down vote
When writing code from scratch that might be used by people other than me, then I tend to write everything within an own namespace where each macro-name has its own prefix formed by the name of the project/package, trailed by an @
and an acronym denoting the person who wrote that code. E.g., for project foobar I don't use @tempa
but I use foobar@UD@tempa
. If I could easily use digits within names of control sequences, I would in many places include version number / date of submission into the namespace-prefix also.
Exception: Macro-names for macros for the user-level.
Besides this I tend to redefine whatsoever "scratch" macros not introduced by me within local scopes only, where at the moment of finishing producing whatsoever boxes, these local scopes are already closed again so that my temporary redefinitions don't interfere during moments where the output-routine is in action. (One can have fun in situations where globaldefs
might have a positive value. ;-) )
Another issue are macros where hooks like everypar
or everyeof
get modified. Modifying somebody else's macros, e.g., scratch-macros from the kernel, might probably affect the way in which things triggered by those hooks are done. This in turn might cause problems.
E.g., recently there was a thread macros - inaccurate hyperlink to customly defined theorems where changing the kernel's box-register @labels
happened even without the user being aware of that:
The labels of the text of a theorem-like environment were to be nested into another itemize-like environment. First the material for typesetting both the theorem-like environment's label and for placing an anchor for hyperlinks was placed into the box-register @labels
. Theorem-like environments rely on everypar
for typesetting the content of that box-register. But the content of that box-register was replaced due to the itemize-like-environment before the everypar
-hook was carried out. This time with material where no anchor for hyperlinks was placed. Thus hyperref-functionality was broken.
So, problems with changing things belonging to the kernel can even happen without users knowing/intending that.
add a comment |
up vote
5
down vote
up vote
5
down vote
When writing code from scratch that might be used by people other than me, then I tend to write everything within an own namespace where each macro-name has its own prefix formed by the name of the project/package, trailed by an @
and an acronym denoting the person who wrote that code. E.g., for project foobar I don't use @tempa
but I use foobar@UD@tempa
. If I could easily use digits within names of control sequences, I would in many places include version number / date of submission into the namespace-prefix also.
Exception: Macro-names for macros for the user-level.
Besides this I tend to redefine whatsoever "scratch" macros not introduced by me within local scopes only, where at the moment of finishing producing whatsoever boxes, these local scopes are already closed again so that my temporary redefinitions don't interfere during moments where the output-routine is in action. (One can have fun in situations where globaldefs
might have a positive value. ;-) )
Another issue are macros where hooks like everypar
or everyeof
get modified. Modifying somebody else's macros, e.g., scratch-macros from the kernel, might probably affect the way in which things triggered by those hooks are done. This in turn might cause problems.
E.g., recently there was a thread macros - inaccurate hyperlink to customly defined theorems where changing the kernel's box-register @labels
happened even without the user being aware of that:
The labels of the text of a theorem-like environment were to be nested into another itemize-like environment. First the material for typesetting both the theorem-like environment's label and for placing an anchor for hyperlinks was placed into the box-register @labels
. Theorem-like environments rely on everypar
for typesetting the content of that box-register. But the content of that box-register was replaced due to the itemize-like-environment before the everypar
-hook was carried out. This time with material where no anchor for hyperlinks was placed. Thus hyperref-functionality was broken.
So, problems with changing things belonging to the kernel can even happen without users knowing/intending that.
When writing code from scratch that might be used by people other than me, then I tend to write everything within an own namespace where each macro-name has its own prefix formed by the name of the project/package, trailed by an @
and an acronym denoting the person who wrote that code. E.g., for project foobar I don't use @tempa
but I use foobar@UD@tempa
. If I could easily use digits within names of control sequences, I would in many places include version number / date of submission into the namespace-prefix also.
Exception: Macro-names for macros for the user-level.
Besides this I tend to redefine whatsoever "scratch" macros not introduced by me within local scopes only, where at the moment of finishing producing whatsoever boxes, these local scopes are already closed again so that my temporary redefinitions don't interfere during moments where the output-routine is in action. (One can have fun in situations where globaldefs
might have a positive value. ;-) )
Another issue are macros where hooks like everypar
or everyeof
get modified. Modifying somebody else's macros, e.g., scratch-macros from the kernel, might probably affect the way in which things triggered by those hooks are done. This in turn might cause problems.
E.g., recently there was a thread macros - inaccurate hyperlink to customly defined theorems where changing the kernel's box-register @labels
happened even without the user being aware of that:
The labels of the text of a theorem-like environment were to be nested into another itemize-like environment. First the material for typesetting both the theorem-like environment's label and for placing an anchor for hyperlinks was placed into the box-register @labels
. Theorem-like environments rely on everypar
for typesetting the content of that box-register. But the content of that box-register was replaced due to the itemize-like-environment before the everypar
-hook was carried out. This time with material where no anchor for hyperlinks was placed. Thus hyperref-functionality was broken.
So, problems with changing things belonging to the kernel can even happen without users knowing/intending that.
edited yesterday
answered Aug 25 at 9:12
Ulrich Diez
3,755515
3,755515
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447584%2fwhat-macros-should-be-used-as-scratch-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I have to admit I have been using the plain TeX conventions here, using
,
1
, etc. But I never dared let any code that I don't have complete control over run between defining and using these macros. Havn't been burned by it yet.– Harald Hanche-Olsen
Aug 24 at 21:07
I happened to stumble across this similar question: tex.stackexchange.com/questions/88252/…
– David Purton
Aug 25 at 15:49