I normally use the LaTeX \newcommand to define macros. However, when using delimited macros I use \def. Is there a way that I can get LaTeX to trigger an error if the command defined by \def is being re-defined by another package, i.e, if someone tries to re-define the command a LaTeX error message is triggered.
|
|
|||||||
|
|
For what it's worth, I think that Yiannis' answer (using e-TeX provides two new primitives to check if a control sequence is defined.
The
Having Edit: |
|||||||||
|
|
TeX does not provide anything similar to
By defining first the command using |
|||||||||||||||||||
|
|
It is technically impossible to protect a macro name (command sequence) from future redefinitions or trigger an error when it is redefined. TeX doesn't even protect its internal command and allows you to redefine them as well. This is by design. You can however check at certain points (like at-begin-document) if your definition is still active and trigger an error otherwise:
|
|||
|
|
|
No, |
|||
|
|
|
Here is a generalization of Martin Scharrer's scheme. We introduce two commands
Tests:
|
||||
|
|