General ⇒ When can \newcommand not replace \def ?
When can \newcommand not replace \def ?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
When can \newcommand not replace \def ?
\newcommand and \renewcommand are limited in parsing arguments. For example things likedeniss wrote:Could anyone please give some examples of such instances and some general guidelines?
Code: Select all
\def\@tempb#1=#2\@nil{#1}
Code: Select all
\long\def\@caption#1[#2]#3{%
...}
As a generic guideline I would say use \newcommand preferred to \def, if possible, so one would not accidently overwrite an already-defined command.