2

I am using the following definition to generate the argmax operator:

\DeclareMathOperator*{\argmax}{\arg\!\max}

However the problem is when I use it in a part that some text exists because of the written argument under argmin the next line appears with a abnoraml distance in order to keep the distance from the argument under argmin. However when I use \frac for example, this time, the proportion adjusts itself to not to overlap with the next line. How can I change the above command to behave like the frac?

Examples:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator*{\argmax}{\arg\!\max}

\begin{document}
  This is a test. This is a test. $\argmax\limits_{x}{x^2}$ This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.
\end{document}

With output enter image description here

As opposed to:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator*{\argmax}{\arg\!\max}

\begin{document}
This is a test. This is a test. $\frac{x}{x^2}$ This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.
\end{document}

With outputenter image description here

Naji
  • 1,505
  • You might want to try $\argmax_{x}{x^2}$ instead of $\argmax\limits_{x}{x^2}$. – moewe Nov 03 '13 at 14:36
  • Thanks, I know that one but I do like to represent argmax in this format. – Naji Nov 03 '13 at 14:38
  • This is the same behavior when you use \lim_{i=1}^n in displaystyle. – Sigur Nov 03 '13 at 14:44
  • 2
    Mhhh, you could \smash{...} the whole thing, but that definitely does not look right. Is there no way you could accept the right subscript? (Note that the output of \frac in text style is not optimal either.) BTW: you can define argmax via \DeclareMathOperator*{\argmax}{argmax}, no need for \arg\!\max. – moewe Nov 03 '13 at 14:44
  • Since you have an operator with symbol a text it is strange if it is not aligned with the baseline. – Sigur Nov 03 '13 at 14:54
  • You can do slightly better using \DeclareMathOperator*{\argmax}{\smash{\text{argmax}}}, which removes the descender depth from the operator. – Werner Nov 03 '13 at 15:08
  • 1
    @Naji If you look closely, the fraction is typeset in a very different way: both the numerator and the denominator are smaller and the fraction line is raised from the baseline; nothing of this kind is possible with \argmax. – egreg Nov 03 '13 at 15:35
  • @Sigur, I actually think this is strange to shift the whole line rather than adjusting the font or alignment of mathematical operator to fit to the line. – Naji Nov 03 '13 at 15:40
  • @egreg, I see. However I was thinking of doing something non-standard like Werner's answer here: http://tex.stackexchange.com/questions/141932/how-to-write-under-an-underline

    i.e. defining a \genfrac with thickness zero?!

    – Naji Nov 03 '13 at 15:42
  • 2
    @Naji Since you can't reduce the size of “argmax” there's nothing you can do; setting the limit on the right in inline formulas is a widely used practice. – egreg Nov 03 '13 at 21:14

1 Answers1

3

As far as I understand, you want to manually correct the vertical spacing, making it closer to this without your operator. I am afraid that the result will not be beautiful. An example of such a solution is the following (vertical spacing chosen by hand):

\documentclass{article}
\usepackage{amsmath}

%\DeclareMathOperator*{\argmax}{\arg\!\max}
\DeclareMathOperator*{\argmax}{argmax}



\begin{document}


  This is a test. This is a test. $\argmax\limits_{\raise3pt\hbox{$\scriptstyle x$}}{x^2}$ \vspace{-5pt}
 This is a test. This is a test. This is a test. This is a test. This is a test.  This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.
\end{document}

enter image description here