I tend to use \newcommand to define macros for symbols I use often, e.g. \newcommand{\hankel}{H^{(1)}_0}. One inconvenience of this approach is the fact that command names cannot include numbers. What I ideally want is to map something like \H0 to H^{(1)}_0. I imagine this could be done with some macro expansion/snippet package, or one might use \newcommand to define a command that takes a parameter, etc. Before I start experimenting, though -- is there a canonical way of dealing with this problem?

I think it is important to know what other commands \H... you're going to need. Is it as in Jan's answer? Then that one's perfect for you. If not, can you add some explanation to your question?
–
Hendrik VogtJan 26 '11 at 12:22

Jan's answer works well for many of my use cases; it looks to me like other solutions are cumbersome or have side effects. I often use variables/identifiers with numbers when I compute things, and it is annoying that I cannot reuse these names in LaTeX -- that was my main motivation for asking the question. For the time being I think I'll stick with either not using numbers, or using command parameters as per Jan's suggestion.
–
Leo AlekseyevJan 27 '11 at 5:33

It would be really interesting for me to see other command with numbers that you'd like to use.
–
Hendrik VogtJan 27 '11 at 10:32

1

@Hendrik: how about H2O? :) (I am not a chemist, so I actually don't care much about that one.) In truth, almost all my use cases involve subscripts and superscripts -- perhaps used as powers or to indicate matrix elements. So \newcommand parameters will work well.
–
Leo AlekseyevJan 27 '11 at 18:26

That's a good one, thanks. One could handle such cases, but it wouldn't be nice. Good that you mostly want sub- und superscripts only!
–
Hendrik VogtJan 27 '11 at 21:16

Note that when we call \GG followed by 2, we don't get any error/warning: it is just ignored. This method could seem good, but it has many drawbacks, failing in unexpected cases. For instance, if \foo is say, 123, then