thmtools 自定义定理名称而不创建新环境

thmtools 自定义定理名称而不创建新环境

如何使用接受自定义名称的 thm 工具创建定理?

可以这样工作:

\begin{namedtheorem}[Basic AM-GM Inequality}
For posiive real numbers $a,b$
$$\frac{a+b}{2}\geq \sqrt{ab}$$
\end{namedtheorem}

这将产生类似这样的结果: 图像

答案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

相关内容