PM25/SimplePlus-BeamerTheme

Is code listing expected to work?

Closed this issue ยท 3 comments

I like the theme very much, but I was trying to use the lstlistings (following the Overleaf documentation here), and it does not seem to work.

It just fails to compile ("compilation took too long"), for some reason ๐Ÿ™.

Any idea why?

Just realized it fails with verbatim, too:

\begin{frame}{}
\begin{verbatim}
    blah
\end{verbatim}
\end{frame}

This time it shows an error message:

blah \end {verbatim} \end {beamer@frameslide}\ifbeamer@twoscreenstext \ETC.
! File ended while scanning use of \@xverbatim.
<inserted text> 
                \par 
<*> sample.tex
              
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

Which brought me to this stackoverflow question, hinting towards making the frame "fragile" (whatever that means). This works:

\begin{frame}[fragile]
\begin{lstlisting}[language=Python]
import numpy as np
\end{lstlisting}
\end{frame}
PM25 commented

That's great to hear you fixed it!
It appears that [fragile] is a necessity when using [verbatim] environment.

https://pbelmans.ncag.info/blog/2011/02/20/why-latex-beamer-needs-fragile-when-using-verbatim

If you wish to use a {verbatim} environment in a frame, you have to add the option [fragile] to the {frame} environment.