I sort of understand the difference between the two. But that's not what I'm interested in—I just want to know, which one should I use? In general, when I'm creating commands in a package or class, which one should I use all the time?
In my opinion, it is better to use
\newcommand if there are no obvious expansion issues. There are two drawbacks of
\DeclareRobustCommanddoes not check if the macro is predefined.
Macros defined by
\DeclareRobustCommandare less efficient.
A simple rule of thumb is that if you're creating commands that contain data that LaTeX will reread later, you should be using a robust command that is defined using
Such data is contained in arguments that typically go into table of contents, list of figures, list of tables etc.; namely, data that are written to an auxiliary file and read in later. Other places are those data that might appear in headers or footers.
Section 2.6 of LaTeX 2ε for class and package writers states:
Because LaTeX 2ε supports different encodings, definitions of commands for producing symbols, accents, composite glyphs, etc. must be defined using the commands provided for this purpose and described in LaTeX 2ε Font Selection. [...]
\DeclareRobustCommandshould be used for encoding-independent commands of this type.