summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
diff options
context:
space:
mode:
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