答案1
您可以使用headformat
密钥来实现这一点,但是您也需要进行加载amsthm
。
\documentclass{article}
\usepackage{amsthm,thmtools}
\makeatletter
\declaretheoremstyle
[headformat={\NOTE}, % only note as label
notebraces={}{}, % removing braces from note
notefont=\bfseries, % making the note bold
preheadhook=\def\thmt@space{}, % removing space before the note
numbered=no
]{namedtheorem}
\makeatother
\declaretheorem[style=namedtheorem]{namedtheorem}
\begin{document}
\begin{namedtheorem}[Basic AM-GM Inequality]
For posiive real numbers $a,b$
\[
\frac{a+b}{2}\geq \sqrt{ab}
\]
\end{namedtheorem}
\end{document}
另一个选择是使用定理环境的包装器来为他提供标题
\documentclass{article}
\usepackage{amsthm,thmtools}
\newcommand*\namedtheoremtitle{}
\declaretheorem
[title=\noexpand\noexpand\noexpand\namedtheoremtitle,
numbered=no]
{innernamedtheorem}
% I'm using three \noexpands's so that \namedtheoremtitle will not expand during
% the time of definition of \namedtheorem, but will expand when written to the lot file
\newenvironment{namedtheorem}[1][Theorem]
{%
\renewcommand*\namedtheoremtitle{#1}%
\innernamedtheorem
}{%
\endinnernamedtheorem
}
\begin{document}
\begin{namedtheorem}[Basic AM-GM Inequality]
For posiive real numbers $a,b$
\[
\frac{a+b}{2}\geq \sqrt{ab}
\]
\end{namedtheorem}
\end{document}
均产生
但使用第二种方法,你会得到一个更好的输入格式\listoftheorems
,使用前一种选择,你可能需要重新定义\ll@namedtheorem