# Why this beamer slide about sectioning fails on enumerates?

I am trying to use the code from section title in \frametitle beamer

\documentclass{beamer}
\usetheme{Berkeley}

\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\insertsection-#1}}
{\end{frame}}

\begin{document}
\begin{slide}
\begin{enumerate}
\item lorem
\end{enumerate}
\end{slide}
\end{document}


but get the error

! LaTeX Error: Lonely \item--perhaps a missing list environment.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.15     \end{slide}

• Consider to add the fragile option for such slide wrapper environments – user31729 Dec 31 '16 at 17:58
• @ChristianHupfer Done. I am testing its effect but cannot really understand. Docs say fragile every contents is written into an external file and read back. Not a big deal but makes compiling slow in the thread tex.stackexchange.com/questions/136240/… – Léo Léopold Hertz 준영 Dec 31 '16 at 18:07

The definition of the slide environment here requires a title an the argument. Thus here \begin is being taken as the argument, we have no list starting and \item is misplaced (as the error says). You can fix by supplying something

\documentclass{beamer}
\usetheme{Berkeley}

%
\newenvironment{slide}[1]
{\begin{frame}[environment=slide]
\frametitle{\insertsection-#1}}
{\end{frame}}

\begin{document}
\begin{slide}{Foo}
\begin{enumerate}
\item lorem
\end{enumerate}
\end{slide}
\end{document}


If the frame title is not required then drop the argument entirely

\documentclass{beamer}
\usetheme{Berkeley}

%
\newenvironment{slide}
{\begin{frame}[environment=slide]
\frametitle{\insertsection}}
{\end{frame}}

\begin{document}
\begin{slide}
\begin{enumerate}
\item lorem
\end{enumerate}
\end{slide}
\end{document}

• Is there any workaround for this? - - You can do \begin{slide}{} but it will insert the line - which I would not like to have. – Léo Léopold Hertz 준영 Dec 31 '16 at 17:56
• @LéoLéopoldHertz준영 The entire point of the definition of the slide environment here is to have a 'forced' frame title. If you don't want one, just stick to the standard beamer frame environment and add \frametitle as required. – Joseph Wright Dec 31 '16 at 17:57
• Yes, but if you already have \section which forces the title. I just do not want always have the second part. – Léo Léopold Hertz 준영 Dec 31 '16 at 18:01

Easy to do without the newenvironment:

\documentclass{beamer}
\usepackage{xpatch}

\makeatletter
\patchcmd\beamer@@tmpl@frametitle{\insertframetitle}{\insertsection{} -- \insertframetitle}{}{}
\makeatother

\begin{document}

\section{Sec shun 2}
\begin{frame}{My title 2}
\begin{enumerate}
\item lorem
\end{enumerate}
\end{frame}

\end{document}