Katex: "argmax" and "argmin" not possible to write

Created on 1 Jan 2019  路  6Comments  路  Source: KaTeX/KaTeX

Hi,

I have troubles to write a proper "arg max" and "arg min" such that the argument is below the operator and in the center and not next to it.

It should look like this:

screenshot 2019-01-01 at 18 25 38

I tried

\arg\min_{A, B}
\operatorname{argmin}_{A, B}
\DeclareMathOperator{\argmin}{arg\,min}
\operatorname{argmin}_{\hbox{A, B}}

Do you have an idea how to make this work? Am I missing some obvious solution?

Thanks
Ren茅

All 6 comments

Here's how we define \limsup macro:

"\\mathop{\\operatorname{lim\\,sup}}\\limits"

So you could do the same with argmin (or arg\,min) either by passing a string like above for a macro, or as a one-off (or \def) in TeX like so:

\mathop{\operatorname{arg\,min}}\limits

Wow, thats awesome!

Is there any reason not to add this macro to KaTeX? If not, then I would like to implement this as my first contribution.

I agree that it would be a useful macro. Is it defined in any existing LaTeX package(s)? We generally aim to reproduce LaTeX behavior, so that would be ideal.

I opened #1820. Sadly I could not find any package that defined \argmax nor \argmin. It seems like, everyone always defines them on their own. Also, there does not seem to be a consensus how to define it "properly". Therefore, I created a new section at the very bottom of the macros.js file.

I still believe it makes sense to add it, because it will save a bit time and pain for other users :) Once we find out, that it has been implemented in a package, we can still move it to the right place.

Edit: Okay, now I also found out that you can even pass own macros to the render method. Also \global\def seems to be very useful.

I found a definition of \argmin and \argmax in the CTAN statmath package as

\DeclareMathOperator{\argmin}{arg\,min}
\DeclareMathOperator{\argmax}{arg\,max}

which I think matches your definition.

ah, alright. I put a reference to that package and updated the PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiospampinato picture fabiospampinato  路  4Comments

jason-s picture jason-s  路  3Comments

q2apro picture q2apro  路  3Comments

OisinMoran picture OisinMoran  路  4Comments

msridhar picture msridhar  路  3Comments