# Why am I getting an error when using \renewcommand, here?

I try to type \renewcommand{\mr}{\mathrm}, so that I can then use \mr in my text instead of \mathrm. I get the error \mr Undefined. what is going on?

• That \mr is not defined and you should use \newcommand{\mr}{\mathrm} instead. – egreg Feb 26 '15 at 16:17
• in \newcommand{\mr}{\mathrm}, i am taking the already predefined \mathrm and wanting it to be defined as the shorter \mr so that i can use \mr throughout the document. you now seem to be saying the opposite. \mr is not the command to be redefined; it is what the command \mathrm should be replaced with – user4437416 Feb 26 '15 at 16:29
• @inquiries I think you are misunderstanding 'replaced' here. TeX is a macro expansion language, so with \newcommand{\mr}{\mathrm} when LaTeX finds \mr in your source it replaces it with \mathrm, then looks up the definition of \mathrm, etc. – Joseph Wright Feb 26 '15 at 16:36

TeX uses macro replacement as its fundamental concept. When you say

\newcommand{\foo}{<whatever>}



So with

\newcommand{\mr}{\mathrm}


you are basically creating an alias for \mathrm: upon finding \mr in the input stream, TeX will replace \mr with \mathrm and then \mathrm with its definition and so on until only “purely executable” commands remain, that TeX passes on for further processing in what is usually called the “stomach”.

If the command \foo already had a definition, you need to use \renewcommand (but be always afraid of using it).

The second argument to \newcommand needn't be just a single token: you may as well define

\newcommand{\independence}{When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.}


and upon finding \independence, TeX will replace it with that text.

You find much more in chapter 8 of “LaTeX for complete novices”