
Quiero crear una lista de teoremas agrupados en diferentes secciones como se muestra a continuación. Estoy contento con el resultado, pero por otras razones que no vale la pena explicar, quiero saber si hay una manera de usar ntheorem
comandos \theoremprework
o \theorempostwork
para lograr el mismo efecto sin tener que definir un entorno interno, y luego un entorno de envoltura.
\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}
Respuesta1
Puedes, pero mi solución reemplaza el entorno teórico y todo lo que conlleva al redefinir los estilos de teoremas. La idea es, aproximadamente, capturar el título del parámetro ##3 del teorema (opcional) en un comando TeX (\titlethm). Así que reemplaza en tu preámbulo las definiciones de teorema y teorema con este código (digamos que estás usando un estilo simple):
\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}{}
No modifiqué la definición en caso de que no haya un argumento opcional porque no tengo idea de si le gustaría tener algo escrito en la tabla de contenido o no.