3

I used thmtools package to define theorem style because I wanted just the note to have a different colour:

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

\declaretheoremstyle[ spaceabove = \topsep, spacebelow = \topsep, headfont = \normalfont\bfseries, notefont = \color{olive}\normalfont\mdseries, notebraces = {}{}, headformat = \NAME{} {\NUMBER}\NOTE, headpunct = {\newline}, bodyfont = \normalfont\upshape ]{fordefinition}

\theoremstyle{fordefinition} \newtheorem{defn}{Definition}[section]

\begin{document} \begin{defn}[Property(T) group] asdg \end{defn} \end{document}

But parentheses () behave weirdly within the note. The right parenthesis always appears at the end of the note.

enter image description here

Any idea how to fix this so that I get the parenthesis where I want it to? I tried using \right) but it didn't work and I don't think it is a good idea.

P.S. Have I also defined the newline properly to give a line break after the heading? It works, but I am unsure whether this is the ideal way to do it.

Muddana
  • 132

2 Answers2

3

That's strange, indeed. I tried a few things, well known candidates for trouble, amongst which:

  • putting a % at line ends is needed in macros, but irrelevant here
  • treating the parantheses as a unit (so to say) was vital: {(T)}

Looks like otherwise you confuse this package when its internals "eat and digest" the data (as Knuth put it for TeX) :

  • ...
  • processing t is fine
  • processing y is fine
  • processing is fine
  • processing ( puts you on the wrong route

That's it.

result

% https://tex.stackexchange.com/questions/687217/thmtools-parentheses-behaving-weirdly-in-note

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

\declaretheoremstyle[% spaceabove = \topsep,% spacebelow = \topsep,% headfont = \normalfont\bfseries,% notefont = \color{olive}\normalfont\mdseries,% notebraces = {}{},% headformat = \NAME{} {\NUMBER}\NOTE,% headpunct = {\newline},% bodyfont = \normalfont\upshape% ]{fordefinition}

\theoremstyle{fordefinition} \newtheorem{defn}{Definition}[section]

\begin{document} \begin{defn}[Property {(T)} group]% <<< Some of the most wonderful theorems ever heard of. \end{defn} \end{document}

MS-SPO
  • 11,519
  • 1
    Thanks! Treating the parantheses as a unit worked. – Muddana May 30 '23 at 19:07
  • 3
    This is indeed the solution. The source of the problem is with the internal macro \thmt@embrace, which is defined as \def\thmt@embrace#1#2(#3){#1#3#2}. – Udi Fogiel May 30 '23 at 19:14
1

The thmtools package uses () in order to delimit the note in some of its macros (it shouldn't) and this fails if there are parentheses in the notes.

Here I patch the relevant commands to use <> instead.

\documentclass{article}
\usepackage{xcolor} 
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{xpatch}

\makeatletter \xpatchcmd{\thmt@setheadstyle}{(}{<}{}{} \xpatchcmd{\thmt@setheadstyle}{)}{>}{}{} \def\thmt@embrace#1#2<#3>{#1#3#2} \makeatother

\declaretheoremstyle[ spaceabove = \topsep, spacebelow = \topsep, headfont = \normalfont\bfseries, notefont = \color{olive}\normalfont\mdseries, notebraces = {}{}, headformat = \NAME\ \NUMBER\NOTE, headpunct = {\newline}, bodyfont = \normalfont\upshape ]{fordefinition}

\theoremstyle{fordefinition} \newtheorem{defn}{Definition}[section]

\begin{document}

\begin{defn}[Property(T) group] asdg \end{defn}

\end{document}

enter image description here

egreg
  • 1,121,712