Skip to content

Commit

Permalink
Warn on questionable emergencystretch values.
Browse files Browse the repository at this point in the history
  • Loading branch information
gucci-on-fleek committed Mar 17, 2024
1 parent e049030 commit 49fb91b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Changelog

All notable changes to lua-widow-control will be listed here, in reverse chronological order. **Changes listed in bold** are important changes: they either remove options or commands, or may change the location of page breaks.

## Unreleased

- Warn on questionable `emergencystretch` values.

## [v3.0.1 (2024-03-11)](https://github.com/gucci-on-fleek/lua-widow-control/releases/tag/release-1d224f39e2cadf74e5fb6a5d2dcd42c3fdaf2002)

_Final release present in TeX Live 2023_
Expand Down
19 changes: 18 additions & 1 deletion source/lua-widow-control.sty
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,33 @@
\c_right_brace_str\ instead.
}

\msg_new:nnn
{ \c__lwc_name_str }
{ dubious-emergencystretch }
{
Questionable~ `emergencystretch'~ value. \\
`emergencystretch'~ values~ greater~ than~ \c_backslash_str textwidth~
generally~ give~ poor~ results.~ Use~ at~ your~ own~ risk.~
(Current~ value:~ \dim_use:N \g__lwc_emergencystretch_dim)
}

% Don't let the user proceed unless they are using \LuaTeX{}.
\sys_if_engine_luatex:F {
\msg_critical:nn { \c__lwc_name_str } { no-luatex }
}

% Define (most of) the keys
\cs_generate_variant:Nn \keys_define:nn { Vn }
\dim_new:N \g__lwc_emergencystretch_dim

\keys_define:Vn { \c__lwc_name_str } {
emergencystretch .dim_gset:N = \g__lwc_emergencystretch_dim,
emergencystretch .code:n = {
\dim_gset:Nn \g__lwc_emergencystretch_dim { #1 }
\dim_compare:nNnT { #1 } > { \dim_max:nn { \textwidth } { 6in } }
{
\msg_warning:nn { \c__lwc_name_str } { dubious-emergencystretch }
}
},
emergencystretch .value_required:n = true,
emergencystretch .initial:x = \dim_max:nn { 3em } { 30pt },

Expand Down

0 comments on commit 49fb91b

Please sign in to comment.