summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/letter/extension/optimize.nle
blob: e606a272b2dfcdc25b098f998da0ffa38e2f401a (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
34
35
36
37
38
%D \module
%D   [       file=optimize,
%D        version=2008.12.03,
%D          title=\CONTEXT\ Letter Extension,
%D       subtitle=Alternative input method,
%D         author=Wolfgang Schuster,
%D           date=\currentdate,
%D      copyright=Wolfgang Schuster,
%D          email=schuster.wolfgang@googlemail.com,
%D        license=Public Domain]

\unprotect

\newcount\letter!value!skip   \letter!value!skip  \plusten
\newcount\letter!value!number \letter!value!number\zerocount

\definetwopasslist\v!letter

\setvalue{\v!letter\s!start\c!optimize\v!yes}%
  {\global\advance\letter!value!number\plusone
   \gettwopassdata{\v!letter}%
   \iftwopassdatafound
     \letter!value!skip\twopassdata
     \ctxparskip=\dimexpr\letter!value!skip\ctxparskip/10\relax
   \fi}

\setvalue{\v!letter\s!stop\c!optimize\v!yes}%
  {\ifdim\pagetotal<.25\textheight
     \advance\letter!value!skip\minustwo
   \else\ifdim\pagetotal<.5\textheight
     \advance\letter!value!skip\plustwo
   \fi\fi
   \lazysavetwopassdata{\v!letter}{\number\letter!value!number}{\number\letter!value!skip}}

\setvalue{\v!letter\v!content\v!start\v!optimize\v!yes}{}
\setvalue{\v!letter\v!content\v!stop \v!optimize\v!yes}{}

\protect \endinput