我似乎无法在我的自定义定理环境中找回我的定理的数字,希望能得到一些帮助:
\documentclass[10pt,a4paper]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{hyperref,nameref}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\em\mdseries,
notebraces={(}{)},
headpunct={},
bodyfont=\itshape,
headformat=\NAME\ \NOTE\\\@afterheading,
]{theorem}
\makeatother
\declaretheorem[style=theorem,
numbered=yes,
name=Theorem,
refname={theorem,theorem},
Refname={Theorem,Theorems}]{theorem}
\begin{document}
\section{First section}
\begin{theorem}
First theorem
\end{theorem}
\begin{theorem}
Second theorem
\end{theorem}
\section{Second section}
\begin{theorem}
Third theorem
\end{theorem}
\end{document}
答案1
您只需格式化以添加\NUMBER
命令:
\documentclass[10pt,a4paper]{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{hyperref,nameref}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\em\mdseries,
notebraces={(}{)},
headpunct={},
bodyfont=\itshape,
headformat=\NAME\,\textcolor{red}{\NUMBER}\NOTE\\\@afterheading,
]{theorem}
\makeatother
\declaretheorem[style=theorem,
numbered=yes,
name=Theorem,
refname={theorem,theorem},
Refname={Theorem,Theorems}]{theorem}
\begin{document}
\section{First section}
\begin{theorem}[First trial]
First theorem
\end{theorem}
\begin{theorem}
Second theorem
\end{theorem}
\section{Second section}
\begin{theorem}
Third theorem
\end{theorem}
\end{document}