summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-05-20 21:38:27 +0000
committerKarl Berry <karl@freefriends.org>2022-05-20 21:38:27 +0000
commitfc716f318871295dd96471dd48dd08c117faab50 (patch)
treef6bb74a345d0b69af810207c2c4883717d997f6f /Master/texmf-dist/tex/luatex
parent59514af7db4b65b7f3a143dfbad7c80896dc7d1c (diff)
lua-widow-control (20may22)
git-svn-id: svn://tug.org/texlive/trunk@63345 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua28
-rw-r--r--Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex2
2 files changed, 26 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
index 45360db2092..2af55757994 100644
--- a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
+++ b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.lua
@@ -62,9 +62,9 @@ if format:find("cont") then -- cont-en, cont-fr, cont-nl, ...
end
elseif format:find("latex") then -- lualatex, lualatex-dev, ...
latex = true
-elseif format == "luatex" then -- Plain
+elseif format == "luatex" or format == "luahbtex" then -- Plain
plain = true
-elseif format == "optex" then -- OpTeX
+elseif format:find("optex") then -- OpTeX
optex = true
end
@@ -83,6 +83,7 @@ local par_id = node.id("par") or node.id("local_par")
local penalty_id = node.id("penalty")
-- Local versions of globals
+local abs = math.abs
local copy = node.copy_list or node.copylist
local find_attribute = node.find_attribute or node.findattribute
local flush_list = node.flush_list or node.flushlist
@@ -96,6 +97,7 @@ local set_attribute = node.set_attribute or node.setattribute
local string_char = string.char
local traverse = node.traverse
local traverseid = node.traverse_id or node.traverseid
+local vpack = node.vpack
-- Misc. Constants
local iffalse = token.create("iffalse")
@@ -160,7 +162,7 @@ elseif plain or latex or optex then
luatexbase.provides_module {
name = lwc.name,
date = "2022/05/14", --%%dashdate
- version = "2.1.0", --%%version
+ version = "2.1.1", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -502,6 +504,9 @@ function lwc.remove_widows(head)
info("Widow/orphan/broken hyphen detected. Attempting to remove")
+ local vsize = tex.dimen.vsize
+ local orig_height_diff = vpack(head).height - vsize
+
--[[
Find the paragraph on the page with the least cost.
]]
@@ -698,6 +703,23 @@ function lwc.remove_widows(head)
end
end
+ local new_height_diff = vpack(head_save).height - vsize
+ -- We need the original height discrepancy in case there are \\vfill's
+ local net_height_diff = orig_height_diff - new_height_diff
+
+ --[[ The final \\box255 needs to be exactly \\vsize tall to avoid
+ over/underfull box warnings, so we correct any discrepancies
+ here.
+ ]]
+ if abs(net_height_diff) > 0 and
+ -- A difference larger than 0.25\\baselineskip is probably not from \lwc/
+ abs(net_height_diff) < tex.skip.baselineskip.width / 4
+ then
+ local bottom_glue = new_node("glue")
+ bottom_glue.width = net_height_diff
+ last(head_save).next = bottom_glue
+ end
+
info(
"Widow/orphan/broken hyphen successfully removed at paragraph "
.. paragraph_index
diff --git a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
index 78385ad698d..5c2c93662f8 100644
--- a/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
+++ b/Master/texmf-dist/tex/luatex/lua-widow-control/lua-widow-control.tex
@@ -3,7 +3,7 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2022 Max Chernoff
-\wlog{lua-widow-control v2.1.0} %%version
+\wlog{lua-widow-control v2.1.1} %%version
\ifx\directlua\undefined
\errmessage{%