When I started coding some LaTeX templates for myself, I had a very hard time figuring out how to check if some macro is defined or not. I tried lots of different solutions, and none of them seemed to do what I want (or anything, for that matter). I ended up using ifundef
from the etoolbox
package.
\usepackage{etoolbox}
\ifundef{\somemacro}{
\newcommand{\somemacro}{default value}
}{ \relax } % else: do nothing
Hope this saves you some time ;)