# Trick LaTeX into doing double superscripts

I have a function in my .sty sheet that does a second partial derivative:

\newcommand{\hpartdsq}[2]{\dfrac{\partial^2 #1}{\partial #2 ^2}}


But I'd like to pass it something that already has a superscript (today it's \rho^*).

Is there a way to do this with this function? I feel like wrapping the \rho^* with parentheses would really kill the aesthetics and is not typical for second partial derivatives. Thanks!

-

One cheap solution is to call the macro like this: \hpartdsq{f}{{\rho^*}}.

EDIT: Maybe I should add that it's not a good idea to modify the macro definition so that it contains the braces {}: If you call this macro

\newcommand{\hpartdsq}[2]{\dfrac{\partial^2 #1}{\partial{#2}^2}}


with \hpartdsq{f}{\rho^*}, then it looks as desired, but with \hpartdsq{f}{x_1} the ^2 will be too far to the right.

-
Wow! No wonder google couldn't help me! This is the perfect solution. Thanks! –  Richard Herron Nov 24 '10 at 17:07
@ricardh A good rule of thumb when you are having issues with latex not parsing your intended grouping correctly is to stuff it in brackets. Its the latex equivalent of putting parenthesis around mathematical expressions to explicitly state the order of operations. –  crasic Nov 26 '10 at 8:29
Thanks, I wasn't planning on altering the orig function with this, just applying it as needed. –  Richard Herron Nov 27 '10 at 4:35