[Tex/LaTex] Theorem style with margin on both sides

theoremsthmtools

I'm strugeling with the theorem package thmtools and its features.
I've declared several theorem styles with \declaretheoremstyle and \declaretheorem.

How can I add a hanging paragraph margin on the left relative to the length of the theorem type and an absoulte margin on the right? As shown in the picture, the first line containing the theorem header, should be indented as in the rest of the document. The acctual content of the theorem however, should have a margin on the left as wide as the theorem type "Example". The margin on the right should be defined by an absoulte value. While I have found solutions on indenting the left margin (e.g. here), I have not found anything on doing so with the exact length of the theorem type and nothing on an absoulte margin on the right.

illustration of (1)

A minimal example of the theorem style above in action:

\documentclass[]{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
    spaceabove=\topsep, 
    spacebelow=\topsep,
    headfont=\normalfont\bfseries,
    notefont=\normalfont, 
    notebraces={$\lbrack$}{$\rbrack$},
    bodyfont=\normalfont\itshape,
    postheadspace=\newline
]{examplebreak}

\declaretheorem[style=examplebreak,name=Example]{example}

\begin{document}

\begin{example}[First Example]
    \lipsum[2]
\end{example}

\end{document}

I'm grateful for any help!

Best Answer

You can do that easily with ntheorem:

\documentclass[]{article}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{ntheorem}
\usepackage{thmtools}
\usepackage{lipsum}

%\declaretheoremstyle[
% spaceabove=\topsep,
% spacebelow=\topsep,
% headfont=\normalfont\bfseries,
% notefont=\normalfont\mdseries,
%% notebraces={$\lbrack$}{$\rbrack$},
% bodyfont=\normalfont\itshape,
% % postheadspace=\newline
%]{examplebreak}

\newlength\exampleindent
\settowidth{\exampleindent}{\bfseries Example}
\makeatletter
\newtheoremstyle{examplebreak}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          \llap{##1}\ ##2\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          \llap{##1}\ ##2\ \normalfont\mdseries[##3]\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}
\makeatother
\theoremstyle{examplebreak}
\theoremheaderfont{\normalfont\bfseries}
\theorembodyfont{\normalfont\itshape}
\theoremindent\exampleindent
\theoremrightindent 1.5cm
\newtheorem{example}{Example}

\begin{document}

\begin{example}[First Example]
    \lipsum[2-3]
\end{example}

\begin{example}%[First Example]
    \lipsum[4]
\end{example}
\end{document} 

enter image description here

Related Question