1

I'm working with vectors, which I'm denoting with $\overrightarrow{a}$, where a is just the name of the vector, and thus is a variable that can take any value. I would like to redefine this as $\v{a}$, to save time and effort. How do I do this?

Apologies if this question is a duplicate - I did find some similar questions, but none that I thought directly answered this.

Edit: Question has been extensively answered in the comments. Thanks!

  • 2
    \newcommand*{\V}[1]{$\overrightarrow{#1}$} Use it as \V{a} – user11232 Nov 8 '13 at 9:42
  • Remark: if I'm already in math-mode, it's better to have the command as \newcommand*{\V}[1]{\overrightarrow{#1}} – Newb Nov 8 '13 at 9:49
  • @HarishKumar how would I do that? – Newb Nov 8 '13 at 9:57
  • \newcommand*{\V}[1]{\ensuremath\overrightarrow{#1}}. But use it only if you intend to apply in both modes. Otherwise, as you said \newcommand*{\V}[1]{\overrightarrow{#1}} is better. – user11232 Nov 8 '13 at 10:00
  • If I end up only using it in one mode, why would the latter option be better than the first? – Newb Nov 8 '13 at 10:02
3

LaTeX provides the semantic macro \vec to typeset a vector. This is short, clear and easy to understand for others. As Martin pointed out in Short names for macros there are several one letter macros that do accent stuff. It is also harder to read for others, once you submit your file for editing or proof reading.

As has been pointed out in the comments, you can do \newcommand*{\V}[1]{\overrightarrow{#1}} without automatic selecting math mode if necessary. Be sure to be the one who decides when math should be involved. You can read more about this in When not to use \ensuremath for math macro?

Now, how about efficiency and saving time to type? A general rule of thumb is, don't do it on the LaTeX side, use anassistent to help you, meaning a good text editor that can expand your often used macros with the hit of one button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.