[Tex/LaTex] Vector Arrow Weirdness

math-operatorsvector

Here's something strange:

\documentclass[letterpaper]{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{gensymb}
\DeclareMathOperator{\Vi}{\vec{i}}
\begin{document}
$\Vi$
$\vec{i}$
\end{document}

When I compile this, only the second one produces the desired result. The other gives me a tilde over the i! What gives?

Best Answer

The \DeclareMathOperator function is for defining a quite narrow kind of objects; for instance \log, \exp, \sin or \max use (an equivalent form of) it. So it's for defining function symbols that should consist of letters in the same shape as normal text, as opposed to math italic.

Basically \DeclareMathOperator{\foo}{blurb} does something like

\newcommand{\foo}{\mathop{\mathrm{blurb}}

(I just omit irrelevant technical complications). The \mathop bit is what produces the peculiar spacing around operator names; for instance there is a space in $\log x$, but not in $\log(xy)$. Of course,\mathrm` is what selects upright letters.

The input

\documentclass{article}
%\usepackage{amsmath}

\begin{document}
$\mathrm{\vec{i}}$
\end{document}

produces

enter image description here

but as soon as we uncomment the loading of amsmath we get

enter image description here

The tilde instead of an arrow is a “feature”1 in amsmath, then.

What you need is

\newcommand{\Vi}{\vec{i}}

or, maybe better,

\newcommand{\Vi}{\vec{\imath}}

where the “i” loses its dot.

enter image description here


1 It's not the only “feature” of amsmath related to math accents. The word “feature” is used in its common meaning of “bug”.