Remove “algorithm X :” in an algorithme2 caption

algorithm2ecaptions

I tried to use caption* :

\documentclass{beamer}
\usepackage[lined,boxed,commentsnumbered, ruled,vlined,linesnumbered, french, onelanguage]{algorithm2e}
\usepackage{caption}
\begin{document}
\begin{frame}{Frame 1}
    \begin{algorithm}[H]
        $test$\;
        \caption{alg}
    \end{algorithm}
      \begin{algorithm}[H]
        $test$\;
        \caption*{alg}
    \end{algorithm}
\end{frame}
\end{document}

But it didn't work as intended :
enter image description here

Because I want only alg to be displayed in the caption
enter image description here

Best Answer

Use \NoCaptionOfAlgo You can use it in the preamble or locally. \RestoreCaptionOfAlgo will restore the correct captions.

b

\documentclass{beamer}
\usepackage[lined,boxed,commentsnumbered, ruled,vlined,linesnumbered, french, onelanguage]{algorithm2e}


\NoCaptionOfAlgo % added <<<<<<<<<<<<<<<

\begin{document}
    \begin{frame}{Frame 1}
        \begin{algorithm}[H]
        $test$\;
            \caption{alg A }
        \end{algorithm}
        \begin{algorithm}[H]
            $test$\;
            \caption{alg B}
        \end{algorithm}
        \RestoreCaptionOfAlgo % restore the caption
        \begin{algorithm}[H]
        $test$\;
        \caption{alg C}
    \end{algorithm}
    
    \end{frame}

\end{document}