# How can I use argmax or argmin inside case?

I want use argmax in my beamer slide. I have found this question really useful: Command for argmin or argmax? The problem is I can not use \argmax inside case environment.

Example 1: \argmax works fine outside of case:

\documentclass[demo]{beamer}% <-- demo only for test, delete it in real document
\mode<presentation> {
\setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\DeclareMathOperator*{\argmax}{arg\,max}
\begin{document}
\begin{frame}
\frametitle{Solving MDP 2}
\begin{block}{Optimal Policy}
Optimal policy can be found by maximizing over $q_\ast (s,a)$
\begin{equation*}
\pi_\ast (a|s)=
\begin{cases*}
1 & \text{if }  (s,a) \\
0 &  \text{otherwise}

\end{cases*}
\argmax_{x \in A}  q_\ast(s,a)
\end{equation*}

\end{block}
\end{frame}
\end{document}


Example 2: inside case \argmax does not work

 \documentclass[demo]{beamer}% <-- demo only for test, delete it in real document
\mode<presentation> {
\setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\DeclareMathOperator*{\argmax}{arg\,max}
\begin{document}
\begin{frame}
\frametitle{Solving MDP 2}
\begin{block}{Optimal Policy}
Optimal policy can be found by maximizing over $q_\ast (s,a)$
\begin{equation*}
\pi_\ast (a|s)=
\begin{cases*}
1 & \text{if } \argmax_{x \in A}  q_\ast(s,a)  \\
0 &  \text{otherwise}

\end{cases*}

\end{equation*}

\end{block}
\end{frame}
\end{document}

• Out of the question btw, it's a slide from Reinforcement Learning by David Silver.. I love those slides.. May 6, 2018 at 15:12
• @Ramesh-X This is a part of David Silver course. The course is fantastic: www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html May 8, 2018 at 8:29

Avoid blank lines in math displays.

You can use \limits

\documentclass[demo]{beamer}% <-- demo only for test, delete it in real document
\mode<presentation> {
\setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\DeclareMathOperator*{\argmax}{arg\,max}
\begin{document}

\begin{frame}
\frametitle{Solving MDP 2}
\begin{block}{Optimal Policy}
Optimal policy can be found by maximizing over $q_\ast (s,a)$
\begin{equation*}
\pi_\ast (a|s)=
\begin{cases*}
1 & if $\argmax\limits_{x \in A} q_\ast(s,a)$  \\
0 & otherwise
\end{cases*}
\end{equation*}
\end{block}
\end{frame}
\end{document}


Recall that in cases* the right column is started in text mode.