I've run into some spacing problems when attempting to create my own theorem styles using thmtools. What I want can be condensed into the following points:
- Theorem name should be in the margin and spaced relative to the text body by a
\marginparsepwidth. - The theorem note should be in the text body and have a space following it.
- If no note is used, the following text should still be aligned to the text body with no indents.
I realize that I can create a separate theorem style for when I want to use a note and when I don't, but I'm looking for a solution that doesn't require that if possible.
Here's an example that illustrates the problem I've ran into:

And here's the code for the above example:
\documentclass[11pt,a4paper]{scrartcl}
\usepackage{amsthm}
\usepackage{thmtools}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries\scshape,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemA}
\declaretheorem[
name=Theorem,
style=problemA
]{theoremA}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries\scshape,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={0pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemB}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\bfseries,
notefont=\normalfont, notebraces={(}{)},
bodyfont=\normalfont,
headpunct={},
postheadspace={5pt},
preheadhook=\renewcommand\thmt@space{}, % Removes \NOTE spacing
headformat={%
\makebox[0pt][r]{\NAME\ \NUMBER\hspace{\marginparsep}}\NOTE%
}
]{problemC}
\makeatother
\declaretheorem[
name=Theorem,
style=problemB
]{theoremB}
\declaretheorem[
name=Theorem,
style=problemC
]{theoremC}
\begin{document}
\begin{theoremA}[Test]
Here we get undesired space around \texttt{\textbackslash NOTE}.
\end{theoremA}
\begin{theoremB}[Test]
Now we eliminated the undesired space.
\end{theoremB}
\begin{theoremB}
Also works without the note.
\end{theoremB}
\begin{theoremC}[Test]
Also works with \texttt{postheadspace}.
\end{theoremC}
\begin{theoremC}
But now we get an indent when we don't use a note.
\end{theoremC}
\end{document}
