# Vector Arrow Weirdness

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?

• Why should you define \Vi with \DeclareMathOperator? If your aim is to have an upright “i”, then \newcommand{\Vi}{\vec{\mathrm{i}}} is what you need. – egreg Sep 22 '15 at 14:53
• I'm not sure... is there a better option? I just want something quicker to type than $\vec{i}$ as I write up exams, etc... Perhaps I'm missing the thrust of your question. – Shay Sep 22 '15 at 14:56
• @Shay egreg is asking "Why did you choose to use \DeclareMathOperator?" What is your desired outcome? – darthbith Sep 22 '15 at 14:59
• @egreg I guess \operator@font is interfering with the math accent. Did I just got lucky with tex.stackexchange.com/a/261966/82917? – campa Sep 22 '15 at 15:06

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

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

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.

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