Plain TeX vs. LaTeX Macros

First some terminology: Plain TeX and LaTeX are formats (sets of macros written in the TeX language.) The LaTeX format provides many new commands which are only available to LaTeX users and are not available to plain TeX users. Among these are the commands \newcommand and \setlength. For a list of some of the common correspondences see:

  • List of higher-level LaTeX commands corresponding to TeX commands

Any command which is defined as part of the TeX language itself can be used in either the plain TeX format or LaTeX. However, the converse is not so: commands that are defined in LaTeX cannot be used in plain TeX. So plain TeX users must use \def, while LaTeX users can use either \def or \newcommand. However, there are some differences between the two:

  • What is the difference between \def and \newcommand?

On the differences between the length commands see:

  • What is the difference between \fboxsep=1cm and \setlength{\fboxsep}{1cm}?

  • \newcommand prevents us from accidently overriding the existing command. \def does not provide this compile-checking.
  • \def can accommodate more general delimiters for arguments such as \def\point(#1,#2){\ensuremath{(#1,#2)}}.

For someone that knows LaTeX and having the choice between \def or \newcommand, there should be zero difference. That is, the difference is probably subjective/left up to personal preference. LaTeX defines \newcommand in terms of \def. As such, \newcommand merely provides a user-friendly and therefore slightly restricted interface to defining a macro.

Using \newcommand has the built-in safety of not being able to redefine a macro. For this, one should use \renewcommand. Alternatively, \providecommand can be used to define a new command; it defaults to \newcommand if the command does not exist, or discards its arguments if the command already exists (no redefinition).