
아래와 같이 여러 섹션으로 그룹화된 정리 목록을 만들고 싶습니다. 출력에는 만족하지만 다른 이유로 인해 내부 환경을 정의하지 않고도 ntheorem
' \theoremprework
또는 \theorempostwork
명령을 사용하여 동일한 효과를 얻을 수 있는지 알고 싶습니다 . 래퍼 환경.
\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}
답변1
가능하지만 내 솔루션은 정리 스타일을 재정의하여 정리 환경과 그에 따른 모든 항목을 대체합니다. 대략적으로 TeX 명령(\titlethm)에서 정리(선택 사항) 매개변수 ##3의 제목을 캡처하는 것이 아이디어입니다. 따라서 서문에서 정리 및 정리의 정의를 다음 코드로 바꾸십시오(일반 스타일을 사용한다고 가정).
\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}{}
선택적 인수가 없는 경우에 대비해 정의를 수정하지 않았습니다. 목차에 무언가를 기록하고 싶은지 여부를 알 수 없기 때문입니다.