使用 thmtools 定理前后的垂直间距和行缩进

使用 thmtools 定理前后的垂直间距和行缩进

thmtools我在文档中使用定理和定义。但是,我对一些必要的选项感到困惑。

定理空间

上图显示了我的问题。

  1. 如何消除定理第一行的文本缩进?
  2. 如何保证定理前后的垂直空间相同?

MWE 如下:

\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

好吧,这里有一些修改可以解决您的问题:

  1. 如何消除定理第一行的文本缩进?

\\删除密钥中的多余部分postheadhook={<>}

  1. 如何保证定理前后的垂直空间相同?

有两个键,skipaboveskipbelow,分别可以控制定理上方和下方的空间。

\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}

在此处输入图片描述

相关内容