9

In some places in my document I have used the following (and it works quite well):

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{argmax} % thin space, limits underneath in displays

\begin{document}

\[z = \argmax_x f(x)\]

\end{document}

enter image description here

However, when I try to use something like this:

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{argmax} % thin space, limits underneath in displays

\begin{document}

    \begin{tabular}{c l}
        $z = \argmax_x f(x)$ \\
        $z = \argmax_{x \in \mathcal{X}} f(x)$
    \end{tabular} 

\end{document}

It does not work anymore. It seems that tabular is somehow to blame here.

enter image description here

UPDATE2: Well, it was clearly because I was using inline math ($). Thanks David!

Juan Leni
  • 698
  • 1
    please always post a complete document that shows the problem. I made a complete document as in the answer below but it is not clear what the issue is? – David Carlisle May 18 '17 at 11:10
  • 2
    well of course, you have used inline math there $ so get the inline form not the display layout. and it applies to both cases so the "works" "not works" in the original part of the question is misleading – David Carlisle May 18 '17 at 11:20
  • if you want aligned display use an enviornment for that such as align not tabular – David Carlisle May 18 '17 at 11:22
  • I will edit so it is clearer. Thanks! Could you update your answer with a short example using aligned? that would be awesome! – Juan Leni May 18 '17 at 11:25
  • see this answer for reasons why TeX sets limits to the side in inline math https://tex.stackexchange.com/questions/323367/i-have-a-question-about-the-displaystyle-command/323375#323375 – David Carlisle May 18 '17 at 11:32
  • I hope it makes more sense now – Juan Leni May 18 '17 at 11:33

2 Answers2

12

enter image description here

It isn't clear what you mean by "not work" the output is as I expect.

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{argmax} % thin space, limits underneath in displays

\begin{document}



a
\[z = \argmax_x f(x)\]

b
\[z = \argmax_{x \in \mathcal{X}} f(x)\]

\end{document}

Updated question shows it is just an issue of display or inline setting:

enter image description here

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{argmax} % thin space, limits underneath in displays

\begin{document}



a
\[z = \argmax_x f(x)\]

b
\[z = \argmax_{x \in \mathcal{X}} f(x)\]

a2
$z = \argmax_x f(x)$

b2
$z = \argmax_{x \in \mathcal{X}} f(x)$


a3 (don't do this)
$z = \argmax\limits_x f(x)$

b3 (or this)
$z = \argmax\limits_{x \in \mathcal{X}} f(x)$


c
\begin{align*}
z &= \argmax_x f(x)\\
z &= \argmax_{x \in \mathcal{X}} f(x)
\end{align*}




\end{document}
David Carlisle
  • 757,742
11

Try using \underset{belowtext}{text}.

Note below that:

  • \mathrm is for using non-italics Roman font in math mode.
  • \, is for adding a thin space
z = \underset{x}{\mathrm{argmax}}\, f(x)

enter image description here