我为文档创建了一个新的定理环境,但当定理位于页面末尾时,Latex 会将定理的标题和核心内容分成两页。我该如何避免这种情况(我无法将 \ \ * 代替 \newline 作为 puncthead 的参数,否则会出现错误)。
\documentclass[10pt,a4paper]{article}
\title{Test}
\usepackage{amsmath}
\usepackage{amsthm, thmtools}
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\em\mdseries,
notebraces={(}{)},
headpunct={},
bodyfont=\itshape,
postheadspace=\newline]{theorem}
\declaretheorem[style=theorem, numbered=no,
name=Theorem,
refname={theorem,theorems},
Refname={Theorem,Theorems}]{theorem}
答案1
您可以使用选项headformat
代替postheadspace
并包含\@afterheading
(或任何其他禁止分页符的内容):
\documentclass[10pt,a4paper]{article}
\title{Test}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsthm, thmtools}
\usepackage{lmodern}
\makeatletter
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\em\mdseries,
notebraces={(}{)},
headpunct={},
bodyfont=\itshape,
headformat=\NAME\ \NOTE\\\@afterheading,
]{theorem}
\makeatother
\declaretheorem[style=theorem, numbered=no,
name=Theorem,
refname={theorem,theorems},
Refname={Theorem,Theorems}]{theorem}
\begin{document}
\rule{\linewidth}{.95\textheight}
\begin{theorem}[note]
This is some content, just to check whether everything works out as we want it
to.
\end{theorem}
\end{document}
使用headformat
和\@afterheading
:
您的设置版本(只是为了显示分页符):