Macro Code
% Define "\argmax" and "\argmin" macros.
% These definitions require the amsmath package, 
% which provides "\DeclareMathOperator*".
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}

The macros \argmin and \argmax have the following features:

  1. Correct spacing depending on the surrounding context (e.g., "$\operatorname{arg\hspace{1mu}min}h(x)$" instead of "$\mathrm{arg\hspace{3mu}min}h(x)$").
  2. Always uses the upright mathematics font (they will not become italicized when used inside a theorem body).
  3. Correct placement of limits, e.g., \argmin_{x > 0} is rendered as $\operatorname{arg\,min}_{x > 0}$ in inline equations, whereas in display equations it is rendered as $$\displaystyle\operatorname*{arg\hspace{1mu}min}_{x > 0}$$
  4. a slight space is included between "arg" and "min".
As a side note, $\operatorname{arg\hspace{1mu}min} f$ (and $\operatorname{arg\hspace{1mu}max} f$) is a set, since there is not, in general, $f$ can have multiple minimizing arguments. Consider, for example, $(x, y) \mapsto f(x, y) := x^2$. Then, $$\operatorname{arg\hspace{1mu}min} f = \{(0, y) : y \in \reals\}$$ Thus, in general, one should write $x \in \operatorname{arg\,min} f$ instead of $x = \operatorname{arg\,min} f$ unless $f$ is known to be minimized at a unique point (e.g., if $f$ is strictly convex).

Examples

Code Output
$\argmin_x f(x)$
$$\operatorname{arg\hspace{1mu}min}_{x} f(x)$$
\[
  \argmax_x f(x)
\]
$$\operatorname*{arg\hspace{1mu}min}_{x} f(x)$$
More LaTeX macros are available at paulwintz.com/latex-macros.