# Rewriting a template from amsthm to thmtools

I've been using the Legrand Orange Book template on a project of mine with a friend and coworker. This template uses amsthm and mdframed to format a bunch of environments and I'm rewriting them to use thmtools instead. Here's an example of the sort of things they are doing:

\definecolor{ocre}{RGB}{243,102,25}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% theorem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheoremstyle{ocrenumbox}% % Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% % Body font
{}% Indent amount
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square

\newcounter{dummy}
\numberwithin{dummy}{section}
\theoremstyle{ocrenumbox}
\newtheorem{theoremeT}[dummy]{Theorem}

% Theorem box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
backgroundcolor=black!5,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt]{tBox}

\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheoremstyle{blacknumex}% Theorem style name
{5pt}% Space above
{5pt}% Space below
{\normalfont}% Body font
{} % Indent amount
{\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note

\theoremstyle{blacknumex}
\newtheorem{exampleT}{Example}[chapter]

\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}


and here's how I'm trying to rewrite them:

\definecolor{bookcolor}{RGB}{243,102,25}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% theorem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\declaretheoremstyle[
notebraces={[}{]},
bodyfont=\normalfont\itshape,
spacebelow=0pt,
spaceabove=0pt,
mdframed={
backgroundcolor=black!5,
skipabove=7pt,
skipbelow=7pt,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt
linecolor=bookcolor}
]{Tstyle}

\declaretheorem[
style=Tstyle,
name=Theorem,
numberwithin=section
]{theorem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\declaretheoremstyle[
notebraces={[}{]},
bodyfont=\normalfont,
spacebelow=5pt,
spaceabove=5pt,
postfoothook=\hfill{\tiny\ensuremath{\blacksquare}}
]{Estyle}

\declaretheorem[
style=Estyle,
name=Example,
numberwithin=chapter
]{example}


My question is: How do I implement the formatting in the last box of the \newtheoremstyle command? E.g.

{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}}


From what I can tell this appears to be the headformat key but It looks like it is strongly objecting to passing the #1 and #2 here If i just copy the newtheoremstyle line http://mirrors.ibiblio.org/CTAN/macros/latex/exptl/thmtools/thmtools.pdf

I would prefer solutions using thmtools because I am interested in using other features such as restatable for the theorems.

As mentioned in thmtools.pdf the headformat key has three commands \NAME \NUMBER and \NOTE. There are also commands to set the fonts so that you don't need to declare the fonts in the format. Finally, the notebraces key can be used to produce a --() around any named theorem. Here's the declaretheoremstyle that I have fixing the issues:

\declaretheoremstyle[
bodyfont=\normalfont,
spacebelow=0pt,
spaceabove=0pt,
notefont=\small\bf\sffamily\color{black},
notebraces={---(}{)},