# Mark command as obsolete

Is it possible to declare some command inside a package as obsolete? I work on a package and want to inform users that in the next version of the package this commands will be deleted. What kind of messages will be seen by user in this case?

• You could \typeout a warning to the log file whenever the command is used. Also, you could mention in the documentation that the command is deprecated. My approach in these situations is to leave the outmoded command in the package for several backward compatibility, but to use the documentation to warn against its use, citing lack of technical support moving forward. – Steven B. Segletes May 13 '19 at 11:10

Add a warning to the definition :

\documentclass{article}

\newcommand{\foo}{%
bar
}

\begin{document}

\foo

\end{document}


If it's just a drop-in replacement, then something like below should be good.

\documentclass{article}

\makeatletter % let's emulate a package

\newcommand{\newversion}{This is the command that should be used}

\newcommand{\oldversion}{%
\PackageWarningNoLine{morenko}{%
The command \noexpand\oldversion is obsolete and might get\MessageBreak
removed in future versions of the package.\MessageBreak
}%
\global\let\oldversion\newversion
\newversion
}

\makeatother

\begin{document}

I use \oldversion.

Again I use \oldversion.

Also \newversion.

\end{document}


This way, users will get a single warning and the old command will be redefined to mean the new one.

However, a precise way to do this might depend on the nature of the command: if you use it in an expansion context, the user will get a lot of weird errors.