新环境显示“扫描使用 \thmt@collect@body 时文件结束”。

新环境显示“扫描使用 \thmt@collect@body 时文件结束”。

在下面的代码中,我通过一些宏和命令使用了星号定理。

\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{amssymb,amsthm,amsmath,xparse}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{thmtools, thm-restate}

\newcommand{\starBool}{0} 
\newcommand{\starCommand}{\if\starBool1{ $(\footnotesize{\bigstar})$}\fi}
\makeatletter
\def\thmhead@plain#1#2#3{%
    \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2\starCommand}}%
    \thmnote{{\the\thm@notefont (#3)}}}
\let\thmhead\thmhead@plain
\makeatother
\newcommand{\starToggle}{\if\starBool0{\gdef\starBool{1}}\else{\gdef\starBool{0}}\fi}
\newtheorem{theorem}{Theorem}

\begin{document}

\section{Main part of the paper}

Proofs of theorems marked with a $\star$ are moved to the appendix.

\starToggle
\begin{restatable}{theorem}{AB}
    $A \subseteq B$.
\end{restatable}
\starToggle

\begin{theorem}
    $B \subseteq A$.
\end{theorem}

\begin{proof}
    Trivial.
\end{proof}

\appendix
\section{Details of the proofs}

\AB*

\begin{proof}
    Knuth told me by text message.
\end{proof}

\end{document}

我想创建一个名为 starTheorem 的新环境,它比上面的代码更易于使用。下面,我尝试这样做。

\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{amssymb,amsthm,amsmath,xparse}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{thmtools, thm-restate}

\newcommand{\starBool}{0} 
\newcommand{\starCommand}{\if\starBool1{ $(\footnotesize{\bigstar})$}\fi}
\makeatletter
\def\thmhead@plain#1#2#3{%
    \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }\@upn{#2\starCommand}}%
    \thmnote{{\the\thm@notefont (#3)}}}
\let\thmhead\thmhead@plain
\makeatother
\newcommand{\starToggle}{\if\starBool0{\gdef\starBool{1}}\else{\gdef\starBool{0}}\fi}
\newtheorem{theorem}{Theorem}
\newenvironment{starTheorem}[1]
{\starToggle
    \begin{restatable}{theorem}{#1}
    }
    { 
    \end{restatable}
\starToggle
}

\begin{document}

\section{Main part of the paper}

Proofs of theorems marked with a $\star$ are moved to the appendix.

\begin{starTheorem}{AB}
    $A \subseteq B$.
\end{starTheorem}

\begin{theorem}
    $B \subseteq A$.
\end{theorem}

\begin{proof}
    Trivial.
\end{proof}

\appendix
\section{Details of the proofs}

\AB*

\begin{proof}
    Knuth told me by text message.
\end{proof}

\end{document}

但我收到错误“扫描 \thmt@collect@body 时文件结束”。有什么方法可以修复此问题?

相关内容