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.

ronno
  • 1,325
  • Effectively you are trying to access #1 within #1, this is an error. The What are the values/contents of #1 and #3 ? –  May 17 '15 at 08: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 08:39
  • Note that LoopSpace's answer doesn't use \declaretheoremstyle. – egreg May 17 '15 at 11:05

1 Answers1

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.

egreg
  • 1,121,712
  • 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