Text FormattingProblem using listings

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
d4chris
Posts: 2
Joined: Fri Jun 24, 2011 11:58 am

Problem using listings

Post by d4chris »

Hey guys,

I'm completely new to latex and I'm working on a presentation. In this presentation, I'd like to insert a short C-code snipplet:

Code: Select all

\frame{ \frametitle {Title}

\begin{columns}
	\begin{column}{5cm}
		\begin{block}{acquire}
			\begin{lstlisting}
				some C code here
			\end{lstlisting}
		\end{block}
	\end{column}
\end{columns}
}

So a rather simple Code. But when I try to compile this, I get this error:
./vortrag.tex:135: Argument of \lst@next has an extra }.
<inserted text>
\par
Runaway argument?
./vortrag.tex:135: Paragraph ended before \lst@next was complete.
<to be read again>
\par
l.135 }
l. 135 is the very last line in my code posted above (i.e. the final } ).
Can anyone help me with this? I read that the error output usually tells me about a missing bracket, but there is no bracket missing?!=?!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Problem using listings

Post by Stefan Kottwitz »

Hi,

use the fragile option to the frame. Furthermore, I recommend to use the environment syntax. This is compilable without errors:

Code: Select all

\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\frametitle{Title}
\begin{columns}
   \begin{column}{5cm}
      \begin{block}{acquire}
         \begin{lstlisting}
            some C code here
         \end{lstlisting}
      \end{block}
   \end{column}
\end{columns}
\end{frame}
\end{document}
Stefan
LaTeX.org admin
Post Reply