# Theorem style with margin on both sides

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.

A minimal example of the theorem style above in action:

\documentclass[]{article}

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

\declaretheoremstyle[
spaceabove=\topsep,
spacebelow=\topsep,
notefont=\normalfont,
notebraces={$\lbrack$}{$\rbrack$},
bodyfont=\normalfont\itshape,
]{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!

• You can review the egreg response in this link: tex.stackexchange.com/questions/67242/… Aug 22, 2015 at 2:44
• Thanls, but this does not contain a way for the theorem title / text to be "hanging". Aug 22, 2015 at 7:47

You can do that easily with ntheorem:

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

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

\newlength\exampleindent
\settowidth{\exampleindent}{\bfseries Example}
\makeatletter
\newtheoremstyle{examplebreak}%
\llap{##1}\ ##2\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}%
\llap{##1}\ ##2\ \normalfont\mdseries[##3]\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}
\makeatother
\theoremstyle{examplebreak}
\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}


• Looks good! But would it be totally irrational of me if I wanted to stick with the thmtools package? I have declared roundabout 10 theorems and I'll probably run into some different looking styles whed using nthoerem. Will I not? Aug 22, 2015 at 7:43
• thmtools can use ntheorem as a backend, with some restrictions. Also, probably most of what you set with thmtools can be set with ntheorem. Ntheorem default layout, as far as I know, is LaTeX default and its normal use is to modify LaTeX default from scratch. Aug 22, 2015 at 8:16
• Okay. How would I do that and does it mean I can use thmtools and ntheorem concurrently? Because as of now if I add \usepackage{ntheorem} to my preample all \declaretheoremstyle created theorems produce errors. So I guess I would have to convert them all to the ntheroem syntax?! Aug 22, 2015 at 10:04
• Probably some of the keys are not recognized by ntheorem. That was the problem in your post: the notefont key is not known to ntheorem, hence I had to patch the closest ntheorem style (which is plainbreak) and insert the necessary commands to realise what you want.Very useful, ntheorem defines the theoremindent and \theoremrightindent lengths/commands. Note one of the strengths of ntheorem is its automatic placement of the end-of-proof  symbols. Aug 22, 2015 at 13:25
• Having converted all thmtools int ntheorem definitions I must say I'm not cinviced, or maybe I just don't get it. ;) E.g. once I have added \theoremindent to one of the definitions, all other theorems also have the same ident no matter if the tag is used in that definition. What am I doing wrong here? Aug 22, 2015 at 18:12