18

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

4 Answers4

15

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}
    
  2. Add the listing.

  3. Finally a second ERT with

    \end{frame}
    
Torbjørn T.
  • 206,688
11

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}
egreg
  • 1,121,712
5

In LyX 2.1, you do not need to enter LaTeX code directly to achieve frames handling fragile elements correctly.

Just select the frame and press Alt+A 3. The new field "Options" should appear where you enter fragile. Alternatively, right click on the Frame 'header', and select Frame Options.

Torbjørn T.
  • 206,688
stangls
  • 51
2

use it this way:

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

\defverbatim\lst{%
\begin{lstlisting}
your xml code}
\end{lstlisting}
}

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