0

I use the code given below to create a theorem box using thmtools, I get the error: Package thmtools Error: \declaretheorem key `headformat' not known.

According to the thmtools documentation, headformat is a valid argument to declaretheoremstyle. So I don't understand the error. Please help.

\documentclass[11pt]{book}

%% boxed theorems
\usepackage{thmtools}
\usepackage{etoolbox}
\declaretheoremstyle[numberwithin=chapter,
                    shaded={rulecolor=black!50, textwidth=0.95\linewidth, margin=0.8em, rulewidth=1pt, bgcolor={rgb}{0.9,0.9,0.9}},
                    headformat={\NAME~\NUMBER\hfill\NOTE\smallskip\linebreak}
                    ]{sthm}

\declaretheorem[style=sthm]{hypothesis}


\begin{document}

\begin{hypothesis}[hypothesis name]
    Some hypothesis
\end{hypothesis}

\end{document}
3
  • If you Include \usepackage{xcolor} and \usepackage{amsthm} then this seems to work.
    – murray
    Mar 1, 2022 at 16:22
  • 1
    the documentation is a bit unclear here, but these key definitions are only loaded if amsthm is detected. Mar 1, 2022 at 16:31
  • Got it, thank you
    – kksagar
    Mar 1, 2022 at 22:02

1 Answer 1

0

As mentioned in the comments, you need to load xcolor and amsthm. I also added headpunct={} since presumably you don't want a stray period at the beginning of the line.

\documentclass[11pt]{book}

%% boxed theorems
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{etoolbox}
\declaretheoremstyle[numberwithin=chapter,
                    shaded={rulecolor=black!50, textwidth=0.95\linewidth, margin=0.8em, rulewidth=1pt, bgcolor={rgb}{0.9,0.9,0.9}},
                    headformat={\NAME~\NUMBER\hfill\NOTE\smallskip\linebreak},
                    headpunct={}
                    ]{sthm}

\declaretheorem[style=sthm]{hypothesis}


\begin{document}

\begin{hypothesis}
    Some hypothesis
\end{hypothesis}

\begin{hypothesis}[hypothesis name]
    Some hypothesis
\end{hypothesis}

\end{document}

hypotheses

You must log in to answer this question.

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