算法没有分成多个帧

算法没有分成多个帧
\section[Algorithm]{Algorithm}

\begin{frame}[allowframebreaks]
\begin{algorithm}[H]
\begin{algorithmic}[1]

\STATE \emph {Taking a sequence of values $(f_{1} \dotsc
f_{n/2})$, and calculating $pfbm = |fft(fbmn)^2|$ where
\textbf{fbmn} is \begin{equation}(n -
\mu_{n})/\sigma_{n}.\end{equation} next pfbm is ranged in the
scale of 0 to 2$\pi$}.

\STATE \emph {Calculating the spectral
density of FBM using the estimated Hurst Parameter range between
$0<h\_est<1$}.

\STATE \emph {Calculating the intermediate value of $y_f$
as\begin{equation}y_f =
(pfbm/f\_specd)^2.\end{equation}}.\framebreak
 \STATE \emph { Multiply each term of $f_{j}$ with an independent exponential random variable with mean
1 call it $ \hat{f}$}.

\STATE \emph {Calculate the values of A and B as \begin{equation}
A = 2*((2*\pi)/data)*sum(y_f). \end{equation} \begin{equation} B =
2*((2*\pi)/data)*sum(\sqrt(y_f)).
\end{equation}}
\framebreak \STATE \emph {Construct $(z_{1} \dotsc z_{n/2})$, a
sequence of complex numbers such that $ |z_{i}|= \sqrt{ \hat{f}}$
and the phase of $z_{i}$ is uniformly distributed between 0 and
$2\pi$}.

\STATE \emph {Construct $\lbrace z'_{1}
\dotsc z'_{n} \rbrace$ an expanded version of $\lbrace z_{1}
\dotsc z_{n/2} \rbrace$}.

 \STATE \emph {Inverse-Fourier transform
$z'_{i}$ to obtain the approximate FGN sample path $x_{i}$}.

\end{algorithmic}
\caption{Pseudocode for the generation of Trace Using FGN }
\label{alg:seq1}
\end{algorithm}
\end{frame}

答案1

您正在 (float) 环境中设置算法algorithm,并且浮动不能在页面(或)边界中途中断frame。您可以使用我建议的nofloatalgorithmic环境(来自具有部分边框/框架的算法)以允许这种突破:

在此处输入图片描述

\documentclass{beamer}
\usepackage{algorithm,algcompatible,amsmath,needspace}
\usepackage{lmodern}% https://tex.stackexchange.com/q/58087/5764

\makeatletter
% Taken from https://tex.stackexchange.com/a/178645/5764
\newenvironment{nofloatalgorithmic}[2][0]
  {% \begin{nofloatalgorithmic}
  \par
  %\addvspace{\intextsep}% Vertical gap above in-text float
  \needspace{\dimexpr\baselineskip+6.8pt}%
  \noindent%
  \hrule height.8pt depth0pt \kern2pt% Top horizontal rule
  \refstepcounter{algorithm}% Step algorithm counter
  \addcontentsline{loa}{algorithm}{\numberline{\thealgorithm}#2}% Add entry to LoA
  \noindent\textbf{\fname@algorithm~\thealgorithm} #2\par% Write caption
  \kern2pt\hrule\kern2pt% Middle horizontal rule
  \begin{algorithmic}[#1]
  }
  {% \end{nofloatalgorithmic}
  \end{algorithmic}
  \nobreak\kern2pt\hrule\relax% Bottom horizontal rule
  %\addvspace{\intextsep}% Vertical gap below in-text float
  }
\makeatother

\begin{document}
\section[Algorithm]{Algorithm}

\begin{frame}[allowframebreaks]

  \begin{nofloatalgorithmic}[1]{Pseudocode for the generation of Trace Using FGN\label{alg:seq1}}
    \itshape
    \STATE
    Taking a sequence of values $\bigl( f_{1} \dotsc f_{n/2} \bigr)$, and calculating $\text{pfbm} = 
    |\operatorname{fft}(\textbf{fbmn})^2|$ where \textbf{fbmn} is
    \begin{equation}
      (n - \mu_{n}) / \sigma_{n}
    \end{equation}
    next pfbm is ranged in the scale of~$0$ to~$2\pi$.

    \STATE 
    Calculating the spectral density of FBM using the estimated Hurst Parameter range between $0 < \text{h\_est} < 1$.

    \STATE 
    Calculating the intermediate value of~$y_f$ as
    \begin{equation}
      y_f = \bigl( \text{pfbm}/\text{f\_specd} \bigr)^2.
    \end{equation}

    \framebreak

    \STATE 
    Multiply each term of~$f_{j}$ with an independent exponential random variable with mean $1$ call it~$\hat{f}$.

    \STATE 
    Calculate the values of~$A$ and~$B$ as 
    \begin{align}
      A &= 2 \times \bigl( 2\pi/\text{data} \bigr) \times \sum y_f \\
      B &= 2 \times \bigl( 2\pi/\text{data} \bigr) \times \sum\sqrt{y_f}.
    \end{align}

    \framebreak

    \STATE 
    Construct $\bigl( z_{1} \dotsc z_{n/2} \bigr)$, a sequence of complex numbers such that $\lvert z_{i}\rvert = 
    \sqrt{\hat{f}}$ and the phase of~$z_{i}$ is uniformly distributed between~$0$ and~$2\pi$.

    \STATE 
    Construct $\bigl\{ z'_{1} \dotsc z'_{n} \bigr\}$ an expanded version of $\bigl\{ z_{1} \dotsc z_{n/2} \bigr\}$.

    \STATE 
    Inverse-Fourier transform~$z'_{i}$ to obtain the approximate FGN sample path~$x_{i}$.

  \end{nofloatalgorithmic}
\end{frame}
\end{document}

这里还有一些建议:

  • 使用lmodern避免与字体相关的警告
  • 在演示文稿中对元素(如方程式)进行编号时要小心,因为观众可能跟不上它们。算法也是如此。最好使用人们可以理解的上下文参考,而不是数字;
  • 为了保持一致性,对元素内部使用相同的符号数学之外。

答案2

最简单的解决方案是不使用包algorithm提供的浮动环境algorithm(或类似的),而是定义自己的环境来模拟或的beamer定义(即,使用简单的环境,从而抑制浮动);这也使您的算法标题和或 标题之间的一致性。figuretablecenterfiguretable

所需的定义非常简单:

\makeatletter
\newenvironment{algorithm}[1][]{%
  \def\@captype{algorithm}%
  \par\nobreak\begin{center}\nobreak}
  {\par\nobreak\end{center}\nobreak}
\newcounter{algorithm}
\renewcommand\thealgorithm{\@arabic\c@algorithm}
\makeatother

完整例子:

\documentclass{beamer}
\usepackage{algorithmic}

\makeatletter
\newenvironment{algorithm}[1][]{%
  \def\@captype{algorithm}%
  \par\nobreak\begin{center}\nobreak}
  {\par\nobreak\end{center}\nobreak}
\newcounter{algorithm}
\renewcommand\thealgorithm{\@arabic\c@algorithm}
\makeatother

\begin{document}

\begin{frame}[allowframebreaks]

\begin{algorithm}
\begin{algorithmic}[1]
\STATE \emph {Taking a sequence of values $(f_{1} \dotsc
f_{n/2})$, and calculating $pfbm = |fft(fbmn)^2|$ where
\textbf{fbmn} is \begin{equation}(n -
\mu_{n})/\sigma_{n}.\end{equation} next pfbm is ranged in the
scale of 0 to 2$\pi$}.

\STATE \emph {Calculating the spectral
density of FBM using the estimated Hurst Parameter range between
$0<h\_est<1$}.

\STATE \emph {Calculating the intermediate value of $y_f$
as\begin{equation}y_f =
(pfbm/f\_specd)^2.\end{equation}}.\framebreak
 \STATE \emph { Multiply each term of $f_{j}$ with an independent exponential random variable with mean
1 call it $ \hat{f}$}.

\STATE \emph {Calculate the values of A and B as \begin{equation}
A = 2*((2*\pi)/data)*sum(y_f). \end{equation} \begin{equation} B =
2*((2*\pi)/data)*sum(\sqrt(y_f)).
\end{equation}}
\framebreak \STATE \emph {Construct $(z_{1} \dotsc z_{n/2})$, a
sequence of complex numbers such that $ |z_{i}|= \sqrt{ \hat{f}}$
and the phase of $z_{i}$ is uniformly distributed between 0 and
$2\pi$}.

\STATE \emph {Construct $\lbrace z'_{1}
\dotsc z'_{n} \rbrace$ an expanded version of $\lbrace z_{1}
\dotsc z_{n/2} \rbrace$}.

 \STATE \emph {Inverse-Fourier transform
$z'_{i}$ to obtain the approximate FGN sample path $x_{i}$}.

\end{algorithmic}
\caption{Pseudocode for the generation of Trace Using FGN }
\label{alg:seq1}
\end{algorithm}
\end{frame}

\end{document}

在此处输入图片描述

相关内容