[Tex/LaTex] How to conditionally define a new command in LaTeX


I'm trying to compile a LaTeX code with an older version of some package. Thus, I'm having a few issues due to undefined commands.

How can I add conditional code so that I can define some work-around commands of this older package version?

% I want something like this:
if command \foobar is not defined

% I don't need an "else" clause here, but it would be good
% to know how to add one, in case I need it in future

end if

Best Answer

The LaTeX kernel command \providecommand{\foobar}{FooBar} does exactly what you want.

Related Question