# Custom .sty warning on specific command

I am writing a custom .sty file and I notice that it can break if a certain command, native in Latex, is called.

I would like to throw a warning to the user and say "Don't use this command!". I know the warning can be send as follow:

\PackageWarningNoLine{myClass}{Don't use this command!}

How do I check for whether the command has been used?

• It can't be a well defined package if it breaks with a native command of LaTeX. I think you should provide more information so that we can help you to improve the package. I know it's not a good idea, however you can redefine the certain command like \def\foobar{\PackageWarning – Marco Daniel Jan 4 '15 at 17:05
• Okay, break is a big word. It's the beamer package for presentation and the command \subsection{} will create a new line in the top. I want a background image which fit the top border, so by NOT using \subsection I avoid having to scale the image I insert. – Rasmus Bækgaard Jan 4 '15 at 17:09

\newcommand\subsection[2][]{%