Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
    \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?

share|improve this question
3  
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

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
1  
I needed to use [fragile] with the frame. –  user494461 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.