TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
    \item  monitor
    \item semaphores
    \item blocking at 

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
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
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:



\begin{frame}[fragile]{My java code}
% code
public class HelloWorld
public static void main(String[] args)
System.out.println("Hello World");
% description
\item text
\item text
\item text

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

Your Answer


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.