thmtools
我在文档中使用定理和定义。但是,我对一些必要的选项感到困惑。
上图显示了我的问题。
- 如何消除定理第一行的文本缩进?
- 如何保证定理前后的垂直空间相同?
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
好吧,这里有一些修改可以解决您的问题:
- 如何消除定理第一行的文本缩进?
\\
删除密钥中的多余部分postheadhook={<>}
。
- 如何保证定理前后的垂直空间相同?
有两个键,skipabove
和skipbelow
,分别可以控制定理上方和下方的空间。
\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}