summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-10-11 03:02:08 +0000
committerNorbert Preining <norbert@preining.info>2021-10-11 03:02:08 +0000
commitaac7fdc4c391b318efbdee17381ac83783b2fbbb (patch)
treea9e0357ea02c4fa81e0c8c6edb2e9343b79fff35 /macros/luatex/generic/lua-widow-control/lua-widow-control.sty
parente55f5510950cf773d024770b0a0d66b13e37dae0 (diff)
CTAN sync 202110110302
Diffstat (limited to 'macros/luatex/generic/lua-widow-control/lua-widow-control.sty')
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.sty33
1 files changed, 33 insertions, 0 deletions
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
new file mode 100644
index 0000000000..d5ef8194f1
--- /dev/null
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
@@ -0,0 +1,33 @@
+% lua-widow-control
+% https://github.com/gucci-on-fleek/lua-widow-control
+% SPDX-License-Identifier: MPL-2.0+
+% SPDX-FileCopyrightText: 2021 gucci-on-fleek
+
+\NeedsTeXFormat{LaTeX2e}[2015/01/01] % Formats built after 2015 include \LuaTeX{}Base
+\ProvidesPackage{lua-widow-control}%
+ [2021/10/09 v1.0.0] %%version %%date
+
+\setlength{\clubpenalty}{1}
+\setlength{\widowpenalty}{1}
+\setlength{\displaywidowpenalty}{0}
+\setlength{\interlinepenalty}{0}
+\setlength{\brokenpenalty}{0}
+
+% We can't use \\newlength since that makes a \TeX{} "skip", not a "dimen"
+\newdimen\lwcemergencystretch
+\setlength{\lwcemergencystretch}{3em}
+
+\directlua{require "lua-widow-control"}
+
+% Here, we enable font expansion/contraction. It isn't strictly necessary for
+% \lwc/'s functionality; however, it is required for the
+% lengthened paragraphs to not have terrible spacing.
+\RequirePackage[final]{microtype}
+
+\newcommand{\lwcenable}{\directlua{lwc.enable_callbacks()}}
+\newcommand{\lwcdisable}{\directlua{lwc.disable_callbacks()}}
+
+% Enable \lwc/ by default when the package is loaded.
+\lwcenable
+
+\endinput