summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
blob: d5ef8194f1bfcb229aed3dbf2fae47284c06b693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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