2

The following code gives me an error and I am not sure why:

\documentclass{beamer}

\usepackage{default}
% typesetting of algorithms
\usepackage[vlined,linesnumbered]{algorithm2e}
\SetArgSty{textnormal}
\SetCommentSty{textnormal}

\begin{document}

\begin{frame}%{ % Implementation of pin() (((

  \frametitle{Implementation of \texttt{pin\,()}}

  \begin{function}[H]
    \Titleofalgo{ \texttt{pin($\mathit{pageno}$)}}
    \eIf
      {buffer pool already contains $\mathit{pageno}$}
      {$\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow
           \texttt{pinCount\,(\(\mathit{pageno}\))} + 1$ \;
       \Return{address of frame holding $\mathit{pageno}$ \;}}
      {select a victim frame $v$ using the replacement policy \;
       \If{$\texttt{dirty\,(\(v\))}$}
          {write $v$ to disk \;}
       read page $\mathit{pageno}$ from disk into frame $v$ \;
       $\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow 1$ \;
       $\texttt{dirty\,(\(\mathit{pageno}\))} \leftarrow \text{false}$ \;
       \Return{address of frame $v$} \;
      }
 \end{function}
\end{frame} 

\end{document}

The error message I get is

./test.tex:31: Undefined control sequence.
\beamer@doifinframe ...{function}[H] \Titleofalgo 
                                                  { \texttt {pin($\mathit {p...
l.31 \end{frame}

and I cannot figure out why. What am I missing please?

2 Answers 2

2

Beware of the proper spelling; it's \TitleOfAlgo (T, O, A upper case) and not \Titleofalgo:

\documentclass{beamer}

\usepackage{default}
% typesetting of algorithms
\usepackage[vlined,linesnumbered]{algorithm2e}
\SetArgSty{textnormal}
\SetCommentSty{textnormal}

\begin{document}

\begin{frame}%{ % Implementation of pin() (((

  \frametitle{Implementation of \texttt{pin\,()}}

  \begin{function}[H]
    \TitleOfAlgo{\texttt{pin($\mathit{pageno}$)}}
    \eIf
      {buffer pool already contains $\mathit{pageno}$}
      {$\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow
           \texttt{pinCount\,(\(\mathit{pageno}\))} + 1$ \;
       \Return{address of frame holding $\mathit{pageno}$ \;}}
      {select a victim frame $v$ using the replacement policy \;
       \If{$\texttt{dirty\,(\(v\))}$}
          {write $v$ to disk \;}
       read page $\mathit{pageno}$ from disk into frame $v$ \;
       $\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow 1$ \;
       $\texttt{dirty\,(\(\mathit{pageno}\))} \leftarrow \text{false}$ \;
       \Return{address of frame $v$} \;
      }
 \end{function}
\end{frame} 

\end{document}

The result:

enter image description here

I also suppressed an spurious blank space in the title.

1
  • Thank you Gonzalo and Bernard. I copied this from a slide deck that I received from a colleague and the error occurred while trying to compile his slide deck. I tried a few things, but never thought that his spelling would be wrong. Many thanks.
    – ozsu
    Jul 19, 2015 at 20:56
3

You forgot TeX is case-sensitive – the command is \TitleOfAlgo, and there is no default package – only a default theme for beamer:

\documentclass{beamer}

\usetheme{default}
% typesetting of algorithms
\usepackage[vlined,linesnumbered]{algorithm2e}
\SetArgSty{textnormal}
\SetCommentSty{textnormal}

\begin{document}

\begin{frame}%{ % Implementation of pin() (((

  \frametitle{Implementation of \texttt{pin\,()}}

  \begin{function}[H]
    \TitleOfAlgo{ \texttt{pin($\mathit{pageno}$)}}
    \eIf
      {buffer pool already contains $\mathit{pageno}$}
      {$\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow
           \texttt{pinCount\,(\(\mathit{pageno}\))} + 1$ \;
       \Return{address of frame holding $\mathit{pageno}$ \;}}
      {select a victim frame $v$ using the replacement policy \;
       \If{$\texttt{dirty\,(\(v\))}$}
          {write $v$ to disk \;}
       read page $\mathit{pageno}$ from disk into frame $v$ \;
       $\texttt{pinCount\,(\(\mathit{pageno}\))} \leftarrow 1$ \;
       $\texttt{dirty\,(\(\mathit{pageno}\))} \leftarrow \text{false}$ \;
       \Return{address of frame $v$} \;
      }
 \end{function}
\end{frame}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .