# Restate theorem text within section without "Theorem X" part

I would like to restate a theorem within a section, like:

\documentclass{article}
\usepackage{thmtools}
\usepackage{thm-restate}

\declaretheorem{theorem}

\begin{document}
\begin{restatable}{theorem}{hello}
Hello!
\end{restatable}
\hello*
\section{\protect\hello*}
\end{document}


As you can see in the image the section number "1" is in its own line and an unwanted "Theorem 1" is printed. Wanted output is:

Theorem 1 Hello!
Hello!
1 Hello!


Unfortunately I found no way to only get the text of an theorem (without the "Theorem 1"):

So I am searching for a command similar to \hello* which only yields the text of the theorem. In most cases I still need the \hello* to completely restate the theorem, it is only in some situations that I only need the text, without the line break and "Theorem X". So the fix should not break the behavior of \hello*, but only give me an additional way to restate the theorem with text only.

Thank you!

best regards, Markus

This code is has origins in other closely related answers on this site, but I lost my links to them, and have added and removed my own modifiations in the meantime. Essentially we patch the theoremtools restatable environment so that it doesn't include the header every time, making use of a built in \if that checks if we're inserting it at the original call location.

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\thmt@restatable}% Edit \thmt@restatable
{\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi}% Replace this code,
% which calls the internal "begin theorem" header code...
{\ifthmt@thisistheone% ... with this, which only does so at the original call site.
\csname #2\@xa\endcsname\ifx\@nx#1\@nx\else[{#1}]\fi%
\else\fi}
{}{\typeout{FIRST PATCH TO THM RESTATE FAILED}} % execute on success/failure
\xpatchcmd{\thmt@restatable}% A second edit to \thmt@restatable, so that we also
% have the appropriate # of endgroups in all cases.
{\csname end#2\endcsname}
{\ifthmt@thisistheone\csname end#2\endcsname\else\fi}%
{}{\typeout{FAILED SECOND THMT RESTATE PATCH}}
\makeatother


To understand which code we're replacing in context, you will have to look closely at the theorem tools restatable code.