# A list of theorems grouped into sections

I want to create a list of theorems grouped into different sections as shown below. I am happy with the output, but for other reasons that don't bear going into, I want to know if there is a way to use ntheorem's \theoremprework or \theorempostwork commands to achieve the same effect without having to define an inner environment, and then a wrapper environment.

\documentclass{article}
\usepackage{ntheorem}

\newtheorem{theoreminner}{}
\newenvironment{theorem}[1][]
{
\begin{theoreminner}[#1]
}
{
\end{theoreminner}
}

\begin{document}

\tableofcontents

\section{title of section 1}

\begin{theorem}[title of theorem 1.1]
text of theorem 1.1
\end{theorem}

\begin{theorem}[title of theorem 1.2]
text of theorem 1.2
\end{theorem}

\section{title of section 2}

\begin{theorem}[title of theorem 2.1]
text of theorem 2.1
\end{theorem}

\begin{theorem}[title of theorem 2.2]
text of theorem 2.2
\end{theorem}

\end{document}


You can, but my solution replaces the theoreminner environment and all the stuff that goes with it by redefining the theoremstyles. The idea is, roughly, to capture the title of the theorem (optional )parameter ##3 in a TeX command (\titlethm). So replace in your preamble the definitions of theorem and theoreminner with this code (say you're using plain style):

\makeatletter
\renewtheoremstyle{plain}%