I've defined a couple simple macros to make my life a little easier:
\newcommand{\curl}[1]{\ensuremath{\nabla\times #1}}
\renewcommand{\v}[1]{{\ensuremath{\vec{#1}}}}
This way, in text mode I can write \v{F} or \curl{\v{F}}, and all is well.
But for simplicity, at least in math mode, I'd like to be able to just write \curl\v{F}, and have it expand to
\ensuremath{\nabla\times {\ensuremath\vec{F}}}
just like \curl{\v{F}}. Since I've defined \curl in a pretty simple manner, this currently looks right. However, I think I'm actually getting a stranger behavior: if I change the definition of \curl to have parentheses, like {(\ensuremath{\nabla\times #1})}, then the vector symbol shows up over the closing parenthesis, as if the \v (but not its argument) is being captured as an argument to \curl.
Strangely, though, simply typing \ensuremath{(\nabla\times {\ensuremath\vec})} results in errors.
What's going on here? Is there a good way to do this, and is it a good idea?
(By the way, the reason I have an extra pair of {} in the definition of \v is that it allows me to use \int_\v{x} rather than \int_{\v{x}}. This much seems to work, but I'm not really sure why.)
_\v{f}work as a subscript instead of being interpreted as_{\v}{f}? – jtbandes Oct 10 '11 at 23:29\vhas a pair of braces that will delimit the subscript; I prefer mine, but\newcommand{\v}[1]{{\vec{#1}}}will allow a syntax like_\v{f}. – egreg Oct 10 '11 at 23:41_\v{f}, I would think that expands to_{...contents of \v...}{f}. When/how does the{f}argument replace the#1inside of\v? – jtbandes Oct 10 '11 at 23:46_, it expands the following token until finding something unexpandable before starting to typeset the subscript; so it really sees_{\vec{f}}. – egreg Oct 10 '11 at 23:51\v{f}counts as one token? Or is it just that when\vis expanded to yield#1it eats the{f}argument? – jtbandes Oct 10 '11 at 23:54