# LaTeX error when inserting code listing in LyX

I am currently making a presentation in LyX. After I have inserted some XML code in a code listing, I am getting this error:

Paragraph ended before \lst@next was complete.
Paragraph ended before \lst@next was complete.
LaTeX Error: \begin{lstlisting} on input line 228 ended by \end{beamer@framep
Missing } inserted.
Extra }, or forgotten \endgroup.


What's the problem? Have I to escape some characters or something? I am pretty new to LyX.

EDIT:

Here is a little code snippet. Because I am working with LyX, the code is generated and looks a little bit confusing, I think. I hope you can read it.

\begin_layout BeginFrame
\lang english
Güte der Ergebnisse
\end_layout
\begin_layout Standard
\lang english
\begin_inset listings
inline false
status open
\begin_layout Plain Layout
<server>
\end_layout
\begin_layout Plain Layout
<name>MyServer</name>
\end_layout
\begin_layout Plain Layout
<version>1</version>
\end_layout
\begin_layout Plain Layout
<functionality>0</functionality>
\end_layout
\begin_layout Plain Layout
<platform>Win</platform>
\end_layout
\begin_layout Plain Layout
</server>
\end_layout
\begin_layout Plain Layout
</ddsml>
\end_layout
\end_inset
\end_layout
\begin_layout EndFrame
\start_of_appendix
\end_layout

-
A minimal example would be nice. It looks like you're using beamer as well as listings? How are you using listings? – Seamus Dec 1 '11 at 9:19
If any of the answers below solved your issue, would you consider accepting it by click the checkmark next to it? – Torbjørn T. Dec 9 '11 at 21:09
oh, sorry. i missed that. – Thomas Uhrig Dec 10 '11 at 8:40

Perhaps this should rather be a comment on egregs answer, but it became a little long.

I searched a little, and there is a module for creating fragile frames, that can be found in the LyX wiki. I don't know how to install modules, but I guess that information can also be found in the LyX wiki.

An alternative is to use ERTs (source):

1. Instead of starting a new frame the LyX way, add a TeX code box, or ERT, by hitting Ctrl + L, or choosing Insert --> TeX Code. In this box you write

\begin{frame}[fragile]
\frametitle{Title of the frame}


3. Finally a second ERT with

\end{frame}

-

use it this way:

before the frame insert with Ctrl-L for inserting LaTeX Code

\defverbatim\lst{%
\begin{lstlisting}
\end{lstlisting}
}


inside the frame place also with Ctrl-L the command \lst where the listing should appear.

-

I don't know how to do this in LyX, but a frame containing "verbatim" material such as a lstlisting environment should be declared as fragile:

\begin{frame}[fragile]
...
\begin{lstlisting}
...
\end{lstlisting}

\end{frame}

-