最后一个单词不会自动中断避免

最后一个单词不会自动中断避免

我需要避免最后一个单词中断。它必须在行之前打印在 PDF 中,或者在上一个单词中断之前。

我的 MWE 是:

\documentclass{book}
\doublehyphendemerits=100000 
\frenchspacing
\usepackage{microtype}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
local domobject = require "luaxml-domobject"
sample = [[
<datas>
<p>The investigations of cylindrically symmetric spacetimes can be traced back as far as to 1919 when Levi-Civita (LC) discovered a class of solutions of Einstein&#x2019;s vacuums field equations, corresponding static cylindrical spacetime referring [218]. The extension of the LC spacetimes to the stationary one was independent by Lanczos in 1924 [213] and Lewis in 1932 [219]. In 1925, Beck studied a class of exact solutions and interpreted them as representing the propagation of cylindrical gravitational waves (GWs) [24]. This class of solutions was later rediscovered by Einstein and Rosen in their seminal work on the studies of the nonlinearity of GWs in 1937, and in the same year van Stockum solved the problem of a rigidly rotating infinitely long cylinder of dust, and found explicitly the corresponding metric. In 1957, Bonnor and Weber and Wheeler studied the Einstein&#x2013;Rosen waves in great details, since then, cylindrically symmetric spacetimes [327, 328], have been extensively investigated with various motivations.</p>
</datas>]]
local dom = domobject.parse(sample)
tex.sprint(dom:query_selector("p")[1]:get_text())
\end{luacode*}
\end{document}

我的期望输出结果是:

在此处输入图片描述

答案1

闪闪发光拖船28:2, 2007 展示了控制段落形状的几个示例。这里特别要说明的是,段落的最后一行“不太短”的定义。

按照声明\nottooshort,定义如下

\newdimen\parabout
\newdimen\about
\about=2em
\newcommand*{\nottooshort}{%
\parabout=\hsize
\advance\parabout -\about
\leftskip=0pt plus 0pt minus 0pt
\rightskip=\leftskip
\parfillskip=\parabout minus \parabout
\parindent=2em }

那么段落的最后一行至少会大约\about长。

举例来说:

% nottooshortprob.tex  SE 579338
\documentclass{article}

    \newdimen\parabout
    \newdimen\about
    \about=2em
    \newcommand*{\nottooshort}{%
    \parabout=\hsize
    \advance\parabout -\about
    \leftskip=0pt plus 0pt minus 0pt
    \rightskip=\leftskip
    \parfillskip=\parabout minus \parabout
    \parindent=2em }

\begin{document}

\about=2em
\nottooshort
 A paragraph where the last line is not too short. But we need some more text
to make the paragraph somewhat longer in the sense that it has more lines. 

\about=3em
\nottooshort
 A paragraph where the last line is not too short. But we need some more text
to make the paragraph somewhat longer in the sense that it has more lines. 

\end{document}
 

在此处输入图片描述

相关内容