diff options
author | Karl Berry <karl@freefriends.org> | 2021-11-08 23:21:20 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-11-08 23:21:20 +0000 |
commit | e9ab0cf018b97d1ca34b3b78396d5152b19ac92c (patch) | |
tree | f23ba71514aa2ec5a8be60a0d3f3078a3e4d777a /Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty | |
parent | d15021e33a9c5e367a54267fd7c0db9798c4ba90 (diff) |
lua-widow-control (9nov21)
git-svn-id: svn://tug.org/texlive/trunk@61002 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty index d5ef8194f1b..ff3781944fa 100644 --- a/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty +++ b/Master/texmf-dist/tex/lualatex/lua-widow-control/lua-widow-control.sty @@ -1,11 +1,11 @@ % lua-widow-control % https://github.com/gucci-on-fleek/lua-widow-control % SPDX-License-Identifier: MPL-2.0+ -% SPDX-FileCopyrightText: 2021 gucci-on-fleek +% SPDX-FileCopyrightText: 2021 Max Chernoff \NeedsTeXFormat{LaTeX2e}[2015/01/01] % Formats built after 2015 include \LuaTeX{}Base \ProvidesPackage{lua-widow-control}% - [2021/10/09 v1.0.0] %%version %%date + [2021/11/08 v1.1.0] %%version %%date \setlength{\clubpenalty}{1} \setlength{\widowpenalty}{1} @@ -24,10 +24,42 @@ % lengthened paragraphs to not have terrible spacing. \RequirePackage[final]{microtype} +% Define \TeX{} wrappers for Lua functions \newcommand{\lwcenable}{\directlua{lwc.enable_callbacks()}} \newcommand{\lwcdisable}{\directlua{lwc.disable_callbacks()}} +\newcommand{\iflwc}{\directlua{lwc.if_lwc_enabled()}} % Enable \lwc/ by default when the package is loaded. \lwcenable +% Expansion of some parts of the document, such as section headings, is quite +% undesirable, so we'll disable \lwc/ for certain commands. +\RequirePackage{etoolbox} + +\newcommand{\lwc@patch@warning}[1]{\PackageWarning{lua-widow-control}{% + Patching the \protect#1 command failed% +}} + +% We should only reenable \lwc/ at the end if it was already enabled. +\newif\iflwc@should@reenable + +\newcommand{\lwc@patch@pre}{\iflwc% + \lwc@should@reenabletrue% + \lwcdisable% +\fi} + +\newcommand{\lwc@patch@post}{\iflwc@should@reenable% + \lwcenable% +\fi} + +\newcommand{\lwcdisablecmd}[1]{% + \ifdefined#1 + \pretocmd{#1}{\lwc@patch@pre}{}{\lwc@patch@warning{#1}}% + \apptocmd{#1}{\lwc@patch@post}{}{\lwc@patch@warning{#1}}% + \fi +} + +\lwcdisablecmd{\@sect} % Sectioning + + \endinput |