# Why use \DeclareTextFontCommand vs. just \newcommand?

Why should I use \DeclareTextFontCommand vs. just \newcommand?

In the answer to my previous question, @egreg said:

With \DeclareTextFontCommand you get a robust command that will remain untouched when found in a moving argument such as a section title or a caption.

but I still don't understand what "moving argument" is, and how will \newcommand fail at this - just curious.

-
A moving argument is an argument which is written into an auxiliary file (like .aux, but also .toc and others) which is then read on some other position at the next run. Things like sectioning titles and labels are moving arguments. While written into the auxiliary file the macro is fully expanded into its replacement text, while the underlying primitives (e.g. boxing commands) are not executed but will be written as such into the auxiliary file. This can cause trouble. Instead you want the macro name be written instead. This is achieved by making the macro robust. –  Martin Scharrer Mar 8 '12 at 15:39
Robust means the macro either expands to simple text (e.g. \newcommand{\foo}{The main file is called \jobname}, where \jobname expands in turn to text only) or expands (in this mode) to it's own macro name (maybe followed by a space) using some TeX trickery. E.g.: \foo would expand to \foo . Macros like \DeclareRobustCommand do this for you. e-TeX allows to do this using the new \protected primitive added before a \def or friends. –  Martin Scharrer Mar 8 '12 at 15:44
If you use \DeclareTextFontCommand LaTeX inserts additional code to insert an italic correction \/ at start or end of the text if the surrounding text has a different italic slope, and so the command works in math mode, giving the text font. Martin has added a comment about moving arguments, or it is discussed in more detail in What is the difference between Fragile and Robust commands?
Sorry, but what is an "italic correction"? Does it only apply to math mode, or anything the command is used inside any other command - like \textbf? –  drozzy Mar 8 '12 at 20:31
It's an extra space inserted (in text mode normally) when switching between italic and upright. This site could use it as when you use _ to make italics the following space seems to go. Compare in TeX {\itshape this !} hmmm and {\itshape this !\/} hmmm The \/ command inserts a bit of space specified in the font metrics to account for the slope of the letters, –  David Carlisle Mar 8 '12 at 20:50