# How do I fit java style source code in one frame in beamer?

    \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?

-
Please try to post complete, compilable examples instead of just snippets, even if the addition of a document class and \begin/\end{document} may seem trivial. Such minimal working examples (MWEs) make your questions much more pleasant to read and answer. – doncherry Jun 1 '12 at 8:08

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:

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.

-
I needed to use [fragile] with the frame. – zcqwevb Jun 2 '12 at 6:20
Yes, you need the option [fragile] to insert the code. See section 12.9 Verbatim and Fragile Text in the beamer user guide. – Claudio Fiandrino Jun 2 '12 at 6:27