4
    \frame
{
    \frametitle{Queue}  
    \begin{enumerate}
    \item  monitor
    \item semaphores
    \item blocking at 
    \end{enumerate}
}

How do I fit a piece of source code, which this enumerate describes next to it, in the same page in beamer, by dividing the frame into 2 vertical components?

Speravir
  • 19,491
epsilon8
  • 5,961

1 Answers1

8

You can use the columns environment to divide the page into two columns; then one column will contain your code (in my example I used the listing package) and the second one your list.

Here's an example:

\documentclass{beamer}
\usepackage{listings}
\lstset{language=Java,
                basicstyle=\footnotesize\ttfamily,
                keywordstyle=\footnotesize\color{blue}\ttfamily,
}

\usetheme{CambridgeUS}


\begin{document}
\begin{frame}[fragile]{My java code}
\begin{columns}[T]
% code
\begin{column}{0.64\textwidth}
\begin{lstlisting}
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}
\end{lstlisting}
\end{column}
% description
\begin{column}{0.34\textwidth}
\begin{itemize}
\item text
\item text
\item text
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}

which gives you:

enter image description here

Then, on the based of the length of your code, you can further customize the font size of the code and/or the dimensions of the column.