I wish to choose names for macros in a manner that is least likely to conflict with names of other macros (including macros in packages that are not included in a document). Therefore, simply compiling the document with an invocation of a command and determining whether errors are thrown is not a desirable solution because the macro name may, in fact, be used in a very common package that has not been included in the compiled document. I suppose an ideal solution would be a LaTeX macro search engine that searches all packages in some database or archive (e.g., CTAN). I could then check a desired name for potential conflicts. Another useful solution would be a compiled table of all macros from packages in some archive or archive subset. Such a list would probably require some form of curation, though it could also be automatically generated. A final thought is that one could restrict the search to installed packages on one's machine.
|
This isn't possible, I'm afraid. Macros can be defined (or, more generally, a control sequence can be given a meaning) in many different ways. Just yesterday, while discussing with another member of this community, we came across a macro
or variations thereof. Indeed the control sequence The package wants to define a bunch of similar macros:
and so on, where the internal macros have already been defined. So, instead of repeating those definitions over and over again, the developers wrote
and then they call one of
inside some other macro, so that
and the parameter The conclusion is that's impossible to build a huge database of all defined macros, unless all package writers submit to it a list of all the macros their package defines. And this is hardly possible: some packages provide commands that in turn generate macros according to some scheme, but what macros are actually generated may depend on the user's choice. What can a user do, then? Define your macros to have a meaningful name; avoid "shorthands" (that are impossible to remember after a couple of months); use a prefix; finally, hope for the best. :) In my experience it happened only a handful of times that some of my personal macros came to conflict with a new version of some package or some newly loaded one and were invariably macros whose name had not been chosen according to my own recommendations. :) |
|||||||||||
|
\newcommandwill flag an error if the macro already exists.providecommandwill create your definition of the macro, provided that there was no previous definition; otherwise it will leave the original definition alone. – Brent.Longborough Feb 7 '12 at 10:27\newcommand. – user001 Feb 9 '12 at 6:12