5

I'd like to extend the \min function by a subscript. The definition is

\newcommand{\smoothmin}[1]{\operatorname*{min_{{#1}}}}

But the fonts of #1 in \[ \smoothmin{P,0}_{i=0,\dots,n} \] differ from the font in the subscript. I also tried

\newcommand{\smoothmin}[1]{\operatorname*{min_{\mathnormal{#1}}}},

but this did not help.

What is the correct way of defining the function to have both subscripts in the same font?

3
  • Have you tried \newcommand{\smoothmin}[1]{\min_{#1}} along with ${\smoothmin{P,0}}_{i=0,\dots,n}$? Or, if you prefer, \newcommand{\smoothmin}[1]{\operatorname*{min}_{#1}} along with ${\smoothmin{P,0}}_{i=0,\dots,n}$?
    – Mico
    Apr 5 at 20:24
  • This is not the same in the \[ … \] environment. Instead, your solution produces a double subscript. Apr 5 at 20:34
  • Then just use \operatorname instead of \operatorname*.
    – Mico
    Apr 5 at 20:44

1 Answer 1

5

\operatorname is not the right tool for this job. You might do

\newcommand{\smoothmin}[1]{%
  \operatorname*{min_{\mathgroup=-1 #1}}%
}

but an input such as \smoothmin{P,-1}_{i=0,1,\dots,n} would produce

enter image description here

because minus signs become hyphens in the argument to \operatorname*.

Fix:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\smoothmin}[1]{\mathop{\min\nolimits_{#1}}}

\begin{document}

\[
\smoothmin{P,0}_{i=0,\dots,n}
\]

\end{document}

enter image description here

A suggestion for being able to use this also in inline formulas:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\NewDocumentCommand{\smoothmin}{me{_}}{%
  \mathop{\mathpalette\smoothmin@{{#1}{#2}}}%
}
\NewDocumentCommand{\smoothmin@}{mm}{\smoothmin@@#1#2}
\NewDocumentCommand{\smoothmin@@}{mmm}{%
  % #1 = math style, #2 = subscript, #3 = optional condition
  \ifx#1\displaystyle
    \mathop{\min\nolimits_{#2}}\IfValueT{#3}{_{#3}}%
  \else
    \min_{#2\IfValueT{#3}{;\,#3}}%
  \fi
}
\makeatother

\begin{document}

\[
\smoothmin{P,0}_{i=0,\dots,n}a_i
\]
\begin{center}
$\smoothmin{P,0}_{i=0,\dots,n}a_i$
\end{center}

\end{document}

enter image description here

1
  • This was helpful indeed, thanks! Apr 6 at 11:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .