1

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!

2
3

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

6
  • 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? – user3347232 Aug 22 '15 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. – Bernard Aug 22 '15 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?! – user3347232 Aug 22 '15 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. – Bernard Aug 22 '15 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? – user3347232 Aug 22 '15 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.