diff options
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 | 60 |
1 files changed, 45 insertions, 15 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 6124a13b4d6..367c73adfef 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 @@ -13,7 +13,7 @@ \DeclareRelease{}{0000-00-00}{lua-widow-control-2022-02-22.sty} \DeclareRelease{v1.1.6}{2022-02-22}{lua-widow-control-2022-02-22.sty} -\DeclareCurrentRelease{v2.0.2}{2022-03-20} %%version %%dashdate +\DeclareCurrentRelease{v2.0.3}{2022-03-28} %%version %%dashdate % If this version of LaTeX doesn't support command hooks, then we load % the last v1.1.X version of the package. @@ -23,8 +23,8 @@ \ProvidesExplPackage {lua-widow-control} - {2022/03/20} %%slashdate - {v2.0.2} %%version + {2022/03/28} %%slashdate + {v2.0.3} %%version {Use Lua to remove widows and orphans} % Unconditional Package Loads @@ -102,7 +102,13 @@ disablecmds .clist_gset:N = \g__lwc_disablecmds_cl, disablecmds .value_required:n = false, - disablecmds .initial:n = { \@sect }, + disablecmds .initial:n = { \@sect, % LaTeX default + \M@sect, % Memoir + \@mem@old@ssect, % Memoir Starred + \ttl@straight@ii, % titlesec normal + \ttl@top@ii, % titlesec top + \ttl@part@ii, % titlesec part + }, disablecmds .usage:n = preamble, nobreak .choice:, @@ -150,21 +156,29 @@ % undesirable, so we'll disable \lwc/ for certain commands. \bool_new:N \g__lwc_should_reenable_bool +\cs_new:Npn \__lwc_patch_pre: { + % We should only reenable \lwc/ at the end if it was already enabled. + \__lwc_if_enabled:TF { + \bool_gset_true:N \g__lwc_should_reenable_bool + \__lwc_disable: + } { + \bool_gset_false:N \g__lwc_should_reenable_bool + } +} + +\cs_new:Npn \__lwc_patch_post: { + \bool_if:NT { \g__lwc_should_reenable_bool } { + \__lwc_enable: + } +} + \cs_new:Npn \__lwc_patch_cmd:c #1 { \IfFormatAtLeastTF {2021/06/01 } { \hook_gput_code:nnn { cmd / #1 / before } { \c__lwc_name_str } { - % We should only reenable \lwc/ at the end if it was already enabled. - \__lwc_if_enabled:TF { - \bool_gset_true:N \g__lwc_should_reenable_bool - \__lwc_disable: - } { - \bool_gset_false:N \g__lwc_should_reenable_bool - } + \__lwc_patch_pre: } \hook_gput_code:nnn { cmd / #1 / after } { \c__lwc_name_str } { - \bool_if:NT { \g__lwc_should_reenable_bool } { - \__lwc_enable: - } + \__lwc_patch_post: } } { \msg_warning:nn @@ -177,8 +191,24 @@ \__lwc_patch_cmd:c { \cs_to_str:N #1 } } +\cs_new:Npn \__lwc_patch_cmd:n #1 { + % If the item provided is a single token, we'll assume that it's a \macro. + % If it is multiple tokens, we'll assume that it's a `csname`. + \tl_if_single:nTF { #1 } { + \__lwc_patch_cmd:c { \cs_to_str:N #1 } + } { + \__lwc_patch_cmd:c { #1 } + } +} + \hook_gput_code:nnn { begindocument / before } { \c__lwc_name_str } { - \clist_map_function:NN \g__lwc_disablecmds_cl \__lwc_patch_cmd:N + \clist_map_function:NN \g__lwc_disablecmds_cl \__lwc_patch_cmd:n +} + +% KOMA-Script +\cs_if_exist:NT \AddtoDoHook { + \AddtoDoHook { heading / begingroup } { \__lwc_patch_pre: \use_none:n } + \AddtoDoHook { heading / endgroup } { \__lwc_patch_post: \use_none:n } } % Define some final keys |