页面底部的字母和部分导致分页效果不佳

页面底部的字母和部分导致分页效果不佳

我的自定义字母和部分导致我的一些分页符破坏了我的布局。请参阅通过 XeLaTeX 运行的附加代码的输出示例。

糟糕的分页符!

下一页的第 2 节实际上应该写在 117 行字母的底部旁边。否则,从 117 行字母开始的整个章节应该移到下一页。但在\nopagebreak我的章节之前强行插入也会破坏 118 行字母之前的页面,这是错误的,因为第 117 章很短,出于明显的美观原因,不能放在自己的页面上。

我尝试过使用\nopagebreak[n],但没有得到预期的结果。是否可以针对 TeX 决定分页时更具体自定义优先级?

\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[top=2cm,bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}
\usepackage{xltxtra}
\usepackage{etoolbox}
\usepackage{setspace}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Cardo}

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \setheadrule{.02pt}
  \sethead[\thepage][\chaptertitle][\firsttitlemarks\thesection:\ifthesubsection{\firsttitlemarks\thesubsection}{1}---\bottitlemarks\thesection:\bottitlemarks\thesubsection]{\firsttitlemarks\thesection:\ifthesubsection{\firsttitlemarks\thesubsection}{1}---\bottitlemarks\thesection:\bottitlemarks\thesubsection}{\chaptertitle}{\thepage}
}

% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}

\newlength\howwide

\newcommand\defhowwide{
    \ifnumless{\value{section}}{99}{\ifnumgreater{\value{section}}{8}{\setlength{\howwide}{2.5em}}{\setlength{\howwide}{1em}}}{\ifnumgreater{\value{section}}{98}{\setlength{\howwide}{3.5em}}{\setlength{\howwide}{2.5em}}}
}

% sections and subsections formatting
\titleformat{\section}{}{\lettrine{\thesection}}{0em}{}[\vskip-1\baselineskip]
\titleformat{\subsection}[runin]{\small\bfseries}{\thesubsection}{1em}{}
\titlespacing{\section}{\howwide}{-1pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{1em}

\setlength{\parindent}{0pt}

\newlength\NumLen
\newlength\LinLen
% indents one line of text. Indentation= width of section number + 1em
\newcommand\IndOne{%
  \setlength\NumLen{\howwide}
  \addtolength\NumLen{0.5em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 2 \NumLen \LinLen 0pt \textwidth}
% indents two lines of text. Indentation= width of section number + 1em
\newcommand\IndTwo{%
  \setlength\NumLen{\howwide}
  \addtolength\NumLen{0.5em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 3 \NumLen \LinLen \NumLen \LinLen 0pt \textwidth}

\usepackage[none]{hyphenat}
\sloppy

\begin{document}
\frontmatter

\mainmatter
\pagestyle{Biblestyle}
\newlength{\myIndent}
\begin{center}
THE BOOK OF\\
\vspace{0.15cm}\textbf{\Huge{PSALMS}}\vspace{0.00cm}\\
\end{center}

\renewcommand{\chaptertitle}{Psalms}
\setcounter{section}{115}

%\pdfbookmark[1]{116}{19O116}
\defhowwide
\section{}
\settowidth{\myIndent}
{\IndOne I love the \textsc{Lord}, because he hath heard my voice and my supplications.}
\ifdimless{\the\myIndent}
{\textwidth-\howwide}
{\IndOne I love the \textsc{Lord}, because he hath heard my voice and my supplications. \stepcounter{subsection}
\subsection{} \IndOne Because he hath inclined his ear unto me, therefore will I call upon him as long as I live.}
{\IndTwo I love the \textsc{Lord}, because he hath heard my voice and my supplications. \stepcounter{subsection} \subsection{} Because he hath inclined his ear unto me, therefore will I call upon him as long as I live.}
\subsection{} The sorrows of death compassed me, and the pains of hell gat hold upon me: I found trouble and sorrow.
\subsection{} Then called I upon the name of the \textsc{Lord}; O \textsc{Lord}, I beseech thee, deliver my soul.
\subsection{} Gracious is the \textsc{Lord}, and righteous; yea, our God is merciful.
\subsection{} The \textsc{Lord} preserveth the simple: I was brought low, and he helped me.
\subsection{} Return unto thy rest, O my soul; for the \textsc{Lord} hath dealt bountifully with thee.
\subsection{} For thou hast delivered my soul from death, mine eyes from tears, and my feet from falling.
\subsection{} I will walk before the \textsc{Lord} in the land of the living.
\subsection{} I believed, therefore have I spoken: I was greatly afflicted:
\subsection{} I said in my haste, All men are liars.
\subsection{} What shall I render unto the \textsc{Lord} for all his benefits toward me?
\subsection{} I will take the cup of salvation, and call upon the name of the \textsc{Lord}.
\subsection{} I will pay my vows unto the \textsc{Lord} now in the presence of all his people.
\subsection{} Precious in the sight of the \textsc{Lord} is the death of his saints.
\subsection{} O \textsc{Lord}, truly I am thy servant; I am thy servant, and the son of thine handmaid: thou hast loosed my bonds.
\subsection{} I will offer to thee the sacrifice of thanksgiving, and will call upon the name of the \textsc{Lord}.
\subsection{} I will pay my vows unto the \textsc{Lord} now in the presence of all his people,
\subsection{} In the courts of the \textsc{Lord}'s house, in the midst of thee, O Jerusalem. Praise ye the \textsc{Lord}.

%\pdfbookmark[1]{117}{19O117}
\defhowwide
\section{}
\settowidth{\myIndent}
{\IndOne O praise the \textsc{Lord}, all ye nations: praise him, all ye people.}
\ifdimless{\the\myIndent}
{\textwidth-\howwide}
{\IndOne O praise the \textsc{Lord}, all ye nations: praise him, all ye people. \stepcounter{subsection}
\subsection{} \IndOne For his merciful kindness is great toward us: and the truth of the \textsc{Lord} endureth for ever. Praise ye the \textsc{Lord}.}
{\IndTwo O praise the \textsc{Lord}, all ye nations: praise him, all ye people. \stepcounter{subsection} \subsection{} For his merciful kindness is great toward us: and the truth of the \textsc{Lord} endureth for ever. Praise ye the \textsc{Lord}.}

%\pdfbookmark[1]{118}{19O118}
\defhowwide
\section{}
\settowidth{\myIndent}
{\IndOne O give thanks unto the \textsc{Lord}; for he is good: because his mercy endureth for ever.}
\ifdimless{\the\myIndent}
{\textwidth-\howwide}
{\IndOne O give thanks unto the \textsc{Lord}; for he is good: because his mercy endureth for ever. \stepcounter{subsection}
\subsection{} \IndOne Let Israel now say, that his mercy endureth for ever.}
{\IndTwo O give thanks unto the \textsc{Lord}; for he is good: because his mercy endureth for ever. \stepcounter{subsection} \subsection{} Let Israel now say, that his mercy endureth for ever.}
\end{document}

答案1

请注意,可以将代码片段插入命令\needspace{3\baselineskip}的中间参数\titleformat,如下所示

\titleformat{\section}{\needspace{3\baselineskip}}{\lettrine{\thesection}}{0em}
   {}[\vskip-1\baselineskip]

这肯定比在每个命令前面插入指令要好\section。(请注意,\Needspace宏的精确度不如\needspace确定页面上还剩下多少空间。)

在另一个主题上,我注意到你有很多实例\textsc{Lord};你可能要考虑加载xspace包,定义一个宏,例如

\newcommand{\Lord}{\textsc{Lord}\xspace}

然后在文档正文中将 全局更改为\textsc{Lord}\Lord我推测这会使代码的可读性大大提高。另外,如果您想更改主的称谓的“样式”(例如,添加颜色),则只需在一个实例中执行此操作,即在文档的序言中。

附录:我忍不住要再快速提出两点与文档格式/外观相关的意见。首先,第 116:6 节的第二行只有一个非常短的单词(“me”);如果在单词“helped”和“me”之间插入一个连字符(波浪号),则整节经文将只占用一行。(附带的好处是,整篇诗篇 117 篇现在也适合放在页面上。)其次,尽管它们的大小为,但每节经文开头的数字在外观上相当突兀(部分原因是它们采用粗体显示)。您是否考虑过为它们指定而不是 的\small大小?\footnotesize\small

答案2

我发现这个先前的答案对另一个问题似乎有效,当我使用它修改为\Needspace*{3\baselineskip}

如果页面仅剩 1/4 则分页符?

相关内容