0

How would I make a theorem using thm tools that accepts a custom name?

Something that would work like:

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

That would produce something like: image

1 Answer 1

1

You can use the headformat key for that, but you will need to load amsthm as well.

\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}

Another option is to use a wrapper around the theorem environment that feed him the title

\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}

Both produce

enter image description here

But with the second approach you get a nicer entry format in the \listoftheorems, with the former option you might want to redefine \ll@namedtheorem

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .