3

I'm trying to define something like the named theorems in Customizing theorem name except using thmtools. As far as I understand, the headspec is to be provided in the key headstyle to \declaretheoremstyle. However, the following mwe produces the error

Illegal parameter number in definition of \thmt@tmp. ...eadstyle={{\thmnote{#3's }#1}}]{namedStyle}

Of course I could use \newtheoremstyle instead of \declaretheoremstyle, but I would prefer not to, since I'm using thmtools anyway, and would rather not repeat the built-in defaults when possible. And the thmtools syntax just looks generally cleaner.

\documentclass{minimal}

\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[headstyle={\thmnote{#3's }#1}]{namedStyle}
\declaretheorem[style=namedStyle, title = Theorem]{named}

\begin{document}

Now let us present that most famous of all theorems.

\begin{named}[Fred]
All odd numbers are prime.
\end{named}

\end{document}

Most of the mwe is copied from Loop Space's answer to the above question.

  • Effectively you are trying to access #1 within #1, this is an error. The What are the values/contents of #1 and #3 ? – user31729 May 17 '15 at 8:04
  • As far as I understand, when \begin{named} is processed, #1 is assigned Theorem (as per the title key), #2 is assigned the current value of the associated counter and #3 onwards are the optional arguments passed. – ronno May 17 '15 at 8:39
  • Note that LoopSpace's answer doesn't use \declaretheoremstyle. – egreg May 17 '15 at 11:05
3

Within \declaretheoremstyle you refer to the parameters #1, #2 and #3 used in \newtheoremstyle as \NAME, \NUMBER and \NOTE.

However, \NOTE already receives a formatting, so we need to remove it.

\documentclass{article}
\usepackage{showframe}
\usepackage{amsthm}
\usepackage{thmtools}

\makeatletter
\declaretheoremstyle[
  notebraces={}{},
  notefont=\bfseries,
  headformat=\let\thmt@space\@empty\NOTE's \NAME,
]{namedStyle}
\makeatother

\declaretheorem[style=namedStyle, title = Theorem]{named}

\begin{document}

Now let us present that most famous of all theorems.

\begin{named}[Fred]
All odd numbers are prime.
\end{named}

\end{document}

There's no option for changing \thmt@space, so I used a hack.

enter image description here

The rules are generated by showframe, just to check for no indentation.

|improve this answer|||||
  • I somehow missed the paragraph about \NAME, \NUMBER and \NOTE in the thmtools documentation. However, this looks clumsier than using \newtheoremstyle, so I'll probably stick to that. – ronno May 17 '15 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.