包poetry
会覆盖\\*
,这意味着我不能使用它来防止在节中间出现分页符。有没有其他方法可以创建换行符,同时禁止在同一位置出现分页符?最好是设置,而不是在每一行末尾添加一些内容 - 但不管怎样,都行。
例子:
\documentclass[a4paper]{article}
\usepackage{poetry}
\begin{document}
Some text.
\vspace{15cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\
The end\\-
\end{document}
我想防止在节中间出现分页符(在编译示例的最后一节中)。
答案1
不确定这是否足够,但它可以通过增加页面来避免出现 1 行寡妇\baselineskip
。它被调用\\*
“修复”通过重新定义 来实现这一点\poem@endpart
,这是通过 调用的\\*
。原始文件\poem@endpart
保存在\poemendpart
以下 MWE 演示了在第 1 页上使用\\*
,但不在第 2 页上使用(第 3 页换行)。
\documentclass[a4paper]{article}
\usepackage{poetry}
\makeatletter
\let\poemendpart\poem@endpart
\def\poem@endpart{\enlargethispage{\baselineskip}\poem@endline}
\makeatother
\begin{document}
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\*
The end\\-
\clearpage
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\
The end\\-
\end{document}
另一个方向的替代方法是强制提前中断,即\clearpage
在 之前立即发出\\
,例如
\documentclass[a4paper]{article}
\usepackage{poetry}
\begin{document}
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\clearpage\\!
The final stanza\\
A final metaphor\\
The end\\-
\clearpage
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\
The end\\-
\end{document}
补充
这次尝试尝试修改 的使用,\\
以便完全避免分页。因此,正常的诗句永远不会在中途跨越页面边界。似乎适用于此用例。
我编辑\poem@endline
为以 开头\nopagebreak
,这样就不会在这样的行上发生中断。但是,需要在宏中的 实例之后\nopagebreak
添加额外的 实例,以防止在行号之后(但在诗行之前)出现分页符。我不认为我全部都得到了,但足以展示 OP 的 MWE 中的效果。\placelineno
\hskip
\documentclass[a4paper]{article}
\usepackage{poetry}
\makeatletter
\def\poem@endline{\nopagebreak%
\par%
\advance\poemlineno by1%
\advance\vslineno by1%
\poem@defaultpars%
\leftskip=\poem@defleftskip%
\placelineno%
}%
\def\placelineno{%
\setcounter{verseline}{\the\vslineno}%
\setcounter{poemline}{\the\poemlineno}%
\poem@linenumsevery=\value{poemlinenumsevery}%
\poem@linenumboxgap=\the\poemlinenumboxgap%
\poem@linenumboxwd=\the\poemlinenumboxwd%
\modulo{\the\poemlineno}{\the\poem@linenumsevery}%
\ifpoemlinenums%
\ifnum\poem@tmpa=0%
\ifpoemlinenumright%
\hskip0pt\nopagebreak\tlap{%
\rlap{%
\hskip\poem@maxlinewd%
\hskip\poem@linenumboxgap%
\hbox to\poem@linenumboxwd{%
\hfil%
\poemlinenumstyle\thepoemline%
}%
}%
}%
\else%
\hskip-\poem@linenumboxgap\nopagebreak%
\llap{%
\tlap{%
\hbox to\poem@linenumboxwd{%
\poemlinenumstyle\thepoemline%
\hfil%
}\penalty10000%
}%
}\penalty10000%
\fi%
\else
\hskip-\poem@linenumboxgap\nopagebreak%
\llap{\tlap{\hbox to\poem@linenumboxwd{\hfil}}}%
\penalty10000%
\fi%
\else
\hskip-\poem@linenumboxgap\nopagebreak%
\llap{\tlap{\hbox to\poem@linenumboxwd{\hfil}}}%
\penalty10000%
\fi%
\par\vskip-\baselineskip%
\poem@indentevery=\value{poemindentevery}%
\ifnum\poem@indentevery=0%
\else%
\modulo{\the\poemlineno}{\the\poem@indentevery}%
\ifnum\poem@tmpa=0%
\hin%
\fi%
\fi%
\expandafter\poem@expandvsloop\expandafter{\poemvsindentlines}%
\def\@currentlabel{\thepoemline}%
\phantomsection%
}%
\let\poemendpart\poem@endpart
\def\poem@endpart{\enlargethispage{\baselineskip}\poem@endline}
\makeatother
\begin{document}
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\*
The end\\-
\clearpage
Some text.
\vspace{16.2cm} % Force poem down page
\poem
Some poetry\\
A metaphor here,\\
A metaphor there.\\!
Here begins another stanza\\
More words.\\!
The final stanza\\
A final metaphor\\
The end\\-
\end{document}