I am trying to use a custom theorem-like environment inside a list (using the enumitem
package), but I get the error message
``LaTeX Error: Something's wrong--perhaps a missing \item.''
Outside the list, the custom environment works correctly. How can I correct this? Is there an incompatibility between the enumitem
package and custom environments?
Here is the MWE:
\documentclass{article}
\usepackage{amsthm} % theorem-like environments
\usepackage{framed} % vertical bar to the left of text of custom environment
\usepackage{enumitem} % enumerations
\usepackage{lipsum} % dummy text
% custom environment, with vertical bar to the left of text
\newtheorem{theoremzz}{Theorem}
\newenvironment{theorem}[1][]{\begin{theoremzz}[#1]\begin{leftbar}}{\end{leftbar}\end{theoremzz}}
% default environment
\newtheorem{proposition}[theoremzz]{Proposition}
\begin{document}
\begin{enumerate}
\item I want my custom \texttt{theorem} environment inside this item of the list.
\begin{theorem}
\lipsum[1][1-4]
\end{theorem}
As you can see, it did not work correctly.
\item Now an attempt with a default \texttt{proposition} environment:
\begin{proposition}
\lipsum[2][1-4]
\end{proposition}
It works!
\end{enumerate}
\noindent Outside the list, the custom environment works:
\begin{theorem}
\lipsum[3][1-4]
\end{theorem}
\end{document}