diff options
author | Norbert Preining <norbert@preining.info> | 2023-10-14 03:01:20 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-10-14 03:01:20 +0000 |
commit | 315010c30c0dab68a71ca741364438a7a0b1261f (patch) | |
tree | 1892d65e76bc025eede34669c33667d1e8c1f218 /macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx | |
parent | 7c1335b7f300ea31a40bf83026d6b7d24d7bafc5 (diff) |
CTAN sync 202310140301
Diffstat (limited to 'macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx')
-rw-r--r-- | macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx b/macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx new file mode 100644 index 0000000000..9ab907dea2 --- /dev/null +++ b/macros/context/contrib/context-lua-widow-control/source/luatex/lua-widow-control/lwc-zpravodaj-figure.ctx @@ -0,0 +1,161 @@ +% lua-widow-control +% https://github.com/gucci-on-fleek/lua-widow-control +% SPDX-License-Identifier: MPL-2.0+ OR CC-BY-SA-4.0+ +% SPDX-FileCopyrightText: 2022 Max Chernoff + +\startbuffer[demo-text] + \definepapersize[smallpaper][ + width=6cm, + height=8.3cm + ] + \setuppapersize[smallpaper] + + \def\lwc/{\sans{lua-\allowbreak widow-\allowbreak control}} + \def\Lwc/{\sans{lua-\allowbreak widow-\allowbreak control}} + + \setupbodyfont[9pt] + \setupindenting[yes, 2em] + \setupalign[tolerant] + + \definecolor[midlightgray][s=0.75] + \definepalet[layout][grid=midlightgray] + \showgrid[nonumber, none, lines] + + \definefontfeature[default][default][expansion=quality,protrusion=quality] + + \usetypescript[modern-base] + \setupbodyfont[reset,modern] + + \setupalign[hz,hanging,tolerant] + + \setuplanguage[en][spacing=packed] + + \setuplayout[ + topspace=0.1cm, + backspace=0.1cm, + width=middle, + height=\dimexpr 21\baselineskip + 1.1pt, + header=0pt, + footer=0pt, + ] + + \starttext + % This text has been carefully adjusted to produce a good demonstration. Be careful before modifying it. + \Lwc/ can remove most widows and orphans from a document, \emph{without} + stretching any glue or shortening any pages. + + \ifx\uselooseness\undefined\else\uselooseness\fi It does so by automatically lengthening a paragraph on a page where a + widow or orphan would otherwise occur. While \TeX{} breaks paragraphs + into their natural length, \lwc/ is breaking the paragraph 1~line + longer than its natural length. \TeX{}'s paragraph is output to the + page, but \lwc/'s paragraph is just stored for later. When a widow or + orphan occurs, \lwc/ can take over. It selects the previously-saved + paragraph with the least badness; then, it replaces \TeX{}'s paragraph + with its saved paragraph. This increases the text block height of the + page by 1~line. + + Now, the last line of the current page can be pushed to the top of the + next page. This removes the widow or the orphan without creating any + additional work. + \stoptext + \stoptext +\stopbuffer +\savebuffer[list=demo-text] + +\startbuffer[shorten] + \parskip=0pt + \input lwc-zpravodaj-figure-demo-text.tmp +\stopbuffer + +\startbuffer[shorten-code] + \parskip=0pt + \clubpenalty=10000 + \widowpenalty=10000 +\stopbuffer + +\startbuffer[stretch] + \parskip=0pt plus 1fill + \input lwc-zpravodaj-figure-demo-text.tmp +\stopbuffer + +\startbuffer[stretch-code] + \parskip=0pt plus 1fill + \clubpenalty=10000 + \widowpenalty=10000 +\stopbuffer + +\startbuffer[ignore] + \startsetups[*default] + \clubpenalty=0 + \widowpenalty=0 + \displaywidowpenalty=0 + \interlinepenalty=0 + \brokenpenalty=0 + \stopsetups + + \setups[*default] + + \input lwc-zpravodaj-figure-demo-text.tmp +\stopbuffer + +\startbuffer[ignore-code] + \parskip=0pt + \clubpenalty=0 + \widowpenalty=0 +\stopbuffer + +\startbuffer[lwc] + \def\uselooseness{\looseness=1} + \input lwc-zpravodaj-figure-demo-text.tmp +\stopbuffer + +% We're pretending that we're using LaTeX for the demo since that's what +% 99% of users will be using. +\startbuffer[lwc-code] + \usepackage + {lua-widow-control} +\stopbuffer + +\setupbodyfont[9pt] + +\setupbackend[format=PDF/A-1b:2005] % Force PDF version <1.5 + +\startTEXpage[ + align=normal, + width=492.5733pt, + offset=0pt, +] + \veryraggedcenter + \setupTABLE[row][1][style=\bfa, align=middle, offset=0pt] + % \setupTABLE[row][4][toffset=2ex] + \setupTABLE[frame=off, distance=0em] + \startTABLE + \NC Ignore + \NC Shorten + \NC Stretch + \NC \sans{lua-widow-control} + \NC\NR + + \NC \typesetbuffer[ignore][frame=on, page=1, scale=700] + \NC \typesetbuffer[shorten][frame=on, page=1, scale=700] + \NC \typesetbuffer[stretch][frame=on, page=1, scale=700] + \NC \typesetbuffer[lwc][frame=on, page=1, scale=700] + \NC\NR + + \NC \clip[height=2cm]{\typesetbuffer[ignore] + [frame=on, page=2, scale=700]} + \NC \clip[height=2cm]{\typesetbuffer[shorten] + [frame=on, page=2, scale=700]} + \NC \clip[height=2cm]{\typesetbuffer[stretch] + [frame=on, page=2, scale=700]} + \NC \clip[height=2cm]{\typesetbuffer[lwc] + [frame=on, page=2, scale=700]} + \NC\NR + + \NC \typebuffer[ignore-code] + \NC \typebuffer[shorten-code] + \NC \typebuffer[stretch-code] + \NC \typebuffer[lwc-code] + \NC\NR + \stopTABLE +\stopTEXpage |