2

I am using thmtools for theorems and definitions in my document. However, I struggle with some of the necessary options.

theorem spaces

The above picture shows my problems.

  1. How do I get rid of the text indent in the first line of the theorem?
  2. How do I ensure the same vertical space before and after the theorem?

A MWE is as follows:

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}


\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{needspace}


\declaretheoremstyle[
numberwithin=chapter,
headfont=\normalfont\bfseries,
notefont=\normalfont\scshape, 
notebraces={$\lbrack$}{$\rbrack$},
postheadhook={\textcolor{gray!80}{\rule[.6ex]{\linewidth}{0.4pt}}\\},
bodyfont=\normalfont\itshape,
mdframed={
    backgroundcolor=gray!20, 
    linecolor=gray!20, 
    innertopmargin=6pt,
    innerbottommargin=6pt },
postheadspace=\newline
]{definition}

\declaretheorem[style=definition,name=Definition]{definition}
\AtBeginEnvironment{definition}{\Needspace{10\baselineskip}}

\begin{document}

\title{Simple Book Example}

\mainmatter

\chapter{The First Chapter}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Consectetuer adipiscing elit.
\begin{definition}[A Definition]
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet.
\end{definition}
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

\end{document}
1

Well, here are some modifications to address your issues:

  1. How do I get rid of the text indent in the first line of the theorem?

Remove that extra \\ in the postheadhook={<>} key.

  1. How do I ensure the same vertical space before and after the theorem?

There are two keys, skipabove and skipbelow with which you can control the space above and below the theorem, repectively.

\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{needspace}

\declaretheoremstyle[
numberwithin=chapter,
headfont=\normalfont\bfseries,
notefont=\normalfont\scshape, 
notebraces={$\lbrack$}{$\rbrack$},
postheadhook={\textcolor{gray!80}{\rule[.6ex]{\linewidth}{0.4pt}}}, % \\ removed
bodyfont=\normalfont\itshape,
mdframed={%
    backgroundcolor=gray!20, 
    linecolor=gray!20,
    splittopskip=20pt, 
    skipabove = 16pt, % to adjust the above skip
    innertopmargin=6pt,
    innerbottommargin=6pt},
postheadspace=\newline
]{definition}

\declaretheorem[style=definition,name=Definition]{definition}
\AtBeginEnvironment{definition}{\Needspace{10\baselineskip}}

\begin{document}

\title{Simple Book Example}

\mainmatter

\chapter{The First Chapter}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Consectetuer adipiscing elit.
%
\begin{definition}[A Definition]
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet.
\end{definition}
%
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

\end{document}

enter image description here

1
  • Thank you very much! This works. However, I do not understand the "adjustment" at skipabove. How do I know I have to correct for 4pt here? – user3347232 Nov 23 '16 at 23:40

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.