# Plain TeX vs. LaTeX Macros


-
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 '11 at 3:36
@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 '11 at 3:39
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 '11 at 3:43
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 '11 at 4:00
Alan: Thanks, that was even a more simple response than I expected. –  night owl Nov 21 '11 at 4:02
show 1 more comment

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:

-
+1...Perfect Summary. –  night owl Nov 21 '11 at 5:07
• \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 '11 at 3:45