2

I'm trying to put an algorithm in a beamer document (using the algorithm2e package). But the line numbers are being printed outside the box. Rest of the text is also printed somewhat left-shifted. The issue mentioned in this question is identical, except I did not import the parskip package.

MWE:

\documentclass[aspectratio = 169]{beamer}

\usepackage[linesnumbered, boxruled, boxed]{algorithm2e}
\usepackage{algpseudocode}

\SetKwInput{KwInput}{Input}

\begin{document}
    \begin{frame}{Algorithm}
        \begin{algorithm}[H]
            \caption{An algorithm.}
            \label{alg:example}
            \DontPrintSemicolon
            % 
            %%%%%%%%%%%%%%%%%%%%%
            %       I/O
            %%%%%%%%%%%%%%%%%%%%%
            
            \KwInput
            {
                Some input.
            }
            % 
            \BlankLine
            
            %%%%%%%%%%%%%%%%%%%%%
            %       BODY
            %%%%%%%%%%%%%%%%%%%%%
            
            First step. \;
            % 
            Second step. \;
            % 
            Third step. \;
        \end{algorithm}
    \end{frame}
\end{document}

Output:

Output

1

0

Your Answer

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

Browse other questions tagged or ask your own question.