2

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> {
    \usetheme{Madrid}
    \setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\usepackage{tikz}               % add background image
\usepackage{mathtools}               % add background image
\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> {
    \usetheme{Madrid}
    \setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\usepackage{tikz}               % add background image
\usepackage{mathtools}               % add background image
\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}
2

1 Answer 1

5

Avoid blank lines in math displays.

You can use \limits

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

\usepackage{booktabs}           % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\usepackage{tikz}               % add background image
\usepackage{mathtools}               % add background image
\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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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