2

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]
        \addcontentsline{toc}{subsection}{\protect\numberline{\thetheoreminner}#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}
2

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}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##1\ ##2\ (##3)\theorem@separator]\def\titlethm{##3}}%
 \makeatother

\theorempostwork{ \addcontentsline{toc}{subsection}{\protect\numberline {\thetheorem}\titlethm}}%
\theoremstyle{plain}
\newtheorem{theorem}{}

I did not modify the definition in case there is no optional argument because I have no idea whether you would like to have something written in the table of contents or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.