I was wondering what's the (advantage) of doing something one way over the other in different systems. For instance, I read that users of plain TEX should use \def whenever they want to create a new command rather than using \(re)newcommand in LaTeX, and dimen assignments whenever they want to set lengths to something rather than using \setlength. I was just wanting to know the reasons for this, because I use LaTeX2e, but I tend to choose \def over using \(re)newcommand or \newcommand. To be more clear, I am looking for an explanation similar to the case of using \(...\) and \[...\] over $...$ and $$...$$ respectively.

  • 2
    Duplicate for the \def part: macros - What is the difference between \def and \newcommand. Duplicate for the \setlength part: What is the difference between \fboxsep=1cm and \setlength{\fboxsep}{1cm}
    – Alan Munn
    Nov 21, 2011 at 3:36
  • 2
    @AlanMunn: Not so fast. It is not a duplicate I think at all. I am not asking for the difference between them in what their functionality provides. I am more specifically asking why would one use one over the other. Hence, using \def in plain TeX and using \newcommand in LaTeX. A question that could arise maybe, why can't one use either or for what platform they are working with? And sure, one probably can use either or (I never used plain-TeX), but there must be an advantage using one over the other depending on which platform you use.
    – night owl
    Nov 21, 2011 at 3:39
  • 1
    Well the first answer linked mentions advantages and disadvantages of both (e.g. checking if defined (\newcommand); delimited arguments (\def)). Maybe less so for the lengths commands. Maybe you could clarify your question based on the answers given there, then?
    – Alan Munn
    Nov 21, 2011 at 3:43
  • 1
    Given your comment below, the answer is simple: \newcommand and \setlength are not defined in plain TeX, so plain TeX users must use \def etc. LaTeX users can use both, since \def etc. are defined in the TeX language, and not specifically part of the plain format. So the choice is either/or for LaTeX users, but not for plain TeX users.
    – Alan Munn
    Nov 21, 2011 at 4:00
  • Alan: Thanks, that was even a more simple response than I expected.
    – night owl
    Nov 21, 2011 at 4:02

3 Answers 3


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:

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:

On the differences between the length commands see:

  • \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)}}.
  • Thanks. But I am looking for an answer as to why a plain-TeX user is suggested to use \def over using \newcommand and also dimen over \setlength. Not necessarily what they do when compiled.
    – night owl
    Nov 21, 2011 at 3:45

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .