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.

When I write listings in my LaTeX code I usually follow this format

\begin{lstlisting}
foo
bar
baz
\end{lstlisting}

and when I put this inside a normal LaTeX document, things look fine. But when I put this inside a beamer block, there is an extra line that is included at the end and I need to do

\begin{lstlisting}
foo
bar
baz\end{lstlisting}

to get it to look right. Is there any way to tell listings to ignore the final newline?

share|improve this question

migrated from stackoverflow.com May 31 '12 at 16:44

This question came from our site for professional and enthusiast programmers.

    
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner May 31 '12 at 16:46
    
Could you provide a small (minimal) example that highlights this? Also include the versions of the files your using. Do so by adding \listfiles to your document preamble and including the contents after *File List* in your .log file. –  Werner May 31 '12 at 16:48
    
It works for me with last beamer version and Warsaw theme. Remember that you must use \begin{frame}[fragile] to include verbatim code. –  Ignasi Jun 1 '12 at 7:13

1 Answer 1

up vote 1 down vote accepted

To remove this question from the unanswered list

Your effect can't be reproduced. The example below results in the following frame: enter image description here

You can see there isn't any additional line. Please note if you use the environment lstlisting inside a beamer frame -- the environment frame needs the option fragile. For more information consult the documentation of beamer.

\documentclass{beamer}
\usepackage{listings}
\lstset{frame=single}
\begin{document}
 \begin{frame}[fragile]
  Text
  \begin{lstlisting}
  foo
  bar
  baz
  \end{lstlisting}
  Text
 \end{frame}
\end{document}
share|improve this answer

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.