TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made a class file. It defines commands for use in document files. I want to change some of the command names, but I also want old document files to work without changing them.

Here's an example to illustrate:


For this example I want to change "commandnameA" to "commandnameB" in the class file and have the document file work whether it contains \commandnameA{test} or \commandnameB{test}.

Any help is appreciated.

share|improve this question
up vote 14 down vote accepted

\let\commandnameB\commandnameA in your class file. Then the two macros are the same!

share|improve this answer
or \def\commandnameB{\commandnameA} if you want to keep both in sync even after \commandnameA got redefined. – Martin Scharrer Apr 10 '11 at 12:41

You may add a warning that \commandnameA is deprecated:

  \ClassWarning{yourclass}{Command \string\commandnameA\space is deprecated.%
  \MessageBreak Use \string\commandnameA\space instead.}%
share|improve this answer

Since \commandnameA and/or \commandnameB expect an argument, Tobi's solution should have been

  \ClassWarning{myclass}{Command `\string\commandnameA' is deprecated.
  \MessageBreak Use `\string\commandnameB' instead}%

I have added \protected because \commandnameB is not expandable.

share|improve this answer
It would be nicer if you could keep your answer self-contained and could avoid questions to the poster and others. – Marc van Dongen Feb 21 '12 at 1:30
@MarcvanDongen: Thanks. I have removed why?. – Ahmed Musa Feb 21 '12 at 13:20
I didn't mean you should remove the question. I had hoped you could expand on it further. It would provide more insight and would improve the answer. That's all. – Marc van Dongen Feb 21 '12 at 13:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.