I want to achieve this
but if I use
\mathrm{argmax}_{y\in\mathcal{Y}}
it does not put y\in\mathcal{Y}
below argmax
. How can I solve this?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityWelcome to TeX.SX! What you probably struggle with is the fact that TeX knows two different modes of typesetting math: inline and display. While display math is used to display mathematical formulas separate from floating text, inline math is used, well, in-line, that is, in the context of other surrounding text.
As for your concrete example, the argument {y \in \mathscr{Y}}
will not be placed underneath "argmax" when you use inline math. This is a typographic decision made by TeX to reduce the space mathematical formulas take when typeset inline. If you use your command in an display-math environment, it will be typeset as you intend:
The above output is generated by the following code:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\argmax}{argmax}
\begin{document}
This is inline: $\argmax_{y \in \mathcal{Y}}$ and more text to follow.
\bigskip
This is not:
\[ \argmax_{y \in \mathcal{Y}} \]
\end{document}
As long as you use the macro \DeclareMathOperator*
(provided by the amsmath
package) to declare the operator via, say,
\DeclareMathOperator*{\argmax}{argmax}
TeX will place the argument of the operator -- here: y\in\mathcal{Y}
-- below the operator itself (a) if the instruction is encountered in display-style math mode (unless overridden by a \nolimits
instruction) or (b) if the operator instruction is followed by \limits
while in text style (or script or scriptscript style).
This is summarized in the following table. The first column shows the default behavior for the four math styles, i.e., without the use of \nolimits
or \limits
. The second column shows the result of overriding the default, either via \nolimits
for display-style math or via \limits
for the other three math styles.
\documentclass{article}
\usepackage{amsmath} % for '\DeclareMathOperator*' macro
\DeclareMathOperator*{\argmax}{argmax}
\usepackage{array} % for '\newcolumntype' macro
\newcolumntype{L}{>{$}l<{$}}
\begin{document}
\renewcommand\arraystretch{1.5} % just for this example
\begin{tabular}{ LL >{\ttfamily}l }
\displaystyle \argmax_{y\in\mathcal{Y}}
& \displaystyle \argmax\nolimits_{y\in\mathcal{Y}}
& \string\displaystyle \\
\argmax_{y\in\mathcal{Y}} % '\textstyle' is the default
& \argmax\limits_{y\in\mathcal{Y}}
& \string\textstyle \\
\scriptstyle \argmax_{y\in\mathcal{Y}}
& \scriptstyle \argmax\limits_{y\in\mathcal{Y}}
& \string\scriptstyle \\
\scriptscriptstyle \argmax_{y\in\mathcal{Y}}
& \scriptscriptstyle \argmax\limits_{y\in\mathcal{Y}}
& \string\scriptscriptstyle
\end{tabular}
\end{document}
\limits
?