summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/letter/extension/optimize.nle
blob: 05a7f182799475596f83e9e3c6e63905c37695a3 (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
39
40
41
%D \module
%D   [       file=optimize,
%D        version=2008.04.23,
%D          title=\CONTEXT\ Letter Extension,
%D       subtitle=Alternative input method,
%D         author=Wolfgang Schuster,
%D           date=\currentdate,
%D      copyright=Public Domain]

\unprotect

%D The \tex{minustwo} counter was added with the \CONTEXT\ version
%D from \date[d=18,m=4,y=2008] and older versions will complain
%D about a undefined control sequence, to prevend this problem
%D I added a test if \tex{minustwo} is undefined and define it this
%D is necessary.

\ifx\minustwo\undefined \newcount\minustwo \minustwo=-2 \fi

\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}}

\protect \endinput