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.

  • 3
    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. Mar 8, 2012 at 15:39
  • 3
    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. Mar 8, 2012 at 15:44

1 Answer 1


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? Mar 8, 2012 at 20:31
  • 3
    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, Mar 8, 2012 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.