I'm trying to define a custom command for use in math mode, defined as
\newcommand{\deriv2}[2]{\ensuremath{\frac{\partial^2 {#1}}{\partial {#2}^2}}}
Other non-math mode \newcommands work in my document, but as soon as I put one into math mode I get the error messages:
! LaTeX Error: Missing \begin{document}
! You can't use `macro parameter character #' in math mode.
I have also tried defining my \newcommand without \ensuremath, and in all combinations of calling it within the equation environment, $$, and \[ \]. I've also tested it without the arguments #1 and #2, but any \newcommand I make seems to fail in math mode.
Now, I know one can roll their own commands to save tedium in math mode, and even pass arguments to them.



\pderiv[2]{...}{...}from cool. – Chel Feb 14 '12 at 16:33