2

I have to write a long pseudo code in latex but one slide only takes 22 syntex. How to continue the remaining syntex in next slides.

Please see my codes, I am using the extra packages for other documents.

My Thanks in advance !!

\documentclass{beamer} 
 \usepackage{amssymb} 
 \addtobeamertemplate{navigation symbols}{}{ \usebeamerfont{footline} 
 \usebeamercolor[fg]{footline} \hspace{1em} } \setbeamertemplate{footline}{ 
 \raisebox{5pt}{\makebox[\paperwidth]{\hfill\makebox[10pt] 
 {\scriptsize\insertframenumber}}}} \renewcommand\thefootnote{\textcolor{red} 
 {\arabic{footnote}}} \usepackage[multiple]{footmisc} \usepackage[usestackEOL] 
 {stackengine} \usepackage{scalerel} 
 \def\myoverline#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$} 
 \stackengine{1.2\LMpt}{$\SavedStyle#1$}{\rule{\wd0}{0.95\LMpt}}{O}{c}{F}{F}{S}}} 
 \renewcommand{\footnotesize}{\fontsize{7pt}{9pt}\selectfont}
    
  \usepackage{algpseudocode}
  \usepackage{ragged2e} 
  \usepackage{lipsum} 
  \usepackage[T1]{fontenc} 
  \usepackage{xcolor}
  \usepackage{lmodern}
  \usepackage[english]{babel} 
  \usepackage[utf8x]{inputenc} 
  \usepackage{graphicx} 
  \usepackage{color} 
  \setbeamercolor{frametitle}{fg=blue}
  \usepackage{amsthm}
  \setbeamertemplate{theorems}[numbered]
    
    \newtheorem{proposition}[theorem]{Proposition} \theoremstyle{definition} 
    \newtheorem*{sketch}{Proof sketch.}
    
  \usepackage{algorithm} 
  \usepackage{algpseudocode} 
  \usepackage{amsmath, latexsym} 
  \usepackage{amssymb}
  \usepackage{mathtools} 
  \usepackage{amsthm} 
  \usepackage{amsmath,amsfonts} 
  \usepackage{amssymb}
    
  \usepackage{multirow} 
  \usepackage{graphicx} 
  \usepackage{graphicx}
    
  \begin{document}
    
  \begin{frame}{Main Results} \begin{algorithm} [H] \tiny
    
    \caption{Determine whether a given vector is quasi-uniform entropy vector and if it is, give a consistent quasi-uniform distribution.}\label{alg:1} \begin{algorithmic}[1]
    
    \Require $\mathbf{h}^{\text{t}}$
    
    \Ensure $\mathbf{h}^{\text{t}}, \mathbf{p}$
    
    \State {$\mathnormal{s}{\alpha} \leftarrow 2^{\textbf{h}{\alpha}^{\text{t}}}, \alpha \subseteq [\mathnormal{n}]$}
    
    \If {$\mathnormal{s}_{\alpha} \in \mathbb{N}, \emptyset \neq \alpha \subseteq [\mathnormal{n}]$}
    
    \State {$\mathnormal{S}{\mathnormal{k}} \leftarrow {0,1, \ldots,\mathnormal{s}{\mathnormal{k}}-1}$}
    
    \State {$\mathcal{X}{[\mathnormal{n}]} \leftarrow \prod{\mathnormal{k}=1}^{\mathnormal{n}}\mathnormal{S}_{\mathnormal{k}}$}
    
    \Else \\\
    
    \Return {$\textbf{h}^{\text{t}} \notin \Lambda_{\mathnormal{n}}$ \text{and terminate}}
    
    \EndIf
    
    \State{$\mathnormal{i} \leftarrow 1, \mathbf{p} \leftarrow \mathbf{0}{|\mathcal{X}{[\mathnormal{n}]}|\times 1}, \mathnormal{m} \leftarrow |\mathcal{X}_{[\mathnormal{n}]}|, \mathnormal{f} \leftarrow 0$}
    
    \State \textbf{function} {M{\tiny AKE}QUD $(\mathnormal{i},\mathnormal{s}{[\mathnormal{n}]},\mathnormal{m},\mathbf{p},\textbf{h}^{\text{t}},\mathcal{X}{[\mathnormal{n}]},\mathnormal{f})$}
    
    \If{$\mathnormal{m}=1$}
    
    \State {$\mathnormal{p}(\mathcal{X}{[n]}) \leftarrow 1- \sum{\mathnormal{x}=1}^{\mathcal{X}_{[\mathnormal{n}]}-1}\mathnormal{p}(\mathnormal{x})$}
    
    \State{$\mathbf{p'}\leftarrow \textbf{p}, \mathbf{h'}\leftarrow \textbf{h}$}
    
    \If{$\mathnormal{p}(\boldsymbol{\mathnormal{x}}{\alpha}) \in {0, 1/\mathnormal{s}{\alpha}}, \forall \boldsymbol{\mathnormal{x}}{\alpha} \in \boldsymbol{\mathcal{X}}{\alpha}, \sum_{\boldsymbol{\mathnormal{x}}{\alpha}}\mathnormal{p}(\boldsymbol{\mathnormal{x}}{\alpha})=1, \forall \emptyset \neq \alpha \subsetneq [\mathnormal{n}]$}
    
    \State {$\mathnormal{f} \leftarrow 1$}
    
    \EndIf
    
    \Else
    
    \State{$\mathnormal{v} \leftarrow \left[0, \frac{1}{\mathnormal{s}_{[\mathnormal{n}]}}\right]$}
    
    \For {$\mathnormal{j}=1:1:2$}
    
    \If {$\mathnormal{f}=1$} \\\
    
    \Return {$\mathbf{h}^{\text{t}} \in \Lambda_{\mathnormal{n}}$ \text{and terminate}}
    
    \EndIf
    
    \State $\mathnormal{p}(\mathnormal{i}) \leftarrow \mathnormal{v}(\mathnormal{j})$
    
    \If {$0 \leq 1-\sum_{a=1}^{|\mathcal{X}{[\mathnormal{n}]}|}\mathnormal{p}(a) \leq \frac{|\mathcal{X}{[\mathnormal{n}]}|-i}{\mathnormal{s}{[\mathnormal{n}]}}, \text{Pr}{\boldsymbol{\mathnormal{X}}{\alpha} = \boldsymbol{\mathnormal{x}}{\alpha}} \leq \frac{1}{\mathnormal{s}{\alpha}},\forall \boldsymbol{\mathnormal{x}}{\alpha} \in \boldsymbol{\mathcal{X}}{\alpha},\forall \emptyset \neq \alpha \subsetneq [\mathnormal{n}]$} \
    
    \Return {M{\tiny AKE}QUD$(\mathnormal{i}+1,\mathnormal{s}{[\mathnormal{n}]},\mathnormal{m}-1,\mathbf{p},\mathbf{h}^{\text{t}},\mathcal{X}{[\mathnormal{n}]},\mathnormal{f})$}
    
    \EndIf
    
    \EndFor
    
    \EndIf
    
    \State \textbf{end function}\
    
    \Return {$\mathbf{h}^{\text{t}} \notin \Lambda_{\mathnormal{n}}$} \end{algorithmic} \end{algorithm} \end{frame}
    
    \end{document}
2
  • 1
    A side note: There are several repeated packages called which should be reduced.
    – Leucippus
    Sep 8 at 19:15
  • 1
    @Saleem Please stop vandalising the question and answers. If you are concerned about the exact content shown here, replace the content of your algorithm with some dummy content, but don't completely remove the code from your question and the answers. The purpose of this site is not just helping you, but to build a library of knowledge to help future users with the same problem! Sep 10 at 12:43

1 Answer 1

1

If you refrain from wrapping your algorithm into a floating environment (which isn't terrible useful as beamer doesn't have a floating mechanism), you can let beamer automatically split your algorithm with the allowframebreaks frame option:

\documentclass{beamer} 
%\usepackage{amssymb} 
\addtobeamertemplate{navigation symbols}{}{ \usebeamerfont{footline} 
\usebeamercolor[fg]{footline} \hspace{1em} } \setbeamertemplate{footline}{ 
\raisebox{5pt}{\makebox[\paperwidth]{\hfill\makebox[10pt] 
{\scriptsize\insertframenumber}}}} \renewcommand\thefootnote{\textcolor{red} 
{\arabic{footnote}}} 
%\usepackage[multiple]{footmisc} 
\usepackage[usestackEOL]{stackengine} 
\usepackage{scalerel} 
\def\myoverline#1{\ThisStyle{\setbox0=\hbox{$\SavedStyle#1$} 
\stackengine{1.2\LMpt}{$\SavedStyle#1$}{\rule{\wd0}{0.95\LMpt}}{O}{c}{F}{F}{S}}} 
\renewcommand{\footnotesize}{\fontsize{7pt}{9pt}\selectfont}

\usepackage{algpseudocode}
\usepackage{ragged2e} 
\usepackage{lipsum} 
\usepackage[T1]{fontenc} 
%\usepackage{xcolor}
\usepackage{lmodern}
\usepackage[english]{babel} 
%\usepackage[utf8x]{inputenc} 
%\usepackage{graphicx} 
%\usepackage{color} 
\setbeamercolor{frametitle}{fg=blue}
%\usepackage{amsthm}
\setbeamertemplate{theorems}[numbered]

\newtheorem{proposition}[theorem]{Proposition} \theoremstyle{definition} 
\newtheorem*{sketch}{Proof sketch.}

\usepackage{algorithm} 
\usepackage{algpseudocode} 
%\usepackage{amsmath} 
\usepackage{latexsym} 
%\usepackage{amssymb}
\usepackage{mathtools} 
%\usepackage{amsthm} 
%\usepackage{amsmath,amsfonts} 
%\usepackage{amssymb}

\usepackage{multirow} 
%\usepackage{graphicx} 
%\usepackage{graphicx}

\usepackage{caption}

\begin{document}

\begin{frame}[allowframebreaks]
\frametitle{Main Results} 
\captionof{algorithm}{Determine whether a given vector is quasi-uniform entropy vector and if it is, give a consistent quasi-uniform distribution.}
\label{alg:1} 
\tiny
\begin{algorithmic}[1]

\Require $\mathbf{h}^{\text{t}}$

\Ensure $\mathbf{h}^{\text{t}}, \mathbf{p}$

\State {$\mathnormal{s}{\alpha} \leftarrow 2^{\textbf{h}{\alpha}^{\text{t}}}, \alpha \subseteq [\mathnormal{n}]$}

\If {$\mathnormal{s}_{\alpha} \in \mathbb{N}, \emptyset \neq \alpha \subseteq [\mathnormal{n}]$}

\State {$\mathnormal{S}{\mathnormal{k}} \leftarrow {0,1, \ldots,\mathnormal{s}{\mathnormal{k}}-1}$}

\State {$\mathcal{X}{[\mathnormal{n}]} \leftarrow \prod{\mathnormal{k}=1}^{\mathnormal{n}}\mathnormal{S}_{\mathnormal{k}}$}

\Else \\\

\Return {$\textbf{h}^{\text{t}} \notin \Lambda_{\mathnormal{n}}$ \text{and terminate}}

\EndIf

\State{$\mathnormal{i} \leftarrow 1, \mathbf{p} \leftarrow \mathbf{0}{|\mathcal{X}{[\mathnormal{n}]}|\times 1}, \mathnormal{m} \leftarrow |\mathcal{X}_{[\mathnormal{n}]}|, \mathnormal{f} \leftarrow 0$}

\State \textbf{function} {M{\tiny AKE}QUD $(\mathnormal{i},\mathnormal{s}{[\mathnormal{n}]},\mathnormal{m},\mathbf{p},\textbf{h}^{\text{t}},\mathcal{X}{[\mathnormal{n}]},\mathnormal{f})$}

\If{$\mathnormal{m}=1$}

\State {$\mathnormal{p}(\mathcal{X}{[n]}) \leftarrow 1- \sum{\mathnormal{x}=1}^{\mathcal{X}_{[\mathnormal{n}]}-1}\mathnormal{p}(\mathnormal{x})$}

\State{$\mathbf{p'}\leftarrow \textbf{p}, \mathbf{h'}\leftarrow \textbf{h}$}

\If{$\mathnormal{p}(\boldsymbol{\mathnormal{x}}{\alpha}) \in {0, 1/\mathnormal{s}{\alpha}}, \forall \boldsymbol{\mathnormal{x}}{\alpha} \in \boldsymbol{\mathcal{X}}{\alpha}, \sum_{\boldsymbol{\mathnormal{x}}{\alpha}}\mathnormal{p}(\boldsymbol{\mathnormal{x}}{\alpha})=1, \forall \emptyset \neq \alpha \subsetneq [\mathnormal{n}]$}

\State {$\mathnormal{f} \leftarrow 1$}

\EndIf

\Else

\State{$\mathnormal{v} \leftarrow \left[0, \frac{1}{\mathnormal{s}_{[\mathnormal{n}]}}\right]$}

\For {$\mathnormal{j}=1:1:2$}

\If {$\mathnormal{f}=1$} \\\

\Return {$\mathbf{h}^{\text{t}} \in \Lambda_{\mathnormal{n}}$ \text{and terminate}}

\EndIf

\State $\mathnormal{p}(\mathnormal{i}) \leftarrow \mathnormal{v}(\mathnormal{j})$

\If {$0 \leq 1-\sum_{a=1}^{|\mathcal{X}{[\mathnormal{n}]}|}\mathnormal{p}(a) \leq \frac{|\mathcal{X}{[\mathnormal{n}]}|-i}{\mathnormal{s}{[\mathnormal{n}]}}, \text{Pr}{\boldsymbol{\mathnormal{X}}{\alpha} = \boldsymbol{\mathnormal{x}}{\alpha}} \leq \frac{1}{\mathnormal{s}{\alpha}},\forall \boldsymbol{\mathnormal{x}}{\alpha} \in \boldsymbol{\mathcal{X}}{\alpha},\forall \emptyset \neq \alpha \subsetneq [\mathnormal{n}]$} \

\Return {M{\tiny AKE}QUD$(\mathnormal{i}+1,\mathnormal{s}{[\mathnormal{n}]},\mathnormal{m}-1,\mathbf{p},\mathbf{h}^{\text{t}},\mathcal{X}{[\mathnormal{n}]},\mathnormal{f})$}

\EndIf

\EndFor

\EndIf

\State \textbf{end function}\

\Return {$\mathbf{h}^{\text{t}} \notin \Lambda_{\mathnormal{n}}$} \end{algorithmic} 
\end{frame}

\end{document}

Off-topic:

  • don't load the same package multiple times
  • you don't need to load any of these ams* packages, beamer loads them automatically
  • don't use footmisc with beamer, it can make footnotes disappear
  • you don't need to load xcolor or color, beamer loads them automatically
  • better not use the utf8x option. If your latex distribution is somewhat up-to-date, utf8 is used automatically
  • no need for graphicx, beamer loads it automatically

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.