
一開始,我想定義一個定理環境沒有號碼,所以我嘗試了以下程式碼:
\LoadClass[a4paper]{article}
\RequirePackage{amsmath,amssymb,amsthm}
\RequirePackage{thmtools}
\declaretheoremstyle[]{testbox}
\declaretheorem[style=testbox,name=Theorem]{theo}
\renewcommand{\thetheo}{} %Cancelling the number
\begin{document}
\begin{theo}
Content.
\end{theo}
\end{document}
效果很好。然後我嘗試將其擴展到
\LoadClass[a4paper]{article}
\RequirePackage{amsmath,amssymb,amsthm}
\RequirePackage{thmtools}
\declaretheoremstyle[]{testbox}
\newcommand{\newtestbox}[2]{
\declaretheorem[style=testbox,name=#1]{#2}
\renewcommand{\the#2}{} %Error
}
\newtestbox{Theorem}{theo}
\begin{document}
\begin{theo}
Content.
\end{theo}
\end{document}
但現在看來,這被\the#2
認為是一些不恰當的反擊。我該如何正確使用它?如果故事太長,我很抱歉。
答案1
使用numbered=no
(thmtools 手冊第 3 頁)。
\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{thmtools}
\declaretheoremstyle[]{testbox}
\declaretheorem[
style=testbox,
numbered=no,
name=Theorem,
]{theo}
\begin{document}
\begin{theo}
Content.
\end{theo}
\end{document}
numbered=no
與不使用but 時得到的(錯誤)輸出進行比較\renewcommand{\thetheo}{}
,即
答案2
你可以說:
\LoadClass[a4paper]{article}
\RequirePackage{amsmath,amssymb,amsthm}
\RequirePackage{thmtools}
\declaretheoremstyle[]{testbox}
\newcommand{\newtestbox}[2]{
\declaretheorem[style=testbox,name=#1]{#2}
\expandafter\renewcommand\csname the#2\endcsname{} %Error
}
\newtestbox{Theorem}{theo}
\begin{document}
\begin{theo}
Content.
\end{theo}
\end{document}