How to include a code snippet in a beamer presentation?
Asked Answered
G

2

19

What's the best way to include some code snippets in a beamer presentation?

I've already tried verbatim, and lstlisting environments - both destroyed my presentation.

Gaal answered 6/11, 2009 at 16:17 Comment(0)
C
26

Use the [fragile] option:

\begin{frame}[fragile]
\begin{verbatim}
...
\end{verbatim}
\end{frame}
Complicated answered 6/11, 2009 at 16:43 Comment(2)
I've already tried this, with a strange result. The slide with code looks OK, but all slides before have paper size changed to A4.Gaal
That is very strange indeed, as the "paper size" should be 128mm times 96mm to reflect the 4:3 ratio of most beamers output. You didn't fiddle around with that setting, did you?Complicated
M
3

I recently used something like

\verbatiminput{blah.c}

in a beamer presentation, and it worked alright for me...

Wanna post your code?

Menial answered 6/11, 2009 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.