我正在为学生制作一本练习册。我想创建一个练习问题定理环境,其中包含定理环境后的空白区域。
到目前为止我已经:
\newtheoremstyle{exampstyle}
{} % Space above
{2in} % Space below
{} % Body font
{} % Indent amount
{\bfseries} % Theorem head font
{.} % Punctuation after theorem head
{.5em} % Space after theorem head
{} % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{exampstyle}
而且它运行得相对良好。但是,如果定理位于页面底部,我会失去 2 英寸的工作空间。如何强制 LaTeX 保留 2 英寸,即使这意味着下一页顶部有一个尴尬的空白空间?我想我需要类似 \vspace* 的东西,但在尝试时会返回错误:
{\vspace*{2in}} % Space below
有什么建议吗?谢谢!
答案1
如果你不介意使用ntheorem
\documentclass{article}
\usepackage{ntheorem}
% combined with the ntheorem default, the following
% four lines reproduces your theorem style.
\theorembodyfont{\normalfont}
\theoremseparator{.\hspace{0.5em}}
\theorempreskip{}
\theorempostskip{}
% Instead of using postskip, we use ntheorem's postwork command
% to add vspace*
\theorempostwork{\vspace*{2in}}
% define the new theorem
\newtheorem{exampstyle}{Example}
% lipsum loaded for blind text
\usepackage{lipsum}
\begin{document}
\begin{exampstyle}
\lipsum[1]
\end{exampstyle}
\begin{exampstyle}
\lipsum[1]
\end{exampstyle}
\begin{exampstyle}
\lipsum[2]
\end{exampstyle}
\begin{exampstyle}
\lipsum[2]
\end{exampstyle}
\begin{exampstyle}
\lipsum[1]
\end{exampstyle}
\end{document}
答案2
你可以使用needspace
为此,如果您没有(比如说)2in
在定理下方,这将强制分页,之后您可以插入\vspace*{2in}
:
\documentclass{article}
\usepackage{amsthm,needspace}
\newtheoremstyle{exampstyle}
{} % Space above
{} % Space below
{} % Body font
{} % Indent amount
{\bfseries} % Theorem head font
{.} % Punctuation after theorem head
{.5em} % Space after theorem head
{} % Theorem head spec (can be left empty, meaning `normal')
\theoremstyle{exampstyle}
\newtheorem{theoremA}{Theorem}
\newenvironment{theorem}{%
\begin{theoremA}%
}{%
\end{theoremA}
\needspace{2in}% If less than 2in left on page, issue a page break
\vspace*{2in}% Insert 2in of vertical space, even at top of page
}%
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
\begin{theorem}
\lipsum[1]
\end{theorem}
Something following.
\end{document}