# Custom theorem title in place

I want to do something like this:

\begin{theorem}[Actual name of theorem]
This theorem states that...
\end{theorem}


and it should render:

Actual name of theorem. This theorem states that...


I changed the name of theorem by creating a theorem-like environment, but I want to do this one in line, without creating a new environment.

It is unclear from the question whether no new environment is to be created, on the one hand, or whether multiple new environments, one for each separate named theorem, are to be created.

Assuming the latter, perhaps something like this?

\documentclass{book}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheorem[name=Theorem,numberwithin=chapter]{theorem}

\makeatletter
\declaretheoremstyle[
notefont=\bfseries,
notebraces={}{},
bodyfont=\mdseries\itshape,
spaceabove=12pt,spacebelow=12pt,
]{namedthmstyle}
\makeatother

\declaretheorem[
style=namedthmstyle,
name=Theorem,
title = {},
numberlike=theorem
]{namedtheorem}

\begin{document}

\chapter{The whole thing}

\begin{namedtheorem}[Theorem of Pythagoras]

The square on the hypotenuse of a right triangle equals the sum of the squares other two sides.

\end{namedtheorem}

\begin{namedtheorem}[Fermat's Last Theorem]

For $n > 2$, there are no positive integers $a, b, c$ for which $a^{n} + b^{n} = c^{n}$.

\end{namedtheorem}

\end{document}


Note that I had to "fake" making the namedtheorem name typeset essentially flush with the left margin by using headindent=-0.25em. Surely there's a better—and more precise—way to accomplish that.