4

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?

  • 4
    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. – underwhelmer 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
  • 3
    \DeclareMathOperator is for very particular objects such as \log, \max or \sin. You just need \newcommand{\Vi}{\vec{i}}, probably, or better, \newcommand{\Vi}{\vec{\imath}} – egreg Sep 22 '15 at 14:59
  • Ok, that's great. I'm still curious about why \DeclareMathOperator turns $\vec$ into $\tilde$. That seems rather odd behavior to me. – underwhelmer Sep 22 '15 at 15:01
  • 1
    @egreg I guess \operator@font is interfering with the math accent. Did I just got lucky with http://tex.stackexchange.com/a/261966/82917? – campa Sep 22 '15 at 15:06
  • Thanks, @campa. I guess the general worry is this: I've always used DeclarMathOperator for things like this. If that's not what I should be doing, fine, but this is the first time it's ever broken for me and I'd like to know in general when it's going to break. – underwhelmer Sep 22 '15 at 15:09

1 Answers1

4

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”.

egreg
  • 1,121,712