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