\penalty 不生效

\penalty 不生效

我试图抑制我定义的小标题后面的分页符。但是,无论我将它放在哪里,惩罚似乎都没有任何效果。MWE:

\documentclass{article}
\pagestyle{empty}
\makeatletter
\def\gennotes{%
    \vskip\baselineskip%
    {\Large\scshape\noindent Notes}%
    \vskip\baselineskip%
    \@afterindentfalse\@afterheading%
}%
\makeatother
\usepackage[paperheight=3.5in,paperwidth=2in]{geometry}
\begin{document}
\sloppy\noindent
So I really want to have both the indent be surpressed on
the next line \emph{and} the page break penalty be applied.
However, this does not seem to work when I combine the two.
I have made my page quite small here to demonstrate the
problem:

\gennotes

And what now?  Will the indent be surpressed?  Will the page
penalty be applied?  Who can tell?  I certainly can't; all I
know is that it never seems to work the way that I want to,
no matter how much meaningless faff I type into this minimal
example.
\end{document}

结果如下:

第1页 第2页

我尝试过将\penalty10000任何对我有意义的东西都放进去,但似乎都没有任何效果。它应该放在哪里才能防止在“注释”标题之后但在其后的文本之前出现分页符?

答案1

\documentclass{article}
\pagestyle{empty}
\makeatletter
\def\gennotes{%
    \vskip\baselineskip%
    {\Large\scshape\noindent Notes}%
    \par\nobreak
    \vskip\baselineskip%
    \@afterindentfalse\@afterheading%
}%
\makeatother
\usepackage[paperheight=3.5in,paperwidth=2in]{geometry}
\begin{document}
\sloppy\noindent
So I really want to have both the indent be surpressed on
the next line \emph{and} the page break penalty be applied.
However, this does not seem to work when I combine the two.
I have made my page quite small here to demonstrate the
problem:

\gennotes

And what now?  Will the indent be surpressed?  Will the page
penalty be applied?  Who can tell?  I certainly can't; all I
know is that it never seems to work the way that I want to,
no matter how much meaningless faff I type into this minimal
example.
\end{document}

在此处输入图片描述

这只是在标题后的跳过之前立即添加\nobreak( )。\penalty10000

相关内容