1

I'm using \DeclareMathOperator*{\argmin}{argmin} for getting the argmin parameter. Every thing is Ok expect if I type it inside algorithmic table, it fails to show the correct output. In the below picture, the scenario is shown

enter image description here

The code for this picture is

\documentclass{article}
\usepackage{algorithm,algpseudocode,float}
\usepackage{amsmath}

\DeclareMathOperator*{\argmin}{argmin}


%-----------
\makeatletter
\newenvironment{breakablealgorithm}
  {% \begin{breakablealgorithm}
   \begin{center}
     \refstepcounter{algorithm}% New algorithm
     \hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
     \renewcommand{\caption}[2][\relax]{% Make a new \caption
       {\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
       \ifx\relax##1\relax % #1 is \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
       \else % #1 is not \relax
         \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
       \fi
       \kern2pt\hrule\kern2pt
     }
  }{% \end{breakablealgorithm}
     \kern2pt\hrule\relax% \@fs@post for \@fs@ruled
   \end{center}
  }
\makeatother

\begin{document}


$$
a = \argmin_s
$$

\begin{breakablealgorithm}
  \caption{XXXXXXXXX}
  \begin{algorithmic}[1]
    \State{$\text{A} = \argmin_s B$}
\end{algorithmic}
\end{breakablealgorithm}



\end{document}

My question is now why it doesn't work properly inside the algorithm.

2
2

Inside the algorithmic environment you're in regular text-style when entering math mode. And operators in text-style have their limits displayed in that way rather than underneath/over top. You have to force an explicit \displaystyle to have it set in the same way:

enter image description here

\documentclass{article}
\usepackage{algorithm,algpseudocode,amsmath}

\DeclareMathOperator*{\argmin}{argmin}

\begin{document}

\[
  a = \argmin_s
\]

\begin{algorithm}
  \caption{XXXXXXXXX}
  \begin{algorithmic}[1]
    \State $\text{A} = \displaystyle\argmin_s B$
  \end{algorithmic}
\end{algorithm}

\end{document}

I wouldn't do it though.

1
  • I'd suggest \argmin\limits instead. However it's a duplicate. – egreg Feb 25 '15 at 8:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.