# Command for argmin or argmax?

How can you get the argmin or argmax in Latex? Two solutions I found are:

\underset{x}{\operatorname{argmax}}

\DeclareMathOperator*{\argmin}{arg\,min}


Any other ideas?

-
How do these solutions (especially the second) feel not right? The \DeclareMathOperator is the way to go in this case. –  Pieter Nov 11 '10 at 17:57
No, it does not use italics. Did you try it? –  Jukka Suomela Nov 11 '10 at 19:18
You are right. I tried before but forgot the \ in front of \argmin. Stupid me. –  Alejandro Nov 11 '10 at 21:24
It would really help, when asking this kind of questions, to specify what is wrong with the solutions you found, and what features are you actually looking for. –  Jan Hlavacek Nov 12 '10 at 3:37

As Pieter says in his comment, \DeclareMathOperator*{\argmin}{arg\,min} is indeed the correct LaTeX way to do that.

This requires \usepackage{amsmath} (actually amsopn would be sufficient, it's automatically loaded by amsmath which is recommended for math typesetting anyway).

Note: the * that follows \DeclareMathOperator sets the underscored option (the argument) underneath the operator like the \lim operator.

-
If you use \DeclareMathOperator*{\argmin}{\arg\!\min} you get rid of the ugly space between arg and min. –  rbp Apr 6 '11 at 21:39
@rbp Why should one use \arg\min when simply argmin does the same? –  egreg Jul 8 '12 at 15:31
@egreg you're right. I arrived at this one from some experimentation with other options, and didn't look back :) –  rbp Jul 9 '12 at 11:56
And don't forget to load the "amsmath" package... \usepackage{amsmath} \DeclareMathOperator*{\argmin}{arg\,min} etc. –  user24477 Jan 16 '13 at 15:49
In ConTeXt that is: \definemathcommand [argmin] [limop] {\mfunction{arg\,min}} –  mb21 Jul 30 '13 at 11:49

I use \newcommand{\argmin}{\operatornamewithlimits{argmin}}.

-
+1 I like this - why overcomplicate things? This looks exactly the same as the \DeclareMathOperator* answer. –  zelanix Aug 13 '14 at 13:52

or you could use the underset command. For example:

    R = \underset{n} {\mathrm{argmax}} ~P(L_n|\mathbf{x})

-
Please don't use this. This makes argmin a mathord rather than a mathop and the spacing is incorrect. Moreover, this will not automatically adjust the limits in inline math mode. –  Aditya Sep 19 '13 at 15:19

Just another alternative (in some sense the poorer solution around), could be to define \argmin in terms of \min and \arg commands.

\newcommand{\argmin}{\arg\!\min}


In this way, 1) \argmin will behave always the same way as \min, 2) doesn't need amsmath or care about \operator... commands 3) yes, the variable in not centered (it is centered in the min part), but that may even be what you want (since it is centered in the same ways a \min, also the 'g' in \arg doesn't further lower the under-argument).

\documentclass[fleqn]{article}
\newcommand{\argmin}{\arg\!\min}
\begin{document}

$\argmin_x f(x) = \{x | f(x) = \min_{x'} f(x')\}$
$\min_x f(x) = \{f(x) | f(x) < f(x_0) \forall x_0 \in R$

\end{document}


-
This doesn't look like a good idea. \argmin_{x\in X\cap Y} f(x) will break it completely. –  yo' Feb 2 '14 at 18:03
What is the \arg command for anyway? –  Thomas Ahle Jun 3 '14 at 12:47
@ThomasAhle, arg is for the argument function (angle in the complex plane, $z = |z| e^{i \arg z}$. tohecz is right by the way. –  alfC Jun 3 '14 at 15:33