From 0c00e8e4486fe1cc526eee6df2e4b9b3ab0ba519 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 16 Sep 2009 20:07:00 +0200 Subject: beta 2009.09.16 20:07 --- scripts/context/lua/mtx-modules.lua | 4 +- scripts/context/lua/mtx-server-ctx-fonttest.lua | 2 +- tex/context/base/anch-pgr.mkiv | 12 + tex/context/base/cont-new.tex | 2 +- tex/context/base/context.mkii | 5 +- tex/context/base/context.mkiv | 10 +- tex/context/base/context.tex | 2 +- tex/context/base/core-grd.mkii | 1074 ------ tex/context/base/core-grd.mkiv | 1074 ------ tex/context/base/core-spa.lua | 720 ---- tex/context/base/core-spa.mkii | 4656 ----------------------- tex/context/base/core-spa.mkiv | 4250 --------------------- tex/context/base/font-syn.lua | 40 +- tex/context/base/math-for.mkiv | 1 + tex/context/base/meta-ini.mkiv | 2 +- tex/context/base/mult-sys.tex | 1 + tex/context/base/pack-rul.mkiv | 6 +- tex/context/base/page-txt.mkiv | 2 +- tex/context/base/s-mod-01.tex | 17 +- tex/context/base/spac-ali.mkiv | 653 ++++ tex/context/base/spac-def.mkiv | 119 + tex/context/base/spac-fnt.mkiv | 91 + tex/context/base/spac-gen.mkii | 4656 +++++++++++++++++++++++ tex/context/base/spac-grd.lua | 41 + tex/context/base/spac-grd.mkii | 1074 ++++++ tex/context/base/spac-grd.mkiv | 1095 ++++++ tex/context/base/spac-hor.mkiv | 821 ++++ tex/context/base/spac-pag.mkiv | 201 + tex/context/base/spac-par.mkiv | 206 + tex/context/base/spac-ver.lua | 732 ++++ tex/context/base/spac-ver.mkiv | 1485 ++++++++ tex/context/base/strc-flt.mkiv | 22 +- tex/context/base/strc-itm.mkiv | 65 +- tex/context/base/strc-mat.mkiv | 28 +- tex/context/base/strc-not.mkiv | 15 +- tex/context/base/strc-num.mkiv | 67 +- tex/context/base/strc-ref.lua | 8 +- tex/context/base/strc-ref.mkiv | 4 +- tex/context/base/strc-sec.mkiv | 3 +- tex/context/base/x-mathml.mkiv | 2 +- tex/context/base/x-set-11.tex | 3 +- tex/generic/context/luatex-fonts-merged.lua | 2 +- 42 files changed, 11408 insertions(+), 11865 deletions(-) delete mode 100644 tex/context/base/core-grd.mkii delete mode 100644 tex/context/base/core-grd.mkiv delete mode 100644 tex/context/base/core-spa.lua delete mode 100644 tex/context/base/core-spa.mkii delete mode 100644 tex/context/base/core-spa.mkiv create mode 100644 tex/context/base/spac-ali.mkiv create mode 100644 tex/context/base/spac-def.mkiv create mode 100644 tex/context/base/spac-fnt.mkiv create mode 100644 tex/context/base/spac-gen.mkii create mode 100644 tex/context/base/spac-grd.lua create mode 100644 tex/context/base/spac-grd.mkii create mode 100644 tex/context/base/spac-grd.mkiv create mode 100644 tex/context/base/spac-hor.mkiv create mode 100644 tex/context/base/spac-pag.mkiv create mode 100644 tex/context/base/spac-par.mkiv create mode 100644 tex/context/base/spac-ver.lua create mode 100644 tex/context/base/spac-ver.mkiv diff --git a/scripts/context/lua/mtx-modules.lua b/scripts/context/lua/mtx-modules.lua index 65d9330ba..1a6593004 100644 --- a/scripts/context/lua/mtx-modules.lua +++ b/scripts/context/lua/mtx-modules.lua @@ -40,16 +40,18 @@ local function source_to_ted(inpname,outname,filetype) local inp = io.open(inpname) if not inp then logs.simple("unable to open '%s'",inpname) + return end local out = io.open(outname,"w") if not out then logs.simple("unable to open '%s'",outname) + return end logs.simple("converting '%s' to '%s'",inpname,outname) local skiplevel, indocument, indefinition = 0, false, false out:write(format("\\startmodule[type=%s]\n",filetype or file.suffix(inpname))) for line in inp:lines() do - line = strip(line) +--~ line = strip(line) if find(line,"^%%D ") or find(line,"^%%D$") then if skiplevel == 0 then local someline = (#line < 3 and "") or sub(line,4,#line) diff --git a/scripts/context/lua/mtx-server-ctx-fonttest.lua b/scripts/context/lua/mtx-server-ctx-fonttest.lua index f593c2e35..f3a5d7690 100644 --- a/scripts/context/lua/mtx-server-ctx-fonttest.lua +++ b/scripts/context/lua/mtx-server-ctx-fonttest.lua @@ -30,7 +30,7 @@ local process_templates = { } process_templates.default = [[ \starttext \setcharactermirroring[1] - \definefontfeature[sample][%s] + \definefontfeature[sample][analyse=yes,%s] \definedfont[name:%s*sample] \startTEXpage[offset=3pt] \detokenize{%s} diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index c558bb04f..9e6bc027d 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -26,6 +26,18 @@ \ifx\textheight\undefined \def\textheight{\vsize} \fi +%D Helper: + +\def\doassignsomeskip#1\to#2% ook nog \v!halfline+fuzzysnap + {\doifelse{#1}\v!line + {#2\openlineheight} + {\ifgridsnapping + \assigndimension{#1}{#2}{.25\openlineheight}{.5\openlineheight}\openlineheight + \else + \assigndimension{#1}{#2}\smallskipamount\medskipamount\bigskipamount + \fi}% + \relax} + %D The next macros so some housekeeping. \def\pageanchor{page:0} % for the moment only one pagesize diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 1379af14b..d09e31d67 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.09.15 12:27} +\newcontextversion{2009.09.16 20:07} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index e418d7a26..bbc05ae50 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -181,8 +181,9 @@ %D macros' that are seen by the users. The order of loading %D is important, due to dependancies. -\loadmarkfile{core-spa} -\loadmarkfile{core-grd} +\loadmarkfile{spac-gen} +\loadmarkfile{spac-grd} + \loadmarkfile{strc-mar} \loadmarkfile{anch-pos} diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 1f8de3e0a..387c8aa90 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -164,8 +164,14 @@ \loadmarkfile{strc-ref} \loadmarkfile{strc-reg} -\loadmarkfile{core-spa} -\loadmarkfile{core-grd} +\loadmarkfile{spac-hor} +\loadmarkfile{spac-ver} +\loadmarkfile{spac-ali} +\loadmarkfile{spac-pag} +\loadmarkfile{spac-fnt} +\loadmarkfile{spac-par} +\loadmarkfile{spac-def} +\loadmarkfile{spac-grd} \loadmarkfile{anch-pos} diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 4124f5924..bd0c49d95 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.09.15 12:27} +\edef\contextversion{2009.09.16 20:07} %D For those who want to use this: diff --git a/tex/context/base/core-grd.mkii b/tex/context/base/core-grd.mkii deleted file mode 100644 index 249e2e430..000000000 --- a/tex/context/base/core-grd.mkii +++ /dev/null @@ -1,1074 +0,0 @@ -%D \module -%D [ file=core-grd, -%D version=1998.03.10, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Grid Snapping (Experimental), -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Core Macros / Grid Snapping} - -\unprotect - -%D Moved from supp-box: - -%D \macros -%D {startbaselinecorrection,baselinecorrection, -%D showbaselinecorrection,offbaselinecorrection} -%D -%D Spacing around ruled boxes can get pretty messed up. The -%D next macro tries as good as possible to fix this. -%D -%D \startbuffer[1] -%D \startbaselinecorrection -%D \ruledhbox{Rule Brittanica} -%D \stopbaselinecorrection -%D \stopbuffer -%D -%D \typebuffer[1] -%D -%D The macros put some white space around the box: -%D -%D \getbuffer[1] -%D -%D A simple alternative is \type {\baselinecorrection}, which -%D only looks at the previous line. -%D -%D \startbuffer[2] -%D \baselinecorrection -%D \ruledhbox{Rule Brittanica} -%D \baselinecorrection -%D \stopbuffer -%D -%D \typebuffer[2] -%D -%D This time the last preceding line gets a correction,% -%D dependant on the depth. -%D -%D \getbuffer[2] -%D -%D One can make the correction visible by saying \type -%D {\showbaselinecorrection}. Part of the correction is -%D calculated from the dimensions of a~(. One can disble the -%D correction by calling \type {\offbaselinecorrection}. -%D -%D When visualize the first example looks like: -%D -%D {\showbaselinecorrection\getbuffer[1]} -%D -%D and the second one comes out as: -%D -%D {\showbaselinecorrection\getbuffer[2]} - -% \definecolor[GridLineColor][red] -% \definecolor[GridTextColor][blue] - -\definepalet - [grid] - [ one=red, - two=green, - three=blue, - four=gray] - -\def\setbaselinecorrections - {\setbox0\hbox{\setstrut\strut}% - \setbox2\hbox{(}% - \dimen0\ht0\advance\dimen0 -\ht2 - \ifdim\dimen0<\zeropoint\dimen0\zeropoint\fi - \dimen2\dp0\advance\dimen2 -\dp2 - \ifdim\dimen2<\zeropoint\dimen2\zeropoint\fi - \edef\thetopbaselinecorrection {\the\dimen0}\dimen0-\dimen0 - \edef\thebotbaselinecorrection {\the\dimen2}\dimen2-\dimen2 - \edef\thenegtopbaselinecorrection{\the\dimen0}% - \edef\thenegbotbaselinecorrection{\the\dimen2}} - -\def\dotopbaselinecorrection {\kern\thetopbaselinecorrection} -\def\dobotbaselinecorrection {\kern\thebotbaselinecorrection} -\def\donegtopbaselinecorrection{\kern\thenegtopbaselinecorrection} -\def\donegbotbaselinecorrection{\kern\thenegbotbaselinecorrection} - -\def\showbaselinecorrection - {\def\dobaselinecorrection % visualization is not watertight! - {\bgroup -\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi - \setbox0\null - \wd0\hsize - \dp0\strutdp - \nointerlineskip - \forgetall - \ruledvbox{\box0}% - \egroup - \prevdepth\strutdp}% - \def\dotopbaselinecorrection - {\hrule\!!height\thetopbaselinecorrection}% - \def\dobotbaselinecorrection - {\hrule\!!height\thebotbaselinecorrection}} - -\def\dobaselinecorrection - {\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi - \kern\strutdp - \prevdepth\strutdp} - -% \def\baselinecorrection -% {\endgraf -% \ifvmode -% \ifdim\prevdepth<\maxdimen -% \ifdim\prevdepth<\zeropoint \else -% \ifdim\prevdepth<\strutdp -% \dobaselinecorrection -% \fi -% \fi -% \fi -% \fi} - -\def\baselinecorrection - {\endgraf - \ifvmode - \ifdim\prevdepth<\maxdimen - \ifdim\prevdepth<\zeropoint \else - \ifdim\prevdepth<\strutdepth \relax - \pushlastnode - \dobaselinecorrection - \poplastnode - \fi - \fi - \fi - \fi} - -\def\pagebaselinecorrection - {\ifdim\pagegoal<\maxdimen - \ifdim\pagetotal>\lineheight % or \topskip - \scratchdimen\pagetotal - \advance\scratchdimen\lineheight - \ifdim\scratchdimen<\pagegoal - \baselinecorrection - \fi - \fi - \fi} - -% Beware, keep this one as it is, see for instance module -% m-steps.tex, where we apply a \localhsize to the \vbox, in -% order to follow narrower and side floats ! - -% \def\startbaselinecorrection -% {\baselinecorrection -% \ifvmode -% \bgroup -% \setbox\scratchbox\vbox\bgroup -% \ignorespaces -% \let\stopbaselinecorrection\dostopbaselinecorrection -% \else -% \let\stopbaselinecorrection\relax -% \fi} - -% \def\dostopbaselinecorrection % I have to check columns yet. -% {\endgraf -% \egroup -% \topbaselinecorrection -% \box\scratchbox -% \botbaselinecorrection -% \egroup} - -% \let\stopbaselinecorrection=\relax - -\def\startbaselinecorrection - {\bgroup - \let\stopbaselinecorrection\egroup - \ifcase\baselinecorrectionmode - \or % normal - \baselinecorrection - \ifvmode - \setbox\scratchbox\vbox\bgroup\ignorespaces - \let\stopbaselinecorrection\donormalstopbaselinecorrection - \fi - \or % off - \or % force - \baselinecorrection - \ifvmode - \setbox\scratchbox\vbox\bgroup\ignorespaces - \let\stopbaselinecorrection\doforcedstopbaselinecorrection - \fi - \fi} - -\let\stopbaselinecorrection\relax - -\def\donormalstopbaselinecorrection % I have to check columns yet. - {\egroup - \topbaselinecorrection - \box\scratchbox - \botbaselinecorrection - \egroup} - -\def\doforcedstopbaselinecorrection % I have to check columns yet. - {\egroup - \forcedtopbaselinecorrection - \box\scratchbox - \forcedbotbaselinecorrection - \egroup} - -%D We do a bit more checking than needed. The pageborder check -%D is not needed, but I want to look the visualization as good -%D as possible too. - -% \def\offbaselinecorrection % Can be used inside correction. -% {\def\startbaselinecorrection{\bgroup\let\stopbaselinecorrection\egroup}} - -\chardef\baselinecorrectionmode\plusone - -\def\onbaselinecorrection {\chardef\baselinecorrectionmode\plusone } -\def\offbaselinecorrection {\chardef\baselinecorrectionmode\plustwo } -\def\forcebaselinecorrection{\chardef\baselinecorrectionmode\plusthree} - -%D \macros -%D {topbaselinecorrection,botbaselinecorrection} -%D -%D The actual top and bottom corrections are implemented as: - -% \def\topbaselinecorrection -% {\ifvmode \ifdim\pagegoal<\maxdimen -% \bgroup -% \setbaselinecorrections -% \whitespace -% \nointerlineskip -% \dotopbaselinecorrection -% \egroup -% \fi \fi} - - -\def\topbaselinecorrection - {\ifvmode \ifdim\pagegoal<\maxdimen - \forcedtopbaselinecorrection - \fi \fi} - -\def\forcedtopbaselinecorrection - {\ifvmode - \bgroup - \setbaselinecorrections - \whitespace - \nointerlineskip - \dotopbaselinecorrection - \egroup - \fi} - -\def\botbaselinecorrection - {\ifvmode - \bgroup - \setbaselinecorrections - \dobotbaselinecorrection - \allowbreak % new, otherwise problems when many in a row - \prevdepth\strutdp - \egroup - \fi} - -\let\forcedbotbaselinecorrection\botbaselinecorrection - -%D Still very experimental and therefore undocumented. - -\newif\ifgridsnapping % UNDER DEVELOPMENT, USE WITH CARE -\newif\ifforcepresnap \forcepresnaptrue % false in mixed single/double -\newif\ifstrutsnapping \strutsnappingtrue % sometimes handy to be false - -\def\positiveextrasnap {\gdef\extrasnapsign{+}} -\def\negativeextrasnap {\gdef\extrasnapsign{-}} - -\def\extrasnapreset {\global\chardef\@@extrasnap0 - \positiveextrasnap} -\def\extrasnapbefore {\global\chardef\@@extrasnap1 } -\def\extrasnaparound {\global\chardef\@@extrasnap2 } -\def\extrasnapafter {\global\chardef\@@extrasnap3 } - -\def\enablepresnapcorrection {\global\chardef\@@presnap\zerocount} -\def\disablepresnapcorrection {\global\chardef\@@presnap\plusone} - -\extrasnapreset \enablepresnapcorrection - -\newif\iftracegridsnapping -\newif\ifshowgridboxes -\newif\ifshowfuzzyskips - -\let\showgridboxes\showgridboxestrue - -\def\showgridsnapping - {\tracegridsnappingtrue - \showgridboxestrue} - -\chardef\@@alignsnap =0 -\chardef\@@alignsnapbox =0 -\chardef\@@alignsnapmethod=0 - -\let\presnapskip \!!zeropoint \def\presnap {-} -\let\postsnapskip\!!zeropoint \let\postsnap\presnap - -\newcount\currentgridsnap - -\def\tracedsnapping - {\iftracegridsnapping - \llap - {\startlayoutcomponent{gridsnaps}{grid snaps}% - \infofont - \global\advance\currentgridsnap\plusone - \color[grid:three]{\vl\presnapskip - \vl\presnap - \vl\postsnap - \ifcase\@@alignsnapbox\relax - \vl\ifcase\@@extrasnap - 00\or - \extrasnapsign0\or - \extrasnapsign\extrasnapsign\or - 0\extrasnapsign\fi - \fi - \vl\the\currentgridsnap\vl}% - \stoplayoutcomponent}% - \fi} - -\def\snaptogrid% [#1]#2 -> #2 == \hbox|\vbox - {\dosingleempty\dosnaptogrid} - -% \def\dosnaptogrid[#1]% -% {\ifgridsnapping -% \iffirstargument\doifsomething{#1}{\verplaatsopgrid[#1]}\fi -% \expandafter\dodosnaptogrid -% \fi} - -% \def\dosnaptogrid[#1]% -% {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up -% \ifgridsnapping -% \iffirstargument\doifsomething{#1}{\moveongrid[#1]}\fi -% \expandafter\dodosnaptogrid -% \fi} - -\def\dosnaptogrid[#1]% - {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up - \doifinsetelse\v!force{#1}% - {\moveongrid[#1]% - \dodosnaptogrid} - {\ifgridsnapping - \doifsomething{#1}{\moveongrid[#1]}% - \expandafter\dodosnaptogrid - \fi}} - -% \def\forcedpresnapcorrection % test this on 'details' -% {\ifforcepresnap -% \ifvmode \else \par \fi % new -% % we don't want top of page space when 'top' option -% %\verticalstrut\nobreak\vskip-\struttotal -% %\verticalstrut\vskip-\struttotal -% % nobreak really needed -% \allowbreak\verticalstrut\nobreak\vskip-\struttotal -% %\ifdim\pagetotal>\topskip \else -% % eigenlijk signal -% %\writestatus{grid}{removing dummy at top of page}% -% %\bgroup -% %\output{\setbox\scratchbox\box255}% -% %\penalty\outputpenalty -% %\egroup -% %\fi -% \fi} - -\def\forcedpresnapcorrection % test this on 'details' - {\ifforcepresnap - \ifvmode \else \par \fi % new - % we don't want top of page space when 'top' option - % \verticalstrut\nobreak\vskip-\struttotal - % \verticalstrut\vskip-\struttotal - % \nobreak really needed - % \dosomebreak\allowbreak % no: spoils heads, so only under know situation, not in snapper - \verticalstrut - \nobreak - \vskip-\struttotal - %\ifdim\pagetotal>\topskip \else - % eigenlijk signal - %\writestatus{grid}{removing dummy at top of page}% - %\bgroup - %\output{\setbox\scratchbox\box255}% - %\penalty\outputpenalty - %\egroup - %\fi - \fi} - -\def\setgridtracebox#1[#2]% % maybe reverse the order - {\setbox\nextbox#1% - {\hbox - {\hbox to \zeropoint - {\startlayoutcomponent{gridsnaps}{grid snaps}% - \color[grid:#2]{\ruledhbox{\fakebox\nextbox}}% - \stoplayoutcomponent - \hss}% - \flushnextbox}}} - -\newif\ifboxedsnapping \boxedsnappingtrue - -\chardef\depthsnapmethod \plusone % downward compatible, minus one line -\chardef\heightsnapmethod\plusone % downward compatible, minus one line - -\def\dodosnaptogrid - {\dowithnextbox - {\bgroup - \ifcase\@@alignsnapmethod \or - % we're dealing with text with a possible big depth/height - \chardef\depthsnapmethod \plustwo - \chardef\heightsnapmethod\plustwo - \fi - \ifdim\nextboxht<\textheight % handle special case (like page fig) - \ifcase\@@alignsnapbox\relax - \ifcase\@@alignsnap\else % 1=top 2=high 3=middle 4=low - \ifshowgridboxes - \setgridtracebox\hbox[two]% - \fi - %\getnoflines{\nextboxht}% - \getnoflines\nextboxht - \setbox\nextbox\vbox to \noflines\lineheight - {\ifnum\@@alignsnap=1 \kern\lineheight\kern-\topskip\fi - \ifnum\@@alignsnap>2 \vfill\fi - \flushnextbox - \ifnum\@@alignsnap<4 \vfill\fi}% - \fi - \ifshowgridboxes - \setgridtracebox\hbox[three]% - \fi - \forgetall - \par - \ifvbox\nextbox - \setbox\nextbox\hbox{\flushnextbox}% don't ask - \fi - \scratchskip\lastskip - \edef\presnapskip{\the\lastskip}% - % mixing single/double columns sometimes goes wrong, - % check 'som' document - \ifinsidecolumns - \forcepresnaptrue - \fi - \forcedpresnapcorrection - \ifdim\nextboxht>\strutht - \scratchdimen\nextboxht - \ifcase\@@presnap\relax - \ifdim\scratchskip>\zeropoint\relax - \scratchcounter\scratchskip - \advance\scratchcounter -\openlineheight - \ifnum\scratchcounter<0 - \scratchcounter-\scratchcounter - \fi - \ifnum\scratchcounter<10 % \lastkip is about \openlineheight - \advance\scratchdimen -\openstrutdepth - \edef\presnapskip{*\presnapskip}% - \else\ifdim\scratchskip>\openlineheight - %<\openlineheight \else - \advance\scratchdimen -\openstrutdepth - \edef\presnapskip{*\presnapskip}% - \fi\fi - \fi - \fi - % \getnoflines\scratchdimen % maybe raw ? - % \advance\noflines -1 - \ifcase\heightsnapmethod - % raw - \or - \advance\scratchdimen-\lineheight % tight (default) - \or - \advance\scratchdimen-\strutheight % fit (text) - \or - \advance\scratchdimen-\strutheight % tolerant - \advance\scratchdimen-\roundingeps - \fi - \getnoflines\scratchdimen - \ifnum\noflines>0 - \scratchdimen\noflines\lineheight - \else - \scratchdimen\zeropoint - \fi - \else - \scratchdimen\zeropoint - \fi - \ifnum\@@extrasnap=1 \advance\scratchdimen \extrasnapsign \lineheight \fi - \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi - \edef\presnap{\the\scratchdimen}% - \ifstrutsnapping - \ifboxedsnapping - \getrawnoflines\scratchdimen - \advance\scratchdimen-\noflines\lineheight - \vskip\scratchdimen % disappears at top of page - \dorecurse\noflines{\verticalstrut\nobreak}% - \else \ifdim\scratchdimen=\zeropoint - % nothing to skip - \else % disappears at top of page - \vskip\scratchdimen - \fi \fi - \fi - \ifdim\nextboxdp>\strutdp - % \getnoflines\nextboxdp - % \advance\noflines \minusone - \scratchdimen\nextboxdp\relax - \ifcase\depthsnapmethod - % raw - \or - \advance\scratchdimen-\lineheight % tight (default) - \or - \advance\scratchdimen-\strutdepth % fit (text) - \or - \advance\scratchdimen-\strutdepth % tolerant - \advance\scratchdimen-\roundingeps - \fi - \getnoflines\scratchdimen - \ifnum\noflines>0 - \scratchdimen\noflines\lineheight - \else - \scratchdimen\zeropoint - \fi - \else - \scratchdimen\zeropoint - \fi - \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi - \ifnum\@@extrasnap=3 \advance\scratchdimen \extrasnapsign \lineheight \fi - \edef\postsnap{\the\scratchdimen}% - \ifstrutsnapping - \nextboxht\strutht - \nextboxdp\strutdp - \else - \scratchdimen\presnap - \advance\scratchdimen \strutht - \nextboxht\scratchdimen - \scratchdimen\postsnap - \advance\scratchdimen \strutdp - \nextboxdp\scratchdimen - \fi - \hbox{\tracedsnapping\flushnextbox}% - \ifstrutsnapping - \ifdim\scratchdimen=\zeropoint\else\vskip\scratchdimen\fi - \fi - \else - \scratchdimen\nextboxht\relax - \ifcase\@@alignsnapbox - % can't happen here - \or - \getrawnoflines\scratchdimen - \else - \getnoflines \scratchdimen - \fi - \scratchdimen\noflines\lineheight\relax - \advance\scratchdimen-\strutdepth - % spoils the whole game (fit/broad/line) - % \ifnum\pagetotal>\zeropoint \else % disable this as option - % \advance\scratchdimen-\strutheight - % \advance\scratchdimen+\topskip - % \fi - \dimen0=\scratchdimen - \dimen2=\strutdepth - \ifshowgridboxes - \setgridtracebox\hbox[two]% - \fi - \nextboxdp\strutdp - \dimen4=\nextboxht - \dimen6=\nextboxdp - \iftracegridsnapping - \setbox\scratchbox\hbox - {\scratchdimen\@@alignsnapamount\relax - \ifdim\scratchdimen<\zeropoint - \tracedgridamount\zeropoint{-\scratchdimen}% - \else - \tracedgridamount\scratchdimen\zeropoint - \fi}% - \smashbox\scratchbox - \setbox\nextbox\hbox{\box\scratchbox\flushnextbox}% - \fi - \setbox\nextbox\hbox - {\scratchdimen\@@alignsnapamount\relax - \ifcase\@@alignsnapdepth\or - % don't change this ever ! - \ifdim\dimen0<\lineheight - % otherwise it is ok, but ending up inside - % the next paragraph is seldom what we want, - % so we move one line up - \advance\scratchdimen-\lineheight - \advance\scratchdimen\strutheight - \else - % otherwise we can move down to the - % baseline - \advance\scratchdimen\dimen6 % == \strutdepth - \fi - \fi - \lower\scratchdimen\flushnextbox}% - \nextboxht\dimen4 - \nextboxdp\dimen6 - \ifnum\@@alignsnap<4 % 4 = regel - \setbox\nextbox\vbox to \scratchdimen - {\forgetall - \ifnum\@@alignsnap>2 \vfill\fi % 3 4 - \flushnextbox - \nointerlineskip % \offinterlineskip - \ifnum\@@alignsnap<4 \vfill\fi % 2 3 - \kern\zeropoint}% - \fi - \ifshowgridboxes - \setgridtracebox\vbox[three]% - \fi - \scratchdimen\@@alignsnapamount - \edef\presnapskip{\the\scratchdimen}% - \ifnum\@@alignsnap>2 \def\presnap {+}\fi - \ifnum\@@alignsnap<4 \def\postsnap{+}\fi - \setbox\nextbox\hbox{\tracedsnapping\flushnextbox}% - \par - \nextboxht\dimen0 - \nextboxdp\dimen2 - \forcedpresnapcorrection - \nointerlineskip - \flushnextbox - \fi - \else - \setbox\nextbox\vbox to \textheight - {\ifdim\nextboxdp=\zeropoint - \hbox{\lower\strutdepth\flushnextbox} - \else % this branch is yet untested - \vss - \hbox{\lower\nextboxdp\flushnextbox} - \vskip-\strutdepth - \fi}% - \nextboxdp\strutdepth - \flushnextbox - \fi - \extrasnapreset - \enablepresnapcorrection - \global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount - \egroup}} - -\def\tracedgridamount#1#2% - {\startlayoutcomponent{gridsnaps}{grid snaps}% - \color[grid:four]{\vrule\!!width\nextboxwd\!!height#1\!!depth#2}% - \stoplayoutcomponent} - -\def\snaptomathgrid % probably not working ok, also kind of obsolete - {\ifgridsnapping - \dowithnextbox - {\blank[\v!line]\snaptogrid\vbox{\flushnextbox}\blank[\v!line]} - \vbox\bgroup - \forgetdisplayskips - \@EA\let\@EA\next - \fi} - -\def\topsnaptogrid - {\ifgridsnapping - \dowithnextbox - {\scratchdimen\nextboxht - \advance\scratchdimen -\strutht - \advance\scratchdimen \topskip - \nextboxht\scratchdimen - \nextboxdp\zeropoint - \flushnextbox - \kern\lineheight - \kern-\topskip - \nointerlineskip} - \hbox - \fi} - -% \def\centertogrid % meant for special situations -% {\ifgridsnapping -% \dowithnextboxcontent -% {\ignorespaces} -% {\bgroup -% \par -% \scratchdimen\nextboxht -% \advance\scratchdimen \nextboxdp -% \getnoflines\scratchdimen -% \setbox\nextbox\vbox to \noflines\lineheight -% {\forgetall -% \vskip\zeropoint \!!plus \nextboxht -% \copy\nextbox -% \kern.5\strutdp % VOORLOPIGE WAARDE -% \vskip\zeropoint \!!plus \nextboxdp}% -% \noindent\snaptogrid\vbox{\flushnextbox}% -% \egroup} -% \vbox % was \hbox -% \fi} - -% The next implementation is sub-optimal -% -% \def\centertogrid % usage: see ie pascal / stepcharts -% {\snaptogrid[\v!midden,.5\strutdp]\vbox} - -\def\centertogrid % meant for special situations - {\ifgridsnapping - \dowithnextboxcontent - {\ignorespaces} - {\bgroup - \par - \scratchdimen\nextboxht - \advance\scratchdimen \nextboxdp - \getnoflines\scratchdimen - \setbox\nextbox\vbox to \noflines\lineheight - {\forgetall - \vss - \topbaselinecorrection - \copy\nextbox - \botbaselinecorrection - \vss}% - \setbox\nextbox\hbox{\lower\strutdp\flushnextbox}% - \forgeteverypar % new per 3/4/2008, prevents duplicate pos nodes resulting in extra whitespace - \noindent\snaptogrid\vbox{\flushnextbox}% - \egroup} - \vbox % was \hbox - \fi} - -% testbed for \centertogrid -% -% \strut Bruggetje -% \startlinecorrection -% \startcombination -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination[2*2] -% {\framed{test}} {} {\framed{test}} {} -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination[2*2] -% {\framed{test}} {} {\framed{test}} {} -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination[2*2] -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination[2*2] -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection - -\ifx\startbaselinecorrection\undefined \wait \fi % change order - -\let\normalstartbaselinecorrection=\startbaselinecorrection - -\def\startbaselinecorrection - {\ifgridsnapping - \centertogrid\bgroup - \let\stopbaselinecorrection\egroup - \else - \normalstartbaselinecorrection - \fi} - -\chardef\gridboxlinenomode\plusone -\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame - -\def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi} -\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth} - -\def\setgridbox#1#2#3% - {\setbox#1\gridboxvbox to #3 % given size - {\forgetall - \resetteststrut - \offinterlineskip - \hsize#2% - \baselinerulefalse - \gridboxvbox % calculated size - {\getrawnoflines{#3}% \getnoflines{#3}% - \vskip\topskip - \vskip-\strutht - \scratchdimen#2\advance\scratchdimen \lineheight - \dorecurse\noflines - {\strut - \hskip-.5\lineheight - \ifcase\gridboxlinenomode\or - \rlap - {\hskip.2\bodyfontsize\hskip\scratchdimen - \infofont\hbox to 1em{\hss\recurselevel}}% - \or - \llap - {\infofont\hbox to 1em{\hss\recurselevel}% - \hskip.2\bodyfontsize}% - \fi - \vrule - \!!height \gridboxwidth - \!!depth \gridboxwidth - \!!width \scratchdimen - \par}} - \vfill}} - -%D Some intervention macros: - -\def\gridwarning#1{\message{[beware of #1 extra snap]}} - -\global\let\@@alignsnapamount\!!zeropoint -\global\chardef\@@alignsnapdepth0 - -\def\@@unknowngriddisplacement - {\global\chardef\@@alignsnapbox\plusthree - \global\let\@@alignsnapamount\commalistelement} - -\def\domoveongrid[#1]% - {\ifgridsnapping\doifsomething{#1}{\dodomoveongrid[#1]}\fi} - -\def\dodomoveongrid[#1]% some day : speed up - {\global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount - \global\chardef\@@alignsnapdepth\zerocount - \global\chardef\@@alignsnapmethod\zerocount - \global\let\@@alignsnapamount\!!zeropoint - \donefalse - \expanded{\processallactionsinset[#1]} - [\v!standard=>, - \v!normal=>, % to be sure - \v!yes=>, % to be sure - \v!top=>\gridwarning+\positiveextrasnap\extrasnapbefore, - \v!bottom=>\gridwarning+\positiveextrasnap\extrasnapafter, - \v!both=>\positiveextrasnap\extrasnaparound, - -\v!top=>\gridwarning-\negativeextrasnap\extrasnapbefore, - -\v!bottom=>\gridwarning-\negativeextrasnap\extrasnapafter, - -\v!both=>\negativeextrasnap\extrasnaparound, - \v!text=>\global\chardef\@@alignsnapmethod\plusone, % accurate calculations - \v!page=>\global\chardef\@@alignsnap\plusone, % topskip - \v!high=>\global\chardef\@@alignsnap\plustwo, - \v!middle=>\global\chardef\@@alignsnap\plusthree, - \v!low=>\global\chardef\@@alignsnap\plusfour, - \v!fit=>\global\chardef\@@alignsnapbox\plusone, % new - \v!broad=>\global\chardef\@@alignsnapbox\plustwo, % new - \v!depth=>\global\chardef\@@alignsnapdepth\plusone, % new - \v!line=>\global\chardef\@@alignsnapbox\plusthree -% \global\chardef\@@alignsnapdepth\plusone - \global\chardef\@@alignsnap\plusfour, - \v!reset=>\positiveextrasnap\extrasnapreset, - \v!none=>\global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount, - \v!force=>, % turns on grid snapping even when not on - \s!default=>, - \s!unknown=>\@@unknowngriddisplacement]} - -\def\moveongrid - {\dosingleempty\domoveongrid} - -\def\doplaceongrid[#1]% - {\domoveongrid[#1]\snaptogrid\vbox} - -\def\placeongrid - {\dosingleempty\doplaceongrid} - -%D Snapping is rather robust as long as we use whole lines. -%D Half lines of white space can however be handled when they -%D come in pairs. The corrections needed when crossing page -%D boundaries in the middle of such a pair, are handled by -%D macros that are (named) sort of fuzzy. This fuzzy mechanism -%D was written as an extension to the grid typesetting needed -%D for typesetting (part of) the \MAPS. -%D -%D \starttyping -%D \setuptyping -%D [before={\blank[halfline]}, -%D after={\blank[halfline]}] -%D \stoptyping - -\newif \iffuzzyvskip -\newif \iffuzzysnapdone -\newif \iffuzzysnapping -\newif \iffuzzysnapped -\chardef \fuzzysnappedleft=0 % ==1 when fuzzybegin still open -\newpersistentmark\fuzzymark % (!) -\newcount \fuzzymarker -\newbox \fuzzysnapbox -\newbox \fuzzysnapsplit - -\def\dosyncfuzzyvskip - {\ifvmode\ifdim\lastskip<\lineheight\ifdim\lastskip>\zeropoint - \bgroup % - added 28/2/2003: check this, there was no - - \endgraf\forgetall\verticalstrut\nobreak\vskip-\struttotal - \egroup - \fi\fi\fi} - -\def\fuzzyvskip#1% - {\iffuzzysnapdone - \dosyncfuzzyvskip % NEWER - \endfuzzysnapping - \vskip#1\relax - \global\fuzzysnapdonefalse - \else - \vskip#1\relax - \beginfuzzysnapping - \global\fuzzysnapdonetrue - \fi} - -\def\setfuzzymark#1#2#3% #1/#2 => error recovery - {\ifgridsnapping - \global\fuzzysnappingtrue - \global\advance\fuzzymarker \ifodd\fuzzymarker#1\else#2\fi - \nobreak - \ifshowfuzzyskips - \hbox{\color[grid:three] - {\llap{\infofont#3\vl\the\fuzzymarker}\nobreak - \vrule\!!width\hsize\!!height.1\lineheight}} - \nobreak - \fi - %[\the\fuzzymarker] - %\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% - \expandafter\rawsetmark\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% - \nobreak - \fi} - -\def\beginfuzzysnapping{\setfuzzymark21\v!start} % odd -\def\endfuzzysnapping {\setfuzzymark12\v!stop } % even - -\def\removelastfuzzyvskip - {\ifgridsnapping - \iffuzzysnapping - \ifdim\lastskip<\openlineheight - \else - \removelastskip - \fi - \else - \removelastskip - \fi - \else - \removelastskip - \fi} - -\def\docheckfuzzysnap#1% - {\bgroup - \dontcomplain - \setbox\fuzzysnapbox\copy#1\relax - \setbox\fuzzysnapsplit\vsplit\fuzzysnapbox to 1\lineheight - \let\topfuzzymark\empty % indeed here ... no real mark - \getsplitmarks\fuzzymark -% \ifcase0\topfuzzymark - \ifcase0\rawgetsplittopmark\fuzzymark - \global\chardef\fuzzysnappedleft\zerocount - \global\fuzzysnappedfalse -% \else\ifodd\topfuzzymark - \else\ifodd\rawgetsplittopmark\fuzzymark - \global\chardef\fuzzysnappedleft\plusone - \global\fuzzysnappedtrue - \else - \global\chardef\fuzzysnappedleft=2 - \global\fuzzysnappedtrue - \fi\fi - \iffuzzysnapped \else - \doloop - {\ifvoid\fuzzysnapbox - \exitloop - \else - \setbox\fuzzysnapsplit=\vsplit\fuzzysnapbox to \lineheight - %\let\topfuzzymark=\empty % ... but not here - \getsplitmarks\fuzzymark -% \ifcase0\topfuzzymark - \ifcase0\rawgetsplittopmark\fuzzymark - % continue -% \else\ifodd\topfuzzymark - \else\ifodd\rawgetsplittopmark\fuzzymark - \exitloop - \else - \global\chardef\fuzzysnappedleft\plusone - \global\fuzzysnappedtrue - \exitloop - \fi\fi - \fi}% - \fi - \egroup} - -\def\getfuzzysnapcorrection#1% - {\global\let\presnapcorrection \relax - \global\let\postsnapcorrection\relax - \ifgridsnapping\iffuzzysnapping - \docheckfuzzysnap{#1}% - \iffuzzysnapped - \iftracegridsnapping - \gdef\presnapcorrection - {\color[grid:four]{\hrule\!!height.5\openlineheight\!!width\hsize}}% - \else - \gdef\presnapcorrection{\kern.5\openlineheight}% - \fi - \gdef\postsnapcorrection{\kern-.5\openlineheight}% get the height ok - \fi - \fi\fi} - -\def\fuzzysnappedbox#1#2% \box \unvbox - {\getfuzzysnapcorrection{#2}% - \presnapcorrection - #1#2% - \postsnapcorrection} - -\def\adaptfuzzypagegoal - {\ifgridsnapping\iffuzzysnapping\ifcase\fuzzysnappedleft\or % see dopagecontents - \scratchdimen\pagegoal - \advance\scratchdimen -.5\openlineheight - \global\pagegoal\scratchdimen - \global\advance\vsize -.5\openlineheight - \global\chardef\fuzzysnappedleft0 - \fi\fi\fi} - -%D New, experimental, used in caption snapping: -%D -%D \starttyping -%D \startcolumnset -%D -%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=top] -%D -%D \placefigure [lrtb] {\dorecurse{5}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D \placefigure [lrtb] {\dorecurse{15}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D -%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=bottom] -%D -%D \placefigure [rltb] {\dorecurse{5}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D \placefigure [rltb] {\dorecurse{15}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D -%D \input thuan -%D -%D \stopcolumnset -%D \stoptyping - -\def\moveboxontogrid#1#2#3% box method firstlineht % experimental ! ! ! - {\doifsomething{#2} - {\getnoflines{\ht#1}% no depth taken into account, depth preserved - \scratchdimen\noflines\lineheight - \advance\scratchdimen-\strutdp - \bgroup - \advance\scratchdimen-\onepoint % be a bit tolerant - \ifdim\scratchdimen>\ht#1\relax - \egroup - \doif{#2}\v!top {\setbox#1\vbox to \scratchdimen{\vskip-#3\vskip\strutht\box#1\vfill}}% - \doif{#2}\v!bottom{\setbox#1\vbox to \scratchdimen{\vfill\box#1\removedepth}}% - \dp#1\strutdp - \else - \egroup - \ht#1\scratchdimen - \dp#1\strutdp - \fi}} - -%D New: - -\let\checkgridsnapping\relax - -\protect \endinput diff --git a/tex/context/base/core-grd.mkiv b/tex/context/base/core-grd.mkiv deleted file mode 100644 index d6cc93735..000000000 --- a/tex/context/base/core-grd.mkiv +++ /dev/null @@ -1,1074 +0,0 @@ -%D \module -%D [ file=core-grd, -%D version=1998.03.10, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Grid Snapping (Experimental), -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Core Macros / Grid Snapping} - -\unprotect - -%D Moved from supp-box: - -%D \macros -%D {startbaselinecorrection,baselinecorrection, -%D showbaselinecorrection,offbaselinecorrection} -%D -%D Spacing around ruled boxes can get pretty messed up. The -%D next macro tries as good as possible to fix this. -%D -%D \startbuffer[1] -%D \startbaselinecorrection -%D \ruledhbox{Rule Brittanica} -%D \stopbaselinecorrection -%D \stopbuffer -%D -%D \typebuffer[1] -%D -%D The macros put some white space around the box: -%D -%D \getbuffer[1] -%D -%D A simple alternative is \type {\baselinecorrection}, which -%D only looks at the previous line. -%D -%D \startbuffer[2] -%D \baselinecorrection -%D \ruledhbox{Rule Brittanica} -%D \baselinecorrection -%D \stopbuffer -%D -%D \typebuffer[2] -%D -%D This time the last preceding line gets a correction,% -%D dependant on the depth. -%D -%D \getbuffer[2] -%D -%D One can make the correction visible by saying \type -%D {\showbaselinecorrection}. Part of the correction is -%D calculated from the dimensions of a~(. One can disble the -%D correction by calling \type {\offbaselinecorrection}. -%D -%D When visualize the first example looks like: -%D -%D {\showbaselinecorrection\getbuffer[1]} -%D -%D and the second one comes out as: -%D -%D {\showbaselinecorrection\getbuffer[2]} - -% \definecolor[GridLineColor][red] -% \definecolor[GridTextColor][blue] - -\let\thetopbaselinecorrection \!!zeropoint -\let\thebotbaselinecorrection \!!zeropoint -\let\thenegtopbaselinecorrection\!!zeropoint -\let\thenegbotbaselinecorrection\!!zeropoint - -\definepalet - [grid] - [ one=red, - two=green, - three=blue, - four=gray] - -\def\setbaselinecorrections - {\setbox0\hbox{\setstrut\strut}% - \setbox2\hbox{(}% - \dimen0\ht0\advance\dimen0 -\ht2 - \ifdim\dimen0<\zeropoint\dimen0\zeropoint\fi - \dimen2\dp0\advance\dimen2 -\dp2 - \ifdim\dimen2<\zeropoint\dimen2\zeropoint\fi - \edef\thetopbaselinecorrection {\the\dimen0}\dimen0-\dimen0 - \edef\thebotbaselinecorrection {\the\dimen2}\dimen2-\dimen2 - \edef\thenegtopbaselinecorrection{\the\dimen0}% - \edef\thenegbotbaselinecorrection{\the\dimen2}} - -\def\dotopbaselinecorrection {\kern\thetopbaselinecorrection} -\def\dobotbaselinecorrection {\kern\thebotbaselinecorrection} -\def\donegtopbaselinecorrection{\kern\thenegtopbaselinecorrection} -\def\donegbotbaselinecorrection{\kern\thenegbotbaselinecorrection} - -\def\showbaselinecorrection - {\def\dobaselinecorrection % visualization is not watertight! - {\bgroup -\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi - \setbox0\null - \wd0\hsize - \dp0\strutdp - \nointerlineskip - \forgetall - \ruledvbox{\box0}% - \egroup - \prevdepth\strutdp}% - \def\dotopbaselinecorrection - {\hrule\!!height\thetopbaselinecorrection}% - \def\dobotbaselinecorrection - {\hrule\!!height\thebotbaselinecorrection}} - -\def\dobaselinecorrection - {\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi - \kern\strutdp - \prevdepth\strutdp} - -% \def\baselinecorrection -% {\endgraf -% \ifvmode -% \ifdim\prevdepth<\maxdimen -% \ifdim\prevdepth<\zeropoint \else -% \ifdim\prevdepth<\strutdp -% \dobaselinecorrection -% \fi -% \fi -% \fi -% \fi} - -\def\baselinecorrection - {\endgraf - \ifvmode - \ifdim\prevdepth<\maxdimen - \ifdim\prevdepth<\zeropoint \else - \ifdim\prevdepth<\strutdepth \relax - \pushlastnode - \dobaselinecorrection - \poplastnode - \fi - \fi - \fi - \fi} - -\def\pagebaselinecorrection - {\ifdim\pagegoal<\maxdimen - \ifdim\pagetotal>\lineheight % or \topskip - \scratchdimen\pagetotal - \advance\scratchdimen\lineheight - \ifdim\scratchdimen<\pagegoal - \baselinecorrection - \fi - \fi - \fi} - -% Beware, keep this one as it is, see for instance module -% m-steps.tex, where we apply a \localhsize to the \vbox, in -% order to follow narrower and side floats ! - -% \def\startbaselinecorrection -% {\baselinecorrection -% \ifvmode -% \bgroup -% \setbox\scratchbox\vbox\bgroup -% \ignorespaces -% \let\stopbaselinecorrection\dostopbaselinecorrection -% \else -% \let\stopbaselinecorrection\relax -% \fi} - -% \def\dostopbaselinecorrection % I have to check columns yet. -% {\endgraf -% \egroup -% \topbaselinecorrection -% \box\scratchbox -% \botbaselinecorrection -% \egroup} - -% \let\stopbaselinecorrection=\relax - -\def\startbaselinecorrection - {\bgroup - \let\stopbaselinecorrection\egroup - \ifcase\baselinecorrectionmode - \or % normal - \baselinecorrection - \ifvmode - \setbox\scratchbox\vbox\bgroup\ignorespaces - \let\stopbaselinecorrection\donormalstopbaselinecorrection - \fi - \or % off - \or % force - \baselinecorrection - \ifvmode - \setbox\scratchbox\vbox\bgroup\ignorespaces - \let\stopbaselinecorrection\doforcedstopbaselinecorrection - \fi - \fi} - -\let\stopbaselinecorrection\relax - -\def\donormalstopbaselinecorrection % I have to check columns yet. - {\egroup - \topbaselinecorrection - \box\scratchbox - \botbaselinecorrection - \egroup} - -\def\doforcedstopbaselinecorrection % I have to check columns yet. - {\egroup - \forcedtopbaselinecorrection - \box\scratchbox - \forcedbotbaselinecorrection - \egroup} - -%D We do a bit more checking than needed. The pageborder check -%D is not needed, but I want to look the visualization as good -%D as possible too. - -% \def\offbaselinecorrection % Can be used inside correction. -% {\def\startbaselinecorrection{\bgroup\let\stopbaselinecorrection\egroup}} - -\chardef\baselinecorrectionmode\plusone - -\def\onbaselinecorrection {\chardef\baselinecorrectionmode\plusone } -\def\offbaselinecorrection {\chardef\baselinecorrectionmode\plustwo } -\def\forcebaselinecorrection{\chardef\baselinecorrectionmode\plusthree} - -%D \macros -%D {topbaselinecorrection,botbaselinecorrection} -%D -%D The actual top and bottom corrections are implemented as: - -% \def\topbaselinecorrection -% {\ifvmode \ifdim\pagegoal<\maxdimen -% \bgroup -% \setbaselinecorrections -% \whitespace -% \nointerlineskip -% \dotopbaselinecorrection -% \egroup -% \fi \fi} - - -\def\topbaselinecorrection - {\ifvmode \ifdim\pagegoal<\maxdimen - \forcedtopbaselinecorrection - \fi \fi} - -\def\forcedtopbaselinecorrection - {\ifvmode - \bgroup - \setbaselinecorrections - \whitespace - \nointerlineskip - \dotopbaselinecorrection - \egroup - \fi} - -\def\botbaselinecorrection - {\ifvmode - \bgroup - \setbaselinecorrections - \dobotbaselinecorrection - \allowbreak % new, otherwise problems when many in a row - \prevdepth\strutdp - \egroup - \fi} - -\let\forcedbotbaselinecorrection\botbaselinecorrection - -%D Still very experimental and therefore undocumented. - -\newif\ifgridsnapping % UNDER DEVELOPMENT, USE WITH CARE -\newif\ifforcepresnap \forcepresnaptrue % false in mixed single/double -\newif\ifstrutsnapping \strutsnappingtrue % sometimes handy to be false - -\def\positiveextrasnap {\gdef\extrasnapsign{+}} -\def\negativeextrasnap {\gdef\extrasnapsign{-}} - -\def\extrasnapreset {\global\chardef\@@extrasnap0 - \positiveextrasnap} -\def\extrasnapbefore {\global\chardef\@@extrasnap1 } -\def\extrasnaparound {\global\chardef\@@extrasnap2 } -\def\extrasnapafter {\global\chardef\@@extrasnap3 } - -\def\enablepresnapcorrection {\global\chardef\@@presnap\zerocount} -\def\disablepresnapcorrection {\global\chardef\@@presnap\plusone} - -\extrasnapreset \enablepresnapcorrection - -\newif\iftracegridsnapping -\newif\ifshowgridboxes -\newif\ifshowfuzzyskips - -\let\showgridboxes\showgridboxestrue - -\def\showgridsnapping - {\tracegridsnappingtrue - \showgridboxestrue} - -\chardef\@@alignsnap =0 -\chardef\@@alignsnapbox =0 -\chardef\@@alignsnapmethod=0 - -\let\presnapskip \!!zeropoint \def\presnap {-} -\let\postsnapskip\!!zeropoint \let\postsnap\presnap - -\newcount\currentgridsnap - -\def\tracedsnapping - {\iftracegridsnapping - \llap - {\setlayoutcomponentattribute\v!grid\v!test - \hbox \layoutcomponentboxattribute - {\infofont - \global\advance\currentgridsnap\plusone - \color[grid:three] - {\vl\presnapskip - \vl\presnap - \vl\postsnap - \ifcase\@@alignsnapbox\relax\vl\ifcase\@@extrasnap00\or\extrasnapsign0\or\extrasnapsign\extrasnapsign\or0\extrasnapsign\fi\fi - \vl\the\currentgridsnap\vl}}}% - \fi} - -\def\snaptogrid% [#1]#2 -> #2 == \hbox|\vbox - {\dosingleempty\dosnaptogrid} - -% \def\dosnaptogrid[#1]% -% {\ifgridsnapping -% \iffirstargument\doifsomething{#1}{\verplaatsopgrid[#1]}\fi -% \expandafter\dodosnaptogrid -% \fi} - -% \def\dosnaptogrid[#1]% -% {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up -% \ifgridsnapping -% \iffirstargument\doifsomething{#1}{\moveongrid[#1]}\fi -% \expandafter\dodosnaptogrid -% \fi} - -\def\dosnaptogrid[#1]% - {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up - \doifinsetelse\v!force{#1}% - {\moveongrid[#1]% - \dodosnaptogrid} - {\ifgridsnapping - \doifsomething{#1}{\moveongrid[#1]}% - \expandafter\dodosnaptogrid - \fi}} - -% \def\forcedpresnapcorrection % test this on 'details' -% {\ifforcepresnap -% \ifvmode \else \par \fi % new -% % we don't want top of page space when 'top' option -% %\verticalstrut\nobreak\vskip-\struttotal -% %\verticalstrut\vskip-\struttotal -% % nobreak really needed -% \allowbreak\verticalstrut\nobreak\vskip-\struttotal -% %\ifdim\pagetotal>\topskip \else -% % eigenlijk signal -% %\writestatus{grid}{removing dummy at top of page}% -% %\bgroup -% %\output{\setbox\scratchbox\box255}% -% %\penalty\outputpenalty -% %\egroup -% %\fi -% \fi} - -\def\forcedpresnapcorrection % test this on 'details' - {\ifforcepresnap - \ifvmode \else \par \fi % new - % we don't want top of page space when 'top' option - % \verticalstrut\nobreak\vskip-\struttotal - % \verticalstrut\vskip-\struttotal - % \nobreak really needed - % \dosomebreak\allowbreak % no: spoils heads, so only under know situation, not in snapper - \verticalstrut - \nobreak - \vskip-\struttotal - %\ifdim\pagetotal>\topskip \else - % eigenlijk signal - %\writestatus{grid}{removing dummy at top of page}% - %\bgroup - %\output{\setbox\scratchbox\box255}% - %\penalty\outputpenalty - %\egroup - %\fi - \fi} - -\def\setgridtracebox#1[#2]% % maybe reverse the order - {\setbox\nextbox#1% - {\hbox - {\hbox to \zeropoint - {\setlayoutcomponentattribute\v!grid\v!test - \color[grid:#2]{\ruledhbox \layoutcomponentboxattribute {\fakebox\nextbox}}% - \hss}% - \flushnextbox}}} - -\newif\ifboxedsnapping \boxedsnappingtrue - -\chardef\depthsnapmethod \plusone % downward compatible, minus one line -\chardef\heightsnapmethod\plusone % downward compatible, minus one line - -\def\dodosnaptogrid - {\dowithnextbox - {\bgroup - \ifcase\@@alignsnapmethod \or - % we're dealing with text with a possible big depth/height - \chardef\depthsnapmethod \plustwo - \chardef\heightsnapmethod\plustwo - \fi - \ifdim\nextboxht<\textheight % handle special case (like page fig) - \ifcase\@@alignsnapbox\relax - \ifcase\@@alignsnap\else % 1=top 2=high 3=middle 4=low - \ifshowgridboxes - \setgridtracebox\hbox[two]% - \fi - %\getnoflines{\nextboxht}% - \getnoflines\nextboxht - \setbox\nextbox\vbox to \noflines\lineheight - {\ifnum\@@alignsnap=1 \kern\lineheight\kern-\topskip\fi - \ifnum\@@alignsnap>2 \vfill\fi - \flushnextbox - \ifnum\@@alignsnap<4 \vfill\fi}% - \fi - \ifshowgridboxes - \setgridtracebox\hbox[three]% - \fi - \forgetall - \par - \ifvbox\nextbox - \setbox\nextbox\hbox{\flushnextbox}% don't ask - \fi - \scratchskip\lastskip - \edef\presnapskip{\the\lastskip}% - % mixing single/double columns sometimes goes wrong, - % check 'som' document - \ifinsidecolumns - \forcepresnaptrue - \fi - \forcedpresnapcorrection - \ifdim\nextboxht>\strutht - \scratchdimen\nextboxht - \ifcase\@@presnap\relax - \ifdim\scratchskip>\zeropoint\relax - \scratchcounter\scratchskip - \advance\scratchcounter -\openlineheight - \ifnum\scratchcounter<0 - \scratchcounter-\scratchcounter - \fi - \ifnum\scratchcounter<10 % \lastkip is about \openlineheight - \advance\scratchdimen -\openstrutdepth - \edef\presnapskip{*\presnapskip}% - \else\ifdim\scratchskip>\openlineheight - %<\openlineheight \else - \advance\scratchdimen -\openstrutdepth - \edef\presnapskip{*\presnapskip}% - \fi\fi - \fi - \fi - % \getnoflines\scratchdimen % maybe raw ? - % \advance\noflines -1 - \ifcase\heightsnapmethod - % raw - \or - \advance\scratchdimen-\lineheight % tight (default) - \or - \advance\scratchdimen-\strutheight % fit (text) - \or - \advance\scratchdimen-\strutheight % tolerant - \advance\scratchdimen-\roundingeps - \fi - \getnoflines\scratchdimen - \ifnum\noflines>0 - \scratchdimen\noflines\lineheight - \else - \scratchdimen\zeropoint - \fi - \else - \scratchdimen\zeropoint - \fi - \ifnum\@@extrasnap=1 \advance\scratchdimen \extrasnapsign \lineheight \fi - \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi - \edef\presnap{\the\scratchdimen}% - \ifstrutsnapping - \ifboxedsnapping - \getrawnoflines\scratchdimen - \advance\scratchdimen-\noflines\lineheight - \vskip\scratchdimen % disappears at top of page - \dorecurse\noflines{\verticalstrut\nobreak}% - \else \ifdim\scratchdimen=\zeropoint - % nothing to skip - \else % disappears at top of page - \vskip\scratchdimen - \fi \fi - \fi - \ifdim\nextboxdp>\strutdp - % \getnoflines\nextboxdp - % \advance\noflines \minusone - \scratchdimen\nextboxdp\relax - \ifcase\depthsnapmethod - % raw - \or - \advance\scratchdimen-\lineheight % tight (default) - \or - \advance\scratchdimen-\strutdepth % fit (text) - \or - \advance\scratchdimen-\strutdepth % tolerant - \advance\scratchdimen-\roundingeps - \fi - \getnoflines\scratchdimen - \ifnum\noflines>0 - \scratchdimen\noflines\lineheight - \else - \scratchdimen\zeropoint - \fi - \else - \scratchdimen\zeropoint - \fi - \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi - \ifnum\@@extrasnap=3 \advance\scratchdimen \extrasnapsign \lineheight \fi - \edef\postsnap{\the\scratchdimen}% - \ifstrutsnapping - \nextboxht\strutht - \nextboxdp\strutdp - \else - \scratchdimen\presnap - \advance\scratchdimen \strutht - \nextboxht\scratchdimen - \scratchdimen\postsnap - \advance\scratchdimen \strutdp - \nextboxdp\scratchdimen - \fi - \hbox{\tracedsnapping\flushnextbox}% - \ifstrutsnapping - \ifdim\scratchdimen=\zeropoint\else\vskip\scratchdimen\fi - \fi - \else - \scratchdimen\nextboxht\relax - \ifcase\@@alignsnapbox - % can't happen here - \or - \getrawnoflines\scratchdimen - \else - \getnoflines \scratchdimen - \fi - \scratchdimen\noflines\lineheight\relax - \advance\scratchdimen-\strutdepth - % spoils the whole game (fit/broad/line) - % \ifnum\pagetotal>\zeropoint \else % disable this as option - % \advance\scratchdimen-\strutheight - % \advance\scratchdimen+\topskip - % \fi - \dimen0=\scratchdimen - \dimen2=\strutdepth - \ifshowgridboxes - \setgridtracebox\hbox[two]% - \fi - \nextboxdp\strutdp - \dimen4=\nextboxht - \dimen6=\nextboxdp - \iftracegridsnapping - \setbox\scratchbox\hbox - {\scratchdimen\@@alignsnapamount\relax - \ifdim\scratchdimen<\zeropoint - \tracedgridamount\zeropoint{-\scratchdimen}% - \else - \tracedgridamount\scratchdimen\zeropoint - \fi}% - \smashbox\scratchbox - \setbox\nextbox\hbox{\box\scratchbox\flushnextbox}% - \fi - \setbox\nextbox\hbox - {\scratchdimen\@@alignsnapamount\relax - \ifcase\@@alignsnapdepth\or - % don't change this ever ! - \ifdim\dimen0<\lineheight - % otherwise it is ok, but ending up inside - % the next paragraph is seldom what we want, - % so we move one line up - \advance\scratchdimen-\lineheight - \advance\scratchdimen\strutheight - \else - % otherwise we can move down to the - % baseline - \advance\scratchdimen\dimen6 % == \strutdepth - \fi - \fi - \lower\scratchdimen\flushnextbox}% - \nextboxht\dimen4 - \nextboxdp\dimen6 - \ifnum\@@alignsnap<4 % 4 = regel - \setbox\nextbox\vbox to \scratchdimen - {\forgetall - \ifnum\@@alignsnap>2 \vfill\fi % 3 4 - \flushnextbox - \nointerlineskip % \offinterlineskip - \ifnum\@@alignsnap<4 \vfill\fi % 2 3 - \kern\zeropoint}% - \fi - \ifshowgridboxes - \setgridtracebox\vbox[three]% - \fi - \scratchdimen\@@alignsnapamount - \edef\presnapskip{\the\scratchdimen}% - \ifnum\@@alignsnap>2 \def\presnap {+}\fi - \ifnum\@@alignsnap<4 \def\postsnap{+}\fi - \setbox\nextbox\hbox{\tracedsnapping\flushnextbox}% - \par - \nextboxht\dimen0 - \nextboxdp\dimen2 - \forcedpresnapcorrection - \nointerlineskip - \flushnextbox - \fi - \else - \setbox\nextbox\vbox to \textheight - {\ifdim\nextboxdp=\zeropoint - \hbox{\lower\strutdepth\flushnextbox} - \else % this branch is yet untested - \vss - \hbox{\lower\nextboxdp\flushnextbox} - \vskip-\strutdepth - \fi}% - \nextboxdp\strutdepth - \flushnextbox - \fi - \extrasnapreset - \enablepresnapcorrection - \global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount - \egroup}} - -\def\tracedgridamount#1#2% - {\startcolor[grid:four]% - \setlayoutcomponentattribute\v!grid\v!test - \hbox \layoutcomponentboxattribute{\vrule\!!width\nextboxwd\!!height#1\!!depth#2}% - \stopcolor} - -\def\snaptomathgrid % probably not working ok, also kind of obsolete - {\ifgridsnapping - \dowithnextbox - {\blank[\v!line]\snaptogrid\vbox{\flushnextbox}\blank[\v!line]} - \vbox\bgroup - \forgetdisplayskips - \@EA\let\@EA\next - \fi} - -\def\topsnaptogrid - {\ifgridsnapping - \dowithnextbox - {\scratchdimen\nextboxht - \advance\scratchdimen -\strutht - \advance\scratchdimen \topskip - \nextboxht\scratchdimen - \nextboxdp\zeropoint - \flushnextbox - \kern\lineheight - \kern-\topskip - \nointerlineskip} - \hbox - \fi} - -% \def\centertogrid % meant for special situations -% {\ifgridsnapping -% \dowithnextboxcontent -% {\ignorespaces} -% {\bgroup -% \par -% \scratchdimen\nextboxht -% \advance\scratchdimen \nextboxdp -% \getnoflines\scratchdimen -% \setbox\nextbox\vbox to \noflines\lineheight -% {\forgetall -% \vskip\zeropoint \!!plus \nextboxht -% \copy\nextbox -% \kern.5\strutdp % VOORLOPIGE WAARDE -% \vskip\zeropoint \!!plus \nextboxdp}% -% \noindent\snaptogrid\vbox{\flushnextbox}% -% \egroup} -% \vbox % was \hbox -% \fi} - -% The next implementation is sub-optimal -% -% \def\centertogrid % usage: see ie pascal / stepcharts -% {\snaptogrid[\v!midden,.5\strutdp]\vbox} - -\def\centertogrid % meant for special situations - {\ifgridsnapping - \dowithnextboxcontent - {\ignorespaces} - {\bgroup - \par - \scratchdimen\nextboxht - \advance\scratchdimen \nextboxdp - \getnoflines\scratchdimen - \setbox\nextbox\vbox to \noflines\lineheight - {\forgetall - \vss - \topbaselinecorrection - \copy\nextbox - \botbaselinecorrection - \vss}% - \setbox\nextbox\hbox{\lower\strutdp\flushnextbox}% - \forgeteverypar % new per 3/4/2008, prevents duplicate pos nodes resulting in extra whitespace - \noindent\snaptogrid\vbox{\flushnextbox}% - \egroup} - \vbox % was \hbox - \fi} - -% testbed for \centertogrid -% -% \strut Bruggetje -% \startlinecorrection -% \startcombination -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination[2*2] -% {\framed{test}} {} {\framed{test}} {} -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination[2*2] -% {\framed{test}} {} {\framed{test}} {} -% {\framed{test}} {} {\framed{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection -% \startcombination[2*2] -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection -% \strut Bruggetje -% \startlinecorrection[blank] -% \startcombination[2*2] -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} -% \stopcombination -% \stoplinecorrection - -\ifx\startbaselinecorrection\undefined \wait \fi % change order - -\let\normalstartbaselinecorrection=\startbaselinecorrection - -\def\startbaselinecorrection - {\ifgridsnapping - \centertogrid\bgroup - \let\stopbaselinecorrection\egroup - \else - \normalstartbaselinecorrection - \fi} - -\chardef\gridboxlinenomode\plusone -\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame - -\def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi} -\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth} - -\def\setgridbox#1#2#3% - {\setbox#1\gridboxvbox to #3 % given size - {\forgetall - \resetteststrut - \offinterlineskip - \hsize#2% - \baselinerulefalse - \gridboxvbox % calculated size - {\getrawnoflines{#3}% \getnoflines{#3}% - \vskip\topskip - \vskip-\strutht - \scratchdimen#2\advance\scratchdimen \lineheight - \dorecurse\noflines - {\strut - \hskip-.5\lineheight - \ifcase\gridboxlinenomode\or - \rlap - {\hskip.2\bodyfontsize\hskip\scratchdimen - \infofont\hbox to 1em{\hss\recurselevel}}% - \or - \llap - {\infofont\hbox to 1em{\hss\recurselevel}% - \hskip.2\bodyfontsize}% - \fi - \vrule - \!!height \gridboxwidth - \!!depth \gridboxwidth - \!!width \scratchdimen - \par}} - \vfill}} - -%D Some intervention macros: - -\def\gridwarning#1{\message{[beware of #1 extra snap]}} - -\global\let\@@alignsnapamount\!!zeropoint -\global\chardef\@@alignsnapdepth0 - -\def\@@unknowngriddisplacement - {\global\chardef\@@alignsnapbox\plusthree - \global\let\@@alignsnapamount\commalistelement} - -\def\domoveongrid[#1]% - {\ifgridsnapping\doifsomething{#1}{\dodomoveongrid[#1]}\fi} - -\def\dodomoveongrid[#1]% some day : speed up - {\global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount - \global\chardef\@@alignsnapdepth\zerocount - \global\chardef\@@alignsnapmethod\zerocount - \global\let\@@alignsnapamount\!!zeropoint - \donefalse - \expanded{\processallactionsinset[#1]} - [\v!standard=>, - \v!normal=>, % to be sure - \v!yes=>, % to be sure - \v!top=>\gridwarning+\positiveextrasnap\extrasnapbefore, - \v!bottom=>\gridwarning+\positiveextrasnap\extrasnapafter, - \v!both=>\positiveextrasnap\extrasnaparound, - -\v!top=>\gridwarning-\negativeextrasnap\extrasnapbefore, - -\v!bottom=>\gridwarning-\negativeextrasnap\extrasnapafter, - -\v!both=>\negativeextrasnap\extrasnaparound, - \v!text=>\global\chardef\@@alignsnapmethod\plusone, % accurate calculations - \v!page=>\global\chardef\@@alignsnap\plusone, % topskip - \v!high=>\global\chardef\@@alignsnap\plustwo, - \v!middle=>\global\chardef\@@alignsnap\plusthree, - \v!low=>\global\chardef\@@alignsnap\plusfour, - \v!fit=>\global\chardef\@@alignsnapbox\plusone, % new - \v!broad=>\global\chardef\@@alignsnapbox\plustwo, % new - \v!depth=>\global\chardef\@@alignsnapdepth\plusone, % new - \v!line=>\global\chardef\@@alignsnapbox\plusthree -% \global\chardef\@@alignsnapdepth\plusone - \global\chardef\@@alignsnap\plusfour, - \v!reset=>\positiveextrasnap\extrasnapreset, - \v!none=>\global\chardef\@@alignsnap\zerocount - \global\chardef\@@alignsnapbox\zerocount, - \v!force=>, % turns on grid snapping even when not on - \s!default=>, - \s!unknown=>\@@unknowngriddisplacement]} - -\def\moveongrid - {\dosingleempty\domoveongrid} - -\def\doplaceongrid[#1]% - {\domoveongrid[#1]\snaptogrid\vbox} - -\def\placeongrid - {\dosingleempty\doplaceongrid} - -%D Snapping is rather robust as long as we use whole lines. -%D Half lines of white space can however be handled when they -%D come in pairs. The corrections needed when crossing page -%D boundaries in the middle of such a pair, are handled by -%D macros that are (named) sort of fuzzy. This fuzzy mechanism -%D was written as an extension to the grid typesetting needed -%D for typesetting (part of) the \MAPS. -%D -%D \starttyping -%D \setuptyping -%D [before={\blank[halfline]}, -%D after={\blank[halfline]}] -%D \stoptyping - -\newif \iffuzzyvskip -\newif \iffuzzysnapdone -\newif \iffuzzysnapping -\newif \iffuzzysnapped -\chardef \fuzzysnappedleft=0 % ==1 when fuzzybegin still open -\newpersistentmark\fuzzymark % (!) -\newcount \fuzzymarker -\newbox \fuzzysnapbox -\newbox \fuzzysnapsplit - -\def\dosyncfuzzyvskip - {\ifvmode\ifdim\lastskip<\lineheight\ifdim\lastskip>\zeropoint - \bgroup % - added 28/2/2003: check this, there was no - - \endgraf\forgetall\verticalstrut\nobreak\vskip-\struttotal - \egroup - \fi\fi\fi} - -\def\fuzzyvskip#1% - {\iffuzzysnapdone - \dosyncfuzzyvskip % NEWER - \endfuzzysnapping - \vskip#1\relax - \global\fuzzysnapdonefalse - \else - \vskip#1\relax - \beginfuzzysnapping - \global\fuzzysnapdonetrue - \fi} - -\def\setfuzzymark#1#2#3% #1/#2 => error recovery - {\ifgridsnapping - \global\fuzzysnappingtrue - \global\advance\fuzzymarker \ifodd\fuzzymarker#1\else#2\fi - \nobreak - \ifshowfuzzyskips - \hbox{\color[grid:three] - {\llap{\infofont#3\vl\the\fuzzymarker}\nobreak - \vrule\!!width\hsize\!!height.1\lineheight}} - \nobreak - \fi - %[\the\fuzzymarker] - %\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% - \expandafter\rawsetmark\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% - \nobreak - \fi} - -\def\beginfuzzysnapping{\setfuzzymark21\v!start} % odd -\def\endfuzzysnapping {\setfuzzymark12\v!stop } % even - -\def\removelastfuzzyvskip - {\ifgridsnapping - \iffuzzysnapping - \ifdim\lastskip<\openlineheight - \else - \removelastskip - \fi - \else - \removelastskip - \fi - \else - \removelastskip - \fi} - -\def\docheckfuzzysnap#1% - {\bgroup - \dontcomplain - \setbox\fuzzysnapbox\copy#1\relax - \setbox\fuzzysnapsplit\vsplit\fuzzysnapbox to 1\lineheight - \let\topfuzzymark\empty % indeed here ... no real mark - \getsplitmarks\fuzzymark -% \ifcase0\topfuzzymark - \ifcase0\rawgetsplittopmark\fuzzymark - \global\chardef\fuzzysnappedleft\zerocount - \global\fuzzysnappedfalse -% \else\ifodd\topfuzzymark - \else\ifodd\rawgetsplittopmark\fuzzymark - \global\chardef\fuzzysnappedleft\plusone - \global\fuzzysnappedtrue - \else - \global\chardef\fuzzysnappedleft=2 - \global\fuzzysnappedtrue - \fi\fi - \iffuzzysnapped \else - \doloop - {\ifvoid\fuzzysnapbox - \exitloop - \else - \setbox\fuzzysnapsplit=\vsplit\fuzzysnapbox to \lineheight - %\let\topfuzzymark=\empty % ... but not here - \getsplitmarks\fuzzymark -% \ifcase0\topfuzzymark - \ifcase0\rawgetsplittopmark\fuzzymark - % continue -% \else\ifodd\topfuzzymark - \else\ifodd\rawgetsplittopmark\fuzzymark - \exitloop - \else - \global\chardef\fuzzysnappedleft\plusone - \global\fuzzysnappedtrue - \exitloop - \fi\fi - \fi}% - \fi - \egroup} - -\def\getfuzzysnapcorrection#1% - {\global\let\presnapcorrection \relax - \global\let\postsnapcorrection\relax - \ifgridsnapping\iffuzzysnapping - \docheckfuzzysnap{#1}% - \iffuzzysnapped - \iftracegridsnapping - \gdef\presnapcorrection - {\color[grid:four]{\hrule\!!height.5\openlineheight\!!width\hsize}}% - \else - \gdef\presnapcorrection{\kern.5\openlineheight}% - \fi - \gdef\postsnapcorrection{\kern-.5\openlineheight}% get the height ok - \fi - \fi\fi} - -\def\fuzzysnappedbox#1#2% \box \unvbox - {\getfuzzysnapcorrection{#2}% - \presnapcorrection - #1#2% - \postsnapcorrection} - -\def\adaptfuzzypagegoal - {\ifgridsnapping\iffuzzysnapping\ifcase\fuzzysnappedleft\or % see dopagecontents - \scratchdimen\pagegoal - \advance\scratchdimen -.5\openlineheight - \global\pagegoal\scratchdimen - \global\advance\vsize -.5\openlineheight - \global\chardef\fuzzysnappedleft0 - \fi\fi\fi} - -%D New, experimental, used in caption snapping: -%D -%D \starttyping -%D \startcolumnset -%D -%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=top] -%D -%D \placefigure [lrtb] {\dorecurse{5}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D \placefigure [lrtb] {\dorecurse{15}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D -%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=bottom] -%D -%D \placefigure [rltb] {\dorecurse{5}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D \placefigure [rltb] {\dorecurse{15}{green gras}} -%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} -%D -%D \input thuan -%D -%D \stopcolumnset -%D \stoptyping - -\def\moveboxontogrid#1#2#3% box method firstlineht % experimental ! ! ! - {\doifsomething{#2} - {\getnoflines{\ht#1}% no depth taken into account, depth preserved - \scratchdimen\noflines\lineheight - \advance\scratchdimen-\strutdp - \bgroup - \advance\scratchdimen-\onepoint % be a bit tolerant - \ifdim\scratchdimen>\ht#1\relax - \egroup - \doif{#2}\v!top {\setbox#1\vbox to \scratchdimen{\vskip-#3\vskip\strutht\box#1\vfill}}% - \doif{#2}\v!bottom{\setbox#1\vbox to \scratchdimen{\vfill\box#1\removedepth}}% - \dp#1\strutdp - \else - \egroup - \ht#1\scratchdimen - \dp#1\strutdp - \fi}} - -%D New: - -\let\checkgridsnapping\relax - -\protect \endinput diff --git a/tex/context/base/core-spa.lua b/tex/context/base/core-spa.lua deleted file mode 100644 index e32e968e1..000000000 --- a/tex/context/base/core-spa.lua +++ /dev/null @@ -1,720 +0,0 @@ -if not modules then modules = { } end modules ['core-spa'] = { - version = 1.001, - comment = "companion to core-spa.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - --- this code dates from the beginning and is kind of experimental; it --- will be optimized and improved soon - -local next, type = next, type -local format, gmatch, concat = string.format, string.gmatch, table.concat -local texsprint, texlists = tex.sprint, tex.lists - -local ctxcatcodes = tex.ctxcatcodes - --- vertical space handler - -local trace_vbox_vspacing = false trackers.register("nodes.vbox_vspacing", function(v) trace_vbox_vspacing = v end) -local trace_page_vspacing = false trackers.register("nodes.page_vspacing", function(v) trace_page_vspacing = v end) -local trace_collect_vspacing = false trackers.register("nodes.collect_vspacing", function(v) trace_collect_vspacing = v end) -local trace_vspacing = false trackers.register("nodes.vspacing", function(v) trace_vspacing = v end) - -local skip_category = attributes.private('skip-category') -local skip_penalty = attributes.private('skip-penalty') -local skip_order = attributes.private('skip-order') -local snap_category = attributes.private('snap-category') -local display_math = attributes.private('display-math') - -local has_attribute = node.has_attribute -local unset_attribute = node.unset_attribute -local set_attribute = node.set_attribute -local find_node_tail = node.tail -local free_node = node.free -local copy_node = node.copy -local traverse_nodes = node.traverse -local insert_node_before = node.insert_before -local insert_node_after = node.insert_after -local remove_node = nodes.remove -local make_penalty_node = nodes.penalty -local count_nodes = nodes.count -local node_ids_to_string = nodes.ids_to_string -local hpack_node = node.hpack - -local glyph = node.id("glyph") -local penalty = node.id("penalty") -local kern = node.id("kern") -local glue = node.id('glue') -local hlist = node.id('hlist') -local vlist = node.id('vlist') -local adjust = node.id('adjust') - -vspacing = vspacing or { } - -vspacing.categories = { - [0] = 'discard', - [1] = 'largest', - [2] = 'force' , - [3] = 'penalty', - [4] = 'add' , - [5] = 'disable', - [6] = 'nowhite', - [7] = 'goback', -} - -local categories = vspacing.categories - -function vspacing.tocategories(str) - local t = { } - for s in gmatch(str,"[^, ]") do - local n = tonumber(s) - if n then - t[categories[n]] = true - else - t[b] = true - end - end - return t -end - -function vspacing.tocategory(str) - if type(str) == "string" then - return set.tonumber(vspacing.tocategories(str)) - else - return set.tonumber({ [categories[str]] = true }) - end -end - -vspacing.data = vspacing.data or { } -vspacing.data.map = vspacing.data.map or { } -vspacing.data.skip = vspacing.data.skip or { } - -storage.register("vspacing/data/map", vspacing.data.map, "vspacing.data.map") -storage.register("vspacing/data/skip", vspacing.data.skip, "vspacing.data.skip") - -do -- todo: interface.variables - - local function logger(c,s) - logs.report("vspacing",s) - texsprint(c,s) - end - - vspacing.fixed = false - - local map = vspacing.data.map - local skip = vspacing.data.skip - - local multiplier = lpeg.C(lpeg.S("+-")^0 * lpeg.R("09")^1) * lpeg.P("*") - local category = lpeg.P(":") * lpeg.C(lpeg.P(1)^1) - local keyword = lpeg.C((1-category)^1) - local splitter = (multiplier + lpeg.Cc(1)) * keyword * (category + lpeg.Cc(false)) - - local function analyse(str,oldcategory,texsprint) - for s in gmatch(str,"([^ ,]+)") do - local amount, keyword, detail = splitter:match(s) - if keyword then - local mk = map[keyword] - if mk then - category = analyse(mk,category,texsprint) - elseif keyword == "fixed" then - texsprint(ctxcatcodes,"\\fixedblankskip") - elseif keyword == "flexible" then - texsprint(ctxcatcodes,"\\flexibleblankskip") - elseif keyword == "category" then - local category = tonumber(detail) - if category then - texsprint(ctxcatcodes,format("\\setblankcategory{%s}",category)) - if category ~= oldcategory then - texsprint(ctxcatcodes,"\\flushblankhandling") - oldcategory = category - end - end - elseif keyword == "order" and detail then - local order = tonumber(detail) - if order then - texsprint(ctxcatcodes,format("\\setblankorder{%s}",order)) - end - elseif keyword == "penalty" and detail then - local penalty = tonumber(detail) - if penalty then - texsprint(ctxcatcodes,format("\\setblankpenalty{%s}",penalty)) - texsprint(ctxcatcodes,"\\flushblankhandling") - end - else - amount = tonumber(amount) or 1 - local sk = skip[keyword] - if sk then - texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,sk[1],sk[2] or sk[1])) - else -- no check - texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,keyword,keyword)) - end - end - else - logs.report("vspacing","unknown directive: %s",s) - end - end - return category - end - - function vspacing.analyse(str) - local texsprint = (trace_vspacing and logger) or texsprint - texsprint(ctxcatcodes,"\\startblankhandling") - analyse(str,1,texsprint) - texsprint(ctxcatcodes,"\\stopblankhandling") - end - - -- - - function vspacing.setmap(from,to) - map[from] = to - end - - function vspacing.setskip(key,value,grid) - if value ~= "" then - if grid == "" then grid = value end - skip[key] = { value, grid } - end - end - -end - --- implementation - -nodes.snapvalues = { } - -function nodes.setsnapvalue(n,ht,dp) - nodes.snapvalues[n] = { ht, dp, ht+dp } -end - -local trace_list, tracing_info, before, after = { }, false, "", "" - -local function glue_to_string(glue) - local spec = glue.spec - if spec then - local t = { } - t[#t+1] = aux.strip_zeros(number.topoints(spec.width)) - if spec.stretch_order and spec.stretch_order ~= 0 then - t[#t+1] = format("plus -%sfi%s",spec.stretch/65536,string.rep("l",math.abs(spec.stretch_order)-1)) - elseif spec.stretch and spec.stretch ~= 0 then - t[#t+1] = format("plus %s",aux.strip_zeros(number.topoints(spec.stretch))) - end - if spec.shrink_order and spec.shrink_order ~= 0 then - t[#t+1] = format("minus -%sfi%s",spec.shrink/65536,string.rep("l",math.abs(spec.shrink_order)-1)) - elseif spec.shrink and spec.shrink ~= 0 then - t[#t+1] = format("minus %s",aux.strip_zeros(number.topoints(spec.shrink))) - end - return concat(t," ") - else - return "[0pt]" - end -end - -local function nodes_to_string(head) - local current, t = head, { } - while current do - local id = current.id - local ty = node.type(id) - if id == penalty then - t[#t+1] = format("%s:%s",ty,current.penalty) - elseif id == glue then - if current.spec then - t[#t+1] = format("%s:%s",ty,aux.strip_zeros(number.topoints(current.spec.width))) - else - t[#t+1] = format("%s:[0pt]",ty) - end - elseif id == kern then - t[#t+1] = format("%s:%s",ty,aux.strip_zeros(number.topoints(current.kern))) - else - t[#t+1] = ty - end - current = current.next - end - return concat(t," + ") -end - -local function reset_tracing(head) - trace_list, tracing_info, before, after = { }, false, nodes_to_string(head), "" -end - -local function trace_skip(str,sc,so,sp,data) - trace_list[#trace_list+1] = { "skip", format("%s | %s | category %s | order %s | penalty %s", str, glue_to_string(data), sc or "-", so or "-", sp or "-") } - tracing_info = true -end - -local function trace_natural(str,data) - trace_list[#trace_list+1] = { "skip", format("%s | %s", str, glue_to_string(data)) } - tracing_info = true -end - -local function trace_info(message, where, what) - trace_list[#trace_list+1] = { "info", format("%s: %s/%s",message,where,what) } -end - -local function trace_node(what) - local nt = node.type(what.id) - local tl = trace_list[#trace_list] - if tl[1] == "node" then - trace_list[#trace_list] = { "node", tl[2] .. " + " .. nt } - else - trace_list[#trace_list+1] = { "node", nt } - end -end - -local function trace_done(str,data) - if data.id == penalty then - trace_list[#trace_list+1] = { "penalty", format("%s | %s", str, data.penalty) } - else - trace_list[#trace_list+1] = { "glue", format("%s | %s", str, glue_to_string(data)) } - end - tracing_info = true -end - -local function show_tracing(head) - if tracing_info then - after = nodes_to_string(head) - for i=1,#trace_list do - local tag, text = unpack(trace_list[i]) - if tag == "info" then - logs.report("collapse",text) - else - logs.report("collapse"," %s: %s",tag,text) - end - end - logs.report("collapse","before: %s",before) - logs.report("collapse","after : %s",after) - end -end - --- alignment box begin_of_par vmode_par hmode_par insert penalty before_display after_display - -local user_skip = 0 -local line_skip = 1 -local baseline_skip = 2 -local par_skip = 3 -local above_display_skip = 4 -local below_display_skip = 5 -local above_display_short_skip = 6 -local below_display_short_skip = 7 -local left_skip_code = 8 -local right_skip_code = 9 -local top_skip_code = 10 -local split_top_skip_code = 11 -local tab_skip_code = 12 -local space_skip_code = 13 -local xspace_skip_code = 14 -local par_fill_skip_code = 15 -local thin_mu_skip_code = 16 -local med_mu_skip_code = 17 -local thick_mu_skip_code = 18 - -local skips = { - [ 0] = "user_skip", - [ 1] = "line_skip", - [ 2] = "baseline_skip", - [ 3] = "par_skip", - [ 4] = "above_display_skip", - [ 5] = "below_display_skip", - [ 6] = "above_display_short_skip", - [ 7] = "below_display_short_skip", - [ 8] = "left_skip_code", - [ 9] = "right_skip_code", - [10] = "top_skip_code", - [11] = "split_top_skip_code", - [12] = "tab_skip_code", - [13] = "space_skip_code", - [14] = "xspace_skip_code", - [15] = "par_fill_skip_code", - [16] = "thin_mu_skip_code", - [17] = "med_mu_skip_code", - [18] = "thick_mu_skip_code", -} - -local free_glue_node = free_node -local free_glue_spec = free_node -local discard, largest, force, penalty, add, disable, nowhite, goback = 0, 1, 2, 3, 4, 5, 6, 7 - -local function collapser(head,where,what,trace) -- maybe also pass tail - if trace then - reset_tracing(head) - trace_info("start analyzing",where,what) - end - local current = head - local glue_order, glue_data = 0, nil - local penalty_order, penalty_data, natural_penalty = 0, nil, nil - local parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false - while current do - local id = current.id - if id == glue and current.subtype == 0 then -- todo, other subtypes, like math - local sc = has_attribute(current,skip_category) -- has no default, no unset (yet) - local so = has_attribute(current,skip_order ) or 1 -- has 1 default, no unset (yet) - local sp = has_attribute(current,skip_penalty ) -- has no degault, no unset (yet) - if not sc then - if glue_data then - if trace then trace_done("flush",glue_data) end - head, current = nodes.before(head,current,glue_data) - if trace then trace_natural("natural",current) end - else - -- not look back across head - local previous = current.prev - if previous and previous.id == glue and previous.subtype == 0 then - local ps = previous.spec - if ps then - local cs = current.spec - if cs and ps.stretch_order == 0 and ps.shrink_order == 0 and cs.stretch_order == 0 and cs.shrink_order == 0 then - local pw, pp, pm = ps.width, ps.stretch, ps.shrink - local cw, cp, cm = cs.width, cs.stretch, cs.shrink - ps.width, ps.stretch, ps.shrink = pw + cw, pp + cp, pm + cm - if trace then trace_natural("removed",current) end - head, current = remove_node(head, current, true) - current = previous - if trace then trace_natural("collapsed",current) end - else - if trace then trace_natural("filler",current) end - end - else - if trace then trace_natural("natural (no prev spec)",current) end - end - else - if trace then trace_natural("natural (no prev)",current) end - end - end - glue_order, glue_data = 0, nil - if current then - current = current.next - end - else - if sc == disable then - ignore_following = true - if trace then trace_skip("disable",sc,so,sp,current) end - head, current = remove_node(head, current, true) - elseif sc == nowhite then - ignore_whitespace = true - head, current = remove_node(head, current, true) - elseif sc == discard then - if trace then trace_skip("discard",sc,so,sp,current) end - head, current = remove_node(head, current, true) - else - if sp then - if not penalty_data then - penalty_data = sp - elseif penalty_order < so then - penalty_order, penalty_data = so, sp - elseif penalty_order == so and sp > penalty_data then - penalty_data = sp - end - end - if ignore_following then - if trace then trace_skip("disabled",sc,so,sp,current) end - head, current = remove_node(head, current, true) - elseif not glue_data then - if trace then trace_skip("assign",sc,so,sp,current) end - glue_order = so - head, current, glue_data = remove_node(head, current) - elseif glue_order < so then - if trace then trace_skip("force",sc,so,sp,current) end - glue_order = so - free_glue_node(glue_data) - head, current, glue_data = remove_node(head, current) - elseif glue_order == so then - -- is now exclusive, maybe support goback as combi, else why a set - if sc == largest then - local cs, gs = current.spec, glue_data.spec - local cw = (cs and cs.width) or 0 - local gw = (gs and gs.width) or 0 - if cw > gw then - if trace then trace_skip('largest',sc,so,sp,current) end - free_glue_node(glue_data) -- also free spec - head, current, glue_data = remove_node(head, current) - else - if trace then trace_skip('remove smallest',sc,so,sp,current) end - head, current = remove_node(head, current, true) - end - elseif sc == goback then - if trace then trace_skip('goback',sc,so,sp,current) end - free_glue_node(glue_data) -- also free spec - head, current, glue_data = remove_node(head, current) - elseif sc == force then - -- todo: inject kern - if trace then trace_skip('force',sc,so,sp,current) end - free_glue_node(glue_data) -- also free spec - head, current, glue_data = remove_node(head, current) - elseif sc == penalty then - if trace then trace_skip('penalty',sc,so,sp,current) end - free_glue_node(glue_data) -- also free spec - glue_data = nil - head, current = remove_node(head, current, true) - elseif sc == add then - if trace then trace_skip('add',sc,so,sp,current) end - local old, new = glue_data.spec, current.spec - old.width = old.width + new.width - old.stretch = old.stretch + new.stretch - old.shrink = old.shrink + new.shrink - -- toto: order - head, current = remove_node(head, current, true) - else - if trace then trace_skip("unknown",sc,so,sp,current) end - head, current = remove_node(head, current, true) - end - else - if trace then trace_skip("unknown",sc,so,sp,current) end - head, current = remove_node(head, current, true) - end - end - end - elseif id == penalty then - --~ natural_penalty = current.penalty - --~ if trace then trace_done("removed penalty",current) end - --~ head, current = remove_node(head, current, true) - current = current.next - elseif id == glue and current.subtype == 2 then - local sn = has_attribute(current,snap_category) - if sn then - -- local sv = nodes.snapvalues[sn] - -- if sv then - if trace then trace_natural("removed baselineskip",current) end - head, current = remove_node(head, current, true) - -- else - -- current = current.next - -- end - else - if trace then trace_natural("keep baselineskip",current) end - current = current.next - end - elseif id == glue and current.subtype == 3 then - -- parskip always comes later - if ignore_whitespace then - if trace then trace_natural("ignored parskip",current) end - head, current = remove_node(head,current,true) - elseif glue_data then - local ps, gs = current.spec, glue_data.spec - if ps and gs and ps.width > gs.width then - -- free_glue_spec(glue_data.spec) -- result in double free - glue_data.spec = copy_node(ps) - if trace then trace_natural("taking parskip",current) end - else - if trace then trace_natural("removed parskip",current) end - end - head, current = remove_node(head, current,true) - else - if trace then trace_natural("honored parskip",current) end - head, current, glue_data = remove_node(head, current) - end - --~ if trace then trace_natural("removed parskip",current) end - --~ current.spec = nil - --~ current = current.next - else --- reversed - if penalty_data then - local p = make_penalty_node(penalty_data) - if trace then trace_done("flushed",p) end - head, current = insert_node_before(head,current,p) - penalty_data = nil - end - if glue_data then - if trace then trace_done("flushed",glue_data) end - head, current = insert_node_before(head,current,glue_data) - glue_order, glue_data = 0, nil - end - if trace then trace_node(current) end - if id == hlist and where == 'hmode_par' then - local list = current.list - if list then - local sn = has_attribute(list,snap_category) - if sn then - local sv = nodes.snapvalues[sn] - if sv then - local height, depth, lineheight = sv[1], sv[2], sv[3] - -- is math.ceil really needed? - current.height = math.ceil((current.height-height)/lineheight)*lineheight + height - current.depth = math.ceil((current.depth -depth )/lineheight)*lineheight + depth - end - end - end - end - current = current.next - end - end - if trace then trace_info("stop analyzing",where,what) end - --~ if natural_penalty and (not penalty_data or natural_penalty > penalty_data) then - --~ penalty_data = natural_penalty - --~ end - if trace and (glue_data or penalty_data) then - trace_info("start flushing",where,what) - end - local tail - if penalty_data then - tail = find_node_tail(head) - local p = make_penalty_node(penalty_data) - if trace then trace_done("result",p) end - head, tail = insert_node_after(head,tail,p) - end - if glue_data then - if not tail then tail = find_node_tail(head) end - if trace then trace_done("result",glue_data) end - head, tail = insert_node_after(head,tail,glue_data) - end - if trace then - if glue_data or penalty_data then - trace_info("stop flushing",where,what) - end - show_tracing(head) - end - return head, true -end - --- alignment after_output end box new_graf vmode_par hmode_par insert penalty before_display after_display --- \par -> vmode_par --- --- status.best_page_break --- tex.lists.best_page_break --- tex.lists.best_size (natural size to best_page_break) --- tex.lists.least_page_cost (badness of best_page_break) --- tex.lists.page_head --- tex.lists.contrib_head - -local stackhead, stacktail, stackhack = nil, nil, false - -local function report(message,lst) - logs.report("vspacing",message,count_nodes(lst,true),node_ids_to_string(lst)) -end - -function nodes.handle_page_spacing(where) - local newhead = texlists.contrib_head - if newhead then - statistics.starttiming(vspacing) - local newtail = find_node_tail(newhead) - local flush = false - for n in traverse_nodes(newhead) do -- we could just look for glue nodes - local id = n.id - if id == glue then - if n.subtype == 0 then - if has_attribute(n,skip_category) then - stackhack = true - else - flush = true - end - else - -- tricky - end - else - flush = true - end - end - if flush then - if stackhead then - if trace_collect_vspacing then report("appending %s nodes to stack (final): %s",newhead) end - stacktail.next = newhead - newhead.prev = stacktail - newhead = stackhead - stackhead, stacktail = nil, nil - end - if stackhack then - stackhack = false - if trace_collect_vspacing then report("processing %s nodes: %s",newhead) end - texlists.contrib_head = collapser(newhead,"page",where,trace_page_vspacing) - else - if trace_collect_vspacing then report("flushing %s nodes: %s",newhead) end - texlists.contrib_head = newhead - end - else - if stackhead then - if trace_collect_vspacing then report("appending %s nodes to stack (intermediate): %s",newhead) end - stacktail.next = newhead - newhead.prev = stacktail - else - if trace_collect_vspacing then report("storing %s nodes in stack (initial): %s",newhead) end - stackhead = newhead - end - stacktail = newtail - texlists.contrib_head = nil - end - statistics.stoptiming(vspacing) - end -end - -local ignore = table.tohash { - "split_keep", - "split_off", - -- "vbox", -} - -function nodes.handle_vbox_spacing(head,where) - if head and not ignore[where] and head.next then - statistics.starttiming(vspacing) - head = collapser(head,"vbox",where,trace_vbox_vspacing) - statistics.stoptiming(vspacing) - end - return head -end - -statistics.register("v-node processing time", function() - if statistics.elapsedindeed(vspacing) then - return format("%s seconds", statistics.elapsedtime(vspacing)) - end -end) - --- these are experimental callback definitions that definitely will --- be moved elsewhere as part of a chain of vnode handling - -function vspacing.enable() ---~ callback.register('vpack_filter', nodes.handle_vbox_spacing) - callback.register('buildpage_filter', nodes.handle_page_spacing) -end - -function vspacing.disable() - callback.register('vpack_filter', nil) - callback.register('buildpage_filter', nil) -end - --- we will split this module hence the locals - -local attribute = attributes.private('graphicvadjust') - -local hlist = node.id('hlist') -local vlist = node.id('vlist') - -local remove_node = nodes.remove -local hpack_node = node.hpack -local has_attribute = node.has_attribute - -function nodes.repackage_graphicvadjust(head,groupcode) -- we can make an actionchain for mvl only - if groupcode == "" then -- mvl only - local h, p, done = head, nil, false - while h do - local id = h.id - if id == hlist or id == vlist then - local a = has_attribute(h,attribute) - if a then - if p then - local n - head, h, n = remove_node(head,h) - local pl = p.list - if n.width ~= 0 then - n = hpack_node(n,0,'exactly') - end - if pl then - pl.prev = n - n.next = pl - end - p.list = n - done = true - else - -- can't happen - end - else - p = h - h = h.next - end - else - h = h.next - end - end - return head, done - else - return head, false - end -end - ---~ tasks.appendaction("finalizers", "lists", "nodes.repackage_graphicvadjust") diff --git a/tex/context/base/core-spa.mkii b/tex/context/base/core-spa.mkii deleted file mode 100644 index 4f365b498..000000000 --- a/tex/context/base/core-spa.mkii +++ /dev/null @@ -1,4656 +0,0 @@ -%D \module -%D [ file=core-spa, -%D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Spacing, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Core Macros / Spacing} - -% to be sorted out: dependencies, order of initialization / also some dutch code here - -\unprotect - -% some will move to core-var - -\newif \ifgridsnapping -\newif \iffuzzyvskip -\let \fuzzyvskip \gobbleoneargument -\let \removelastfuzzyvskip \relax - -\let \startbaselinecorrection \relax -\let \stopbaselinecorrection \relax -\let \baselinecorrection \relax -\let \offbaselinecorrection \relax - -\appendtoks \spacing 1\to \everybodyfont -\appendtoks \presetnormallineheight \to \everybodyfont -\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant -\appendtoks \setstrut \to \everybodyfont % check if redundant -\appendtoks \settopskip \to \everybodyfont -\appendtoks \setmaxdepth \to \everybodyfont -%appendtoks \spacing 1\to \everybodyfont -\appendtoks \simplesetupindenting \to \everybodyfont -\appendtoks \simplesetupblank \to \everybodyfont -\appendtoks \simplesetupwhitespace \to \everybodyfont -%appendtoks \checknotes \to \everybodyfont % not -\appendtoks \simplesetupspacing \to \everybodyfont % nieuw -\appendtoks \setrelativeinterlinespace \to \everybodyfont - -\appendtoks \updateraggedskips \to \everyfontswitch % under test -\prependtoks \let\par\endgraf \to \everypagebody % see \fillinline -\appendtoks \simplesetupspacing \to \everydefinedfont - -% if you want to hyphenate the first word of a paragraph ... \appendtoks\hskip0pt\to\everypar - -\def\stelfactorenin - {\simplesetupwhitespace - \simplesetupblank - \settopskip - \setmaxdepth} - -\def\softbreak - {\relax\ifhmode\hskip\parfillskip\break\fi} - -\let\poplastnode\relax - -\def\pushlastnode - {\ifdim\lastskip=\zeropoint - \ifnum\lastpenalty=\zerocount - \ifnum\lastkern=\zerocount - \let\poplastnode\relax - \else - \edef\poplastnode{\kern\the\lastkern\relax}\kern-\lastkern % untested - \fi - \else - \edef\poplastnode{\penalty\the\lastpenalty\relax}\nobreak % untested - \fi - \else - \edef\poplastnode{\vskip\the\lastskip\relax}\vskip-\lastskip % \removelastskip - \fi} - -%D The dreadful sequence \type {\bgroup} \unknown\ -%D \type {\carryoverpar} \unknown\ \type {\egroup} is needed -%D when for instance sidefloats are used in combination with -%D something that starts with a group. This is because -%D otherwise the indentation as set (by the output routine) -%D inside the group are forgotten afterwards. (I must -%D not forget its existence). - -\global\let\carriedoverpar\relax - -\def\carryoverpar#1% - {\expanded % \scratchtoks{#1}% - {\noexpand#1% \the\scratchtoks - \hangindent\the\hangindent - \hangafter \the\hangafter - \parskip \the\parskip - \leftskip \the\leftskip - \rightskip \the\rightskip}} - -%D A quick way to determine left|/|middle|/|right states -%D (experimental). - -\setvalue{\??as\v!left }{0} -\setvalue{\??as\v!middle}{1} -\setvalue{\??as\v!right }{2} - -\def\setalignmentswitch#1% - {\chardef\alignmentswitch0\csname\??as#1\endcsname\relax} - -%D There are two ways to influence the interline spacing. The -%D most general and often most consistent way is using -%D -%D \showsetup{setupinterlinespace} -%D -%D For instance -%D -%D \starttyping -%D \setupinterlinespace[line=2.8ex] -%D \stoptyping -%D -%D This setting adapts itself to the bodyfontsize, while for -%D instance saying -%D -%D \starttyping -%D \setupinterlinespace[line=12pt] -%D \stoptyping -%D -%D sets things fixed for all sizes, which is definitely not -%D what we want. Therefore one can also say: -%D -%D \starttyping -%D \definebodyfontenvironment[9pt][interlinespace=11pt] -%D \stoptyping -%D -%D One can still use \type{\setupinterlinespace} (without -%D arguments) to set the interline space according to the -%D current font, e.g. a \type{\bfa}. - -\newif\iflocalinterlinespace - -% font-ini - -\ifx\bodyfontinterlinespecs\undefined - - \let\bodyfontinterlinespecs\empty - \let\bodyfontinterlinespace\empty - -\fi - -\def\presetnormallineheight - {\edef\normallineheight{\@@itline}% -% done elsewhere : \spacing\!!plusone % new per 10/08/2004, else problems in otr / !! needed - \iflocalinterlinespace \else - \doifdefined\bodyfontinterlinespecs - {\doifsomething\bodyfontinterlinespace - {\edef\normallineheight{\bodyfontinterlinespace}}}% - \fi} - -\def\setupspecifiedinterlinespace[#1]% - {\getparameters[\??it][#1]% - \scratchdimen0\@@itheight\points - \advance\scratchdimen 0\@@itdepth\points - \ifdim\scratchdimen>\onepoint - \showmessage\m!layouts{10}{\@@itheight,\@@itdepth}% - \let\@@itheight\strutheightfactor - \let\@@itdepth \strutdepthfactor - \else - \let\strutheightfactor\@@itheight - \let\strutdepthfactor \@@itdepth - \fi - \let\minimumstrutheight \@@itminheight - \let\minimumstrutdepth \@@itmindepth - \let\minimumlinedistance\@@itdistance - \let\normallineheight \@@itline % let ! ! ! ! ! ivm ex - \doifelse\@@ittop\v!height % new, topskip does more bad than good - {\let\topskipfactor \@@itheight} - {\let\topskipfactor \@@ittop }% - \let\maxdepthfactor \@@itbottom - \let\baselinegluefactor \@@itstretch - \setfontparameters % redundant, can be \setstrut, test first - \updateraggedskips} % yes indeed - -% \let\currentrelativeinterlinespace\empty -% -% \def\setuprelativeinterlinespace[#1]% -% {\processallactionsinset -% [#1] -% [ \v!on=>\oninterlineskip, -% \v!off=>\offinterlineskip, -% \v!reset=>\let\currentrelativeinterlinespace\empty -% \setfontparameters,% just \setstrut, test first -% \s!unknown=>\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}% -% \spacing\currentrelativeinterlinespace]} - -% \setupinterlinespace[big] \switchtobodyfont[11pt] -> forgotten -% \setupinterlinespace[auto,big] \switchtobodyfont[11pt] -> remembered - -\let\currentrelativeinterlinespace\empty - -\def\setuprelativeinterlinespace[#1]% - {\processallactionsinset - [#1] - [ \v!on=>\oninterlineskip, - \v!off=>\offinterlineskip, - \v!reset=>\let\currentrelativeinterlinespace\empty - \let\setrelativeinterlinespace\relax - \setfontparameters, - \v!auto=>\let\setrelativeinterlinespace\dosetrelativeinterlinespace, - \s!unknown=>\assignvalue\commalistelement\currentrelativeinterlinespace{1.00}{1.25}{1.50}% - \spacing\currentrelativeinterlinespace]} - -\def\dosetrelativeinterlinespace - {\ifx\currentrelativeinterlinespace\empty\else - \spacing\currentrelativeinterlinespace - \fi} - -\let\setrelativeinterlinespace\relax - -% \appendtoks \setrelativeinterlinespace \to \everybodyfont - -\def\complexsetupinterlinespace[#1]% \commalistelement ipv #1 - {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]} - -\def\setuplocalinterlinespace[#1]% - {\localinterlinespacetrue - \setupinterlinespace[#1]% - \localinterlinespacefalse} - -\def\simplesetupinterlinespace - {\localinterlinespacetrue - \setfontparameters - \updateraggedskips % funny one here - \localinterlinespacefalse} - -\definecomplexorsimple\setupinterlinespace - -% In earlier versions \type{\bigskipamount} was -% \type{\ht\strutbox} and the stretch was plus or minus -% \type{.4\dp\strutbox}. Don't ask me why. The most recent -% implementation is based on a user supplied distance, which -% is by default \type{.75\normalskipamount} where -% \type{\normalskipamount} equals the current baseline -% distance. - -% \lineskiplimit = -\maxdimen -> freezes baselineskip - -% can be conditionals - -\newif\ifblanknowhite \blanknowhitefalse -\newif\ifblankindeed \blankindeedfalse -\newif\ifblankreset \blankresetfalse -\newif\ifblankdisable \blankdisablefalse -\newif\ifblankflexible \blankflexibletrue -\newif\ifblankouter -\newif\ifblankforce -\newif\ifblankgoback - -\newskip\blankskip \blankskip=\bigskipamount -\newskip\blankskipamount - -\def\skipfactor {.75} -\def\skipgluefactor{.25} - -\def\normalskipamount - {\openlineheight - \ifgridsnapping \else \ifblankflexible - \!!plus \skipgluefactor\openlineheight - \!!minus\skipgluefactor\openlineheight - \fi \fi - \relax} - -\def\linedistance {\normalskipamount} -\def\appliedblankskip{\skipfactor\linedistance} -\def\lastblankskip {\blankskip} -\def\currentblank {\v!big} -\def\oldprevdepth {\prevdepth} -\def\newprevdepth {-1001pt} -\def\mindimen {1sp} % was: 0.00002pt - -\newif\iflocalblankfixed -\newif\iflocalblankflexible - -\def\geenblanko{\removelastskip} % will become obsolete - -%%%% pas op, wordt ook in core-pos gebruikt - -\def\doassignsomeskip#1\to#2% ook nog \v!halfline+fuzzysnap - {\doifelse{#1}\v!line - {#2\openlineheight} - {\ifgridsnapping - \assigndimension{#1}{#2}{.25\openlineheight}{.5\openlineheight}\openlineheight - \else - \assigndimension{#1}{#2}\smallskipamount\medskipamount\bigskipamount - \fi}% - \relax} - -% \relax is really needed, else we may loose stretch due to lookahead; somehow -% this bug was introduced a while ago but somehow went unnoticed; fixed 2/7/2008 - -\def\addblankskip#1#2#3{\global\advance\blankskip#1\ifgridsnapping#3\else#2\fi\relax} - -\def\defineblankmethod[#1]#2{\setvalue{\??bo\??bo#1}{#2}} - -\defineblankmethod [\v!big] {\addblankskip+\bigskipamount \openlineheight} -\defineblankmethod [-\v!big] {\addblankskip-\bigskipamount \openlineheight} -\defineblankmethod [\v!medium] {\addblankskip+\medskipamount {.5\openlineheight}} -\defineblankmethod [-\v!medium] {\addblankskip-\medskipamount {.5\openlineheight}} -\defineblankmethod [\v!small] {\addblankskip+\smallskipamount{.25\openlineheight}} -\defineblankmethod [-\v!small] {\addblankskip-\smallskipamount{.25\openlineheight}} -\defineblankmethod [\v!white] {\addblankskip+\parskip \openlineheight} -\defineblankmethod [-\v!white] {\addblankskip-\parskip \openlineheight} -\defineblankmethod [\v!line] {\addblankskip+\openlineheight \openlineheight} -\defineblankmethod [-\v!line] {\addblankskip-\openlineheight \openlineheight} - -\defineblankmethod [\v!formula] {\global\advance\blankskip\medskipamount} -\defineblankmethod [\v!nowhite] {\global\blanknowhitetrue} -\defineblankmethod [\v!disable] {\global\blankdisabletrue} -\defineblankmethod [\v!force] {\global\blankforcetrue} -\defineblankmethod [\v!outer] {\ifvmode\ifinner\blankoutertrue\fi\fi} -\defineblankmethod [\v!reset] {\global\blankresettrue} -\defineblankmethod [\v!flexible] {\global\localblankflexibletrue} -\defineblankmethod [\v!fixed] {\global\localblankfixedtrue} -\defineblankmethod [\v!back] {\global\blankgobacktrue} % {\geenblanko} -\defineblankmethod [\v!halfline] {\ifgridsnapping\global\fuzzyvskiptrue\fi - \global\advance\blankskip .5\lineheight} -\defineblankmethod [\v!none] {\global\blankresettrue} -\defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} -\defineblankmethod[\v!synchronize] {\verticalstrut\vskip-2\lineheight\verticalstrut} - -% \vtop{\blank[synchronize]\blank[line]test} - -\defineblankmethod [\v!always] {\redowhitespace} % experimental - -% happens often, so we speed this up: -% -% \defineblankmethod [2*\v!line] {\addblankskip+{2\openlineheight}{2\openlineheight}} -% \defineblankmethod [2*\v!big] {\addblankskip+{2\bigskipamount }{2\openlineheight}} -% -% no, with 2\whatever we loose the stretch and shrink! Taco's alternative: - -\defineblankmethod - [2*\v!line] - {\addblankskip+\openlineheight\openlineheight - \addblankskip+\openlineheight\openlineheight} - -\defineblankmethod - [2*\v!big] - {\addblankskip+\bigskipamount\openlineheight - \addblankskip+\bigskipamount\openlineheight} - -\def\doblank#1% - {\edefconvertedargument\ascii{#1}% - \ifx\ascii\empty\else - \ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname - \else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax - \else - \dorepeatwithcommand[#1]\redoblank - \fi\fi - \fi - \relax} - -\def\redoblank#1% - {\edefconvertedargument\ascii{#1}% - \ifx\ascii\empty\else - \ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname - \else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax - \else - \global\advance\blankskip#1\relax - \fi\fi - \fi - \relax} - -\unexpanded\def\blank % the \relax is definitely needed due to the many \if's - {\relax\complexorsimple\doblank} - -\def\complexdoblank - {\flushnotes - \ifmmode - \@EA\nocomplexdoblank - \else - \ifopelkaar - \ifinpagebody - \@EA\@EAEAEA\@EA\docomplexdoblank - \else - \@EA\@EAEAEA\@EA\nocomplexdoblank - \fi - \else - \@EAEAEA\docomplexdoblank - \fi - \fi} - -\def\nocomplexdoblank[#1]% - {% evt blokkeerfalse - \ifmmode\else\par\fi} - -% Overloaded in cont-new! - -\newsignal\noblanksignal - -% \def\doinhibitblank -% {\kern\noblanksignal} - -% \def\inhibitblank% the fast, local way -% {\endgraf\ifvmode\prevdepth\newprevdepth\fi} - -% \def\docomplexdoblank[#1]% pas op \relax's zijn nodig ivm volgende \if -% {\global\blankresetfalse -% \global\blankdisablefalse -% \global\blanknowhitefalse -% \global\localblankflexiblefalse -% \global\localblankfixedfalse -% \global\blankskip\zeropoint -% \global\blankforcefalse -% \global\blankgobackfalse -% \blankouterfalse -% \expanded{\rawprocesscommalist[#1]}\doblank -% \ifdim\blankskip=\zeropoint\relax -% \iflocalblankflexible -% \doglobal\advance\blankskip \currentblank -% \else\iflocalblankfixed -% \doglobal\advance\blankskip \currentblank -% \fi\fi -% \fi -% \ifblankouter -% \else -% \par -% \ifvmode -% \ifblankgoback -% \removelastskip -% \fi -% \ifblankforce -% % dit gaat mis in pos fonts -% % \ifdim\prevdepth>\zeropoint\else ... -% % -1000pt signals top of page or column (\ejectcolumn) -% \bgroup\forgeteverypar\verticalstrut\egroup\kern-\struttotal -% \fi -% \ifblankdisable -% \global\blankindeedfalse -% \ifgridsnapping -% \ifdim\prevdepth<\zeropoint -% % brrr -% \else -% % dirty trick: smaller blanks are ignored after -% % a larger one, so 10 lines is probably safe; first make -% % sure that we honor penalties -% \scratchcounter\lastpenalty -% % now comes the trick (cross our fingers that this works -% % well in multi columns; maybe an ifinner test is needed -% % \vskip-10\lineheight -% % \ifnum\scratchcounter=\zerocount \else \penalty\lastpenalty \fi -% % \vskip 10\lineheight -% % allas, this leads to overfull pages, so we try this: -% \kern-\noblanksignal -% \ifnum\scratchcounter=\zerocount -% \else -% \penalty\lastpenalty -% \fi -% \kern\noblanksignal -% % end-of-dirty-trick -% \fi -% \else -% \ifdim\prevdepth<\zeropoint -% % brrr -% \else -% % ensure at least a proper prevdepth, this should be -% % an option -% \vskip-\prevdepth -% \vskip\strutdepth -% \prevdepth\strutdepth -% \fi -% % the old crappy piece of code -% \edef\oldprevdepth{\the\prevdepth}% -% \prevdepth\newprevdepth -% \fi -% \else -% \global\blankindeedtrue -% \fi -% \ifblankreset -% \global\blankindeedtrue -% \ifgridsnapping -% % let's play safe and not fool around with the depth, if -% % only because it took a lot of effort to sort out the grid -% % stuff in the first place -% \else -% \ifdim\prevdepth=\newprevdepth -% \prevdepth\oldprevdepth -% \fi -% \fi -% \fi -% \ifblankindeed -% \ifdim1\lastskip<1\blankskip\relax -% % else when \blanko[2*groot] + \blanko[3*groot] with parskip -% % equaling 1*groot, gives a groot=\parskip so adding a small -% % value makes it distinguishable; can also be done at parskip -% % setting time (better) -% \global\advance\blankskip \mindimen\relax % = skip -% % test this on 2* + 3* and parskip groot -% \ifblanknowhite -% \global\advance\blankskip -\parskip -% \else -% \ifdim\lastskip=\parskip -% \else % force this due to previous comment -% \ifdim\parskip>\zeropoint\relax -% \ifdim\blankskip<\parskip\relax -% \global\blankskip\zeropoint -% \else -% \global\advance\blankskip -\parskip -% \fi -% \fi -% \fi -% \fi -% \ifblankflexible \else -% \blankskip1\blankskip -% \fi -% \iflocalblankfixed -% \blankskip1\blankskip -% \fi -% \iflocalblankflexible -% \blankskip1\blankskip -% \!!plus\skipgluefactor\blankskip -% \!!minus\skipgluefactor\blankskip -% \fi -% \ifdim\lastkern=\noblanksignal % controled and grid -% \global\blankindeedfalse -% \else\ifgridsnapping\else\ifdim\prevdepth=\newprevdepth -% \global\blankindeedfalse -% \fi\fi\fi -% \ifblankindeed -% \iffuzzyvskip -% \removelastfuzzyvskip -% \fuzzyvskip\blankskip\relax -% \else -% \removelastskip -% \vskip\blankskip\relax -% \fi -% \fi -% \else -% \iffuzzyvskip -% \removelastfuzzyvskip -% \fuzzyvskip\blankskip\relax -% \else -% % new, test this on pascal -% \ifdim\blankskip<\zeropoint -% \advance\blankskip-\lastskip -% \removelastskip -% \ifdim\blankskip>\zeropoint -% \vskip\blankskip -% \else -% \vskip\zeropoint -% \fi -% \else -% % also new -% \ifdim\blankskip=\zeropoint -% \ifblanknowhite -% \geenwitruimte -% \fi -% \fi -% \fi -% \fi -% \fi -% \fi -% \fi -% \fi -% \global\fuzzyvskipfalse -% \presetindentation} - -% goback was broken: - -% \def\doinhibitblank -% {\kern\noblanksignal} - -% \def\inhibitblank% the fast, local way -% {\endgraf\ifvmode\prevdepth\newprevdepth\fi} - -% problem: we cannot look back in the mvl so we need 3 kinds of signals - -\def\noblankpsignal{1010101} - -\def\inhibitgridblank % was doinhibitblank - {\ifvmode\else\endgraf\fi - \ifvmode - \ifnum\lastpenalty<10000 - \kern-\noblanksignal % new - \kern \noblanksignal - \else - \penalty\noblankpsignal - \fi - \fi} - -\def\inhibittextblank % was inhibitblank - {\endgraf - \ifvmode - \prevdepth\newprevdepth - \fi} - -% new macro -% -% \def\inhibitblank % need some work -% {\endgraf -% \ifvmode -% \ifgridsnapping -% \inhibitgridblank -% \else -% % this one spoils the grid -% \inhibittextblank -% \fi -% \fi} - -\def\doinhibitblank{\inhibitgridblank} -\def\inhibitblank {\inhibittextblank} - -% will become obsolete - -\ifx\undefined\savedlastskip \newskip \savedlastskip \fi -\ifx\undefined\savedlastpenalty \newcount\savedlastpenalty \fi - -% beware, prevdepth can have funny values (e.g. mvl value when in box) - -\def\docomplexdoblank[#1]% pas op \relax's zijn nodig ivm volgende \if - {\global\blankresetfalse - \global\blankdisablefalse - \global\blanknowhitefalse - \global\localblankflexiblefalse - \global\localblankfixedfalse - \global\blankforcefalse - \global\blankgobackfalse - \blankouterfalse - \global\blankskip\zeropoint -% -\edefconvertedargument\ascii{#1}% todo fast check for simple -\ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname -\else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax -\else - \expanded{\rawprocesscommalist[#1]}\doblank -\fi\fi -% - \relax % to be sure - \ifdim\blankskip=\zeropoint\relax - \iflocalblankflexible - \doglobal\advance\blankskip \currentblank - \else\iflocalblankfixed - \doglobal\advance\blankskip \currentblank - \fi\fi - \fi - \relax % to be sure - \ifblankouter - % do nothing - \else - \par - \ifvmode - \ifblankgoback - \ifdim\lastskip>\zeropoint \vskip-\lastskip \fi - \savedlastskip\zeropoint - \else\ifdim\lastskip>\zeropoint - \savedlastskip\lastskip - \else % todo: lastnode, dan namelijk geen skip ! - \savedlastskip\zeropoint - \fi\fi - \ifblankforce - % dit gaat mis in pos fonts - % \ifdim\prevdepth>\zeropoint\else ... - % -1000pt signals top of page or column (\ejectcolumn) - \bgroup\forgeteverypar\verticalstrut\egroup\kern-\struttotal - \savedlastskip\zeropoint - \fi - \savedlastpenalty\lastpenalty % hm, now it gets lost - \ifblankdisable - \global\blankindeedfalse % keep this, i.e. disable current too - \ifgridsnapping - \ifdim\prevdepth<\zeropoint - % brrr - \else - % dirty trick: smaller blanks are ignored after a - % larger one, so 10 lines is probably safe; we need - % to make sure that we honor penalties; here comes the - % trick (cross our fingers that this works well in - % multi columns; maybe an ifinner test is needed - % \scratchcounter\lastpenalty - % \vskip-10\lineheight - % \ifnum\scratchcounter=\zerocount \else \penalty\lastpenalty \fi - % \vskip 10\lineheight - % alas, this leads to overfull pages, so we try this: - \inhibitgridblank - \fi - \else - \ifdim\prevdepth<\zeropoint - % brrr - \else - % ensure at least a proper prevdepth, this should be - % an option - \vskip-\prevdepth - \vskip\strutdepth - \prevdepth\strutdepth - \fi - % the old crappy piece of code - \edef\oldprevdepth{\the\prevdepth}% - \prevdepth\newprevdepth % == \inhibittextblank - \fi - \else - \global\blankindeedtrue - \fi - \ifblankreset - \global\blankindeedtrue - \ifgridsnapping - % let's play safe and not fool around with the depth, if - % only because it took a lot of effort to sort out the grid - % stuff in the first place - \else - \ifdim\prevdepth=\newprevdepth - \prevdepth\oldprevdepth - \fi - \fi - \fi - \ifblankindeed - \ifdim1\savedlastskip<1\blankskip\relax - % else when \blank[2*groot] + \blank[3*groot] with parskip - % equaling 1*groot, gives a groot=\parskip so adding a small - % value makes it distinguishable; can also be done at parskip - % setting time (better) - \global\advance\blankskip \mindimen\relax % = skip - % test this on 2* + 3* and parskip groot - \ifblanknowhite - \global\advance\blankskip -\parskip - \else - \ifdim\savedlastskip=\parskip - \else % force this due to previous comment - \ifdim\parskip>\zeropoint\relax - \ifdim\blankskip<\parskip\relax - \global\blankskip\zeropoint - \else - \global\advance\blankskip -\parskip - \fi - \fi - \fi - \fi - \ifblankflexible \else - \blankskip1\blankskip - \fi - \iflocalblankfixed - \blankskip1\blankskip - \fi - \iflocalblankflexible - \blankskip1\blankskip - \!!plus \skipgluefactor\blankskip - \!!minus\skipgluefactor\blankskip - \fi - \ifdim\lastkern=\noblanksignal\relax % controlled and grid - \global\blankindeedfalse - \else\ifnum\savedlastpenalty=\noblankpsignal\relax % controlled and grid - \global\blankindeedfalse - \else\ifgridsnapping\else\ifdim\prevdepth=\newprevdepth - \global\blankindeedfalse - \fi\fi\fi\fi - \ifblankindeed - \iffuzzyvskip - \removelastfuzzyvskip - \fuzzyvskip\blankskip\relax - \else - \relax\ifdim\savedlastskip=\zeropoint\else - \vskip-\savedlastskip - \fi - \vskip\blankskip\relax - \fi - \fi - \else - \iffuzzyvskip - \removelastfuzzyvskip - \fuzzyvskip\blankskip\relax - \else - % new, test this on pascal - \ifdim\blankskip<\zeropoint - \relax\ifdim\savedlastskip=\zeropoint\else - \advance\blankskip-\savedlastskip - \vskip-\savedlastskip - \fi - \ifdim\blankskip>\zeropoint - \vskip\blankskip - \else - \vskip\zeropoint - \fi - \else - % also new - \ifdim\blankskip=\zeropoint - \ifblanknowhite - \nowhitespace - \fi - \fi - \fi - \fi - \fi - \fi - \fi - \fi - \global\fuzzyvskipfalse - \presetindentation} - -%D For a long time we had: -%D -%D \starttyping -%D \def\simpledoblank% -%D {\doifelse{\currentwhitespace}{\v!geen} -%D {\blank[\currentblank]} -%D {\blank[\currentwhitespace]}} -%D \stoptyping -%D -%D But Berend de Boer wanted more control, so now we have: - -\def\simpledoblank % ... - {\doifelse\currentwhitespace\v!none - {\blank[\currentblank]} - {\blank[\s!default]}} - -%D Another useful definition would be: -%D -%D \starttyping -%D \defineblank -%D [\s!default] -%D [\v!groot] -%D \stoptyping - -\def\dosetupblank#1% amount are an plain inheritance - {\bigskipamount#1\relax - \ifblankflexible \else - \bigskipamount1\bigskipamount - \fi - \medskipamount \bigskipamount \divide\medskipamount \plustwo - \smallskipamount\bigskipamount \divide\smallskipamount\plusfour}% - -\def\complexsetupblank[#1]% more \let's -> this also wil become installable - {\ifgridsnapping - \blankflexiblefalse - \else - \ExpandFirstAfter\processallactionsinset - [#1] - [ \v!flexible=>\blankflexibletrue, - \v!fixed=>\blankflexiblefalse]% - \fi - \ExpandFirstAfter\processallactionsinset - [#1] - [ \v!flexible=>\dosetupblank\appliedblankskip, - \v!fixed=>\dosetupblank\appliedblankskip, - \v!line=>\edef\appliedblankskip{\linedistance}% - \dosetupblank\appliedblankskip, - \v!halfline=>\scratchskip.5\linedistance - \edef\appliedblankskip{\the\scratchskip}% - \dosetupblank\appliedblankskip, - \v!big=>\ifgridsnapping - \edef\appliedblankskip{\linedistance}% - \dosetupblank\appliedblankskip - \fi - \let\currentblank\v!big, - \v!medium=>\let\currentblank\v!medium, - \v!small=>\let\currentblank\v!small, - \v!global=>\let\currentblank\v!global, - \v!normal=>\dosetupblank\appliedblankskip, - \v!standard=>\edef\appliedblankskip{\skipfactor\linedistance}% - \dosetupblank\appliedblankskip, - \s!default=>\dosetupblank\appliedblankskip, - \s!unknown=>\let\appliedblankskip\commalistelement - \dosetupblank\appliedblankskip]% - \simplesetupwhitespace} - -% \definecomplexorsimpleempty\setupblank -% -% speed gain: 60 sec -> 30 sec - -\definecomplexorsimple\setupblank - -\def\simplesetupblank % == snelle \setupblank[\s!default] - {\ifgridsnapping - \blankflexiblefalse - \fi - \dosetupblank\appliedblankskip - % \let\deblanko\v!big - \simplesetupwhitespace} - -\def\restorestandardblank% \v!standard - {\edef\appliedblankskip{\skipfactor\linedistance}% - \dosetupblank\appliedblankskip - }%\let\deblanko\v!big} - -\def\dodefineblank[#1][#2]% - {\def\docommand##1{\setvalue{\??bo##1}{#2}}% - \processcommalist[#1]\docommand} - -\def\defineblank - {\dodoubleargument\dodefineblank} - -\def\savecurrentblank - {\edef\restorecurrentblank - {\bigskipamount\the\bigskipamount - \medskipamount\the\medskipamount - \smallskipamount\the\smallskipamount - \noexpand\def\noexpand\currentblank{\currentblank}% - \ifblankflexible - \noexpand\blankflexibletrue - \else - \noexpand\blankflexiblefalse - \fi}} - -%D Now. - -\defineblank [\s!default] [\v!white] -\defineblank [\v!height] [\strutheight] -\defineblank [\v!depth] [\strutdepth] - -% old implementation -% -% \let\currentindentation=\empty -% -% \newdimen\ctxparindent -% -% \newif\ifindentfirstparagraph % \indentfirstparagraphtrue -% -% \def\presetindentation -% {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} -% -% \definecomplexorsimple\setupindenting -% -% \def\complexsetupindenting[#1]% -% {\processallactionsinset -% [#1] -% [ \v!first=>\indentfirstparagraphtrue, -% \v!next=>\indentfirstparagraphfalse, -% \s!default=>\simplesetupindenting, -% \s!unknown=>\edef\currentindentation{\commalistelement}% -% \simplesetupindenting]} -% -% \def\simplesetupindenting -% {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}% -% \parindent\ctxparindent\relax} -% -% \def\indenting % watch out: \dodo and no \do -% {\dosingleargument\dodoindenting} -% -% \def\dodoindenting[#1]% oeps, we needed a commalist handler here! -% {\edef\currentindenting{#1}% -% \processcommacommand[#1]\dododoindenting} -% -% \def\dododoindenting#1% -% {\executeifdefined{\??in:#1}\donothing} -% -% \let\currentindenting\empty -% -% \def\defineindentingmethod[#1]#2% -% {\setvalue{\??in:#1}{#2}} -% -% \defineindentingmethod [\v!no] {\parindent\ctxparindent\noindent} -% \defineindentingmethod [\v!not] {\parindent\ctxparindent\noindent} -% -% \defineindentingmethod [\v!first] {\indentfirstparagraphtrue} -% \defineindentingmethod [\v!next] {\indentfirstparagraphfalse} -% -% \defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! -% \defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! -% -% \defineindentingmethod [\v!never] {\parindent\zeropoint\relax} % no \indent ! -% -% \def\noindenting{\indenting[\v!no,\v!next]} % was \nietinspringen -% \def\doindenting{\indenting[\v!yes,\v!first]} % was \welinspringen -% -% \def\dochecknextindentation#1% internal one -% {\checknextindentation[\getvalue{#1\c!indentnext}]} -% -% \def\checknextindentation[#1]% -% {\processaction[#1][%\v!keep=>, -% \v!yes=>\doindentation, -% \v!no=>\noindentation, -% \v!auto=>\autoindentation]} -% -% \def\doindentation% too simple -% {\gdef\checkindentation{\global\indentationtrue}} -% -% \ifx\autoindentation\undefined -% \let\autoindentation\relax -% \fi -% -% \newif\ifindentation \indentationtrue % documenteren, naar buiten -% -% \let\checkindentation=\relax -% -% \def\donoindentation -% {\ifdim\parindent=\zeropoint \else -% \bgroup \setbox\scratchbox\lastbox \egroup -% \fi} -% -% \def\noindentation % made global -% {\ifinpagebody \else -% \global\indentationfalse -% \gdef\checkindentation -% {\donoindentation -% \gdef\checkindentation{\global\indentationtrue}}% -% \fi} -% -% \def\nonoindentation % bv bij floats -% {\ifinpagebody \else -% \global\indentationtrue -% \gdef\checkindentation{\global\indentationtrue}% -% \fi} -% -% \def\indentation -% {\ifvmode \ifdim\parindent=\zeropoint \else -% % was : \hskip\parindent -% % can be: \indent -% % but we test: -% \noindent\hskip\parindent -% \fi \fi} - -\let\currentindentation\empty % amount/keyword -% \let\normalindentation \empty % used for reinstating normal indentation -\let\currentindenting \empty % method - -\newdimen\ctxparindent - -\newif\ifindentfirstparagraph % \indentfirstparagraphtrue - -\chardef\indentingtoggle\zerocount - -%D After a blank or comparable situation (left side floats) we -%D need to check if the next paragraph has to be indented. - -\def\presetindentation - {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} - -%D This sets up the (normally) global indentation behavior as well -%D as the amounts. - -\definecomplexorsimple\setupindenting - -% \def\complexsetupindenting[#1]% -% {\edef\currentindenting{#1}% -% \indentfirstparagraphtrue -% \parindent\ctxparindent -% \chardef\indentingtoggle\zerocount -% \processcommalist[#1]\docomplexsetupindenting -% \ifindentfirstparagraph\else\noindentation\fi % added -% \toggleindentation} - -\indentfirstparagraphtrue -\parindent\ctxparindent -\chardef\indentingtoggle\zerocount - -% \newtoks\savedeverypar \savedeverypar\everypar -% \def\restoreeverypar{\everypar\savedeverypar} - -% we need a better everypar model: for each option a switch, which we -% set to false with \forgetall and can enable when needed (context 4); -% that way we can control the order of execution of options - -\def\checkeverypar % currently a hack - {\ifzeropt\parindent\else - \doifsometokselse\everypar\donothing{\appendtoks\checkindentation\to\everypar}% - \fi} - -\def\complexsetupindenting[#1]% - {\edef\currentindenting{#1}% - \doifsomething\currentindenting % handy when a parameter is passed - {% not here: \indentfirstparagraphtrue - % not here: \parindent\ctxparindent - % not here: \chardef\indentingtoggle\zerocount - % we use commacommand in order to catch #1 being a command (expanded parameter) - \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc - \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest - \checkeverypar % only when non-empty #1 - \ifindentfirstparagraph\else\noindentation\fi % added - \toggleindentation}} - -\def\docomplexsetupindentingA#1% - {\edefconvertedargument\!!stringa{#1}% - \doifundefined{\??in:\!!stringa}% - {\edef\currentindentation{#1}% - \let\normalindentation\currentindentation - \simplesetupindenting}} - -\def\docomplexsetupindentingB#1% - {\edefconvertedargument\!!stringa{#1}% catch #1=\somedimen - \executeifdefined{\??in:\!!stringa}\donothing} - -\def\simplesetupindenting % empty case, a it strange, needed this way? - {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} - -\def\indenting % kind of obsolete - {\dosingleargument\complexsetupindenting} - -% use \noindentation to suppress next indentation - -\def\defineindentingmethod[#1]#2% - {\setvalue{\??in:#1}{#2}} - -\defineindentingmethod [\v!no] {\parindent\zeropoint}% was: \ctxparindent\noindent} -\defineindentingmethod [\v!not] {\parindent\zeropoint}% was: \ctxparindent\noindent} - -\defineindentingmethod [\v!first] {\indentfirstparagraphtrue} -\defineindentingmethod [\v!next] {\indentfirstparagraphfalse} - -\defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! -\defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! - -\defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! - \chardef\indentingtoggle\zerocount} - -\defineindentingmethod [\v!odd] {\chardef\indentingtoggle\plusone} -\defineindentingmethod [\v!even] {\chardef\indentingtoggle\plustwo} - -\defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else - \let\currentindentation\normalindentation - \simplesetupindenting - \fi} - -\defineindentingmethod [\v!reset] {\indentfirstparagraphtrue - \parindent\zeropoint - \chardef\indentingtoggle\zerocount} - -\def\noindenting{\indenting[\v!no, \v!next ]} -\def\doindenting{\indenting[\v!yes,\v!first]} - -%D This one sets up the local indentation behaviour (i.e. either or not -%D a next paragraph will be indented). - -\def\dochecknextindentation#1% internal one - {\checknextindentation[\getvalue{#1\c!indentnext}]} - -\def\checknextindentation[#1]% - {\processaction - [#1] - [%\v!keep=>, - \v!yes=>\doindentation, - \v!no=>\noindentation, - \v!auto=>\autoindentation]} - -%D Here come the handlers. - -\newif\ifindentation \indentationtrue % documenteren, naar buiten - -\let\checkindentation\relax - -\ifx\autoindentation\undefined \let\autoindentation\relax \fi % hook - -\def\doindentation - {\gdef\checkindentation{\global\indentationtrue}} - -\def\noindentation % made global - {\ifinpagebody \else - \global\indentationfalse - \gdef\checkindentation - {\donoindentation - \gdef\checkindentation{\global\indentationtrue}}% - \fi} - -\def\nonoindentation % bv bij floats - {\ifinpagebody \else - \global\indentationtrue - \gdef\checkindentation{\global\indentationtrue}% - \fi} - -\def\donoindentation - {\ifdim\parindent=\zeropoint \else - \bgroup \setbox\scratchbox\lastbox \egroup - \fi} - -\def\indentation - {\ifvmode \ifdim\parindent=\zeropoint \else - % was : \hskip\parindent - % can be: \indent - % but we test: - \noindent\hskip\parindent - \fi \fi} - -\def\toggleindentation - {\ifcase\indentingtoggle - % nothing - \or - \notoggleindentation - \or - \dotoggleindentation - \fi} - -\def\dokillindentation - {\gdef\checkindentation{\global\indentationfalse\donoindentation}} - -\def\dotoggleindentation - {\gdef\checkindentation{\global\indentationfalse\notoggleindentation\donoindentation}} - -\def\notoggleindentation - {\gdef\checkindentation{\global\indentationtrue\dotoggleindentation}} - -\appendtoks - \pushmacro\checkindentation - \pushmacro\ifindentation -\to \everypushsomestate - -\appendtoks - \popmacro\ifindentation - \popmacro\checkindentation -\to \everypopsomestate - -% we need to save the state if we want to adapt behaviour to empty lines -% -% \def\setlasthvmode -% {\global\chardef\savedhvmode\ifhmode\plusone\else\ifvmode\plustwo\else\zerocount\fi\fi} -% -% \def\resetlasthvmode -% {\global\chardef\savedhvmode\zerocount} -% -% \chardef\savedhvmode\zerocount - -% This is a user requested hack (using the auto-hook). - -\chardef\recheckindentationmode\zerocount - -\def\dontrechecknextindentation - {\global\chardef\recheckindentationmode\zerocount} - -\def\dorechecknextindentation - {\ifcase\recheckindentationmode - % nothing - \or - \dontrechecknextindentation - \expandafter\doautoindentation - \fi} - -\def\doautoindentation - {\doifnextcharelse\par\donothing\noindentation} - -\def\autoindentation - {\global\chardef\recheckindentationmode\plusone} - -%D An example of usage: -%D -%D \starttyping -%D \setupindenting[small,yes] -%D -%D \setupitemize [indentnext=auto] -%D \setuptyping [indentnext=auto] -%D \setupformulas[indentnext=auto] -%D -%D \input tufte -%D -%D \startitemize -%D \item itemize -%D \stopitemize -%D \input tufte -%D -%D \startitemize -%D \item itemize -%D \stopitemize -%D -%D \input tufte -%D -%D \startitemize -%D \item itemize -%D \stopitemize -%D -%D \page -%D -%D \input tufte -%D -%D \starttyping -%D verbatim -%D \stoptyping -%D \input tufte -%D -%D \starttyping -%D verbatim -%D \stoptyping -%D -%D \input tufte -%D -%D \starttyping -%D verbatim -%D \stoptyping -%D -%D \page -%D -%D \input tufte -%D -%D \startformula -%D a = b -%D \stopformula -%D \input tufte -%D -%D \startformula -%D a = b -%D \stopformula -%D -%D \input tufte -%D -%D \startformula -%D a = b -%D \stopformula - - -%D \macros -%D {frenchspacing,nonfrenchspacing} -%D -%D Smehow \type{\frenchspacing} can lead to hyphenation between -%D dashes so we now have \type {\newfrenchspacing} (moved from -%D \type {syst-chr}). - -%D Hm ... todo: - -\sfcode`\)=0 -\sfcode`\'=0 -\sfcode`\]=0 - -\def\setfrenchspacing#1% - {\sfcode`\.#1 \sfcode`\,#1\relax - \sfcode`\?#1 \sfcode`\!#1\relax - \sfcode`\:#1 \sfcode`\;#1\relax} - -\def\frenchspacing - {\setfrenchspacing{1000}} - -\def\resetfrenchspacing - {\sfcode`\.3000 \sfcode`\,1250 - \sfcode`\?3000 \sfcode`\!3000 - \sfcode`\:2000 \sfcode`\;1500 } - -\def\frenchspacing {\setfrenchspacing{1000}} -\def\newfrenchspacing{\setfrenchspacing{1050}} -\def\nonfrenchspacing{\resetfrenchspacing} - -\def\definespacingmethod[#1]#2{\setvalue{\??sg\??sg#1}{#2}} - -\definespacingmethod[\v!packed]{\newfrenchspacing} -\definespacingmethod[\v!broad ]{\nonfrenchspacing} - -\def\complexsetupspacing[#1]% - {\executeifdefined{\??sg\??sg#1}\relax - \updateraggedskips} - -\def\simplesetupspacing - {\updateraggedskips} - -\definecomplexorsimple\setupspacing - -% \dorecurse{100}{\recurselevel\spacefactor 800 \space} \par -% \dorecurse{100}{\recurselevel\spacefactor1200 \space} \par -% \dorecurse{100}{\recurselevel\spacefactor 800 \normalspaceprimitive} \par -% \dorecurse{100}{\recurselevel\spacefactor1200 \normalspaceprimitive} \par - -% When we don't add the % here, we effectively get \ and -% since we have by default \def\^^M{\ } we get into a loop. - -\let\normalspaceprimitive=\ % space-comment is really needed - -\unexpanded\def\ {\mathortext\normalspaceprimitive\space} % no \dontleavehmode\space (else no frenchspacing) - -\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\space} - -\letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later - -\def\space { } -\def\removelastspace{\ifhmode\unskip\fi} -\def\nospace {\removelastspace\ignorespaces} - -% in tables we need: -% -% \def\fixedspace {\hskip.5em\relax} -% -% but, since not all fonts have .5em digits: - -\unexpanded\def\fixedspace - {\setbox\scratchbox\normalhbox{\mathortext{0}{0}}% - \hskip\wd\scratchbox\relax} - -\def\fixedspaces - {\letcatcodecommand \ctxcatcodes `\~ \fixedspace} - -\def\removeunwantedspaces - {\ifhmode % we also need to unskip 0pt skips - \unskip\unskip\unskip\unskip\unskip - \unskip\unskip\unskip\unskip\unskip - \fi} - -\appendtoks\let~\space\to\simplifiedcommands - -% still not fixed in aleph / luatex -% -% \def\removeunwantedspaces -% {\ifhmode \ifnum\lastnodetype=\@@gluenode -% \unskip \@EAEAEA\removeunwantedspaces -% \fi \fi} - -%D For old time sake, will disappear soon. - -\let\hardespatie\fixedspace -\let\geenspatie \nospace - -% \startbuffer -% \startlines \tt \fixedspaces -% 0~1~~2~~~3~~~~4~~~~~5 -% 0~~~~~~~~~~~~~~~~~~~5 -% $0~1~~2~~~3~~~~4~~~~~5$ -% $0~~~~~~~~~~~~~~~~~~~5$ -% \stoplines -% -% \starttabulate[|~|] -% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \NR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \NR -% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \NR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \NR -% \stoptabulate -% -% \starttable[||] -% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \AR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \AR -% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \AR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \AR -% \stoptable -% \stopbuffer -% -% \setupbodyfont[cmr] \getbuffer -% \setupbodyfont[lbr] \getbuffer - -\def\packed - {\nointerlineskip} - -\def\godown[#1]% - {\relax - \ifhmode\endgraf\fi - \ifvmode\nointerlineskip\vskip#1\relax\fi} - -%D A couple of plain macros: - -\ifx\thinspace\undefined - - \def\thinspace {\kern .16667em } - \def\negthinspace{\kern-.16667em } - \def\enspace {\kern .5em } - - \def\thinspace {\kern .16667\emwidth} - \def\negthinspace{\kern-.16667\emwidth} - \def\enspace {\kern .5\emwidth} - -\fi - -\ifx\quad\undefined - - \def\enskip{\hskip.5em\relax} - \def\quad {\hskip 1em\relax} - \def\qquad {\hskip 2em\relax} - - \def\enskip{\hskip.5\emwidth} - \def\quad {\hskip \emwidth} - \def\qquad {\hskip 2\emwidth} - -\fi - -\let\emspace\quad - -\ifx\smallskip\undefined - - \def\smallskip{\vskip\smallskipamount} - \def\medskip {\vskip\medskipamount} - \def\bigskip {\vskip\bigskipamount} - -\fi - -\ifx\allowbreak\undefined - - \def\break {\penalty\ifhmode-\plustenthousand\else\ejectpenalty\fi} - \def\nobreak {\penalty \plustenthousand} - \def\allowbreak{\penalty \zeropoint} - \def\filbreak {\par\vfil\penalty-200\vfilneg} - \def\goodbreak {\par\penalty-500 } - -\fi - -%D Made slightly more readable: - -\ifx\vglue\undefined - - \def\vglue {\afterassignment\dovglue\scratchskip=} - \def\hglue {\afterassignment\dohglue\scratchskip=} - \def\topglue{\nointerlineskip\vglue-\topskip\vglue} - - \def\dovglue - {\par - \scratchdimen\prevdepth - \hrule\!!height\zeropoint - \nobreak\vskip\scratchskip - \prevdepth\scratchdimen} - - \def\dohglue - {\dontleavehmode % \leavevmode - \scratchcounter\spacefactor - \vrule\!!width\zeropoint - \nobreak\hskip\scratchskip - \spacefactor\scratchcounter} - -\fi - -\ifx\eject\undefined - - \def\eject{\par\break} - -\fi - -\ifx\supereject\undefined - - \def\supereject{\par\penalty\superpenalty} - -\fi - -\ifx\dosupereject\undefined - - \def\dosupereject - {\ifnum\insertpenalties>\zerocount % something is being held over - \line{} - \kern-\topskip - \nobreak - \vfill\supereject - \fi} - -\fi - -%D We adapt plain's \type {\removelastskip} a bit: - -\ifx\removelastskip\undefined - - \def\removelastskip - {\ifvmode \ifdim\lastskip=\zeropoint \else - \vskip-\lastskip - \fi \fi} - -\fi - -\ifx\smallbreak\undefined - -\def\smallbreak - {\par - \ifdim\lastskip<\smallskipamount - \removelastskip - \penalty-50 - \smallskip - \fi} - -\def\medbreak - {\par - \ifdim\lastskip<\medskipamount - \removelastskip - \penalty-100 - \medskip - \fi} - -\def\bigbreak - {\par - \ifdim\lastskip<\bigskipamount - \removelastskip - \penalty-200 - \bigskip - \fi} - -\fi - -\newskip\ctxparskip \ctxparskip\zeropoint - -\newconditional \flexiblewhitespace \settrue\flexiblewhitespace - -\def\blankokleinmaat {\smallskipamount} -\def\blankomiddelmaat {\medskipamount} -\def\blankogrootmaat {\bigskipamount} -\def\currentwhitespace {\zeropoint} - -\definecomplexorsimple\setupwhitespace - -% \def\simplesetupwhitespace -% {\doifnot\currentwhitespace\v!none\dosetupwhitespace} -% -% \def\complexsetupwhitespace[#1]% -% {\doifelsenothing{#1} -% {\simplesetupwhitespace} -% {\edef\currentwhitespace{#1}% -% \dosetupwhitespace}} -% -% \def\dosetupwhitespace -% {\processcommacommand[\currentwhitespace]\dowhitespacemethod -% \dodosetupwhitespace} - -\def\simplesetupwhitespace - {\doifnot\currentwhitespace\v!none\dosetupwhitespace} - -\def\complexsetupwhitespace[#1]% - {\edef\nextcurrentwhitespace{#1}% - \ifx\nextcurrentwhitespace\empty - \simplesetupwhitespace - \else - \let\currentwhitespace\nextcurrentwhitespace - \dosetupwhitespace - \fi} - -\def\dosetupwhitespace % quick test for no list - {\doifdefinedelse{\??ws\??ws\currentwhitespace}% no ifcsname due to nested \lineheight - {\getvalue{\??ws\??ws\currentwhitespace}}% - {\processcommacommand[\currentwhitespace]\dowhitespacemethod}% - \ifgridsnapping - \setfalse\flexiblewhitespace - \ifdim\ctxparskip>\zeropoint - \ctxparskip - \ifcase\baselinegridmode - \baselineskip % normal ! ! ! ! !! - \or - \ifdim\scratchdimen=\baselineskip % maybe range - \baselineskip % normal ! ! ! ! !! - \else - \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax - \fi - \else - \baselineskip % normal ! ! ! ! !! - \fi - \fi - \else - \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi - \fi - \parskip\ctxparskip} - -\chardef\baselinegridmode=0 % option in layout / 1=permit_half_lines - -\def\dodosetupwhitespace - {\ifgridsnapping - \setfalse\flexiblewhitespace - \ctxparskip1\ctxparskip - \ifdim\ctxparskip>\zeropoint - \ifcase\baselinegridmode - \ctxparskip\baselineskip % normal ! ! ! ! !! - \or - \ifdim\scratchdimen=\baselineskip % maybe range - \ctxparskip\baselineskip % normal ! ! ! ! !! - \else - \ctxparskip\numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax - \fi - \else - \ctxparskip\baselineskip % normal ! ! ! ! !! - \fi - \fi - \else - \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi - \fi - \parskip\ctxparskip} - -\definesystemvariable {ws} % whitespace - -\def\definewhitespacemethod[#1]#2{\setvalue{\??ws\??ws#1}{#2}} - -\definewhitespacemethod [\v!fix] {} -\definewhitespacemethod [\v!fixed] {\setfalse\flexiblewhitespace} -\definewhitespacemethod [\v!flexible] {\settrue\flexiblewhitespace} -\definewhitespacemethod [\v!line] {\ctxparskip \baselineskip} -\definewhitespacemethod [\v!halfline] {\ctxparskip.5\baselineskip} -\definewhitespacemethod [\v!none] {\ctxparskip \zeropoint} -\definewhitespacemethod [\v!big] {\ctxparskip \bigskipamount} -\definewhitespacemethod [\v!medium] {\ctxparskip \medskipamount} -\definewhitespacemethod [\v!small] {\ctxparskip \smallskipamount} - -\definewhitespacemethod [\s!default] {\simplesetupwhitespace} % {\stelwitruimteopnieuwin} - -% \def\dowhitespacemethod#1% -% {\executeifdefined{\??ws\??ws#1}{\ctxparskip#1}\relax} - -\def\dowhitespacemethod#1% \doifdefined because of \lineheight - {\doifdefinedelse{\??ws\??ws#1}{\getvalue{\??ws\??ws#1}}{\ctxparskip#1}\relax} - -\def\nowhitespace - {\ifdim\parskip>\zeropoint\relax - \ifdim\lastskip=-\parskip - \else - \vskip-\parskip - \fi - \fi} - -\def\nowhitespaceunlessskip - {\ifdim\lastskip>\zeropoint \else - \nowhitespace - \fi} - -\def\redowhitespace - {\ifdim\lastskip>-\parskip \else - \vskip\parskip - \fi} - -\def\savecurrentwhitespace - {\edef\restorecurrentwhitespace - {\ctxparskip\the\ctxparskip - \parskip\the\parskip - \noexpand\def\noexpand\currentwhitespace{\currentwhitespace}% - \ifconditional\flexiblewhitespace - \noexpand\settrue\flexiblewhitespace - \else - \noexpand\setfalse\flexiblewhitespace - \fi}} - -% deze variant is nodig binnen \startopelkaar -% steeds testen: -% -% \hoofdstuk{..} -% \plaatslijst[..] -% \hoofdstuk{..} -% \input tufte -% -% met/zonder witruimte - -\def\whitespace - {\par - \ifdim\parskip>\zeropoint\relax - %\ifdim\lastskip>\parskip \else - % \removelastskip interferes with blanko blokkeer en klein - \vskip\parskip - %\fi - \fi} - -\def\nonoblanko[#1]% - {\par} - -\def\noblanko - {\dosingleempty\nonoblanko} - -% De onderstaande macro handelt ook de situatie dat er geen -% tekst tussen \start ... \stop is geplaatst. Daartoe wordt de -% laatste skip over de lege tekst heen gehaald. Dit komt goed -% van pas bij het plaatsen van (mogelijk lege) lijsten. - -\newif\ifopelkaar - -\newsignal \noparskipsignal % \def\noparskipsignal {0.00001pt} -\def\lastdoneparskip {0pt} - -\def\startpacked - {\dosingleempty\dostartpacked} - -\def\dostartpacked[#1]% nesting afvangen - {\par - \ifvmode - \edef\lastdoneparskip {\the\lastskip}% - \edef\lastdoneprevdepth{\the\prevdepth}% zeer recent toegevoegd - \ifdim\prevdepth=-\thousandpoint % toegevoegd omdat binnen - \else % een vbox een extra skip - \whitespace % ongewenst is; dit kan - \baselinecorrection %% zie in \placeregister[n=1] - \vskip\noparskipsignal % waarschijnlijk ook in - \fi % blanko blokkeer - \bgroup - \doifelse{#1}\v!blank - \opelkaarfalse - \opelkaartrue - \blank[\v!disable] % dit is nog niet ok, gaat fout - \setupwhitespace[\v!none] % bovenin vtop (dwz, baseline) - \fi} - -\def\stoppacked - {\par - \ifvmode - \egroup - \ifdim\lastskip=\noparskipsignal\relax - \removelastskip - \nowhitespace - \vskip-\lastdoneparskip - \vskip+\lastdoneparskip - \prevdepth-\lastdoneprevdepth % zeer recent toegevoegd - \fi - \fi} - -\def\startunpacked - {\blank - \leavevmode - \bgroup} - -\def\stopunpacked - {\egroup - \blank} - -% De onderstaande macro's moeten nog eens nader worden uitgewerkt. -% Ze spelen een rol bij de spatiering rond omkaderde teksten -% en/of boxen zonder diepte. - -\def\toonregelcorrectie{\showbaselinecorrection} -\def\regelcorrectie {\baselinecorrection} - -% \prevdepth crosses pageboundaries! -% -% todo: a version that works ok inside a box - -\let\doaroundlinecorrection\relax - -\def\startlinecorrection - {\dodoubleempty\dostartlinecorrection} - -\def\dostartlinecorrection[#1][#2]% #2 gobbles spaces - {\bgroup - \processaction - [#1] - [ \v!blank=>\let\doaroundlinecorrection\blank, - \s!default=>\let\doaroundlinecorrection\relax, - \s!unknown=>{\def\doaroundlinecorrection{\blank[#1]}}]% - \doaroundlinecorrection - \startbaselinecorrection - \offbaselinecorrection - \ignorespaces} - -\def\stoplinecorrection - {\stopbaselinecorrection - \doaroundlinecorrection - \egroup} - -\def\correctwhitespace - {\dowithnextbox - {\startbaselinecorrection - \flushnextbox - \stopbaselinecorrection}% - \vbox} - -\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}} -\def\horizontalstrut{\normalhbox {\strut}} - -% Hieronder volgen enkele instellingen en macro's ten behoeve -% van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en -% 0.28 zijn ooit eens ontleend aan INRS-TEX en moeten wellicht -% nog eens instelbaar worden. -% -% \lineheight : de hoogte van een regel -% \spacing{getal} : instellen interlinie -% \normalbaselines : instellen regelafstend -% -% \setstrut : instellen \strut -% \setnostrut : resetten \strut, \endstrut, \begstrut -% -% \setteststrut : instellen zichtbare struts -% \resetteststrut : instellen onzichtbare struts -% -% \setfontparameters : instellen na fontset -% -% De hoogte van een regel (\lineheight) is gelijk aan de -% som van de hoogte (\ht) en diepte (\dp) van \strutbox. -% -% \strut : denkbeeldig blokje met hoogte en diepte -% -% Een \hbox kan als deze aan het begin van een regel staat -% een breedte \hsize krijgen. Dit is soms te voorkomen met het -% commando \leavevmode. Binnen een \vbox geeft dit echter -% niet altijd het gewenste resultaat, vandaar het commando -% -% \leaveoutervmode - -% Pas op: niet zomaar \topskip en \baselineskip aanpassen -% en zeker niet \widowpenalty. Dit kan ernstige gevolgen -% hebben voor kolommen. -% -% Enige glue kan op zich geen kwaad, echter als blanko=vast, -% dan moet ook de rek 0 zijn. Binnen kolommen is rek ook -% niet bepaald mooi. Een hele kleine waarde (0.025) voldoet, -% omdat een positieve glue eindeloos rekbaar is. - -\newdimen\strutdimen -\newdimen\lineheight -\newdimen\openlineheight -\newdimen\openstrutheight -\newdimen\openstrutdepth -\newdimen\topskipgap -\newdimen\struttotal - -\def\strutheightfactor {.72} -\def\strutdepthfactor {.28} - -\def\baselinefactor {2.8} -\def\baselinegluefactor {0} - -\def\minimumstrutheight {0pt} -\def\minimumstrutdepth {0pt} - -\def\normallineheight {\baselinefactor ex} -\def\minimumlinedistance {\lineskip} - -\def\strutheight {0pt} -\def\strutdepth {0pt} -\def\strutwidth {0pt} - -\def\spacingfactor {1} - -\def\topskipfactor {1.0} -\def\maxdepthfactor {0.5} - -\def\systemtopskipfactor {\topskipfactor} -\def\systemmaxdepthfactor {\maxdepthfactor} - -% De onderstaande definitie wordt in de font-module overruled - -\ifdefined\globalbodyfontsize\else - \newdimen\globalbodyfontsize - \globalbodyfontsize=12pt -\fi - -\ifx\normalizedbodyfontsize\undefined - \def\normalizedbodyfontsize{12pt} -\fi - -% door een \dimen. Dit is geen probleem omdat (1) de default -% korpsgrootte 12pt is en (2) de fonts nog niet geladen zijn -% en de instellingen bij het laden nogmaals plaatsvinden. - -% \def\topskipcorrection -% {\ifdim\topskip>\openstrutheight -% % == \vskip\topskipgap -% \vskip\topskip -% \vskip-\openstrutheight -% \fi -% \verticalstrut -% \vskip-\struttotal} - -\def\topskipcorrection - {\simpletopskipcorrection - \vskip-\struttotal - \verticalstrut} - -\def\simpletopskipcorrection - {\ifdim\topskip>\openstrutheight - % == \vskip\topskipgap - \vskip\topskip - \vskip-\openstrutheight - \fi} - -% \def\settopskip % the extra test is needed for the lbr family -% {\topskip\systemtopskipfactor\globalbodyfontsize -% \ifgridsnapping \else -% \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi -% \fi -% \relax % the skip -% \topskipgap\topskip -% \advance\topskipgap -\openstrutheight\relax -% \ifdim\topskip<\strutheightfactor\openlineheight -% \topskip\strutheightfactor\openlineheight\relax -% \fi} - -\def\settopskip % the extra test is needed for the lbr family - {\topskip\systemtopskipfactor\globalbodyfontsize - \ifgridsnapping \else - \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi - \fi - \relax % the skip - \topskipgap\topskip - \advance\topskipgap -\openstrutheight\relax -\ifdim\minimumstrutheight>\zeropoint - \ifdim\topskip<\minimumstrutheight - \topskip\minimumstrutheight\relax - \fi -\else - \ifdim\topskip<\strutheightfactor\openlineheight - \topskip\strutheightfactor\openlineheight\relax - \fi -\fi} - -\def\setmaxdepth - {\maxdepth\systemmaxdepthfactor\globalbodyfontsize} - -\def\normalbaselines - {\baselineskip \normalbaselineskip - \lineskip \normallineskip - \lineskiplimit\normallineskiplimit} - -% \def\setnormalbaselines -% {\ifdim\normallineheight>\zeropoint -% \lineheight\normallineheight -% \fi -% \openlineheight\spacingfactor\lineheight -% \openstrutheight\strutheightfactor\openlineheight -% \openstrutdepth \strutdepthfactor \openlineheight -% \normalbaselineskip\openlineheight -% \!!plus\baselinegluefactor\openlineheight -% \!!minus\baselinegluefactor\openlineheight -% \normallineskip\minimumlinedistance\relax % \onepoint\relax -% \normallineskiplimit\zeropoint\relax -% \normalbaselines} - -\def\setnormalbaselines - {\ifdim\normallineheight>\zeropoint - \lineheight\normallineheight - \fi - \openlineheight\spacingfactor\lineheight - \openstrutheight \ifdim\minimumstrutheight>\zeropoint - \minimumstrutheight % new - \else - \strutheightfactor\openlineheight - \fi - \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth % new - \else - \strutdepthfactor \openlineheight - \fi - \ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint - \openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new - \fi - \normalbaselineskip\openlineheight - \ifgridsnapping\else - \!!plus \baselinegluefactor\openlineheight - \!!minus\baselinegluefactor\openlineheight - \fi - \normallineskip\minimumlinedistance\relax % \onepoint\relax - \normallineskiplimit\zeropoint\relax - \normalbaselines} - -% \def\setspacingfactor#1\to#2\by#3\\% -% {\strutdimen#2\points -% \strutdimen#3\strutdimen -% \edef#1{\withoutpt\the\strutdimen}} -% -% \def\spacing#1% -% {\ifgridsnapping -% %\doifnot{#1}{1}{\showmessage\m!layouts{11}{#1}}% -% \ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{#1}\fi -% \edef\spacingfactor{1}% -% \else -% \edef\spacingfactor{#1}% -% \fi -% \setspacingfactor\systemtopskipfactor \to\topskipfactor \by#1\\% why no \spacingfactor ? -% \setspacingfactor\systemmaxdepthfactor\to\maxdepthfactor\by#1\\% why no \spacingfactor ? -% \setnormalbaselines -% \setstrut} -% -% \def\setspacingfactor#1#2#3% -% {\edef#1{\withoutpt\the\dimexpr#2\points*#3\relax}} - -\def\spacing#1% - {\ifgridsnapping - \ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{#1}\fi - \edef\spacingfactor{1}% - \else - \edef\spacingfactor{#1}% - \fi - %\setspacingfactor\systemtopskipfactor \topskipfactor {#1}% why no \spacingfactor ? - %\setspacingfactor\systemmaxdepthfactor\maxdepthfactor{#1}% why no \spacingfactor ? - \edef\systemtopskipfactor {\withoutpt\the\dimexpr#1\dimexpr\topskipfactor \points}% - \edef\systemmaxdepthfactor{\withoutpt\the\dimexpr#1\dimexpr\maxdepthfactor\points}% - \setnormalbaselines - \setstrut} - -%D Sometimes one needs to freeze the interlinespacing -%D -%D \starttyping -%D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf} -%D \stoptyping - -\let\restoreinterlinespace\relax - -\def\saveinterlinespace - {\edef\restoreinterlinespace - {\lineheight \the\lineheight - \openstrutheight \the\openstrutheight - \openstrutdepth \the\openstrutdepth - \openlineheight \the\openlineheight - \normalbaselineskip \the\normalbaselineskip - \normallineskip \the\normallineskip - \normallineskiplimit\the\normallineskiplimit - \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}% - \noexpand\normalbaselines}} - -% plain definition: -% -% \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} -% -% could be: -% -% \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} - -\ifx\strutbox\undefined - - \newbox\strutbox - - \setbox\strutbox=\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint} - - %\def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} - \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} - -\fi - -\let\normalstrut\strut - -% The double \hbox construction enables us to \backtrack -% boxes. - -% \def\setstrutdimen#1#2#3% % een strut is n.m maal ex -% {\strutdimen\normallineheight % wat niet per se \lineheight -% \strutdimen#2\strutdimen % is omdat een strut lokaal -% \strutdimen#3\strutdimen % kan afwijken van de globale -% \edef#1{\the\strutdimen}} % macro % strut - -% \def\setstrutdimen#1#2#3% % een strut is n.m maal ex -% {\strutdimen\normallineheight % wat niet per se \lineheight -% \strutdimen#2\strutdimen % is omdat een strut lokaal -% \strutdimen#3\strutdimen % kan afwijken van de globale -% \edef#1{\the\strutdimen}} % macro % strut - -% \def\setstrut -% {\setstrutdimen\strutheight\strutheightfactor\spacingfactor -% \setstrutdimen\strutdepth \strutdepthfactor \spacingfactor -% \let\strut=\normalstrut -% \setbox\strutbox=\normalhbox -% {\normalhbox -% {\vrule -% \!!width \strutwidth -% \!!height \strutheight -% \!!depth \strutdepth -% \normalkern-\strutwidth}}} - -% \def\setstrut -% {\setstrutdimen\strutheight\strutheightfactor\spacingfactor -% \setstrutdimen\strutdepth \strutdepthfactor \spacingfactor -% \dosetstrut} - -% \def\setstrut -% {\strutdimen\normallineheight -% \strutdimen\strutheightfactor\strutdimen -% \strutdimen\spacingfactor\strutdimen -% \edef\strutheight{\the\strutdimen}% -% \strutdimen\normallineheight -% \ifgridsnapping -% \advance\strutdimen-\strutheight -% \else -% \strutdimen\strutdepthfactor\strutdimen -% \strutdimen\spacingfactor\strutdimen -% \fi -% \edef\strutdepth{\the\strutdimen}% -% \dosetstrut} - -% interesting, strutdepth is 4.05064pt vs 4.05066pt depending on grid -% nasty rounding problem - -% \def\setstrut -% {% height -% \strutdimen\normallineheight -% \ifdim\minimumstrutheight>\zeropoint -% \strutdimen\minimumstrutheight -% \else -% \strutdimen\strutheightfactor\strutdimen -% \fi -% \strutdimen\spacingfactor\strutdimen -% \edef\strutheight{\the\strutdimen}% -% % depth -% \strutdimen\normallineheight -% \ifgridsnapping -% \ifdim\minimumstrutdepth>\zeropoint -% \strutdimen\minimumstrutdepth -% \else -% \advance\strutdimen-\strutheight -% \fi -% \else -% \ifdim\minimumstrutdepth>\zeropoint -% \strutdimen\minimumstrutdepth -% \else -% \strutdimen\strutdepthfactor\strutdimen -% \fi -% \strutdimen\spacingfactor\strutdimen -% \fi -% \edef\strutdepth{\the\strutdimen}% -% % finish -% \dosetstrut} - -% \def\setstrut -% {% height -% \ifdim\minimumstrutheight>\zeropoint -% \edef\strutheight{\the\dimexpr\spacingfactor\dimexpr\minimumstrutheight}% -% \else -% \edef\strutheight{\the\dimexpr\spacingfactor\dimexpr\strutheightfactor\dimexpr\normallineheight}% -% \fi -% % depth -% \ifgridsnapping -% \ifdim\minimumstrutdepth>\zeropoint -% \edef\strutdepth{\the\dimexpr\minimumstrutdepth}% -% \else -% \edef\strutdepth{\the\dimexpr\normallineheight-\strutheight}% -% \fi -% \else -% \ifdim\minimumstrutdepth>\zeropoint -% \edef\strutdepth{\the\dimexpr\spacingfactor\dimexpr\minimumstrutdepth}% -% \else -% \edef\strutdepth{\the\dimexpr\spacingfactor\dimexpr\strutdepthfactor\dimexpr\normallineheight}% -% \fi -% \fi -% % finish -% \dosetstrut} - -\unexpanded\def\setstrut - {% height - \edef\strutheight - {\the\dimexpr\spacingfactor\dimexpr - \ifdim\minimumstrutheight>\zeropoint - \minimumstrutheight - \else - \strutheightfactor\dimexpr\normallineheight - \fi}% - % depth - \edef\strutdepth - {\the\dimexpr - \ifgridsnapping - \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth - \else - \normallineheight-\strutheight - \fi - \else - \spacingfactor\dimexpr - \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth - \else - \strutdepthfactor\dimexpr\normallineheight - \fi - \fi}% - % finish - \dosetstrut} - -\unexpanded\def\setcharstrut#1% - {\setbox\strutbox\normalhbox{#1}% - \edef\strutheight{\the\strutht}% - \edef\strutdepth {\the\strutdp}% - \dosetstrut} - -% \def\setfontstrut -% {\setcharstrut{(}} -% -% better, since some fonts have small (but descending Q etc) - -\unexpanded\def\setfontstrut - {\setcharstrut{(gplQT}} - -\unexpanded\def\setcapstrut% could be M, but Q has descender - {\setcharstrut{Q}} - -%D Handy for math (used in mathml): - -\def\charhtstrut - {\begingroup - \setcharstrut{GJY}% - \vrule\!!width\zeropoint\!!depth\zeropoint\!!height\strutht - \endgroup} - -\def\chardpstrut - {\begingroup - \setcharstrut{gjy}% - \vrule\!!width\zeropoint\!!depth\strutdp\!!height\zeropoint - \endgroup} - -%D Centered looks nicer: - -% \def\dosetstrut -% {\let\strut\normalstrut -% \setbox\strutbox\normalhbox -% {\normalhbox to \zeropoint -% {% \hss % new, will be option -% \vrule -% \!!width \strutwidth -% \!!height\strutheight -% \!!depth \strutdepth -% \hss}}% -% \struttotal\dimexpr\strutht+\strutdp\relax} -% -% because of all the callbacks in mkiv, we avoid unnecessary boxes ... -% maybe use an attribute so that we can tag boxes that don't need a -% treatment; tests with using an attribute so far have shown that -% it's slower because testing the attribute takes time too - -\def\dosetstrut - {\let\strut\normalstrut - \ifdim\strutwidth=\zeropoint - \setbox\strutbox\normalhbox - {\vrule - \!!width \zeropoint - \!!height\strutheight - \!!depth \strutdepth}% - \else - \setbox\strutbox\normalhbox - {\normalhbox to \zeropoint - {% \hss % new, will be option - \vrule - \!!width \strutwidth - \!!height\strutheight - \!!depth \strutdepth - \hss}}% - \fi - \struttotal\dimexpr\strutht+\strutdp\relax} - -%D The dimen \type {\struttotal} holds the exact size of the -%D strut; occasionally a one scaled point difference can show -%D up with the lineheight. - -%D Sometimes a capstrut comes in handy -%D -%D \starttabulate[|Tl|l|l|] -%D \NC yes \NC normal strut \NC {\showstruts\setupstrut[yes]\strut} \NC \NR -%D \NC no \NC no strut \NC {\showstruts\setupstrut[no]\strut} \NC \NR -%D \NC kap \NC a capital strut (i.e. Q) \NC {\showstruts\setupstrut[cap]\strut} \NC \NR -%D \NC A B \unknown \NC a character strut (e.g. A) \NC {\showstruts\setupstrut[A]\strut} \NC \NR -%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR -%D \stoptabulate - -\def\setupstrut - {\dosingleempty\dosetupstrut} - -\def\dosetupstrut[#1]% yet undocumented, todo: fontstrut - {\processaction - [#1] - [ \v!yes=>\setstrut, - \v!auto=>\setautostrut, - \v!no=>\setnostrut, - \v!cap=>\setcapstrut, - \v!fit=>\setfontstrut, - \v!line=>\setstrut, - \s!default=>\setstrut, - \s!unknown=>\setcharstrut\commalistelement]} - -\def\setteststrut - {\def\strutwidth{.8pt}% - \setstrut} - -\def\autostrutfactor{1.1} - -\def\setautostrut - {\begingroup - \setbox\scratchbox\copy\strutbox - \setstrut - \ifdim\ht\strutbox>\autostrutfactor\ht\scratchbox - \endgroup \setstrut - \else\ifdim\dp\strutbox>\autostrutfactor\dp\scratchbox - \endgroup \setstrut - \else - \endgroup - \fi\fi} - -% simple version -% -% \def\begstrut -% {\relax\ifcase\strutht\else -% \strut -% \normalpenalty\plustenthousand -% \normalhskip\zeropoint -% \ignorespaces -% \fi} -% -% \def\endstrut -% {\relax\ifhmode\ifcase\strutht\else -% \removeunwantedspaces -% \normalpenalty\plustenthousand -% \normalhskip\zeropoint -% \strut -% \fi\fi} - -% when enabled, sigstruts will remove themselves if nothing -% goes inbetween - -\newsignal\strutsignal \setfalse\sigstruts - -\def\begstrut - {\relax\ifcase\strutht\else - \ifconditional\sigstruts - \noindent\horizontalstrut - \normalpenalty\plustenthousand - \normalhskip-\strutsignal - \normalhskip\strutsignal - \else - \strut - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \fi - \expandafter \ignorespaces - \fi} - -\def\endstrut - {\relax\ifhmode\ifcase\strutht\else - \ifconditional\sigstruts - \ifdim\lastskip=\strutsignal - \unskip\unskip\unpenalty\setbox\scratchbox\lastbox - \else - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \strut - \fi - \else - \removeunwantedspaces - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \strut - \fi - \fi\fi} - -\newbox\nostrutbox \setbox\nostrutbox\normalhbox{} % {\normalhbox{}} - -\def\setnostrut - {\setbox\strutbox\copy\nostrutbox - \let\strut\empty - \let\endstrut\empty - \let\begstrut\empty - \let\crlfplaceholder\empty} - -% unsave: -% -% \def\pseudostrut -% {\bgroup -% \setnostrut -% \normalstrut -% \egroup} -% -% try: -% -% \startchemie -% \chemie[ONE,Z0,SB15,MOV1,SB15,Z0][C,C] -% \stopchemie -% -% so: - -\def\pseudostrut - {\noindent} % better: \dontleavehmode - -\let\pseudobegstrut\pseudostrut - -\let\pseudoendstrut\removeunwantedspaces - -\def\resetteststrut - {\let\strutwidth\zeropoint - \setstrut} - -\ifx\setfontparameters\undefined - % problems ! ! ! ! - \def\setfontparameters{\the\everybodyfont} -\fi - -%D Handy: - -\def\baselinedistance{\the\lineheight} - -%D We need \type{\normaloffinterlineskip} because the new -%D definition contains an assignment, and |<|don't ask me -%D why|>| this assignment gives troubles in for instance the -%D visual debugger. - -%D The plain ones: - -\def\offinterlineskip - {\baselineskip-\thousandpoint - \lineskip\zeropoint - \lineskiplimit\maxdimen} - -\def\nointerlineskip - {\prevdepth-\thousandpoint} - -\let\normaloffinterlineskip=\offinterlineskip % knuth's original - -%D My own one: - -\def\offinterlineskip - {\ifdim\baselineskip>\zeropoint - \edef\oninterlineskip - {\baselineskip\the\baselineskip - \lineskip\the\lineskip - \lineskiplimit\the\lineskiplimit - \let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}% - \else - \let\oninterlineskip\setnormalbaselines - \fi - \normaloffinterlineskip} - -\let\oninterlineskip=\relax - -\def\leaveoutervmode - {\ifvmode\ifinner\else - \leavevmode - \fi\fi} - -% We stellen enkele penalties anders in dan Plain TEX: - -% oud -% -% \widowpenalty=\defaultwidowpenalty\relax -% \clubpenalty =\defaultclubpenalty \relax - -\def\resetpenalties#1% - {\ifx#1\undefined\else - #1\minusone - \fi} - -\def\setpenalties#1#2#3% - {\ifx#1\undefined\else % space before #3 prevents lookahead problems, needed when #3=text - #1\numexpr#2+\plusone\relax\space\doexpandedrecurse{\the\numexpr#2\relax}{ #3}\zerocount\relax - \fi} - -\def\doexpandedrecurse#1#2% - {\ifnum#1>\zerocount#2\@EA\doexpandedrecurse\@EA{\the\numexpr#1-1\relax}{#2}\fi} - -%D \macros -%D {keeplinestogether} -%D -%D Dirty hack, needed in margin content that can run of a page. - -\def\keeplinestogether#1% - {\xdef\restoreinterlinepenalty{\global\resetpenalties\interlinepenalties}% - \global\setpenalties\interlinepenalties{#1}\plustenthousand} - -\newif\ifgridsnapping % to be sure - -\def\defaultwidowpenalty {2000} % was: 1000 -\def\defaultclubpenalty {2000} % was: 800 -\def\defaultdisplaywidowpenalty {50} -\def\defaultbrokenpenalty {100} - -\def\defaultgridwidowpenalty {0} -\def\defaultgridclubpenalty {0} -\def\defaultgriddisplaywidowpenalty {0} -\def\defaultgridbrokenpenalty {0} - -% The original approach: -% -% \def\setdefaultpenalties -% {\ifgridsnapping -% \widowpenalty\defaultgridwidowpenalty -% \clubpenalty \defaultgridclubpenalty -% \else -% \widowpenalty\defaultwidowpenalty -% \clubpenalty \defaultclubpenalty -% \fi} -% -% However, we will use setups: - -% to be documented - -\def\nopenalties - {\widowpenalty \zerocount - \clubpenalty \zerocount - \brokenpenalty \zerocount - \doublehyphendemerits\zerocount - \finalhyphendemerits \zerocount - \adjdemerits \zerocount} - -\def\setdefaultpenalties - {\directsetup{\systemsetupsprefix\s!default}} - -\startsetups [\systemsetupsprefix\s!reset] - \resetpenalties\widowpenalties - \resetpenalties\clubpenalties - \resetpenalties\interlinepenalties -\stopsetups - -% we use \directsetup because it's faster and we know there is no csl - -\startsetups [\systemsetupsprefix\s!default] - - \directsetup{\systemsetupsprefix\s!reset} - - \widowpenalty \defaultwidowpenalty - \clubpenalty \defaultclubpenalty - \displaywidowpenalty\defaultdisplaywidowpenalty - \brokenpenalty \defaultbrokenpenalty - -\stopsetups - -\startsetups [\v!grid] [\systemsetupsprefix\s!default] - - \directsetup{\systemsetupsprefix\s!reset} - - \widowpenalty \defaultgridwidowpenalty - \clubpenalty \defaultgridclubpenalty - \displaywidowpenalty\defaultgriddisplaywidowpenalty - \brokenpenalty \defaultgridbrokenpenalty - -\stopsetups - -% as an illustration: - -\startsetups [\systemsetupsprefix\v!strict] - - \directsetup{\systemsetupsprefix\s!reset} - - \setpenalties\widowpenalties2\maxdimen - \setpenalties\clubpenalties 2\maxdimen - \brokenpenalty \maxdimen - -\stopsetups - -\setdefaultpenalties % will happen later in \setuplayout - -% Suggested by GB (not the name -): - -\def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize} % D.A.'s value - -% Bovendien definieren we enkele extra \fill's: - -\def\hfilll{\hskip\zeropoint\!!plus1filll\relax} -\def\vfilll{\vskip\zeropoint\!!plus1filll\relax} - -% De onderstaande hulpmacro's moeten nog eens instelbaar worden -% gemaakt. - -\def\tfskipsize{1em\relax} -\def\tfkernsize{1ex\relax} - -\def\tfskip{\dotfskip\tfskipsize} -\def\tfkern{\dotfkern\tfkernsize} - -\def\dotfskip#1{{\tf\hskip#1}} -\def\dotfkern#1{{\tf\kern #1}} - -% needs a proper \definenarrower or installnarrower - -\newskip\ctxleftskip -\newskip\ctxrightskip -\newskip\ctxmidskip - -\def\dosinglenarrower#1% - {\processaction - [#1] - [ \v!left=>\global\advance\ctxleftskip \@@slleft, - \v!middle=>\global\advance\ctxmidskip \@@slmiddle, - \v!right=>\global\advance\ctxrightskip \@@slright, - \v!reset=>\global\ctxleftskip \zeropoint - \global\ctxmidskip \zeropoint - \global\ctxrightskip\zeropoint, - \v!none=>, - \s!unknown=>\global\advance\ctxmidskip \commalistelement]} - -% \def\donarrower[#1]% hm, can be dorepeat directly -% {\processaction -% [#1] -% [ \v!left=>\global\advance\ctxleftskip \@@slleft, -% \v!middle=>\global\advance\ctxmidskip \@@slmiddle, -% \v!right=>\global\advance\ctxrightskip \@@slright, -% \v!none=>,% handy for delimitedtexts -% \s!unknown=>{\dorepeatwithcommand[#1]\dosinglenarrower}]} - -\def\donarrower[#1]% hm, can be dorepeat directly - {\dorepeatwithcommand[#1]\dosinglenarrower} - -\def\complexstartnarrower[#1]% - {\@@slbefore % was hard coded \par - \bgroup - \global\ctxleftskip \zeropoint - \global\ctxrightskip\zeropoint - \global\ctxmidskip \zeropoint - \processcommalistwithparameters[#1]\donarrower - \advance\leftskip \ctxleftskip - \advance\rightskip \ctxrightskip - \advance\leftskip \ctxmidskip - \advance\rightskip \ctxmidskip - \seteffectivehsize} - -% todo: definenarrower - -\def\simplestartnarrower - {\startnarrower[\v!middle]} - -\definecomplexorsimple\startnarrower - -\def\stopnarrower - {\@@slafter % was hard coded \par / needed, else skips forgotten - \egroup} - -\def\setupnarrower - {\dodoubleargument\getparameters[\??sl]} - -\newdimen\@@effectivehsize \def\effectivehsize {\hsize} -\newdimen\@@effectiveleftskip \def\effectiveleftskip {\leftskip} -\newdimen\@@effectiverightskip \def\effectiverightskip{\rightskip} - -\def\seteffectivehsize - {\setlocalhsize - \@@effectivehsize \localhsize - \@@effectiveleftskip \leftskip - \@@effectiverightskip \rightskip - \let\effectivehsize \@@effectivehsize - \let\effectiveleftskip \@@effectiveleftskip - \let\effectiverightskip\@@effectiverightskip} - -\def\dodefinehbox[#1][#2]% - {\setvalue{hbox#1}##1% - {\hbox to #2{\begstrut##1\endstrut\hss}}} - -\def\definehbox - {\dodoubleargument\dodefinehbox} - -\def\iobox#1#2#3#% here #3# is not really needed - {\vbox\bgroup % we want to return a vbox like the others - \hbox\bgroup% we need to pack the signal with the box - \signalrightpage - \dowithnextboxcontent - {\let\\=\endgraf\forgetall\doifrightpageelse#1#2} - {\box\nextbox\egroup\egroup} - \vbox#3} - -\def\obox{\iobox\raggedleft \raggedright} % outerbox -\def\ibox{\iobox\raggedright\raggedleft} % innerbox - -\def\dosetraggedvbox#1% - {\let\raggedbox\vbox - \processfirstactioninset - [#1] - [ \v!left=>\let\raggedbox\lbox, - \v!right=>\let\raggedbox\rbox, - \v!middle=>\let\raggedbox\cbox, - \v!inner=>\let\raggedbox\ibox, - \v!outer=>\let\raggedbox\obox, - \v!flushleft=>\let\raggedbox\rbox, - \v!flushright=>\let\raggedbox\lbox, - \v!center=>\let\raggedbox\cbox, - \v!no=>\def\raggedbox{\vbox\bgroup\raggedright\let\next=}]} - -\def\dosetraggedhbox#1% - {\let\raggedbox\hbox - \processaction % slow - [#1] - [ \v!left=>\def\raggedbox{\doalignedline\v!left }, - \v!right=>\def\raggedbox{\doalignedline\v!right }, - \v!middle=>\def\raggedbox{\doalignedline\v!middle}, - \v!inner=>\def\raggedbox{\doalignedline\v!inner }, - \v!outer=>\def\raggedbox{\doalignedline\v!outer }, - \v!flushleft=>\def\raggedbox{\doalignedline\v!right }, - \v!flushright=>\def\raggedbox{\doalignedline\v!left }, - \v!center=>\def\raggedbox{\doalignedline\v!middle}]} - -\def\dosetraggedcommand#1% - {\expanded{\dodosetraggedcommand{#1}}} - -% \def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! -% {\let\raggedcommand \relax -% \let\raggedtopcommand \empty -% \let\raggedbottomcommand\empty -% \chardef\raggedoneliner\zerocount -% \doifsomething{#1} -% {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse -% \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse -% \!!donectrue -% \rawprocesscommalist[#1]\dododosetraggedcommand}} - -\newtoks\everyraggedcommand - -\def\raggedcommand{\the\everyraggedcommand} - -\def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! - {\everyraggedcommand \emptytoks - \let\raggedtopcommand \empty - \let\raggedbottomcommand\empty - \chardef\raggedoneliner\zerocount - \doifsomething{#1} - {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse - \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse - \!!donectrue - \rawprocesscommalist[#1]\dododosetraggedcommand}} - -\def\dododosetraggedcommand#1% - {\executeifdefined{\@@ragged@@command\string#1}\relax} - -\def\@@ragged@@command{@@raggedcommand} - -\setvalue{\@@ragged@@command\v!hanging }{\appendtoks\enableprotruding \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nothanging }{\appendtoks\disableprotruding \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!hz }{\appendtoks\enableadjusting \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nohz }{\appendtoks\disableadjusting \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!spacing }{\appendtoks\enablespacehandling - \enablekernhandling \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nospacing }{\appendtoks\disablespacehandling - \disablekernhandling \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!hyphenated }{\appendtoks\dohyphens \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nothyphenated}{\appendtoks\nohyphens \to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!tolerant }{\appendtoks\tolerance3000\relax \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!verytolerant}{\appendtoks\tolerance4500\relax \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!stretch }{\appendtoks\emergencystretch\bodyfontsize\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!left}% - {\if!!donea \appendtoks\veryraggedleft\to\everyraggedcommand - \else \appendtoks\raggedleft \to\everyraggedcommand - \fi - \!!donecfalse} - -\setvalue{\@@ragged@@command\v!right}% - {\if!!donea \appendtoks\veryraggedright\to\everyraggedcommand - \else \appendtoks\raggedright \to\everyraggedcommand - \fi - \!!donecfalse} - -\setvalue{\@@ragged@@command\v!middle}% - {\if!!donec - \if!!doneb \appendtoks\raggedwidecenter\to\everyraggedcommand - \else\if!!donea \appendtoks\veryraggedcenter\to\everyraggedcommand - \else \appendtoks\raggedcenter \to\everyraggedcommand - \fi\fi - \!!donecfalse - \else - \let\raggedbottomcommand\vfilll % bonus, pretty strong - \let\raggedtopcommand \vfilll % used with \framed for - \fi} % instance in tables - -\setvalue{\@@ragged@@command\v!flushleft }{\getvalue{\@@ragged@@command\v!right }} -\setvalue{\@@ragged@@command\v!flushright}{\getvalue{\@@ragged@@command\v!left }} -\setvalue{\@@ragged@@command\v!center }{\getvalue{\@@ragged@@command\v!middle}} - -\setvalue{\@@ragged@@command\v!high}% - {\let\raggedbottomcommand\vfilll} % and since we lack a - -\setvalue{\@@ragged@@command\v!low}% - {\let\raggedtopcommand\vfilll} % proper keyword, but - -\setvalue{\@@ragged@@command\v!lohi}% - {\let\raggedbottomcommand\vfilll % we do support the - \let\raggedtopcommand\vfilll} % ugly laho (lohi) - -\setvalue{\@@ragged@@command\v!no}% - {\appendtoks\raggedright\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!yes}% - {\appendtoks\notragged\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!normal}% - {\appendtoks\notragged\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!inner}% not yet perfect - {\signalrightpage % may interfere - \doifrightpageelse - {\getvalue{\@@ragged@@command\v!right}} - {\getvalue{\@@ragged@@command\v!left}}} - -\setvalue{\@@ragged@@command\v!outer}% not yet perfect - {\signalrightpage % may interfere - \doifrightpageelse - {\getvalue{\@@ragged@@command\v!left}} - {\getvalue{\@@ragged@@command\v!right}}} - -\setvalue{\@@ragged@@command\v!lesshyphenation}% - {\appendtoks\lesshyphens\to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!morehyphenation}% - {\appendtoks\morehyphens\to\everyraggedcommand} - -% compare: -% -% \framed[width=4cm,align=no] {\hfil xxx} -% \framed[width=4cm,align=disable]{\hfil xxx} - -\setvalue{\@@ragged@@command\v!disable}% for one liners - {\appendtoks\raggedright\parfillskip\zeropoint\to\everyraggedcommand} - -\chardef\raggedoneliner\zerocount - -\setvalue{\@@ragged@@command\v!line}% - {\chardef\raggedoneliner\plusone} - -%D Unofficial, may disappear. Now handled directly in the -%D core-rul module. - -% \def\@@startraggedoneliner -% {\ifcase\raggedoneliner\else -% \dontleavehmode\hbox to \hsize \bgroup % hsize added, else useless -% \ifcase\raggedstatus\or\hss\or\hss\fi -% \ignorespaces -% \bgroup -% \aftergroup\removeunwantedspaces -% \fi} - -% \def\@@stopraggedoneliner -% {\ifcase\raggedoneliner\else -% \egroup -% \ifcase\raggedstatus\or\or\hss\or\hss\fi -% \egroup -% \ignorespaces % ? ? ? -% \fi} - -% \def\@@handleoneliner -% {\ifcase\raggedoneliner\else -% \@@startraggedoneliner -% \aftergroup\@@stopraggedoneliner -% \fi} - -% Nog doen: -% -% \goodbreak -> \allowbreak en \dosomebreak{..} in koppen -% -% bij koppen zowieso: \blanko[reset] - -% Nog in commando verwerken: -% -% \voorkeur … la \blanko -% -% Om ongewenste witruimte te voorkomen kan met \dosomebreak{\break} -% een \penalty voor witruimte worden geplaatst. - -\def\removelastskip % a redefinition of plain - {\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi} - -% first version: -% -% \def\dosomebreak#1% -% {\scratchskip\lastskip -% \removelastskip -% %\type{#1}% -% #1\relax -% \ifdim\scratchskip=\zeropoint \else -% \vskip\scratchskip -% \fi} -% -% don't change the next improvement: - -% \def\dosomebreak#1% -% {\endgraf % beware, this forces a newline -% \ifvmode -% \ifdim\lastskip=\zeropoint -% #1\relax -% \else -% \scratchskip\lastskip -% \removelastskip -% #1\relax -% \vskip\scratchskip -% \fi -% \fi} - -% beter, vooral in \vbox; nog in \pagina toepassen s! - -\def\doifoutervmode#1% - {\ifvmode\ifinner\else#1\fi\fi} - -\ifx\dosomebreak\undefined % defined in mkiv - - \def\dosomebreak#1% - {\doifoutervmode - {\scratchskip\lastskip - \removelastskip - %\leavevmode\type{#1}% - #1\relax - \ifdim\scratchskip=\zeropoint % else interference with footnotes - \else - \vskip\scratchskip - \fi}} - -\fi - -\def\forgeteverypar - {\everypar{\the\neverypar}} - -%\def\forgetparindent -% {\forgeteverypar -% \indentfirstparagraphtrue % recently added -% \setupindenting[\v!geen]} - -%\def\forgetparskip -% {\setupwhitespace[\v!geen]} - -\def\forgetparindent - {\forgeteverypar - \indentfirstparagraphtrue % recently added - \let\currentindentation\v!none - \ctxparindent\zeropoint - \parindent\zeropoint\relax} - -\def\forgetparskip - {\let\currentwhitespace\v!none - \ctxparskip\zeropoint - \parskip\zeropoint\relax} - -\def\forgetbothskips - {\tolerance1500 - \leftskip\zeropoint - \rightskip\zeropoint\relax} - -\def\forgetspacing - {\emergencystretch\zeropoint} - -\newif\ifforgotten % rather good signal for inner - -\appendtoks \forgottentrue \to \everyforgetall -\appendtoks \forgetragged \to \everyforgetall -\appendtoks \forgetparskip \to \everyforgetall -\appendtoks \forgetparindent \to \everyforgetall -\appendtoks \forgetbothskips \to \everyforgetall -\appendtoks \forgetspacing \to \everyforgetall % i.v.m. funny spacing in pagebody -\appendtoks \spacing\!!plusone \to \everyforgetall % new per 10/08/2004, else problems in otr / !! needed -\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! - -\def\localvbox#1#% - {\vbox#1\bgroup - \forgetparskip - \setlocalhsize - \hsize\localhsize - \forgetparindent - \forgetbothskips - \forgeteverypar - \let\next=} - -% ach ja, hoort niet hier - -% \unexpanded\def\dostartattributes#1#2#3% -% {\begingroup % geen \bgroup, anders in mathmode lege \hbox -% \doifdefinedelse{#1#2} -% {\def\fontattribute{\getvalue{#1#2}}} -% {\let\fontattribute=\empty}% -% \doifdefinedelse{#1#3} -% {\def\colorattribute{\getvalue{#1#3}}} -% {\let\colorattribute=\empty}% -% \startcolor[\colorattribute]% -% \@EA\doconvertfont\@EA{\fontattribute}} -% -% \unexpanded\def\dostopattributes% -% {\stopcolor -% \endgroup} -% -% \unexpanded\def\doattributes#1#2#3#4% -% {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} - -%D A hardly faster implementation follows. We cannot use -%D \type {csname} testing since the first argument can be -%D anything, even a raw fontswitch. No a real improvement -%D (some 5 seconds on 260 seconds for the maps bibliography). - -\let\dostopattributes\relax % in case these commands end up in an edef - -\unexpanded\def\dostartattributes#1#2#3% - {\begingroup % geen \bgroup, anders in mathmode lege \hbox - \ifcsname#1#3\endcsname - \let\dostopattributes\@@dostopattributes - \startcolor[\csname#1#3\endcsname]% - \else - \let\dostopattributes\@@nostopattributes - \fi - \ifcsname#1#2\endcsname - \expandafter\doconvertfont - \else - \expandafter\gobbleoneargument - \fi{\csname#1#2\endcsname}} - -\newconditional \parbasedattributes - -\def\finishparbasedattributes - {\ifconditional\parbasedattributes - \setfalse\parbasedattributes - \par - \fi} - -\def\dostopparbasedattributes - {\settrue\parbasedattributes - \dostopattributes} - -\unexpanded\def\@@dostopattributes - {\stopcolor - \finishparbasedattributes - \endgroup} - -\unexpanded\def\@@nostopattributes - {\finishparbasedattributes - \endgroup} - -\unexpanded\def\doattributes#1#2#3#4% - {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} - -% An even faster \ETEX\ version: - -\unexpanded\def\dostartattributes#1#2#3% - {\begingroup % geen \bgroup, anders in mathmode lege \hbox - \ifincolor - \ifcsname#1#3\endcsname - \let\dostopattributes\@@dostopattributes - \faststartcolor[\csname#1#3\endcsname]% - \else - \let\dostopattributes\@@nostopattributes - \fi - \else - \let\dostopattributes\@@nostopattributes - \fi - \ifcsname#1#2\endcsname - % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi} - -\unexpanded\def\@@dostopattributes - {\faststopcolor - \finishparbasedattributes - \endgroup} - -\unexpanded\def\@@nostopattributes - {\finishparbasedattributes - \endgroup} - -%D Bonus macro, see core-sec.tex - -\unexpanded\def\dosetfontattribute#1#2% - {\ifcsname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi\empty} - -%D Since this happens a lot, and sometimes large arguments -%D are passed in \type {#4}, we just copy some code: - -\unexpanded\def\doattributes#1#2#3#4% - {\begingroup % geen \bgroup, anders in mathmode lege \hbox - \ifincolor - \ifcsname#1#3\endcsname - \let\dostopattributes\@@dostopattributes - \faststartcolor[\csname#1#3\endcsname]% - \else - \let\dostopattributes\endgroup - \fi - \else - \let\dostopattributes\endgroup - \fi - \ifcsname#1#2\endcsname - % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi - {#4}% - \dostopattributes} - -% Kan vaker worden toegepast en moet bovendien sneller! - -\newskip\leftskipadaption -\newskip\rightskipadaption - -\def\doadaptleftskip#1% - {\dosetleftskipadaption{#1}% - \advance\leftskip \leftskipadaption} - -\def\doadaptrightskip#1% - {\dosetrightskipadaption{#1}% - \advance\rightskip \rightskipadaption} - -\setvalue{@lsa@\v!standard}{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} -\setvalue{@lsa@\v!yes }{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} -\letvalue{@lsa@\v!no }\zeropoint -\letvalue{@lsa@\empty }\zeropoint -\setvalue{@rsa@\v!standard}{\@@slright} -\setvalue{@rsa@\v!yes }{\@@slright} -\letvalue{@rsa@\v!no }\zeropoint -\letvalue{@rsa@\empty }\zeropoint - -% not safe for 2\parindent -% -% \def\dosetleftskipadaption#1% -% {\leftskipadaption -% \ifcsname @lsa@#1\endcsname -% \csname @lsa@#1\endcsname -% \else -% #1% -% \fi -% \relax} - -\def\dosetleftskipadaption#1% - {\edefconvertedargument\ascii{@lsa@#1}% - \leftskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} - -\def\dosetrightskipadaption#1% - {\edefconvertedargument\ascii{@rsa@#1}% - \rightskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} - -\newcount \noftrackedpagestates -\newif \ifpagestatemismatch -\newcount \realpagestateno -\chardef \frozenpagestate \zerocount - -\def\dotrackpagestate#1#2% - {\ifdoublesided \ifinpagebody \else - \doforcedtrackpagestate{#1}{#2}% - \fi \fi} - -\def\doforcedtrackpagestate#1#2% - {\ifcase\frozenpagestate - \global\advance\noftrackedpagestates\plusone - \global\advance#2\plusone - \lazysavetaggedtwopassdata{#1}{\number\noftrackedpagestates}{\number#2}{\noexpand\realfolio}% - %\llap{\infofont\number\noftrackedpagestates/\number#2}% tracing - \fi} - -\def\doifrightpagestateelse#1#2% - {\ifcase\frozenpagestate - \pagestatemismatchfalse - \realpagestateno\realfolio - \ifinpagebody - \ifdoublesided - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \twopassdatafoundtrue - \fi - \else\ifdoublesided - \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound - \realpagestateno\twopassdata\relax - \ifnum\twopassdata=\realpageno \else - \pagestatemismatchtrue - \fi - \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \else - \twopassdatafoundtrue - \fi\fi - \else - \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \iftwopassdatafound - \@EA\firstoftwoarguments - \else - \@EA\secondoftwoarguments - \fi} - -\def\doifforcedrightpagestateelse#1#2% - {\ifcase\frozenpagestate - \pagestatemismatchfalse - \realpagestateno\realfolio - \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound - \realpagestateno\twopassdata\relax - \ifnum\twopassdata=\realpageno \else - \pagestatemismatchtrue - \fi - \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \else - \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \iftwopassdatafound - \@EA\firstoftwoarguments - \else - \@EA\secondoftwoarguments - \fi} - -\def\freezepagestate {\chardef\frozenpagestate\plusone } -\def\defrostpagestate{\chardef\frozenpagestate\zerocount} - -% we can make more of these on top, but how to deal with mixed frozen states - -\definetwopasslist\s!paragraph \newcount \nofraggedparagraphs - -\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} -\def\doifrightpageelse{\doifrightpagestateelse\s!paragraph\nofraggedparagraphs} - -\newcount\pagesignallevel - -\def\startsignalrightpage % one may do a \postsignalrightplace - {\advance\pagesignallevel\plusone - \presignalrightpage - \let\signalrightpage\relax - \let\presignalrightpage\relax - \let\startsignalrightpage\relax - \doifrightpageelse\donothing\donothing - \freezepagestate} - -\def\stopsignalrightpage - {\ifcase\pagesignallevel\or\postsignalrightpage\fi - \advance\pagesignallevel\minusone} - -\def\setraggedparagraphmode - {\signalrightpage\doifrightpageelse} % move it there - -\ifx\swapmargins\undefined \let\swapmargins\undefined \fi % todo - -\def\doifswappedrightpageelse#1#2% alleen in box construction ! - {\doifrightpageelse - {#1} - {\scratchcounter\realpageno - \realpageno\realpagestateno\relax - \swapmargins - \realpageno\scratchcounter - #2}} - -\newbox\signaledrightpage % this way we can avoid interference, i.e. postpone placement - -\def\presignalrightpage {\global\setbox\signaledrightpage\hbox{\signalrightpage}} -\def\postsignalrightpage{\ifvoid\signaledrightpage\else\box\signaledrightpage\fi} - -% The next feature is is used in: -% -% \definenumber[test][way=bypage] -% -% \def\Test -% {\incrementnumber[test]\rawnumber[test]/% -% \incrementnumber[test]\rawnumber[test]/% -% \incrementnumber[test]\rawnumber[test]\space -% \checkpagechange{oeps}\changedpage{oeps}\space -% \ifpagechanged TRUE\else FALSE\fi} -% -% \Test\page \Test\par \Test\page \Test\par \Test\page \Test\page -% -% (adapted from cont-new.tex:) - -\newif\ifpagechanged \let\lastchangedpage\empty - -\def\docheckpagestatechange#1#2#3% - {\pagechangedfalse - \doforcedtrackpagestate{#2}{#3}% - \findtwopassdata{#2}{\number#3}% - \iftwopassdatafound - \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax - \pagechangedtrue - \fi - \fi - \ifpagechanged - \letgvalue{#2:p:#1}\twopassdata - \globallet\lastchangedpage\twopassdata - \else - \globallet\lastchangedpage\realfolio - \fi} - -\def\changedpagestate#1#2% - {\executeifdefined{#2:p:#1}{0}} - -\def\checkpagechange#1{\docheckpagestatechange{#1}\s!paragraph\nofraggedparagraphs} -\def\changedpage #1{\changedpagestate{#1}\s!paragraph} - -% saved struts - -\ifx\savedstrutbox\undefined \newbox\savedstrutbox \fi - -\def\savestrut {\setbox\savedstrutbox\copy\strutbox} -\def\savedstrut{\copy \savedstrutbox} - -% De onderstaande macro's zijn opgenomen in Plain TeX. -% -% \def\raggedright% -% {\rightskip\zeropoint plus2em \spaceskip.3333em \xspaceskip.5em\relax} -% -% \def\ttraggedright% -% {\tttf\rightskip\zeropoint plus2em\relax} -% -% \newif\ifr@ggedbottom -% -% \def\raggedbottom% -% {\topskip 10\points plus60\points \r@ggedbottomtrue} -% -% \def\normalbottom% -% {\topskip 10\points \r@ggedbottomfalse} -% -% en worden hieronder wat aangepast. - -% the three boolean will become obsolete some day in favour -% of \bottomraggedness - -\chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline - -\def\bottomalignlimit{3\lineheight} - -\newif\ifn@rmalbottom -\newif\ifr@ggedbottom -\newif\ifb@selinebottom - -\def\normalbottom - {% \topskip 10pt - \r@ggedbottomfalse} - -\def\raggedbottom - {\chardef\bottomraggedness\zerocount - \n@rmalbottomfalse - \r@ggedbottomtrue - \b@selinebottomfalse - \settopskip} - -\def\alignbottom - {\chardef\bottomraggedness\plusone - \n@rmalbottomtrue - \r@ggedbottomfalse - \b@selinebottomfalse - \settopskip} - -\def\baselinebottom - {\chardef\bottomraggedness\plustwo - \n@rmalbottomfalse - \r@ggedbottomfalse - \b@selinebottomtrue - \settopskip} - -\let\normalbottom=\alignbottom % downward compatible - -% so, the new one will be -% -% \chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline -% -% \def\bottomalignlimit{3\lineheight} % will be settable -% -% \def\raggedbottom {\chardef\bottomraggedness=0 \settopskip} -% \def\alignbottom {\chardef\bottomraggedness=1 \settopskip} -% \def\baselinebottom{\chardef\bottomraggedness=2 \settopskip} -% -% \let\normalbottom =\alignbottom - -% \hyphenpenalty = ( 2.5 * \hsize ) / \raggedness -% \tolerance >= 1500 % was 200 -% \raggedness = 2 .. 6\bodyfontsize - -\chardef\raggedstatus=0 % normal left center right - -\def\leftraggedness {2\bodyfontsize} -\def\rightraggedness {2\bodyfontsize} -\def\middleraggedness {6\bodyfontsize} - -\def\middleraggedness {.5\hsize} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} - -% oeps, hsize can be 0pt in which case we get a strange division - -\def\middleraggedness {\ifdim\hsize=\zeropoint6\bodyfontsize\else.5\hsize\fi} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} - -%D More hyphenation control, will be combined with align -%D setup. - -\def\nohyphens - {\ifx\dohyphens\relax - \edef\dohyphens - {\hyphenpenalty\the\hyphenpenalty - \exhyphenpenalty\the\exhyphenpenalty\relax}% - \fi - \hyphenpenalty\plustenthousand - \exhyphenpenalty\plustenthousand} - -\let\dohyphens\relax - -%D To prevent unwanted side effects, we also have to check -%D for hyphens here: - -% \def\setraggedness#1% -% {\ifnum\tolerance<1500\relax % small values have -% \tolerance1500\relax % unwanted side effects -% \fi -% \spaceskip2.5\hsize % we misuse these registers -% \xspaceskip#1\relax % for temporary storage; -% \divide\spaceskip \xspaceskip % they are changed anyway -% \ifx\dohyphens\relax -% \hyphenpenalty\spaceskip % \else no hyphens is active -% \fi} - -\newskip\@@raggedskipa -\newskip\@@raggedskipb - -\def\setraggedness#1% - {\ifnum\tolerance<1500\relax % small values have - \tolerance1500\relax % unwanted side effects - \fi - \ifx\dohyphens\relax - % this code will be reconsidered / kind of fuzzy (and old) - \@@raggedskipa 2.5\hsize - \@@raggedskipb #1\relax - \divide\@@raggedskipa \@@raggedskipb - \hyphenpenalty\@@raggedskipa - \fi} - -\let\updateraggedskips\relax - -\def\setraggedskips#1#2#3#4#5#6#7% never change this name - {\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% - \updateraggedskips} - -\def\dosetraggedskips#1#2#3#4#5#6#7% - {\chardef \raggedstatus#1\relax - \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 - \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 - \spaceskip #4\relax - \xspaceskip #5\relax - \parfillskip\zeropoint\!!plus#6\relax - \parindent #7\relax} - -% \def\notragged% -% {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} - -% older (context) names: - -\let\spaceamount \interwordspace -\let\emspaceamount\emwidth - -% tracing: - -\def\doshowpardata#1% - {\ifx#1\relax\else - \hbox{\string#1: \the#1}\endgraf - \expandafter\doshowpardata - \fi} - -\def\showpardata - {\edef\thepardata - {\hbox{font: \fontname\font}\endgraf - \doshowpardata - \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace - \hsize \vsize - \leftskip \rightskip - \spaceskip \xspaceskip - \parindent \parfillskip - \hyphenpenalty \exhyphenpenalty - \displaywidowpenalty \widowpenalty \clubpenalty \brokenpenalty - \doublehyphendemerits \finalhyphendemerits \adjdemerits - \relax}% - \begingroup - \dontshowcomposition - \inleftmargin{\vsmash - {\switchtobodyfont[7pt,tt]% - \framed[\c!align=\v!right]{\thepardata}}}% - \endgroup} - -\def\startshowpardata - {\begingroup - \showcomposition - \showstruts\tracepositionstrue \tracingparagraphs\maxdimen - \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} - -\def\stopshowpardata - {\endgraf - \endgroup} - -% \defineXMLenvironment[showpardata] \startshowpardata \stopshowpardata -% \defineXMLsingular [showpardata] \showpardata - -% defaults - -\def\raggedfillamount {1fil} -\def\raggedhalffillamount{.5fil} -\def\raggedspaceamount {\interwordspace} % {.3333em} -\def\raggedxspaceamount {.5em} - -\def\notragged - {\chardef\raggedstatus\zerocount - \leftskip 1\leftskip - \rightskip 1\rightskip - \spaceskip \zeropoint - \xspaceskip \zeropoint - \parfillskip\zeropoint\!!plus\raggedfillamount\relax - \let\updateraggedskips\relax} % new - -\let\forgetragged\notragged - -\def\raggedleft - {\setraggedness\leftraggedness - \setraggedskips1\leftraggedness\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\def\raggedcenter - {\setraggedness\middleraggedness - \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -%D We used to have: -%D -%D \starttyping -%D \def\raggedright -%D {\setraggedness\rightraggedness -%D \setraggedskips{3}{0em}{\rightraggedness}{.3333em}{.5em}{0em}{\parindent}} -%D \stoptyping -%D -%D However, the next alternative, suggested by Taco, is better. - -\def\raggedright - {\setraggedness\rightraggedness - \setraggedskips3\zeropoint\rightraggedness\raggedspaceamount - \raggedxspaceamount\raggedfillamount\parindent} - -\def\veryraggedleft - {\setraggedskips1\raggedfillamount\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -%D When we want the last line to have a natural width: -%D -%D \starttyping -%D \def\veryraggedleft% -%D {\setraggedskips{1}{1fil}{0em}{.3333em}{.5em}{0em}{-1fil}} -%D \stoptyping -%D -%D but this one is not accepted by the macros. - -\def\veryraggedcenter - {\setraggedskips2\raggedfillamount\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\def\veryraggedright - {\setraggedskips3\zeropoint\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\parindent} - -\def\ttraggedright - {\tttf - \setraggedskips3\zeropoint\rightraggedness - \zeropoint\zeropoint\zeropoint\parindent} % \ctxparindent - -%D A bonus one: - -\def\raggedwidecenter - {\setraggedness\middleraggedness - \setraggedskips2\raggedhalffillamount\raggedhalffillamount - \raggedspaceamount\raggedxspaceamount\zeropoint\zeropoint} - -\newif\if@@asragged \@@asraggedtrue % old method - -% todo -% -% \setuplayout[grid=yes,lines=44] \showgrid -% \starttext -% test \vfill test \endgraf \strut \endgraf \vskip-\lineheight \removedepth \pagina test -% \stoptext - -% \setupalign[reset,new,right,old] - -\def\@@align@@rl{\if!!donea\veryraggedleft \else\raggedleft \fi} -\def\@@align@@rr{\if!!donea\veryraggedright \else\raggedright \fi} -\def\@@align@@rc{\if!!donea\veryraggedcenter\else\raggedcenter\fi} - -\setvalue{@@ngila@@\v!broad }{\!!doneatrue} -\setvalue{@@ngila@@\v!wide }{\!!donebtrue} - -\def\installalign#1#2{\setvalue{@@align@@#1}{#2}} % can be used for overloads - -\installalign \v!new {\@@asraggedfalse} -\installalign \v!old {\@@asraggedtrue} -\installalign \empty {} - -\installalign \v!line {\baselinebottom} -\installalign \v!bottom {\raggedbottom} -\installalign \v!height {\normalbottom} -\installalign \v!width {\notragged} -\installalign \v!normal {\notragged} -\installalign \v!yes {\notragged} -\installalign \v!no {\raggedright} -\installalign \v!inner {\if@@asragged \setraggedparagraphmode\@@align@@rl\@@align@@rr \else - \setraggedparagraphmode\@@align@@rr\@@align@@rl \fi} -\installalign \v!outer {\if@@asragged \setraggedparagraphmode\@@align@@rr\@@align@@rl \else - \setraggedparagraphmode\@@align@@rl\@@align@@rr \fi} -\installalign \v!left {\if@@asragged\@@align@@rl\else\@@align@@rr\fi} -\installalign \v!right {\if@@asragged\@@align@@rr\else\@@align@@rl\fi} -\installalign \v!middle {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!flushleft {\if!!donea\veryraggedright \else\raggedright\fi} -\installalign \v!flushright {\if!!donea\veryraggedleft \else\raggedleft \fi} -\installalign \v!flushouter {\setraggedparagraphmode\raggedleft\raggedright} -\installalign \v!flushinner {\setraggedparagraphmode\raggedright\raggedleft} -\installalign \v!center {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!hanging {\enableprotruding} -\installalign \v!nothanging {\disableprotruding} -\installalign \v!hz {\enableadjusting} -\installalign \v!nohz {\disableadjusting} -\installalign \v!spacing {\enablespacehandling \enablekernhandling} -\installalign \v!nospacing {\disablespacehandling\disablekernhandling} -\installalign \v!hyphenated {\dohyphens} -\installalign \v!nothyphenated {\nohyphens} -\installalign \v!new {\@@asraggedfalse} % so new will give you consistency -\installalign \v!reset {\notragged\normalbottom} - -\installalign \v!tolerant {\tolerance3000 \relax} -\installalign \v!verytolerant {\tolerance4500 \relax} -\installalign \v!stretch {\emergencystretch\bodyfontsize} - -\newcount\hyphenminoffset - -\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi - -\def\lesshyphens - {\advance\hyphenminoffset\plusone - \sethyphenationvariables} - -\def\morehyphens - {\ifcase\hyphenminoffset \else - \advance\hyphenminoffset\minusone - \fi - \sethyphenationvariables} - -\installalign \v!lesshyphenation {\lesshyphens} -\installalign \v!morehyphenation {\morehyphens} - -\def\dodosetupalign#1{\csname @@align@@#1\endcsname} -\def\dodosetupngila#1{\csname @@ngila@@#1\endcsname} - -\def\setupalign - {\dosingleargument\dosetupalign} - -\def\dosetupalign[#1]% can be made faster by checking for defined #1 - {\!!doneafalse - \!!donebfalse - \processcommacommand[#1]\dodosetupngila - \processcommacommand[#1]\dodosetupalign} - -% \setupalign[flushleft] \input ward \par % lijnlinks -% \setupalign[right] \input ward \par - -% \setupalign[flushright] \input ward \par % lijnrechts -% \setupalign[left] \input ward \par - -% \setupalign[middle] \input ward \par % centreer -% \setupalign[center] \input ward \par - -\def\startalignment - {\bgroup - \setupalign} - -\def\stopalignment - {\par - \egroup} - -\chardef\alignstrutmode=1 - -% see later for the real definition, which in the simple case is: - -\newtoks \everyleftofalignedline -\newtoks \everyrightofalignedline - -\def\shiftalignedline#1#2#3#4% left, right, inner, outer - {\rightorleftpageaction - {\everyleftofalignedline {\hskip\dimexpr#1+#3\relax}% - \everyrightofalignedline{\hskip\dimexpr#2+#4\relax}} - {\everyleftofalignedline {\hskip\dimexpr#1+#4\relax}% - \everyrightofalignedline{\hskip\dimexpr#2+#3\relax}}} - -% \def\doalignline#1#2% \\ == newline -% {\begingroup -% \setlocalhsize % new -% \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% -% \dowithnextbox -% {\noindentation % was \noindent -% \dontleavehmode % added in marrakesch at TUG 2006 -% \hbox to \localhsize -% {\ifcase\alignstrutmode\or\strut\fi -% \the\everyleftofalignedline -% #1\unhbox\nextbox#2\relax -% \the\everyrightofalignedline}% -% \endgroup} -% \hbox} - -\def\doalignline#1#2% \\ == newline - {\noindentation % was \noindent - \dontleavehmode % added in marrakesch at TUG 2006\begingroup - \begingroup - \setlocalhsize % new - \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% - \dowithnextbox - {\hbox to \localhsize - {\ifcase\alignstrutmode\or\strut\fi - \the\everyleftofalignedline - #1\unhbox\nextbox#2\relax - \the\everyrightofalignedline}% - \endgroup} - \hbox} - -% plain commands - -\ifx\undefined\line \def\line {\hbox to\hsize} \fi -\ifx\undefined\leftline \def\leftline #1{\line{#1\hss}} \fi -\ifx\undefined\rightline \def\rightline #1{\line{\hss#1}} \fi -\ifx\undefined\centerline \def\centerline#1{\line{\hss#1\hss}} \fi - -% directe commando's - -\def\leftaligned {\doalignline \relax \hss } -\def\midaligned {\doalignline \hss \hss } -\def\rightaligned{\doalignline \hss \relax} - -\let\centeraligned\midaligned - -\def\regelbegrensd#1{\limitatetext{#1}{\hsize}{\unknown}} % to be translated - -% indirecte commando's - -\letvalue{\s!do\v!line\v!left }\leftaligned -\letvalue{\s!do\v!line\v!right }\rightaligned -\letvalue{\s!do\v!line\v!middle }\midaligned -\letvalue{\s!do\v!line\v!flushleft }\rightaligned -\letvalue{\s!do\v!line\v!flushright}\leftaligned -\letvalue{\s!do\v!line\v!center }\midaligned - -\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} - -%D Experimental: - -% simple version -% -% \def\doxalignline#1#2% -% {\bgroup -% \setlocalhsize -% \def\\{\egroup\par\doxalignline{#1}{#2}\bgroup}% inefficient -% \dowithnextbox -% {\noindent\hbox to \localhsize -% {\ifcase\alignstrutmode\or\strut\fi -% \signalrightpage -% \doifrightpageelse{#1\unhbox\nextbox#2}{#2\unhbox\nextbox#1}}% -% \egroup} -% \hbox} -% -% \setvalue{\s!do\v!regel\v!binnen}{\doxalignline\relax\hss} -% \setvalue{\s!do\v!regel\v!buiten}{\doxalignline\hss\relax} -% -% more extensive: - -\def\doxalignline#1#2#3#4#5#6% - {\noindentation % was \noindent - \dontleavehmode % added in marrakesch at TUG 2006\begingroup - \begingroup - \setlocalhsize - \def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient - \dowithnextbox - {%\noindent moved up - \hbox to \localhsize - {#1\hskip\ifdone#2\else#3\fi#4% - \hbox to \localhsize - {\the\everyleftofalignedline - \ifcase\alignstrutmode\or\strut\fi - \ifdone#5\unhbox\nextbox#6\else#6\unhbox\nextbox#5\fi - \the\everyrightofalignedline}% - \hss}% - \endgroup} - \hbox} - -\def\doxcheckline - {\signalrightpage\doifrightpageelse\donetrue\donefalse} - -\setvalue{\s!do\v!line\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } -\setvalue{\s!do\v!line\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} -\setvalue{\s!do\v!line\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } -\setvalue{\s!do\v!line\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} -\setvalue{\s!do\v!line\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } -\setvalue{\s!do\v!line\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} -\setvalue{\s!do\v!line\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } -\setvalue{\s!do\v!line\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} - -\setvalue{\s!do\v!line\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} -\setvalue{\s!do\v!line\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } -\setvalue{\s!do\v!line\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} -\setvalue{\s!do\v!line\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } - -% ! ! ! beware, redefining \doalignline gives the wrong results ! ! ! -% -% \def\doalignline{\doxalignline\donefalse++\zeropoint} - -%D Better: - -\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} - -% \def\alignedline#1#2% setting default -% {\csname -% \s!do\v!line -% \ifundefined{\s!do\v!line#1}#2\else#1\fi -% \endcsname} - -\def\alignedline#1#2% setting default - {\csname\s!do\v!line\ifcsname\s!do\v!line#1\endcsname#1\else#2\fi\endcsname} - -%D ... - -\def\dosetuptolerance[#1]% - {\doifinsetelse\v!vertical{#1}% - {\ExpandFirstAfter\processallactionsinset - [#1] - [ \v!verystrict=>\def\bottomtolerance{}, - \v!strict=>\def\bottomtolerance{.050}, - \v!tolerant=>\def\bottomtolerance{.075}, - \v!verytolerant=>\def\bottomtolerance{.100}]}% - {\ExpandFirstAfter\processallactionsinset - [#1] - [ \v!stretch=>\emergencystretch\bodyfontsize, - \v!space=>\spaceskip.5em\!!plus.25em\!!minus.25em\relax, - \v!verystrict=>\tolerance 200, - \v!strict=>\tolerance1500, - \v!tolerant=>\tolerance3000, - \v!verytolerant=>\tolerance4500]}} - -\def\setuptolerance - {\dosingleargument\dosetuptolerance} - -% \def\woordrechts -% {\groupedcommand{\hfill\hbox}{\parfillskip\zeropoint}} - -% beware: \wordright{whatever\kern-\rightskip} should work! -% so, no funny boxing here - -\def\dowordright[#1]% - {% don't change - \groupedcommand - {\removeunwantedspaces - \hfill - \allowbreak % changed back from \hskip\zeropoint - \strut - \hfill - \quad % decent spacing - \hbox} - {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}% - \parfillskip\zeropoint - %\finalhyphendemerits\zerocount % yes or no - \par}} - -\def\wordright - {\dosingleempty\dowordright} - -% \dorecurse{5}{something } \wordright{--someone} \endgraf -% \dorecurse{6}{something } \wordright{--someone} \endgraf -% \dorecurse{7}{something } \wordright{--someone} \endgraf -% -% \dorecurse{5}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{6}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{7}{something } \wordright{--someone else entirely} \endgraf -% -% \wordright[\rightskip]{whatever} - -% \simplealignedbox{2cm}{right}{x} - -\setvalue{\s!simple\c!align\v!right }#1#2{\hbox to #1{#2\hss}} -\setvalue{\s!simple\c!align\v!left }#1#2{\hbox to #1{\hss#2}} -\setvalue{\s!simple\c!align\v!flushright }#1#2{\hbox to #1{\hss#2}} -\setvalue{\s!simple\c!align\v!flushleft }#1#2{\hbox to #1{#2\hss}} -\setvalue{\s!simple\c!align\v!middle }#1#2{\hbox to #1{\hss#2\hss}} - -\def\simplealignedbox#1{\executeifdefined{\s!simple\c!align#1}{\getvalue{\s!simple\c!align\v!right}}} - -%D \macros -%D {pushindentation,popindentation} -%D -%D The pushing and popping is done by: - -\newbox\indentationboxA -\newbox\indentationboxB - -\def\pushindentation - {\bgroup - \ifhmode - \unskip - \setbox\indentationboxA\lastbox % get \strut if present - \unskip - \setbox\indentationboxB\lastbox % get \indent generated box - \unskip - \else - \hskip\zeropoint % switch to horizontal mode - \unskip - \setbox\indentationboxA\lastbox % get \indent generated box - \setbox\indentationboxB\emptybox - \fi} - -\def\popindentation - {\box\indentationboxB\box\indentationboxA % put back the boxes - \egroup} - -%D The only complication lays in \type{\strut}. In \PLAIN\ -%D \TEX\ a \type{\strut} is defined as: -%D -%D \starttyping -%D \def\strut% -%D {\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} -%D \stoptyping -%D -%D But what is a \type{\strut}? Normally it's a rule of width -%D zero, but when made visual, it's a rule and a negative skip. -%D The mechanism for putting things in the margins described -%D here cannot handle this situation very well. One -%D characteristic of \type{\strut} is that the \type{\unhcopy} -%D results in entering horizontal mode, which in return leads -%D to some indentation. -%D -%D To serve our purpose a bit better, the macro \type{\strut} -%D can be redefined as: -%D -%D \starttyping -%D \def\strut -%D {\relax\ifmmode\else\hskip0pt\fi\copy\strutbox} -%D \stoptyping -%D -%D Or more compatible: -%D -%D \starttyping -%D \def\strut -%D {\relax\ifmmode -%D \copy\strutbox -%D \else -%D \bgroup\setbox\strutbox=\normalhbox{\box\strutbox}\unhcopy\strutbox\egroup -%D \fi} -%D \stoptyping -%D -%D In \CONTEXT\ however we save some processing time by putting -%D an extra \type{\hbox} around the \type{\strutbox}. - -% moved from page-lin.tex to here (due to visualization added -% in august 2003) -% -% \unexpanded \def\crlf -% {\ifhmode\unskip\else\strut\fi\ifcase\raggedstatus\hfil\fi\break} - -\unexpanded \def\crlf - {\ifhmode - \unskip - \prewordbreak\crlfplaceholder - \ifcase\raggedstatus\hfil\or\or\or\hfil\fi - \break - \else - \crlfplaceholder - \endgraf - \fi} - -\def\crlfplaceholder - {\strut} - -\def\settestcrlf - {\def\crlfplaceholder - {\hbox to \zeropoint - {\strut{\infofont\kern.25em}\lohi{\infofont CR}{\infofont LF}\hss}}} - -%D \starttyping -%D % \setuplayout[gridgrid=yes] \showgrid -%D -%D \startbuffer -%D test 1\crlf -%D test 2\crlf -%D -%D \crlf test 3 -%D -%D test 4\crlf -%D test 5 -%D -%D \crlf -%D \crlf -%D \crlf -%D test 6 -%D \stopbuffer -%D -%D \hbox -%D {\hsize5em -%D \ruledvtop{\getbuffer}\enspace -%D \ruledvtop{\showstruts\getbuffer}\enspace -%D \hsize15em \setuptyping[before=,after=]% -%D \ruledvtop{\typebuffer}} -%D \stoptyping - -\def\opeenregel % to be used grouped - {\def\crlf{\removelastspace\space}\let\\\crlf} - -\def\showstruts - {\setteststrut - \settestcrlf} - -\def\definehspace - {\dotripleempty\dodefinehspace} - -\def\dodefinehspace[#1][#2][#3]% #1 = optional namespace - {\ifthirdargument - \setvalue{\??hs#1:#2}{#3}% - \else - \setvalue{\??hs:#1}{#2}% - \fi} - -\unexpanded\def\hspace - {\dodoubleempty\dohspace} - -%\def\dohspace[#1][#2]% -% {\ifhmode -% \removeunwantedspaces -% \hskip -% \ifsecondargument -% \hspaceamount{#1}{#2}% -% \else -% \hspaceamount\empty{\iffirstargument#1\else\s!default\fi}% -% \fi -% \expandafter\ignorespaces -% \fi} - -\def\dohspace[#1][#2]% - {\ifsecondargument - \dodohspace[#1][#2]% - \else\iffirstargument - \hspace[][#1]% - \else - \hspace[][\s!default]% - \fi\fi} - -% \def\dodohspace[#1][#2#3]% -% {\ifhmode -% \removeunwantedspaces -% \doifelse{#2}{-} -% {{\scratchskip\hspaceamount{#1}{#3}\hskip-\scratchskip}} -% {\hskip\hspaceamount{#1}{#2#3}}% -% \expandafter\ignorespaces -% \fi} -% -% not needed, tex handles -- as + - -\def\dodohspace[#1][#2]% - {\ifhmode - \removeunwantedspaces - \hskip\hspaceamount{#1}{#2}% - \expandafter\ignorespaces - \fi} - -\def\hspaceamount#1#2% - {\executeifdefined{\??hs#1:#2}{\executeifdefined{\??hs:#2}\zeropoint}} - -\definehspace [\v!small] [.25\emspaceamount] -\definehspace [\v!medium] [.5\emspaceamount] -\definehspace [\v!big] [1\emspaceamount] -\definehspace [\v!normal] [1\spaceamount] -\definehspace [\v!default] [\spaceamount] - -%D Taken from Taco's math module (cq. \AMS\ macros), but -%D adapted to \type {\hspace}: - -\unexpanded\def\textormathspace#1#2#3% - {\ifmmode\mskip#1#2\else\kern#1\hspaceamount\empty{#3}\fi\relax} - -\newmuskip\hairmuskip \hairmuskip=.15mu - -\def\hairspace {\textormathspace+\hairmuskip{.5}} -\def\thinspace {\textormathspace+\thinmuskip 1} -\def\medspace {\textormathspace+\medmuskip 2} -\def\thickspace {\textormathspace+\thickmuskip3} -\def\neghairspace {\textormathspace-\thinmuskip{.5}} -\def\negthinspace {\textormathspace-\thinmuskip 1} -\def\negmedspace {\textormathspace-\medmuskip 2} -\def\negthickspace{\textormathspace-\thickmuskip3} - -% needed for unicode: - -\def\twoperemspace {\hskip\dimexpr\emwidth/2\relax} % == \enspace -\def\threeperemspace {\hskip\dimexpr\emwidth/3\relax} -\def\fourperemspace {\hskip\dimexpr\emwidth/4\relax} -\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} % goodie -\def\sixperemspace {\hskip\dimexpr\emwidth/6\relax} -\def\figurespace {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this -\def\punctuationspace {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} -\def\ideographicspace {\hskip\dimexpr\emwidth/1\relax} -\def\ideographichalffillspace{\hskip\dimexpr\emwidth/2\relax} -%def\nobreakspace {\penalty\plustenthousand\space} -\def\nobreakspace {\penalty\plustenthousand\kern\interwordspace} -\def\narrownobreakspace {\penalty\plustenthousand\thinspace} -%def\zerowidthnobreakspace {\penalty\plustenthousand\hskip\zeropoint} -\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} -\def\zerowidthspace {\hskip\zeropoint} - -\definehspace[.5][.1250\emspaceamount] % could also be [.1250\spaceamount] -\definehspace[1] [.1667\emspaceamount] -\definehspace[2] [.2222\emspaceamount] -\definehspace[3] [.2777\emspaceamount] - -\let \, \thinspace -\let \: \medspace -\let \; \thickspace -\let \! \negthinspace - -% this will become an alternative bunch of \blank settings -% -% \startlines -% \scratchskip=.23pt plus 10pt minus 4pt \relax \number\scratchskip \space \the\scratchskip -% \setsimplifiedskip\scratchskip1 \number\scratchskip \space \the\scratchskip -% \setsimplifiedskip\scratchskip2 \number\scratchskip \space \the\scratchskip -% \getsimplifiedskip\scratchskip\scratchcounter \number\scratchcounter -% \stoplines -% -% \hrule width10cm \endgraf -% \discardedskip{10pt} -% \retainedskip {4pt} -% \discardedskip {5pt} -% \hrule width10cm \endgraf -% \blockedskip{0pt} -% \discardedskip{10pt} -% \retainedskip {4pt} -% \discardedskip {5pt} -% \hrule width10cm \endgraf -% \frozenskip {4cm} -% \hrule width10cm \endgraf -% \vskip10pt -% \hrule width10cm \endgraf - -% ! ! ! etex only, evt splitskip macro gebruiken (syst-new) - -\newskip\simplifiedskip -\newskip\simplifiedcounter - -\chardef\@@discardedskip1 -\chardef\@@retainedskip 2 -\chardef\@@forcedskip 3 -\chardef\@@blockedskip 4 -\chardef\@@frozenskip 5 % after heads, no break - -\def\setsimplifiedskip#1#2% - {#1\dimexpr(10\dimexpr(#1/10)) plus \gluestretch#1 minus \glueshrink#1\relax - \advance#1\numexpr(#2)sp\relax} - -\def\getsimplifiedskip#1#2% - {\simplifiedskip#1\relax - \ifzeropt\simplifiedskip % \ifdim\simplifiedskip=\zeropoint - #2\zerocount - \else - \simplifiedcounter\dimexpr10\dimexpr#1/10\relax\relax - \advance\simplifiedskip-\simplifiedcounter - #2\number\simplifiedskip\relax - \fi} - -\def\conditionalskip#1#2% - {\scratchskip#1\relax - \setsimplifiedskip\scratchskip#2\relax - \vskip\scratchskip\relax} - -\def\defrostskip - {\scratchskip\lastskip\penalty50000\normalvskip-\scratchskip\penalty50000\relax} - -\def\frozenskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \fi} - -\def\discardedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@discardedskip - \or % discard - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@discardedskip - \fi - \or % retain - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@discardedskip - \fi - \or % forced - \conditionalskip{#1}\@@discardedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -\def\retainedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@retainedskip - \or % discard - \normalvskip-\lastskip - \conditionalskip{#1}\@@retainedskip - \or % retain - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@retainedskip - \fi - \or % forced - \conditionalskip{#1}\@@retainedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -\def\forcedskip#1% - {\endgraf - \ifvmode - \conditionalskip{#1}\@@forcedskip - \fi} - -\def\blockedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@blockedskip - \or % discard - \conditionalskip{#1}\@@blockedskip - \or % retain - \conditionalskip{#1}\@@blockedskip - \or % forced - \conditionalskip{#1}\@@blockedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -% beware, changing this will break some code (like pos/backgrounds) - -\newtoks\everyfirstparagraphintro -\newtoks\everynextparagraphintro -\newtoks\@@everyparagraphtoks - -\chardef\everyparagraphintro\zerocount - -\def\setupparagraphintro - {\dodoubleempty\dosetupparagraphintro} - -\def\dosetupparagraphintro[#1][#2]% - {\processallactionsinset - [#1] - [ \v!reset=>\global\chardef\everyparagraphintro\zerocount - \global\everyfirstparagraphintro\emptytoks - \global\everynextparagraphintro \emptytoks, - \v!first=>\global\chardef\everyparagraphintro\plusone - \doglobal\appendtoks#2\to\everyfirstparagraphintro, - \v!next=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plusone\fi - \doglobal\appendtoks#2\to\everynextparagraphintro, - \v!each=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plustwo\fi - \doglobal\appendtoks#2\to\everyfirstparagraphintro - \doglobal\appendtoks#2\to\everynextparagraphintro]} - -%D We can say: -%D -%D \starttyping -%D \setupparagraphintro[first][\index{Knuth}] -%D \stoptyping -%D -%D Maybe more convenient is: -%D -%D \starttyping -%D \flushatparagraph{\index{Zapf}} -%D \stoptyping - -\def\flushatparagraph#1% - {\global\chardef\everyparagraphintro\plusone - \global\appendtoks{#1}\to\everyfirstparagraphintro} - -% \def\doinsertparagraphintro -% {\ifcase\everyparagraphintro\relax -% % no data -% \@@everyparagraphtoks\emptytoks -% \or -% % first data -% \global\chardef\everyparagraphintro\plustwo -% \@@everyparagraphtoks\everyfirstparagraphintro -% \global\everyfirstparagraphintro\emptytoks -% \or -% % next data -% \@@everyparagraphtoks\everynextparagraphintro -% \fi -% \the\@@everyparagraphtoks} - -\def\doinsertparagraphintro - {\begingroup - \everypar\emptytoks - \ifcase\everyparagraphintro\relax - % no data - \@@everyparagraphtoks\emptytoks - \or - % first data - \global\chardef\everyparagraphintro\plustwo - \@@everyparagraphtoks\everyfirstparagraphintro - \global\everyfirstparagraphintro\emptytoks - \or - % next data - \@@everyparagraphtoks\everynextparagraphintro - \fi - \the\@@everyparagraphtoks - \endgroup} - -\def\insertparagraphintro - {\ifcase\everyparagraphintro\else\@EA\doinsertparagraphintro\fi} - -% \appendtoksonce\insertparagraphintro\to\everypar % should come last - -%D \starttyping -%D \setupparagraphintro[first][\hbox to 3.5em{\tt FIRST \hss}] -%D \setupparagraphintro[first][\hbox to 3.5em{\tt TSRIF \hss}] -%D \setupparagraphintro[next] [\hbox to 3.5em{\tt NEXT \hss}] -%D \setupparagraphintro[next] [\hbox to 3.5em{\tt TXEN \hss}] -%D \setupparagraphintro[each] [\hbox to 3.0em{\tt EACH \hss}] -%D \setupparagraphintro[each] [\hbox to 3.0em{\tt HCEA \hss}] -%D -%D some paragraph \par -%D some paragraph \par -%D some paragraph \par -%D -%D \definelabel[parnumber] -%D -%D \setupparagraphintro[reset,each][\inleft{\slxx\parnumber}] -%D -%D some paragraph \par -%D some paragraph \par -%D some paragraph \par -%D \stoptyping - -%D \macros -%D {flushatnextpar} -%D -%D This macro collects data that will be flushed at the next paragraph. -%D By using this macro you can avoid interfering nodes (writes, etc). - -\newbox \postponednodedata - -\def\flushatnextpar - {\bgroup - \dowithnextbox - {\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}% - \hbox} - -\def\flushpostponednodedata - {\ifvoid\postponednodedata\else - \hbox{\smashedbox\postponednodedata}% - \fi} - -% Very nasty but needed for margin stuff inside colored -% paragraphs. - -\let\normalvadjust\vadjust - -% \def\graphicvadjust % bad, those low level color calls here -% {\dowithnextbox -% {\normalvadjust -% {\dostartgraphicgroup -% \localstarttextcolor -% \unvbox\nextbox -% \localstoptextcolor -% \dostopgraphicgroup}}% -% \vbox} - -% test this prikkels/pascal margin text before heads (mode -% 1) as well as uitwerkingen (mode 2) - -%chardef\graphicvadjustmode=0 % fake -%chardef\graphicvadjustmode=1 % normal -\chardef\graphicvadjustmode=2 % normal + compensate (== default) - -\def\graphicvadjust % bad, those low level color calls here - {\dowithnextboxcontent - {\forgetall} - {\ifcase\graphicvadjustmode \@EA \fakedvadjust \else \@EA\normalvadjust \fi - {\dostartgraphicgroup % don't ask - \localstarttextcolor - \unvbox\nextbox - \localstoptextcolor % don't ask - \dostopgraphicgroup - \ifcase\graphicvadjustmode \or \or - % corrects for one line paragraphs - \nointerlineskip - \kern-\struttotal - \nointerlineskip - \verticalstrut - \fi}}% - \vbox} - -%D This works only in a properly strutted line, and is meant -%D for deeply burried operations, like in heads. - -\def\fakedvadjust - {\dowithnextbox - {\setbox\nextbox\hbox{\llap{\lower\strutdepth\box\nextbox}}% - \smashedbox\nextbox}% - \vtop} - -\def\flexiblespaceamount#1#2#3% - {#1\interwordspace - \!!plus#2\interwordstretch - \!!minus#3\interwordshrink} - -\def\fixedspaceamount#1% - {#1\interwordspace} - -%D This is a dangerous feature because it makes the \TEX\ source -%D less portable, i.e. any parser now needs to apply exactly the -%D same algorithm when it wants to interpret the source. We -%D strongly recommend not to mention this feature in manuals! It's -%D provided for users who are hooked to such a mechanism. -%D -%D \starttyping -%D \setupsorting[logo][next=\autoinsertnextspace] \logo[TEX]{\TeX} -%D -%D bla bla \TEX bla bla \TEX (bla) bla (\TEX) -%D \stoptyping - -\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} - -\def\doautoinsertnextspace % slightly extended version of a user supplied macro - {\ifx\nexttoken \bgroup\else \ifx\nexttoken\begingroup\else - \ifx\nexttoken \egroup\else \ifx\nexttoken \endgroup\else - \ifx\nexttoken \/\else \ifx\nexttoken /\else \ifx\nexttoken ~\else - \ifx\nexttoken \ \else \ifx\nexttoken \blankspace\else \ifx\nexttoken \space\else - \ifx\nexttoken .\else \ifx\nexttoken ,\else - \ifx\nexttoken !\else \ifx\nexttoken ?\else - \ifx\nexttoken :\else \ifx\nexttoken ;\else - \ifx\nexttoken '\else \ifx\nexttoken "\else - \ifx\nexttoken )\else \ifx\nexttoken -\else \ifx\nexttoken |\else - \ifx\nexttoken \%\else \ifx\nexttoken \&\else - \space - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -% moved from page-lin - -\def\installspacehandler#1#2% needs to set \obeyedspace - {\setvalue{\??sr#1}{#2}} - -\installspacehandler \v!on - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}% - \let\ =\obeyedspace} - -\installspacehandler \v!yes - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode \normalspace }}% - \let\ =\obeyedspace} - -\installspacehandler \v!off - {\normalspaces - \let\obeyedspace\normalspace - \let\ =\normalspace} - -\installspacehandler \v!fixed - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode\fixedspace}}% - \let\ =\obeyedspace} - -\def\activatespacehandler#1% - {\executeifdefined{\??sr#1}{\activatespacehandler\v!off}} - -% moved from page-lin - -%D When spacing is active we need to handle commands in -%D a special way: -%D -%D \starttyping -%D \setuplines[space=on] -%D -%D \startlines -%D Let's talk about this{\ttsl\gobbleoneargument or}that. -%D \stoplines -%D -%D \startlines -%D Let's talk about this{\getvalue{ttsl}or}that. -%D \stoplines -%D \stoptyping -%D -%D One can indent in several ways: -%D -%D \starttyping -%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even -%D -%D \startlines -%D first -%D second -%D third -%D fourth -%D \stoplines -%D \stoptyping - -\def\setuplines - {\dodoubleargument\getparameters[\??rg]} - -\def\startlines - {\@@rgbefore - \pushmacro\checkindentation - \whitespace - %\page[\v!preference]} gaat mis na koppen, nieuw: later \nobreak - \begingroup - \setupindenting[\@@rgindenting]% - \typesettinglinestrue - \setupwhitespace[\v!none]% - \obeylines - \ignorespaces - \gdef\afterfirstobeyedline % tzt two pass, net als opsomming - {\gdef\afterfirstobeyedline - {\nobreak - \doifnot\@@rgoption\v!packed{\global\let\afterfirstobeyedline\relax}}}% - \def\obeyedline - {\par - \futurelet\next\dobetweenthelines}% - \activatespacehandler\@@rgspace - \GotoPar} - -\def\stoplines - {\endgroup - \popmacro\checkindentation - \@@rgafter} - -\def\dobetweenthelines - {\doifmeaningelse\next\obeyedline - {\@@rginbetween} - {\afterfirstobeyedline}} - -\setuplines - [\c!option=, - \c!before=\blank, - \c!after=\blank, - \c!inbetween=\blank, - \c!indenting=\v!no, - \c!space=\v!default] - -\def\emptylines - {\dosingleempty\doemptylines} - -\def\doemptylines[#1]% - {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} - -\setupwhitespace - [\v!none] - -% still old-fashioned - -\indenting - [\v!never] - -\setupindenting - [\v!none] - -\setupblank - [\v!standard, - \v!big] - -\defineblank[\v!default] [\currentblank] -\defineblank[\v!before] [\v!default] -\defineblank[\v!inbetween][\v!default] -\defineblank[\v!after] [\v!before] - -\setupinterlinespace - [\c!minheight=0pt, % only special purpose - \c!mindepth=0pt, % only special purpose - \c!height=.72, - \c!depth=.28, - \c!top=1.0, - \c!bottom=0.4, - \c!distance=1pt, - \c!line=2.8ex, - \c!stretch=0] - -\setupnarrower - [\c!before=\endgraf, - \c!after=\endgraf, - \c!left=1.5em, - \c!right=1.5em, - \c!middle=1.5em] - -\setuptolerance - [\v!horizontal,\v!verystrict] - -\setuptolerance - [\v!vertical,\v!strict] - -\setupalign - [\v!bottom, - \v!width] - -\setupspacing - [\v!packed] - -\protect \endinput diff --git a/tex/context/base/core-spa.mkiv b/tex/context/base/core-spa.mkiv deleted file mode 100644 index 2b17cad11..000000000 --- a/tex/context/base/core-spa.mkiv +++ /dev/null @@ -1,4250 +0,0 @@ -%D \module -%D [ file=core-spa, -%D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Spacing, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Core Macros / Spacing} - -% to be sorted out: dependencies, order of initialization / also some dutch code here -% more documentation in the mkii file - -\unprotect - -% some will move to core-var - -\newif \ifgridsnapping -\newif \iffuzzyvskip -\let \fuzzyvskip \gobbleoneargument -\let \removelastfuzzyvskip \relax - -\let \startbaselinecorrection \relax -\let \stopbaselinecorrection \relax -\let \baselinecorrection \relax -\let \offbaselinecorrection \relax - -\appendtoks \spacing\plusone \to \everybodyfont -\appendtoks \presetnormallineheight \to \everybodyfont -\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant -\appendtoks \setstrut \to \everybodyfont % check if redundant -\appendtoks \settopskip \to \everybodyfont -\appendtoks \setmaxdepth \to \everybodyfont -\appendtoks \simplesetupindenting \to \everybodyfont -\appendtoks \simplesetupblank \to \everybodyfont -\appendtoks \simplesetupwhitespace \to \everybodyfont -%appendtoks \checknotes \to \everybodyfont % not -\appendtoks \simplesetupspacing \to \everybodyfont % nieuw -\appendtoks \setrelativeinterlinespace \to \everybodyfont - -\appendtoks \updateraggedskips \to \everyfontswitch % under test -\prependtoks \let\par\endgraf \to \everypagebody % see \fillinline -\appendtoks \simplesetupspacing \to \everydefinedfont - -% if you want to hyphenate the first word of a paragraph ... \appendtoks\hskip0pt\to\everypar - -\def\stelfactorenin - {\simplesetupwhitespace - \simplesetupblank - \settopskip - \setmaxdepth} - -\def\softbreak - {\relax\ifhmode\hskip\parfillskip\break\fi} - -\let\poplastnode\relax - -\def\pushlastnode - {\ifdim\lastskip=\zeropoint - \ifnum\lastpenalty=\zerocount - \ifnum\lastkern=\zerocount - \let\poplastnode\relax - \else - \edef\poplastnode{\kern\the\lastkern\relax}\kern-\lastkern % untested - \fi - \else - \edef\poplastnode{\penalty\the\lastpenalty\relax}\nobreak % untested - \fi - \else - \edef\poplastnode{\vskip\the\lastskip\relax}\vskip-\lastskip % \removelastskip - \fi} - -%D The dreadful sequence \type {\bgroup} \unknown\ -%D \type {\carryoverpar} \unknown\ \type {\egroup} is needed -%D when for instance sidefloats are used in combination with -%D something that starts with a group. This is because -%D otherwise the indentation as set (by the output routine) -%D inside the group are forgotten afterwards. (I must -%D not forget its existence). - -\global\let\carriedoverpar\relax - -\def\carryoverpar#1% - {\normalexpanded % \scratchtoks{#1}% - {\noexpand#1% \the\scratchtoks - \hangindent\the\hangindent - \hangafter \the\hangafter - \parskip \the\parskip - \leftskip \the\leftskip - \rightskip \the\rightskip}} - -%D A quick way to determine left|/|middle|/|right states -%D (experimental). - -\setvalue{\??as\v!left }{0} -\setvalue{\??as\v!middle}{1} -\setvalue{\??as\v!right }{2} - -\def\setalignmentswitch#1% - {\chardef\alignmentswitch0\csname\??as#1\endcsname\relax} - -%D There are two ways to influence the interline spacing. The -%D most general and often most consistent way is using -%D -%D \showsetup{setupinterlinespace} -%D -%D For instance -%D -%D \starttyping -%D \setupinterlinespace[line=2.8ex] -%D \stoptyping -%D -%D This setting adapts itself to the bodyfontsize, while for -%D instance saying -%D -%D \starttyping -%D \setupinterlinespace[line=12pt] -%D \stoptyping -%D -%D sets things fixed for all sizes, which is definitely not -%D what we want. Therefore one can also say: -%D -%D \starttyping -%D \definebodyfontenvironment[9pt][interlinespace=11pt] -%D \stoptyping -%D -%D One can still use \type{\setupinterlinespace} (without -%D arguments) to set the interline space according to the -%D current font, e.g. a \type{\bfa}. - -\newif\iflocalinterlinespace - -% font-ini - -\ifx\bodyfontinterlinespecs\undefined - - \let\bodyfontinterlinespecs\empty - \let\bodyfontinterlinespace\empty - -\fi - -\def\presetnormallineheight - {\edef\normallineheight{\@@itline}% -% done elsewhere : \spacing\!!plusone % new per 10/08/2004, else problems in otr / !! needed - \iflocalinterlinespace \else - \doifdefined\bodyfontinterlinespecs - {\doifsomething\bodyfontinterlinespace - {\edef\normallineheight{\bodyfontinterlinespace}}}% - \fi} - -\def\setupspecifiedinterlinespace[#1]% - {\getparameters[\??it][#1]% - \scratchdimen0\@@itheight\points - \advance\scratchdimen 0\@@itdepth\points - \ifdim\scratchdimen>\onepoint - \showmessage\m!layouts{10}{\@@itheight,\@@itdepth}% - \let\@@itheight\strutheightfactor - \let\@@itdepth \strutdepthfactor - \else - \let\strutheightfactor\@@itheight - \let\strutdepthfactor \@@itdepth - \fi - \let\minimumstrutheight \@@itminheight - \let\minimumstrutdepth \@@itmindepth - \let\minimumlinedistance\@@itdistance - \let\normallineheight \@@itline % let ! ! ! ! ! ivm ex - \doifelse\@@ittop\v!height % new, topskip does more bad than good - {\let\topskipfactor \@@itheight} - {\let\topskipfactor \@@ittop }% - \let\maxdepthfactor \@@itbottom - \let\baselinegluefactor \@@itstretch - \setfontparameters % redundant, can be \setstrut, test first - \updateraggedskips} % yes indeed - -\let\currentrelativeinterlinespace\empty - -\def\setuprelativeinterlinespace[#1]% - {\processallactionsinset - [#1] - [ \v!on=>\oninterlineskip, - \v!off=>\offinterlineskip, - \v!reset=>\let\currentrelativeinterlinespace\empty - \let\setrelativeinterlinespace\relax - \setfontparameters, - \v!auto=>\let\setrelativeinterlinespace\dosetrelativeinterlinespace, - \s!unknown=>\assignvalue\commalistelement\currentrelativeinterlinespace{1.00}{1.25}{1.50}% - \spacing\currentrelativeinterlinespace]} - -\def\dosetrelativeinterlinespace - {\ifx\currentrelativeinterlinespace\empty\else - \spacing\currentrelativeinterlinespace - \fi} - -\let\setrelativeinterlinespace\relax - -% \appendtoks \setrelativeinterlinespace \to \everybodyfont - -\def\complexsetupinterlinespace[#1]% \commalistelement ipv #1 - {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]} - -\def\setuplocalinterlinespace[#1]% - {\localinterlinespacetrue - \setupinterlinespace[#1]% - \localinterlinespacefalse} - -\def\simplesetupinterlinespace - {\localinterlinespacetrue - \setfontparameters - \updateraggedskips % funny one here - \localinterlinespacefalse} - -\definecomplexorsimple\setupinterlinespace - -% In earlier versions \type{\bigskipamount} was -% \type{\ht\strutbox} and the stretch was plus or minus -% \type{.4\dp\strutbox}. Don't ask me why. The most recent -% implementation is based on a user supplied distance, which -% is by default \type{.75\normalskipamount} where -% \type{\normalskipamount} equals the current baseline -% distance. - -% \lineskiplimit = -\maxdimen -> freezes baselineskip - -% can be conditionals - -\newif\ifblanknowhite \blanknowhitefalse -\newif\ifblankindeed \blankindeedfalse -\newif\ifblankreset \blankresetfalse -\newif\ifblankdisable \blankdisablefalse -\newif\ifblankflexible \blankflexibletrue -\newif\ifblankouter -\newif\ifblankforce -\newif\ifblankgoback - -\newskip\blankskip \blankskip=\bigskipamount -\newskip\blankskipamount - -\def\skipfactor {.75} -\def\skipgluefactor{.25} - -\def\normalskipamount - {\openlineheight - \ifgridsnapping \else \ifblankflexible - \!!plus \skipgluefactor\openlineheight - \!!minus\skipgluefactor\openlineheight - \fi \fi - \relax} - -\def\linedistance {\normalskipamount} -\def\appliedblankskip{\skipfactor\linedistance} -\def\lastblankskip {\blankskip} -\def\currentblank {\v!big} -\def\oldprevdepth {\prevdepth} -\def\newprevdepth {-1001pt} -\def\mindimen {1sp} % was: 0.00002pt - -\newif\iflocalblankfixed -\newif\iflocalblankflexible - -\def\geenblanko{\removelastskip} % will become obsolete - -%%%% pas op, wordt ook in core-pos gebruikt - -\def\doassignsomeskip#1\to#2% ook nog \v!halfline+fuzzysnap - {\doifelse{#1}\v!line - {#2\openlineheight} - {\ifgridsnapping - \assigndimension{#1}{#2}{.25\openlineheight}{.5\openlineheight}\openlineheight - \else - \assigndimension{#1}{#2}\smallskipamount\medskipamount\bigskipamount - \fi}% - \relax} - -% \relax is really needed, else we may loose stretch due to lookahead; somehow -% this bug was introduced a while ago but somehow went unnoticed; fixed 2/7/2008 - -\def\addblankskip#1#2#3{\global\advance\blankskip#1\ifgridsnapping#3\else#2\fi\relax} - -\def\defineblankmethod[#1]#2{\setvalue{\??bo\??bo#1}{#2}} - -\defineblankmethod [\v!big] {\addblankskip+\bigskipamount \openlineheight} -\defineblankmethod [-\v!big] {\addblankskip-\bigskipamount \openlineheight} -\defineblankmethod [\v!medium] {\addblankskip+\medskipamount {.5\openlineheight}} -\defineblankmethod [-\v!medium] {\addblankskip-\medskipamount {.5\openlineheight}} -\defineblankmethod [\v!small] {\addblankskip+\smallskipamount{.25\openlineheight}} -\defineblankmethod [-\v!small] {\addblankskip-\smallskipamount{.25\openlineheight}} -\defineblankmethod [\v!white] {\addblankskip+\parskip \openlineheight} -\defineblankmethod [-\v!white] {\addblankskip-\parskip \openlineheight} -\defineblankmethod [\v!line] {\addblankskip+\openlineheight \openlineheight} -\defineblankmethod [-\v!line] {\addblankskip-\openlineheight \openlineheight} - -\defineblankmethod [\v!formula] {\global\advance\blankskip\medskipamount} -\defineblankmethod [\v!nowhite] {\global\blanknowhitetrue} -\defineblankmethod [\v!disable] {\global\blankdisabletrue} -\defineblankmethod [\v!force] {\global\blankforcetrue} -\defineblankmethod [\v!outer] {\ifvmode\ifinner\blankoutertrue\fi\fi} -\defineblankmethod [\v!reset] {\global\blankresettrue} -\defineblankmethod [\v!flexible] {\global\localblankflexibletrue} -\defineblankmethod [\v!fixed] {\global\localblankfixedtrue} -\defineblankmethod [\v!back] {\global\blankgobacktrue} % {\geenblanko} -\defineblankmethod [\v!halfline] {\ifgridsnapping\global\fuzzyvskiptrue\fi - \global\advance\blankskip .5\lineheight} -\defineblankmethod [\v!none] {\global\blankresettrue} -\defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} -\defineblankmethod[\v!synchronize] {\verticalstrut\vskip-2\lineheight\verticalstrut} - -% \vtop{\blank[synchronize]\blank[line]test} - -\defineblankmethod [\v!always] {\redowhitespace} % experimental - -% happens often, so we speed this up: -% -% \defineblankmethod [2*\v!line] {\addblankskip+{2\openlineheight}{2\openlineheight}} -% \defineblankmethod [2*\v!big] {\addblankskip+{2\bigskipamount }{2\openlineheight}} -% -% no, with 2\whatever we loose the stretch and shrink! Taco's alternative: - -\defineblankmethod - [2*\v!line] - {\addblankskip+\openlineheight\openlineheight - \addblankskip+\openlineheight\openlineheight} - -\defineblankmethod - [2*\v!big] - {\addblankskip+\bigskipamount\openlineheight - \addblankskip+\bigskipamount\openlineheight} - -\def\doblank#1% - {\edefconvertedargument\ascii{#1}% - \ifx\ascii\empty\else - \ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname - \else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax - \else - \dorepeatwithcommand[#1]\redoblank - \fi\fi - \fi - \relax} - -\def\redoblank#1% - {\edefconvertedargument\ascii{#1}% - \ifx\ascii\empty\else - \ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname - \else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax - \else - \global\advance\blankskip#1\relax - \fi\fi - \fi - \relax} - -\unexpanded\def\blank % the \relax is definitely needed due to the many \if's - {\relax\complexorsimple\doblank} - -\def\complexdoblank - {\flushnotes - \ifmmode - \@EA\nocomplexdoblank - \else - \ifopelkaar - \ifinpagebody - \@EA\@EAEAEA\@EA\docomplexdoblank - \else - \@EA\@EAEAEA\@EA\nocomplexdoblank - \fi - \else - \@EAEAEA\docomplexdoblank - \fi - \fi} - -\def\nocomplexdoblank[#1]% - {% evt blokkeerfalse - \ifmmode\else\par\fi} - -% Overloaded in cont-new! - -\newsignal\noblanksignal - -% problem: we cannot look back in the mvl so we need 3 kinds of signals - -\def\noblankpsignal{1010101} - -\def\inhibitgridblank % was doinhibitblank - {\ifvmode\else\endgraf\fi - \ifvmode - \ifnum\lastpenalty<10000 - \kern-\noblanksignal % new - \kern \noblanksignal - \else - \penalty\noblankpsignal - \fi - \fi} - -\def\inhibittextblank % was inhibitblank - {\endgraf - \ifvmode - \prevdepth\newprevdepth - \fi} - -% new macro -% -% \def\inhibitblank % need some work -% {\endgraf -% \ifvmode -% \ifgridsnapping -% \inhibitgridblank -% \else -% % this one spoils the grid -% \inhibittextblank -% \fi -% \fi} - -\def\doinhibitblank{\inhibitgridblank} -\def\inhibitblank {\inhibittextblank} - -% will become obsolete - -\ifx\undefined\savedlastskip \newskip \savedlastskip \fi -\ifx\undefined\savedlastpenalty \newcount\savedlastpenalty \fi - -% beware, prevdepth can have funny values (e.g. mvl value when in box) - -\def\docomplexdoblank[#1]% pas op \relax's zijn nodig ivm volgende \if - {\global\blankresetfalse - \global\blankdisablefalse - \global\blanknowhitefalse - \global\localblankflexiblefalse - \global\localblankfixedfalse - \global\blankforcefalse - \global\blankgobackfalse - \blankouterfalse - \global\blankskip\zeropoint -% -\edefconvertedargument\ascii{#1}% todo fast check for simple -\ifcsname\??bo\??bo\ascii\endcsname % internal def - \csname\??bo\??bo\ascii\endcsname -\else\ifcsname\??bo\ascii\endcsname % user def / slow - \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax -\else - \rawprocesscommacommand[#1]\doblank -\fi\fi -% - \relax % to be sure - \ifdim\blankskip=\zeropoint\relax - \iflocalblankflexible - \doglobal\advance\blankskip \currentblank - \else\iflocalblankfixed - \doglobal\advance\blankskip \currentblank - \fi\fi - \fi - \relax % to be sure - \ifblankouter - % do nothing - \else - \par - \ifvmode - \ifblankgoback - \ifdim\lastskip>\zeropoint \vskip-\lastskip \fi - \savedlastskip\zeropoint - \else\ifdim\lastskip>\zeropoint - \savedlastskip\lastskip - \else % todo: lastnode, dan namelijk geen skip ! - \savedlastskip\zeropoint - \fi\fi - \ifblankforce - % dit gaat mis in pos fonts - % \ifdim\prevdepth>\zeropoint\else ... - % -1000pt signals top of page or column (\ejectcolumn) - \bgroup\forgeteverypar\verticalstrut\egroup\kern-\struttotal - \savedlastskip\zeropoint - \fi - \savedlastpenalty\lastpenalty % hm, now it gets lost - \ifblankdisable - \global\blankindeedfalse % keep this, i.e. disable current too - \ifgridsnapping - \ifdim\prevdepth<\zeropoint - % brrr - \else - % dirty trick: smaller blanks are ignored after a - % larger one, so 10 lines is probably safe; we need - % to make sure that we honor penalties; here comes the - % trick (cross our fingers that this works well in - % multi columns; maybe an ifinner test is needed - % \scratchcounter\lastpenalty - % \vskip-10\lineheight - % \ifnum\scratchcounter=\zerocount \else \penalty\lastpenalty \fi - % \vskip 10\lineheight - % alas, this leads to overfull pages, so we try this: - \inhibitgridblank - \fi - \else - \ifdim\prevdepth<\zeropoint - % brrr - \else - % ensure at least a proper prevdepth, this should be - % an option - \vskip-\prevdepth - \vskip\strutdepth - \prevdepth\strutdepth - \fi - % the old crappy piece of code - \edef\oldprevdepth{\the\prevdepth}% - \prevdepth\newprevdepth % == \inhibittextblank - \fi - \else - \global\blankindeedtrue - \fi - \ifblankreset - \global\blankindeedtrue - \ifgridsnapping - % let's play safe and not fool around with the depth, if - % only because it took a lot of effort to sort out the grid - % stuff in the first place - \else - \ifdim\prevdepth=\newprevdepth - \prevdepth\oldprevdepth - \fi - \fi - \fi - \ifblankindeed - \ifdim1\savedlastskip<1\blankskip\relax - % else when \blank[2*groot] + \blank[3*groot] with parskip - % equaling 1*groot, gives a groot=\parskip so adding a small - % value makes it distinguishable; can also be done at parskip - % setting time (better) - \global\advance\blankskip \mindimen\relax % = skip - % test this on 2* + 3* and parskip groot - \ifblanknowhite - \global\advance\blankskip -\parskip - \else - \ifdim\savedlastskip=\parskip - \else % force this due to previous comment - \ifdim\parskip>\zeropoint\relax - \ifdim\blankskip<\parskip\relax - \global\blankskip\zeropoint - \else - \global\advance\blankskip -\parskip - \fi - \fi - \fi - \fi - \ifblankflexible \else - \blankskip1\blankskip - \fi - \iflocalblankfixed - \blankskip1\blankskip - \fi - \iflocalblankflexible - \blankskip1\blankskip - \!!plus \skipgluefactor\blankskip - \!!minus\skipgluefactor\blankskip - \fi - \ifdim\lastkern=\noblanksignal\relax % controlled and grid - \global\blankindeedfalse - \else\ifnum\savedlastpenalty=\noblankpsignal\relax % controlled and grid - \global\blankindeedfalse - \else\ifgridsnapping\else\ifdim\prevdepth=\newprevdepth - \global\blankindeedfalse - \fi\fi\fi\fi - \ifblankindeed - \iffuzzyvskip - \removelastfuzzyvskip - \fuzzyvskip\blankskip\relax - \else - \relax\ifdim\savedlastskip=\zeropoint\else - \vskip-\savedlastskip - \fi - \vskip\blankskip\relax - \fi - \fi - \else - \iffuzzyvskip - \removelastfuzzyvskip - \fuzzyvskip\blankskip\relax - \else - % new, test this on pascal - \ifdim\blankskip<\zeropoint - \relax\ifdim\savedlastskip=\zeropoint\else - \advance\blankskip-\savedlastskip - \vskip-\savedlastskip - \fi - \ifdim\blankskip>\zeropoint - \vskip\blankskip - \else - \vskip\zeropoint - \fi - \else - % also new - \ifdim\blankskip=\zeropoint - \ifblanknowhite - \nowhitespace - \fi - \fi - \fi - \fi - \fi - \fi - \fi - \fi - \global\fuzzyvskipfalse - \presetindentation} - -%D For a long time we had: -%D -%D \starttyping -%D \def\simpledoblank% -%D {\doifelse{\currentwhitespace}{\v!geen} -%D {\blank[\currentblank]} -%D {\blank[\currentwhitespace]}} -%D \stoptyping -%D -%D But Berend de Boer wanted more control, so now we have: - -\def\simpledoblank % ... - {\doifelse\currentwhitespace\v!none - {\blank[\currentblank]} - {\blank[\s!default]}} - -%D Another useful definition would be: -%D -%D \starttyping -%D \defineblank -%D [\s!default] -%D [\v!groot] -%D \stoptyping - -\def\dosetupblank#1% amount are an plain inheritance - {\bigskipamount#1\relax - \ifblankflexible \else - \bigskipamount1\bigskipamount - \fi - \medskipamount \bigskipamount \divide\medskipamount \plustwo - \smallskipamount\bigskipamount \divide\smallskipamount\plusfour}% - -\def\complexsetupblank[#1]% more \let's -> this also wil become installable - {\ifgridsnapping - \blankflexiblefalse - \else - \normalexpanded{\noexpand\processallactionsinset[#1]} - [ \v!flexible=>\blankflexibletrue, - \v!fixed=>\blankflexiblefalse]% - \fi - \normalexpanded{\noexpand\processallactionsinset[#1]} - [ \v!flexible=>\dosetupblank\appliedblankskip, - \v!fixed=>\dosetupblank\appliedblankskip, - \v!line=>\edef\appliedblankskip{\linedistance}% - \dosetupblank\appliedblankskip, - \v!halfline=>\scratchskip.5\linedistance - \edef\appliedblankskip{\the\scratchskip}% - \dosetupblank\appliedblankskip, - \v!big=>\ifgridsnapping - \edef\appliedblankskip{\linedistance}% - \dosetupblank\appliedblankskip - \fi - \let\currentblank\v!big, - \v!medium=>\let\currentblank\v!medium, - \v!small=>\let\currentblank\v!small, - \v!global=>\let\currentblank\v!global, - \v!normal=>\dosetupblank\appliedblankskip, - \v!standard=>\edef\appliedblankskip{\skipfactor\linedistance}% - \dosetupblank\appliedblankskip, - \s!default=>\dosetupblank\appliedblankskip, - \s!unknown=>\let\appliedblankskip\commalistelement - \dosetupblank\appliedblankskip]% - \simplesetupwhitespace} - -% \definecomplexorsimpleempty\setupblank -% -% speed gain: 60 sec -> 30 sec - -\definecomplexorsimple\setupblank - -\def\simplesetupblank % == snelle \setupblank[\s!default] - {\ifgridsnapping - \blankflexiblefalse - \fi - \dosetupblank\appliedblankskip - % \let\deblanko\v!big - \simplesetupwhitespace} - -\def\restorestandardblank% \v!standard - {\edef\appliedblankskip{\skipfactor\linedistance}% - \dosetupblank\appliedblankskip - }%\let\deblanko\v!big} - -\def\dodefineblank[#1][#2]% why #1 commalist? - {\def\docommand##1{\setvalue{\??bo##1}{#2}}% - \processcommalist[#1]\docommand} - -\def\defineblank - {\dodoubleargument\dodefineblank} - -% \def\savecurrentblank -% {\edef\restorecurrentblank -% {\bigskipamount\the\bigskipamount -% \medskipamount\the\medskipamount -% \smallskipamount\the\smallskipamount -% \noexpand\def\noexpand\currentblank{\currentblank}% -% \ifblankflexible -% \noexpand\blankflexibletrue -% \else -% \noexpand\blankflexiblefalse -% \fi}} - -\def\savecurrentblank {\edef\savedcurrentblank{\currentblank}} -\def\restorecurrentblank{\edef\currentblank{\savedcurrentblank}} - -\def\savedcurrentblank{\currentblank} - -%D Now. - -\defineblank [\s!default] [\v!white] -\defineblank [\v!height] [\strutheight] -\defineblank [\v!depth] [\strutdepth] - -\let\currentindentation\empty % amount/keyword -% \let\normalindentation \empty % used for reinstating normal indentation -\let\currentindenting \empty % method - -\newdimen\ctxparindent - -\newif\ifindentfirstparagraph % \indentfirstparagraphtrue - -\chardef\indentingtoggle\zerocount - -%D After a blank or comparable situation (left side floats) we -%D need to check if the next paragraph has to be indented. - -\def\presetindentation - {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} - -%D This sets up the (normally) global indentation behavior as well -%D as the amounts. - -\definecomplexorsimple\setupindenting - -\indentfirstparagraphtrue -\parindent\ctxparindent -\chardef\indentingtoggle\zerocount - -% we need a better everypar model: for each option a switch, which we -% set to false with \forgetall and can enable when needed (context 4); -% that way we can control the order of execution of options - -\def\checkeverypar % currently a hack - {\ifzeropt\parindent\else - \doifsometokselse\everypar\donothing{\appendtoks\checkindentation\to\everypar}% - \fi} - -\def\complexsetupindenting[#1]% - {\edef\currentindenting{#1}% - \doifsomething\currentindenting % handy when a parameter is passed - {% not here: \indentfirstparagraphtrue - % not here: \parindent\ctxparindent - % not here: \chardef\indentingtoggle\zerocount - % we use commacommand in order to catch #1 being a command (expanded parameter) - \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc - \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest - \checkeverypar % only when non-empty #1 - \ifindentfirstparagraph\else\noindentation\fi % added - \toggleindentation}} - -\def\docomplexsetupindentingA#1% - {\edefconvertedargument\!!stringa{#1}% can this be doen differently now? - \ifcsname\??in:\!!stringa\endcsname \else - \edef\currentindentation{#1}% - \let\normalindentation\currentindentation - \simplesetupindenting - \fi} - -\def\docomplexsetupindentingB#1% - {\edefconvertedargument\!!stringa{#1}% catch #1=\somedimen - \executeifdefined{\??in:\!!stringa}\donothing} - -\def\simplesetupindenting % empty case, a it strange, needed this way? - {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} - -\def\indenting % kind of obsolete - {\dosingleargument\complexsetupindenting} - -% use \noindentation to suppress next indentation - -\def\defineindentingmethod[#1]#2% - {\setvalue{\??in:#1}{#2}} - -\defineindentingmethod [\v!no] {\parindent\zeropoint}% was: \ctxparindent\noindent} -\defineindentingmethod [\v!not] {\parindent\zeropoint}% was: \ctxparindent\noindent} - -\defineindentingmethod [\v!first] {\indentfirstparagraphtrue} -\defineindentingmethod [\v!next] {\indentfirstparagraphfalse} - -\defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! -\defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! - -\defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! - \chardef\indentingtoggle\zerocount} - -\defineindentingmethod [\v!odd] {\chardef\indentingtoggle\plusone} -\defineindentingmethod [\v!even] {\chardef\indentingtoggle\plustwo} - -\defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else - \let\currentindentation\normalindentation - \simplesetupindenting - \fi} - -\defineindentingmethod [\v!reset] {\indentfirstparagraphtrue - \parindent\zeropoint - \chardef\indentingtoggle\zerocount} - -\def\noindenting{\indenting[\v!no, \v!next ]} -\def\doindenting{\indenting[\v!yes,\v!first]} - -%D This one sets up the local indentation behaviour (i.e. either or not -%D a next paragraph will be indented). - -\def\dochecknextindentation#1% internal one - {\checknextindentation[\csname#1\c!indentnext\endcsname]} - -\setvalue{\??in->\s!empty}{} -\setvalue{\??in->\v!yes }{\doindentation} -\setvalue{\??in->\v!no }{\noindentation} -\setvalue{\??in->\v!auto }{\autoindentation} - -\def\checknextindentation[#1]% - {\csname\??in->\ifcsname\??in->#1\endcsname#1\else\s!empty\fi\endcsname} - -%D Here come the handlers. - -\newif\ifindentation \indentationtrue % documenteren, naar buiten - -\let\checkindentation\relax - -\ifx\autoindentation\undefined \let\autoindentation\relax \fi % hook - -\def\doindentation - {\gdef\checkindentation{\global\indentationtrue}} - -\def\noindentation % made global - {\ifinpagebody \else - \global\indentationfalse - \gdef\checkindentation - {\donoindentation - \gdef\checkindentation{\global\indentationtrue}}% - \fi} - -\def\nonoindentation % bv bij floats - {\ifinpagebody \else - \global\indentationtrue - \gdef\checkindentation{\global\indentationtrue}% - \fi} - -\def\donoindentation - {\ifdim\parindent=\zeropoint \else - \bgroup \setbox\scratchbox\lastbox \egroup - \fi} - -\def\indentation - {\ifvmode \ifdim\parindent=\zeropoint \else - % was : \hskip\parindent - % can be: \indent - % but we test: - \noindent\hskip\parindent - \fi \fi} - -\def\toggleindentation - {\ifcase\indentingtoggle - % nothing - \or - \notoggleindentation - \or - \dotoggleindentation - \fi} - -\def\dokillindentation - {\gdef\checkindentation{\global\indentationfalse\donoindentation}} - -\def\dotoggleindentation - {\gdef\checkindentation{\global\indentationfalse\notoggleindentation\donoindentation}} - -\def\notoggleindentation - {\gdef\checkindentation{\global\indentationtrue\dotoggleindentation}} - -\appendtoks - \pushmacro\checkindentation - \pushmacro\ifindentation -\to \everypushsomestate - -\appendtoks - \popmacro\ifindentation - \popmacro\checkindentation -\to \everypopsomestate - -% we need to save the state if we want to adapt behaviour to empty lines -% -% \def\setlasthvmode -% {\global\chardef\savedhvmode\ifhmode\plusone\else\ifvmode\plustwo\else\zerocount\fi\fi} -% -% \def\resetlasthvmode -% {\global\chardef\savedhvmode\zerocount} -% -% \chardef\savedhvmode\zerocount - -% This is a user requested hack (using the auto-hook). - -\chardef\recheckindentationmode\zerocount - -\def\dontrechecknextindentation - {\global\chardef\recheckindentationmode\zerocount} - -\def\dorechecknextindentation - {\ifcase\recheckindentationmode - % nothing - \or - \dontrechecknextindentation - \expandafter\doautoindentation - \fi} - -\def\doautoindentation - {\doifnextcharelse\par\donothing\noindentation} - -\def\autoindentation - {\global\chardef\recheckindentationmode\plusone} - -%D An example of usage: -%D -%D \starttyping -%D \setupindenting[small,yes] -%D -%D \setupitemize [indentnext=auto] -%D \setuptyping [indentnext=auto] -%D \setupformulas[indentnext=auto] -%D -%D \input tufte \startitemize \item itemize \stopitemize -%D \input tufte \startitemize \item itemize \stopitemize -%D \input tufte \startitemize \item itemize \stopitemize -%D -%D \page -%D -%D \input tufte -%D \starttyping -%D verbatim -%D \stoptyping -%D -%D \input tufte -%D \starttyping -%D verbatim -%D \stoptyping -%D -%D \input tufte -%D \starttyping -%D verbatim -%D \stoptyping -%D -%D \page -%D -%D \input tufte \startformula a = b \stopformula -%D \input tufte \startformula a = b \stopformula -%D \input tufte \startformula a = b \stopformula -%D \stoptyping - - -%D \macros -%D {frenchspacing,nonfrenchspacing} -%D -%D Smehow \type{\frenchspacing} can lead to hyphenation between -%D dashes so we now have \type {\newfrenchspacing} (moved from -%D \type {syst-chr}). - -%D Hm ... todo: - -\sfcode`\)=0 -\sfcode`\'=0 -\sfcode`\]=0 - -\def\setfrenchspacing#1% - {\sfcode`\.#1 \sfcode`\,#1\relax - \sfcode`\?#1 \sfcode`\!#1\relax - \sfcode`\:#1 \sfcode`\;#1\relax} - -\def\frenchspacing - {\setfrenchspacing{1000}} - -\def\resetfrenchspacing - {\sfcode`\.3000 \sfcode`\,1250 - \sfcode`\?3000 \sfcode`\!3000 - \sfcode`\:2000 \sfcode`\;1500 } - -\def\frenchspacing {\setfrenchspacing{1000}} -\def\newfrenchspacing{\setfrenchspacing{1050}} -\def\nonfrenchspacing{\resetfrenchspacing} - -\def\definespacingmethod[#1]#2{\setvalue{\??sg\??sg#1}{#2}} - -\definespacingmethod[\v!packed]{\newfrenchspacing} -\definespacingmethod[\v!broad ]{\nonfrenchspacing} - -\def\complexsetupspacing[#1]% - {\executeifdefined{\??sg\??sg#1}\relax - \updateraggedskips} - -\def\simplesetupspacing - {\updateraggedskips} - -\definecomplexorsimple\setupspacing - -% \dorecurse{100}{\recurselevel\spacefactor 800 \space} \par -% \dorecurse{100}{\recurselevel\spacefactor1200 \space} \par -% \dorecurse{100}{\recurselevel\spacefactor 800 \normalspaceprimitive} \par -% \dorecurse{100}{\recurselevel\spacefactor1200 \normalspaceprimitive} \par - -% When we don't add the % here, we effectively get \ and -% since we have by default \def\^^M{\ } we get into a loop. - -\let\normalspaceprimitive=\ % space-comment is really needed - -% hm ... - -\unexpanded\def\ {\mathortext\normalspaceprimitive\space} % no \dontleavehmode\space (else no frenchspacing) - -% Because I strip spaces at the end of lines (in the editor) we need a bit of -% a trick to define slash+newline, so \ and \ are the same - -\ctxlua{tex.sprint(tex.ctxcatcodes,"\string\\unexpanded\string\\def\string\\\string\n{\string\\ }")} - -\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\mathortext\ \space} % no space in math - -\letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later - -\def\space { } -\def\removelastspace{\ifhmode\unskip\fi} -\def\nospace {\removelastspace\ignorespaces} - -% in tables we need: -% -% \def\fixedspace {\hskip.5em\relax} -% -% but, since not all fonts have .5em digits: - -\unexpanded\def\fixedspace - {\setbox\scratchbox\normalhbox{\mathortext{0}{0}}% - \hskip\wd\scratchbox\relax} - -\def\fixedspaces - {\letcatcodecommand \ctxcatcodes `\~ \fixedspace} - -\appendtoks\let~\space\to\simplifiedcommands - -% \def\removeunwantedspaces -% {\ifhmode % we also need to unskip 0pt skips -% \unskip\unskip\unskip\unskip\unskip -% \unskip\unskip\unskip\unskip\unskip -% \fi} - -\unexpanded\def\removeunwantedspaces - {\ifhmode - \expandafter \doremoveunwantedspace - \fi} - -\def\doremoveunwantedspace - {\ifnum\lastnodetype=\@@gluenode - \unskip \expandafter\doremoveunwantedspace - \fi} - -% \startbuffer -% \startlines \tt \fixedspaces -% 0~1~~2~~~3~~~~4~~~~~5 -% 0~~~~~~~~~~~~~~~~~~~5 -% $0~1~~2~~~3~~~~4~~~~~5$ -% $0~~~~~~~~~~~~~~~~~~~5$ -% \stoplines -% -% \starttabulate[|~|] -% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \NR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \NR -% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \NR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \NR -% \stoptabulate -% -% \starttable[||] -% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \AR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \AR -% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \AR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \AR -% \stoptable -% \stopbuffer -% -% \setupbodyfont[cmr] \getbuffer -% \setupbodyfont[lbr] \getbuffer - -\def\packed - {\nointerlineskip} - -\def\godown[#1]% - {\relax - \ifhmode\endgraf\fi - \ifvmode\nointerlineskip\vskip#1\relax\fi} - -%D A couple of plain macros: - -\ifx\thinspace\undefined - - \def\thinspace {\kern .16667em } - \def\negthinspace{\kern-.16667em } - \def\enspace {\kern .5em } - - \def\thinspace {\kern .16667\emwidth} - \def\negthinspace{\kern-.16667\emwidth} - \def\enspace {\kern .5\emwidth} - -\fi - -\ifx\quad\undefined - - \def\enskip{\hskip.5em\relax} - \def\quad {\hskip 1em\relax} - \def\qquad {\hskip 2em\relax} - - \def\enskip{\hskip.5\emwidth} - \def\quad {\hskip \emwidth} - \def\qquad {\hskip 2\emwidth} - -\fi - -\let\emspace\quad - -\ifx\smallskip\undefined - - \def\smallskip{\vskip\smallskipamount} - \def\medskip {\vskip\medskipamount} - \def\bigskip {\vskip\bigskipamount} - -\fi - -\ifx\allowbreak\undefined - - \def\break {\penalty\ifhmode-\plustenthousand\else\ejectpenalty\fi} - \def\nobreak {\penalty \plustenthousand} - \def\allowbreak{\penalty \zeropoint} - \def\filbreak {\par\vfil\penalty-200\vfilneg} - \def\goodbreak {\par\penalty-500 } - -\fi - -%D Made slightly more readable: - -\ifx\vglue\undefined - - \def\vglue {\afterassignment\dovglue\scratchskip=} - \def\hglue {\afterassignment\dohglue\scratchskip=} - \def\topglue{\nointerlineskip\vglue-\topskip\vglue} - - \def\dovglue - {\par - \scratchdimen\prevdepth - \hrule\!!height\zeropoint - \nobreak\vskip\scratchskip - \prevdepth\scratchdimen} - - \def\dohglue - {\dontleavehmode % \leavevmode - \scratchcounter\spacefactor - \vrule\!!width\zeropoint - \nobreak\hskip\scratchskip - \spacefactor\scratchcounter} - -\fi - -\ifx\eject\undefined - - \def\eject{\par\break} - -\fi - -\ifx\supereject\undefined - - \def\supereject{\par\penalty\superpenalty} - -\fi - -\ifx\dosupereject\undefined - - \def\dosupereject - {\ifnum\insertpenalties>\zerocount % something is being held over - \line{} - \kern-\topskip - \nobreak - \vfill\supereject - \fi} - -\fi - -%D We adapt plain's \type {\removelastskip} a bit: - -\ifx\removelastskip\undefined - - \def\removelastskip - {\ifvmode \ifdim\lastskip=\zeropoint \else - \vskip-\lastskip - \fi \fi} - -\fi - -\ifx\smallbreak\undefined - -\def\smallbreak - {\par - \ifdim\lastskip<\smallskipamount - \removelastskip - \penalty-50 - \smallskip - \fi} - -\def\medbreak - {\par - \ifdim\lastskip<\medskipamount - \removelastskip - \penalty-100 - \medskip - \fi} - -\def\bigbreak - {\par - \ifdim\lastskip<\bigskipamount - \removelastskip - \penalty-200 - \bigskip - \fi} - -\fi - -\newskip\ctxparskip \ctxparskip\zeropoint - -\newconditional \flexiblewhitespace \settrue\flexiblewhitespace - -\def\blankokleinmaat {\smallskipamount} -\def\blankomiddelmaat {\medskipamount} -\def\blankogrootmaat {\bigskipamount} -\def\currentwhitespace {\zeropoint} - -\definecomplexorsimple\setupwhitespace - -\def\simplesetupwhitespace - {\doifnot\currentwhitespace\v!none\dosetupwhitespace} - -\def\complexsetupwhitespace[#1]% - {\edef\nextcurrentwhitespace{#1}% - \ifx\nextcurrentwhitespace\empty - \simplesetupwhitespace - \else - \let\currentwhitespace\nextcurrentwhitespace - \dosetupwhitespace - \fi} - -\def\dosetupwhitespace % quick test for no list - {\ifcsname\??ws\??ws\currentwhitespace\endcsname - \csname\??ws\??ws\currentwhitespace\endcsname - \else - \expandafter\processcommalist\expandafter[\currentwhitespace]\dowhitespacemethod % can be raw - \fi\relax - \ifgridsnapping - \setfalse\flexiblewhitespace - \ifdim\ctxparskip>\zeropoint - \ctxparskip - \ifcase\baselinegridmode - \baselineskip % normal ! ! ! ! !! - \or - \ifdim\scratchdimen=\baselineskip % maybe range - \baselineskip % normal ! ! ! ! !! - \else - \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax - \fi - \else - \baselineskip % normal ! ! ! ! !! - \fi - \fi - \else - \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi - \fi - \parskip\ctxparskip} - -\chardef\baselinegridmode=0 % option in layout / 1=permit_half_lines - -\def\dodosetupwhitespace - {\ifgridsnapping - \setfalse\flexiblewhitespace - \ctxparskip1\ctxparskip - \ifdim\ctxparskip>\zeropoint - \ifcase\baselinegridmode - \ctxparskip\baselineskip % normal ! ! ! ! !! - \or - \ifdim\scratchdimen=\baselineskip % maybe range - \ctxparskip\baselineskip % normal ! ! ! ! !! - \else - \ctxparskip\numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax - \fi - \else - \ctxparskip\baselineskip % normal ! ! ! ! !! - \fi - \fi - \else - \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi - \fi - \parskip\ctxparskip} - -\definesystemvariable {ws} % whitespace - -\def\definewhitespacemethod[#1]#2{\setvalue{\??ws\??ws#1}{#2}} - -\definewhitespacemethod [\v!fix] {} -\definewhitespacemethod [\v!fixed] {\setfalse\flexiblewhitespace} -\definewhitespacemethod [\v!flexible] {\settrue\flexiblewhitespace} -\definewhitespacemethod [\v!line] {\ctxparskip \baselineskip} -\definewhitespacemethod [\v!halfline] {\ctxparskip.5\baselineskip} -\definewhitespacemethod [\v!none] {\ctxparskip \zeropoint} -\definewhitespacemethod [\v!big] {\ctxparskip \bigskipamount} -\definewhitespacemethod [\v!medium] {\ctxparskip \medskipamount} -\definewhitespacemethod [\v!small] {\ctxparskip \smallskipamount} - -\definewhitespacemethod [\s!default] {\simplesetupwhitespace} % {\stelwitruimteopnieuwin} - -% \def\dowhitespacemethod#1% -% {\executeifdefined{\??ws\??ws#1}{\ctxparskip#1}\relax} - -\def\dowhitespacemethod#1% - {\ifcsname\??ws\??ws#1\endcsname\csname\??ws\??ws#1\endcsname\else\ctxparskip#1\fi\relax} - -\def\nowhitespace - {\ifdim\parskip>\zeropoint\relax - \ifdim\lastskip=-\parskip - \else - \vskip-\parskip - \fi - \fi} - -\def\nowhitespaceunlessskip - {\ifdim\lastskip>\zeropoint \else - \nowhitespace - \fi} - -\def\redowhitespace - {\ifdim\lastskip>-\parskip \else - \vskip\parskip - \fi} - -% \def\savecurrentwhitespace -% {\edef\restorecurrentwhitespace -% {\ctxparskip\the\ctxparskip -% \parskip\the\parskip -% \noexpand\def\noexpand\currentwhitespace{\currentwhitespace}% -% \ifconditional\flexiblewhitespace -% \noexpand\settrue\flexiblewhitespace -% \else -% \noexpand\setfalse\flexiblewhitespace -% \fi}} - -\def\savecurrentwhitespace {\edef\savedcurrentwhitespace{\currentwhitespace}} -\def\restorecurrentwhitespace{\edef\currentwhitespace{\savedcurrentwhitespace}} - -\def\savedcurrentwhitespace{\currentwhitespace} - -% deze variant is nodig binnen \startopelkaar -% steeds testen: -% -% \hoofdstuk{..} -% \plaatslijst[..] -% \hoofdstuk{..} -% \input tufte -% -% met/zonder witruimte - -\def\whitespace - {\par - \ifdim\parskip>\zeropoint\relax - %\ifdim\lastskip>\parskip \else - % \removelastskip interferes with blanko blokkeer en klein - \vskip\parskip - %\fi - \fi} - -\def\nonoblanko[#1]% - {\par} - -\def\noblanko - {\dosingleempty\nonoblanko} - -% I'm not sure if the restore is still needed. Anyway, when we do -% restore, we get a parskip someplace in the output that will push -% the content off page (\vbox to pageheight{skip smashed-box}) so -% we have now disabled this hack. If it is introduced again it needs -% to be more controlled. Test case: -% -% \setupwhitespace[big] -% \starttext -% \startcolumns[n=2]\dorecurse{200}{test\crlf}\stopcolumns -% \stoptext -% -% \def\saveouterspacing -% {\savecurrentblank -% \savecurrentwhitespace -% \def\restoreouterspacing -% {\restorecurrentblank -% \restorecurrentwhitespace}} -% -% \let\restoreouterspacing\relax -% \let\saveouterspacing \relax % mult-ini: i will look into it when needed -% -% let's test this (restore before we restore the global bodyfont): - -\def\saveouterspacing - {\savecurrentblank - \savecurrentwhitespace} - -\def\restoreouterspacing - {\restorecurrentblank - \restorecurrentwhitespace} - -% De onderstaande macro handelt ook de situatie dat er geen -% tekst tussen \start ... \stop is geplaatst. Daartoe wordt de -% laatste skip over de lege tekst heen gehaald. Dit komt goed -% van pas bij het plaatsen van (mogelijk lege) lijsten. - -\newif\ifopelkaar - -\newsignal \noparskipsignal % \def\noparskipsignal {0.00001pt} -\def\lastdoneparskip {0pt} - -\def\startpacked - {\dosingleempty\dostartpacked} - -\def\dostartpacked[#1]% nesting afvangen - {\par - \ifvmode - \edef\lastdoneparskip {\the\lastskip}% - \edef\lastdoneprevdepth{\the\prevdepth}% zeer recent toegevoegd - \ifdim\prevdepth=-\thousandpoint % toegevoegd omdat binnen - \else % een vbox een extra skip - \whitespace % ongewenst is; dit kan - \baselinecorrection %% zie in \placeregister[n=1] - \vskip\noparskipsignal % waarschijnlijk ook in - \fi % blanko blokkeer - \bgroup - \doifelse{#1}\v!blank - \opelkaarfalse - \opelkaartrue - \blank[\v!disable] % dit is nog niet ok, gaat fout - \setupwhitespace[\v!none] % bovenin vtop (dwz, baseline) - \fi} - -\def\stoppacked - {\par - \ifvmode - \egroup - \ifdim\lastskip=\noparskipsignal\relax - \removelastskip - \nowhitespace - \vskip-\lastdoneparskip - \vskip+\lastdoneparskip - \prevdepth-\lastdoneprevdepth % zeer recent toegevoegd - \fi - \fi} - -\def\startunpacked - {\blank - \leavevmode - \bgroup} - -\def\stopunpacked - {\egroup - \blank} - -% De onderstaande macro's moeten nog eens nader worden uitgewerkt. -% Ze spelen een rol bij de spatiering rond omkaderde teksten -% en/of boxen zonder diepte. - -\def\toonregelcorrectie{\showbaselinecorrection} -\def\regelcorrectie {\baselinecorrection} - -% \prevdepth crosses pageboundaries! -% -% todo: a version that works ok inside a box - -\let\doaroundlinecorrection\relax - -\def\startlinecorrection - {\dodoubleempty\dostartlinecorrection} - -\def\dostartlinecorrection[#1][#2]% #2 gobbles spaces - {\bgroup - \processaction - [#1] - [ \v!blank=>\let\doaroundlinecorrection\blank, - \s!default=>\let\doaroundlinecorrection\relax, - \s!unknown=>{\def\doaroundlinecorrection{\blank[#1]}}]% - \doaroundlinecorrection - \startbaselinecorrection - \offbaselinecorrection - \ignorespaces} - -\def\stoplinecorrection - {\stopbaselinecorrection - \doaroundlinecorrection - \egroup} - -\def\correctwhitespace - {\dowithnextbox - {\startbaselinecorrection - \flushnextbox - \stopbaselinecorrection}% - \vbox} - -\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}} -\def\horizontalstrut{\normalhbox {\strut}} - -% Hieronder volgen enkele instellingen en macro's ten behoeve -% van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en -% 0.28 zijn ooit eens ontleend aan INRS-TEX en moeten wellicht -% nog eens instelbaar worden. -% -% \lineheight : de hoogte van een regel -% \spacing{getal} : instellen interlinie -% \normalbaselines : instellen regelafstend -% -% \setstrut : instellen \strut -% \setnostrut : resetten \strut, \endstrut, \begstrut -% -% \setteststrut : instellen zichtbare struts -% \resetteststrut : instellen onzichtbare struts -% -% \setfontparameters : instellen na fontset -% -% De hoogte van een regel (\lineheight) is gelijk aan de -% som van de hoogte (\ht) en diepte (\dp) van \strutbox. -% -% \strut : denkbeeldig blokje met hoogte en diepte -% -% Een \hbox kan als deze aan het begin van een regel staat -% een breedte \hsize krijgen. Dit is soms te voorkomen met het -% commando \leavevmode. Binnen een \vbox geeft dit echter -% niet altijd het gewenste resultaat, vandaar het commando -% -% \leaveoutervmode - -% Pas op: niet zomaar \topskip en \baselineskip aanpassen -% en zeker niet \widowpenalty. Dit kan ernstige gevolgen -% hebben voor kolommen. -% -% Enige glue kan op zich geen kwaad, echter als blanko=vast, -% dan moet ook de rek 0 zijn. Binnen kolommen is rek ook -% niet bepaald mooi. Een hele kleine waarde (0.025) voldoet, -% omdat een positieve glue eindeloos rekbaar is. - -\newdimen\strutdimen -\newdimen\lineheight -\newdimen\openlineheight -\newdimen\openstrutheight -\newdimen\openstrutdepth -\newdimen\topskipgap -\newdimen\struttotal - -\def\strutheightfactor {.72} -\def\strutdepthfactor {.28} - -\def\baselinefactor {2.8} -\def\baselinegluefactor {0} - -\def\minimumstrutheight {0pt} -\def\minimumstrutdepth {0pt} - -\def\normallineheight {\baselinefactor ex} -\def\minimumlinedistance {\lineskip} - -\def\strutheight {0pt} -\def\strutdepth {0pt} -\def\strutwidth {0pt} - -\let\spacingfactor \plusone - -\def\topskipfactor {1.0} -\def\maxdepthfactor {0.5} - -\def\systemtopskipfactor {\topskipfactor} -\def\systemmaxdepthfactor {\maxdepthfactor} - -% De onderstaande definitie wordt in de font-module overruled - -\ifdefined\globalbodyfontsize\else - \newdimen\globalbodyfontsize - \globalbodyfontsize=12pt -\fi - -\ifx\normalizedbodyfontsize\undefined - \def\normalizedbodyfontsize{12pt} -\fi - -% door een \dimen. Dit is geen probleem omdat (1) de default -% korpsgrootte 12pt is en (2) de fonts nog niet geladen zijn -% en de instellingen bij het laden nogmaals plaatsvinden. - -\def\topskipcorrection - {\simpletopskipcorrection - \vskip-\struttotal - \verticalstrut} - -\def\simpletopskipcorrection - {\ifdim\topskip>\openstrutheight - % == \vskip\topskipgap - \vskip\topskip - \vskip-\openstrutheight - \fi} - -\def\settopskip % the extra test is needed for the lbr family - {\topskip\systemtopskipfactor\globalbodyfontsize - \ifgridsnapping \else - \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi - \fi - \relax % the skip - \topskipgap\topskip - \advance\topskipgap -\openstrutheight\relax -\ifdim\minimumstrutheight>\zeropoint - \ifdim\topskip<\minimumstrutheight - \topskip\minimumstrutheight\relax - \fi -\else - \ifdim\topskip<\strutheightfactor\openlineheight - \topskip\strutheightfactor\openlineheight\relax - \fi -\fi} - -\def\setmaxdepth - {\maxdepth\systemmaxdepthfactor\globalbodyfontsize} - -\def\normalbaselines - {\baselineskip \normalbaselineskip - \lineskip \normallineskip - \lineskiplimit\normallineskiplimit} - -\def\setnormalbaselines - {\ifdim\normallineheight>\zeropoint - \lineheight\normallineheight - \fi - \openlineheight\spacingfactor\lineheight - \openstrutheight \ifdim\minimumstrutheight>\zeropoint - \minimumstrutheight % new - \else - \strutheightfactor\openlineheight - \fi - \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth % new - \else - \strutdepthfactor \openlineheight - \fi - \ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint - \openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new - \fi - \normalbaselineskip\openlineheight - \ifgridsnapping\else - \!!plus \baselinegluefactor\openlineheight - \!!minus\baselinegluefactor\openlineheight - \fi - \normallineskip\minimumlinedistance\relax % \onepoint\relax - \normallineskiplimit\zeropoint\relax - \normalbaselines - \dosetupgridsnapping} - -\def\spacing#1% - {\ifgridsnapping - %\ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{\withoutpt\the\dimexpr#1\points\relax}\fi - \let\spacingfactor\plusone - \else - \edef\spacingfactor{#1}% - \fi - \edef\systemtopskipfactor {\withoutpt\the\dimexpr#1\dimexpr\topskipfactor \points}% - \edef\systemmaxdepthfactor{\withoutpt\the\dimexpr#1\dimexpr\maxdepthfactor\points}% - \setnormalbaselines - \setstrut} - -%D Sometimes one needs to freeze the interlinespacing -%D -%D \starttyping -%D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf} -%D \stoptyping - -\let\restoreinterlinespace\relax - -\def\saveinterlinespace - {\edef\restoreinterlinespace - {\lineheight \the\lineheight - \openstrutheight \the\openstrutheight - \openstrutdepth \the\openstrutdepth - \openlineheight \the\openlineheight - \normalbaselineskip \the\normalbaselineskip - \normallineskip \the\normallineskip - \normallineskiplimit\the\normallineskiplimit - \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}% - \noexpand\normalbaselines}} - -% plain definition: -% -% \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} -% -% could be: -% -% \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} - -\ifx\strutbox\undefined - - \newbox\strutbox - - \setbox\strutbox\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint} - - \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} - -\fi - -\let\normalstrut\strut - -% The double \hbox construction enables us to \backtrack -% boxes. - -\let\strutht\undefined \newdimen\strutht -\let\strutdp\undefined \newdimen\strutdp - -\unexpanded\def\setstrut - {\ifgridsnapping - \setstrutgridyes - \else - \setstrutgridnop - \fi} - -\unexpanded\def\setstrutgridyes - {\strutht\spacingfactor\dimexpr - \ifdim\minimumstrutheight>\zeropoint - \minimumstrutheight - \else - \strutheightfactor\dimexpr\normallineheight - \fi - \strutdp\dimexpr - \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth - \else - \normallineheight-\strutht - \fi - \dosetstrut} - -\unexpanded\def\setstrutgridnop - {\strutht\spacingfactor\dimexpr - \ifdim\minimumstrutheight>\zeropoint - \minimumstrutheight - \else - \strutheightfactor\dimexpr\normallineheight - \fi - \strutdp\spacingfactor\dimexpr - \ifdim\minimumstrutdepth>\zeropoint - \minimumstrutdepth - \else - \strutdepthfactor\dimexpr\normallineheight - \fi - \dosetstrut} - -\unexpanded\def\setcharstrut#1% - {\setbox\strutbox\normalhbox{#1}% - \strutht\ht\strutbox - \strutdp\dp\strutbox - \dosetstrut} - -\unexpanded\def\setfontstrut - {\setcharstrut{(gplQT}} - -\unexpanded\def\setcapstrut% could be M, but Q has descender - {\setcharstrut{Q}} - -%D Handy for math (used in mathml): - -\def\charhtstrut - {\begingroup - \setcharstrut{GJY}% - \vrule\!!width\zeropoint\!!depth\zeropoint\!!height\strutht - \endgroup} - -\def\chardpstrut - {\begingroup - \setcharstrut{gjy}% - \vrule\!!width\zeropoint\!!depth\strutdp\!!height\zeropoint - \endgroup} - -% because of all the callbacks in mkiv, we avoid unnecessary boxes ... -% maybe use an attribute so that we can tag boxes that don't need a -% treatment; tests with using an attribute so far have shown that -% it's slower because testing the attribute takes time too - -\def\dosetstrut - {\let\strut\normalstrut - \edef\strutheight{\the\strutht}% - \edef\strutdepth {\the\strutdp}% - \ifdim\strutwidth=\zeropoint - \dosetstruthide - \else - \dosetstrutvide - \fi - \struttotal\dimexpr\strutht+\strutdp\relax} - -\def\dosetstruthide - {\setbox\strutbox\normalhbox - {\vrule - \!!width \zeropoint - \!!height\strutht - \!!depth \strutdp}} - -\def\dosetstrutvide - {\setbox\strutbox\normalhbox - {\normalhbox to \zeropoint - {% \hss % new, will be option - \vrule - \!!width \strutwidth - \!!height\strutht - \!!depth \strutdp - \hss}}} - -%D The dimen \type {\struttotal} holds the exact size of the -%D strut; occasionally a one scaled point difference can show -%D up with the lineheight. - -% experiment - -\newbox\emptystrutbox \setbox\emptystrutbox\hbox{} - -\def\dosetstruthide - {\setbox\strutbox\copy\emptystrutbox - \ht\strutbox\strutht - \dp\strutbox\strutdp} - -\def\strut{\relax\dontleavehmode\copy\strutbox} % still callbacks for \hbox{\strut} - - -\let\normalstrut\strut - -%D Sometimes a capstrut comes in handy -%D -%D \starttabulate[|Tl|l|l|] -%D \NC yes \NC normal strut \NC {\showstruts\setupstrut[yes]\strut} \NC \NR -%D \NC no \NC no strut \NC {\showstruts\setupstrut[no]\strut} \NC \NR -%D \NC kap \NC a capital strut (i.e. Q) \NC {\showstruts\setupstrut[cap]\strut} \NC \NR -%D \NC A B \unknown \NC a character strut (e.g. A) \NC {\showstruts\setupstrut[A]\strut} \NC \NR -%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR -%D \stoptabulate - -\def\setupstrut - {\dosingleempty\dosetupstrut} - -\def\dosetupstrut[#1]% yet undocumented, todo: fontstrut - {\processaction - [#1] - [ \v!yes=>\setstrut, - \v!auto=>\setautostrut, - \v!no=>\setnostrut, - \v!cap=>\setcapstrut, - \v!fit=>\setfontstrut, - \v!line=>\setstrut, - \s!default=>\setstrut, - \s!unknown=>\setcharstrut\commalistelement]} - -\def\setteststrut - {\def\strutwidth{.8pt}% - \setstrut} - -\def\autostrutfactor{1.1} - -\def\setautostrut - {\begingroup - \setbox\scratchbox\copy\strutbox - \setstrut - \ifdim\strutht>\autostrutfactor\ht\scratchbox - \endgroup \setstrut - \else\ifdim\strutdp>\autostrutfactor\dp\scratchbox - \endgroup \setstrut - \else - \endgroup - \fi\fi} - -% when enabled, sigstruts will remove themselves if nothing -% goes inbetween - -\newsignal\strutsignal \setfalse\sigstruts - -\def\begstrut - {\relax\ifcase\strutht\else - \ifconditional\sigstruts - \noindent\horizontalstrut - \normalpenalty\plustenthousand - \normalhskip-\strutsignal - \normalhskip\strutsignal - \else - \strut - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \fi - \expandafter \ignorespaces - \fi} - -\def\endstrut - {\relax\ifhmode\ifcase\strutht\else - \ifconditional\sigstruts - \ifdim\lastskip=\strutsignal - \unskip\unskip\unpenalty\setbox\scratchbox\lastbox - \else - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \strut - \fi - \else - \removeunwantedspaces - \normalpenalty\plustenthousand - \normalhskip\zeropoint - \strut - \fi - \fi\fi} - -\newbox\nostrutbox \setbox\nostrutbox\normalhbox{} % {\normalhbox{}} - -\def\setnostrut - {\setbox\strutbox\copy\nostrutbox - \let\strut\empty - \let\endstrut\empty - \let\begstrut\empty - \let\crlfplaceholder\empty} - -% unsave: -% -% \def\pseudostrut -% {\bgroup -% \setnostrut -% \normalstrut -% \egroup} -% -% try: -% -% \startchemie -% \chemie[ONE,Z0,SB15,MOV1,SB15,Z0][C,C] -% \stopchemie -% -% so: - -\def\pseudostrut - {\noindent} % better: \dontleavehmode - -\let\pseudobegstrut\pseudostrut - -\let\pseudoendstrut\removeunwantedspaces - -\def\resetteststrut - {\let\strutwidth\zeropoint - \setstrut} - -\ifx\setfontparameters\undefined - % problems ! ! ! ! - \def\setfontparameters{\the\everybodyfont} -\fi - -%D Handy: - -\def\baselinedistance{\the\lineheight} - -%D We need \type{\normaloffinterlineskip} because the new -%D definition contains an assignment, and |<|don't ask me -%D why|>| this assignment gives troubles in for instance the -%D visual debugger. - -%D The plain ones: - -\def\offinterlineskip - {\baselineskip-\thousandpoint - \lineskip\zeropoint - \lineskiplimit\maxdimen} - -\def\nointerlineskip - {\prevdepth-\thousandpoint} - -\let\normaloffinterlineskip=\offinterlineskip % knuth's original - -%D My own one: - -\def\dopushinterlineskip - {\edef\oninterlineskip - {\baselineskip\the\baselineskip - \lineskip\the\lineskip - \lineskiplimit\the\lineskiplimit - \let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}} - -\def\nopushinterlineskip - {\let\oninterlineskip\setnormalbaselines} - -\def\offinterlineskip - {\ifdim\baselineskip>\zeropoint - \dopushinterlineskip - \else - \nopushinterlineskip - \fi - \normaloffinterlineskip} - -\let\oninterlineskip=\relax - -\def\leaveoutervmode - {\ifvmode\ifinner\else - \leavevmode - \fi\fi} - -% We stellen enkele penalties anders in dan Plain TEX: - -% oud -% -% \widowpenalty=\defaultwidowpenalty\relax -% \clubpenalty =\defaultclubpenalty \relax - -\def\resetpenalties#1% - {\ifx#1\undefined\else - #1\minusone - \fi} - -\def\setpenalties#1#2#3% - {\ifx#1\undefined\else % space before #3 prevents lookahead problems, needed when #3=text - #1\numexpr#2+\plusone\relax\space\doexpandedrecurse{\the\numexpr#2\relax}{ #3}\zerocount\relax - \fi} - -\def\doexpandedrecurse#1#2% - {\ifnum#1>\zerocount#2\@EA\doexpandedrecurse\@EA{\the\numexpr#1-1\relax}{#2}\fi} - -%D \macros -%D {keeplinestogether} -%D -%D Dirty hack, needed in margin content that can run of a page. - -% just before margintexts ... will eventually be done differently in mkiv using -% attributes - -\newcount\nofkeeplinestogether -\let\restoreinterlinepenalty\relax - -\def\dorestoreinterlinepenalty - {\global\let\restoreinterlinepenalty\relax - \global\resetpenalties\interlinepenalties - \global\nofkeeplinestogether\zerocount} - -\def\keeplinestogether#1% - {\ifnum#1>\nofkeeplinestogether - \global\nofkeeplinestogether#1% - \global\setpenalties\interlinepenalties\nofkeeplinestogether\plustenthousand - \global\let\restoreinterlinepenalty\dorestoreinterlinepenalty - \fi} - -\newif\ifgridsnapping % to be sure - -\def\defaultwidowpenalty {2000} % was: 1000 -\def\defaultclubpenalty {2000} % was: 800 -\def\defaultdisplaywidowpenalty {50} -\def\defaultbrokenpenalty {100} - -\def\defaultgridwidowpenalty {0} -\def\defaultgridclubpenalty {0} -\def\defaultgriddisplaywidowpenalty {0} -\def\defaultgridbrokenpenalty {0} - -\def\nopenalties - {\widowpenalty \zerocount - \clubpenalty \zerocount - \brokenpenalty \zerocount - \doublehyphendemerits\zerocount - \finalhyphendemerits \zerocount - \adjdemerits \zerocount} - -\def\setdefaultpenalties - {\directsetup{\systemsetupsprefix\s!default}} - -\startsetups [\systemsetupsprefix\s!reset] - \resetpenalties\widowpenalties - \resetpenalties\clubpenalties - \resetpenalties\interlinepenalties -\stopsetups - -% we use \directsetup because it's faster and we know there is no csl - -\startsetups [\systemsetupsprefix\s!default] - - \directsetup{\systemsetupsprefix\s!reset} - - \widowpenalty \defaultwidowpenalty - \clubpenalty \defaultclubpenalty - \displaywidowpenalty\defaultdisplaywidowpenalty - \brokenpenalty \defaultbrokenpenalty - -\stopsetups - -\startsetups [\v!grid] [\systemsetupsprefix\s!default] - - \directsetup{\systemsetupsprefix\s!reset} - - \widowpenalty \defaultgridwidowpenalty - \clubpenalty \defaultgridclubpenalty - \displaywidowpenalty\defaultgriddisplaywidowpenalty - \brokenpenalty \defaultgridbrokenpenalty - -\stopsetups - -% as an illustration: - -\startsetups [\systemsetupsprefix\v!strict] - - \directsetup{\systemsetupsprefix\s!reset} - - \setpenalties\widowpenalties2\maxdimen - \setpenalties\clubpenalties 2\maxdimen - \brokenpenalty \maxdimen - -\stopsetups - -\setdefaultpenalties % will happen later in \setuplayout - -% Suggested by GB (not the name -): - -\def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize} % D.A.'s value - -% Bovendien definieren we enkele extra \fill's: - -\def\hfilll{\hskip\zeropoint\!!plus1filll\relax} -\def\vfilll{\vskip\zeropoint\!!plus1filll\relax} - -% De onderstaande hulpmacro's moeten nog eens instelbaar worden -% gemaakt. - -\def\tfskipsize{1em\relax} -\def\tfkernsize{1ex\relax} - -\def\tfskip{\dotfskip\tfskipsize} -\def\tfkern{\dotfkern\tfkernsize} - -\def\dotfskip#1{{\tf\hskip#1}} -\def\dotfkern#1{{\tf\kern #1}} - -% needs a proper \definenarrower or installnarrower - -\newskip\ctxleftskip -\newskip\ctxrightskip -\newskip\ctxmidskip - -\def\dosinglenarrower#1% - {\processaction - [#1] - [ \v!left=>\global\advance\ctxleftskip \@@slleft, - \v!middle=>\global\advance\ctxmidskip \@@slmiddle, - \v!right=>\global\advance\ctxrightskip \@@slright, - \v!reset=>\global\ctxleftskip \zeropoint - \global\ctxmidskip \zeropoint - \global\ctxrightskip\zeropoint, - \v!none=>, - \s!unknown=>\global\advance\ctxmidskip \commalistelement]} - -\def\donarrower[#1]% hm, can be dorepeat directly - {\dorepeatwithcommand[#1]\dosinglenarrower} - -\def\complexstartnarrower[#1]% - {\@@slbefore % was hard coded \par - \bgroup - \global\ctxleftskip \zeropoint - \global\ctxrightskip\zeropoint - \global\ctxmidskip \zeropoint - \processcommalistwithparameters[#1]\donarrower - \advance\leftskip \ctxleftskip - \advance\rightskip \ctxrightskip - \advance\leftskip \ctxmidskip - \advance\rightskip \ctxmidskip - \seteffectivehsize} - -% todo: definenarrower - -\def\simplestartnarrower - {\startnarrower[\v!middle]} - -\definecomplexorsimple\startnarrower - -\def\stopnarrower - {\@@slafter % was hard coded \par / needed, else skips forgotten - \egroup} - -\def\setupnarrower - {\dodoubleargument\getparameters[\??sl]} - -\newdimen\@@effectivehsize \def\effectivehsize {\hsize} -\newdimen\@@effectiveleftskip \def\effectiveleftskip {\leftskip} -\newdimen\@@effectiverightskip \def\effectiverightskip{\rightskip} - -\def\seteffectivehsize - {\setlocalhsize - \@@effectivehsize \localhsize - \@@effectiveleftskip \leftskip - \@@effectiverightskip \rightskip - \let\effectivehsize \@@effectivehsize - \let\effectiveleftskip \@@effectiveleftskip - \let\effectiverightskip\@@effectiverightskip} - -% We will not use bodydir and pagedir so we disable them. That way we get -% normal hyperlink support. - -\let\@@bodydir\normalbodydir -\let\@@pagedir\normalpagedir - -\unexpanded\def\bodydir{\afterassignment\do@@bodydir\@@bodydir} \let\normalbodydir\bodydir -\unexpanded\def\pagedir{\afterassignment\do@@pagedir\@@pagedir} \let\normalpagedir\pagedir - -\def\do@@bodydir{\@@bodydir TLT\relax} -\def\do@@pagedir{\@@pagedir TLT\relax} - -% This will become a more advanced layout controller soon: - -\unexpanded\def\lefttoright{\textdir TLT\pardir TLT\relax} -\unexpanded\def\righttoleft{\textdir TRT\pardir TRT\relax} - -\def\dodefinehbox[#1][#2]% - {\setvalue{hbox#1}##1% - {\hbox to #2{\begstrut##1\endstrut\hss}}} - -\def\definehbox - {\dodoubleargument\dodefinehbox} - -\def\iobox#1#2#3#% here #3# is not really needed - {\vbox\bgroup % we want to return a vbox like the others - \hbox\bgroup% we need to pack the signal with the box - \signalrightpage - \dowithnextboxcontent - {\let\\=\endgraf\forgetall\doifrightpageelse#1#2} - {\box\nextbox\egroup\egroup} - \vbox#3} - -\def\obox{\iobox\raggedleft \raggedright} % outerbox -\def\ibox{\iobox\raggedright\raggedleft} % innerbox - -\def\dosetraggedvbox#1% - {\let\raggedbox\vbox - \processfirstactioninset - [#1] - [ \v!left=>\let\raggedbox\lbox, - \v!right=>\let\raggedbox\rbox, - \v!middle=>\let\raggedbox\cbox, - \v!inner=>\let\raggedbox\ibox, - \v!outer=>\let\raggedbox\obox, - \v!flushleft=>\let\raggedbox\rbox, - \v!flushright=>\let\raggedbox\lbox, - \v!center=>\let\raggedbox\cbox, - \v!no=>\def\raggedbox{\vbox\bgroup\raggedright\let\next=}]} - -\def\dosetraggedhbox#1% - {\let\raggedbox\hbox - \processaction % slow - [#1] - [ \v!left=>\def\raggedbox{\doalignedline\v!left }, - \v!right=>\def\raggedbox{\doalignedline\v!right }, - \v!middle=>\def\raggedbox{\doalignedline\v!middle}, - \v!inner=>\def\raggedbox{\doalignedline\v!inner }, - \v!outer=>\def\raggedbox{\doalignedline\v!outer }, - \v!flushleft=>\def\raggedbox{\doalignedline\v!right }, - \v!flushright=>\def\raggedbox{\doalignedline\v!left }, - \v!center=>\def\raggedbox{\doalignedline\v!middle}]} - -\def\dosetraggedcommand#1% - {\normalexpanded{\noexpand\dodosetraggedcommand{#1}}} - -\newtoks\everyraggedcommand - -\def\raggedcommand{\the\everyraggedcommand} - -\def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! - {\everyraggedcommand \emptytoks - \let\raggedtopcommand \empty - \let\raggedbottomcommand\empty - \chardef\raggedoneliner\zerocount - \doifsomething{#1} - {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse - \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse - \!!donectrue - \rawprocesscommalist[#1]\dododosetraggedcommand}} - -\def\dododosetraggedcommand#1% - {\executeifdefined{\@@ragged@@command\string#1}\relax} - -\def\@@ragged@@command{@@raggedcommand} - -\setvalue{\@@ragged@@command\v!hanging }{\appendtoks\enableprotruding \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nothanging }{\appendtoks\disableprotruding \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!hz }{\appendtoks\enableadjusting \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nohz }{\appendtoks\disableadjusting \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!spacing }{\appendtoks\enablespacehandling - \enablekernhandling \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nospacing }{\appendtoks\disablespacehandling - \disablekernhandling \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!hyphenated }{\appendtoks\dohyphens \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!nothyphenated}{\appendtoks\nohyphens \to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!tolerant }{\appendtoks\tolerance3000\relax \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!verytolerant}{\appendtoks\tolerance4500\relax \to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!stretch }{\appendtoks\emergencystretch\bodyfontsize\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!left}% - {\if!!donea \appendtoks\veryraggedleft\to\everyraggedcommand - \else \appendtoks\raggedleft \to\everyraggedcommand - \fi - \!!donecfalse} - -\setvalue{\@@ragged@@command\v!right}% - {\if!!donea \appendtoks\veryraggedright\to\everyraggedcommand - \else \appendtoks\raggedright \to\everyraggedcommand - \fi - \!!donecfalse} - -\setvalue{\@@ragged@@command\v!middle}% - {\if!!donec - \if!!doneb \appendtoks\raggedwidecenter\to\everyraggedcommand - \else\if!!donea \appendtoks\veryraggedcenter\to\everyraggedcommand - \else \appendtoks\raggedcenter \to\everyraggedcommand - \fi\fi - \!!donecfalse - \else - \let\raggedbottomcommand\vfilll % bonus, pretty strong - \let\raggedtopcommand \vfilll % used with \framed for - \fi} % instance in tables - -\setvalue{\@@ragged@@command\v!flushleft }{\getvalue{\@@ragged@@command\v!right }} -\setvalue{\@@ragged@@command\v!flushright}{\getvalue{\@@ragged@@command\v!left }} -\setvalue{\@@ragged@@command\v!center }{\getvalue{\@@ragged@@command\v!middle}} - -\setvalue{\@@ragged@@command\v!high}% - {\let\raggedbottomcommand\vfilll} % and since we lack a - -\setvalue{\@@ragged@@command\v!low}% - {\let\raggedtopcommand\vfilll} % proper keyword, but - -\setvalue{\@@ragged@@command\v!lohi}% - {\let\raggedbottomcommand\vfilll % we do support the - \let\raggedtopcommand\vfilll} % ugly laho (lohi) - -\setvalue{\@@ragged@@command\v!no}% - {\appendtoks\raggedright\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!yes}% - {\appendtoks\notragged\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!normal}% - {\appendtoks\notragged\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!inner}% not yet perfect - {\signalrightpage % may interfere - \doifrightpageelse - {\getvalue{\@@ragged@@command\v!right}} - {\getvalue{\@@ragged@@command\v!left}}} - -\setvalue{\@@ragged@@command\v!outer}% not yet perfect - {\signalrightpage % may interfere - \doifrightpageelse - {\getvalue{\@@ragged@@command\v!left}} - {\getvalue{\@@ragged@@command\v!right}}} - -\setvalue{\@@ragged@@command\v!lesshyphenation}% - {\appendtoks\lesshyphens\to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!morehyphenation}% - {\appendtoks\morehyphens\to\everyraggedcommand} - -\setvalue{\@@ragged@@command\v!lefttoright}{\appendtoks\lefttoright\to\everyraggedcommand} -\setvalue{\@@ragged@@command\v!righttoleft}{\appendtoks\righttoleft\to\everyraggedcommand} -\setvalue{\@@ragged@@command l2r}{\appendtoks\lefttoright\to\everyraggedcommand} -\setvalue{\@@ragged@@command r2l}{\appendtoks\righttoleft\to\everyraggedcommand} - -% compare: -% -% \framed[width=4cm,align=no] {\hfil xxx} -% \framed[width=4cm,align=disable]{\hfil xxx} - -\setvalue{\@@ragged@@command\v!disable}% for one liners - {\appendtoks\raggedright\parfillskip\zeropoint\to\everyraggedcommand} - -\chardef\raggedoneliner\zerocount - -\setvalue{\@@ragged@@command\v!line}% - {\chardef\raggedoneliner\plusone} - -% Nog doen: -% -% \goodbreak -> \allowbreak en \dosomebreak{..} in koppen -% -% bij koppen zowieso: \blanko[reset] - -% Nog in commando verwerken: -% -% \voorkeur … la \blanko -% -% Om ongewenste witruimte te voorkomen kan met \dosomebreak{\break} -% een \penalty voor witruimte worden geplaatst. - -\def\removelastskip % a redefinition of plain - {\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi} - -\def\doifoutervmode#1% - {\ifvmode\ifinner\else#1\fi\fi} - -\ifx\dosomebreak\undefined % defined in mkiv - - \def\dosomebreak#1% - {\doifoutervmode - {\scratchskip\lastskip - \removelastskip - %\leavevmode\type{#1}% - #1\relax - \ifdim\scratchskip=\zeropoint % else interference with footnotes - \else - \vskip\scratchskip - \fi}} - -\fi - -\def\forgeteverypar - {\everypar{\the\neverypar}} - -\def\forgetparindent - {\forgeteverypar - \indentfirstparagraphtrue % recently added - \let\currentindentation\v!none - \ctxparindent\zeropoint - \parindent\zeropoint\relax} - -\def\forgetparskip - {\let\currentwhitespace\v!none - \ctxparskip\zeropoint - \parskip\zeropoint\relax} - -\def\forgetbothskips - {\tolerance1500 - \leftskip\zeropoint - \rightskip\zeropoint\relax} - -\def\forgetspacing - {\emergencystretch\zeropoint} - -\newif\ifforgotten % rather good signal for inner - -\appendtoks \forgottentrue \to \everyforgetall -\appendtoks \forgetragged \to \everyforgetall -\appendtoks \forgetparskip \to \everyforgetall -\appendtoks \forgetparindent \to \everyforgetall -\appendtoks \forgetbothskips \to \everyforgetall -\appendtoks \forgetspacing \to \everyforgetall % i.v.m. funny spacing in pagebody -\appendtoks \spacing\plusone \to \everyforgetall % new per 10/08/2004, else problems in otr / !! needed -\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! - -\def\localvbox#1#% - {\vbox#1\bgroup - \forgetparskip - \setlocalhsize - \hsize\localhsize - \forgetparindent - \forgetbothskips - \forgeteverypar - \let\next=} - -\let\dostopattributes\relax % in case these commands end up in an edef - -% \unexpanded\def\dostartattributes#1#2#3% -% {\begingroup % geen \bgroup, anders in mathmode lege \hbox -% \ifcsname#1#3\endcsname -% \let\dostopattributes\@@dostopattributes -% \startcolor[\csname#1#3\endcsname]% -% \else -% \let\dostopattributes\@@nostopattributes -% \fi -% \ifcsname#1#2\endcsname -% \expandafter\doconvertfont -% \else -% \expandafter\gobbleoneargument -% \fi{\csname#1#2\endcsname}} - -\newconditional \parbasedattributes - -\def\finishparbasedattributes - {\ifconditional\parbasedattributes - \setfalse\parbasedattributes - \par - \fi} - -\def\dostopparbasedattributes - {\settrue\parbasedattributes - \dostopattributes} - -\unexpanded\def\@@dostopattributes - {\stopcolor - \finishparbasedattributes - \endgroup} - -\unexpanded\def\@@nostopattributes - {\finishparbasedattributes - \endgroup} - -\unexpanded\def\doattributes#1#2#3#4% - {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} - -% An even faster \ETEX\ version: - -\unexpanded\def\dostartattributes#1#2#3% - {\begingroup % geen \bgroup, anders in mathmode lege \hbox - \ifincolor - \ifcsname#1#3\endcsname - \let\dostopattributes\@@dostopattributes - \faststartcolor[\csname#1#3\endcsname]% - \else - \let\dostopattributes\@@nostopattributes - \fi - \else - \let\dostopattributes\@@nostopattributes - \fi - \ifcsname#1#2\endcsname - % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi} - -\unexpanded\def\@@dostopattributes - {\faststopcolor - \finishparbasedattributes - \endgroup} - -\unexpanded\def\@@nostopattributes - {\finishparbasedattributes - \endgroup} - -%D Bonus macro, see core-sec.tex - -\unexpanded\def\dosetfontattribute#1#2% - {\ifcsname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi\empty} - -%D Since this happens a lot, and sometimes large arguments -%D are passed in \type {#4}, we just copy some code: - -\unexpanded\def\doattributes#1#2#3#4% - {\begingroup % geen \bgroup, anders in mathmode lege \hbox - \ifincolor - \ifcsname#1#3\endcsname - \let\dostopattributes\@@dostopattributes - \faststartcolor[\csname#1#3\endcsname]% - \else - \let\dostopattributes\endgroup - \fi - \else - \let\dostopattributes\endgroup - \fi - \ifcsname#1#2\endcsname - % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname - \@EA\doconvertfont\csname#1#2\@EA\endcsname - \fi - {#4}% - \dostopattributes} - -% Kan vaker worden toegepast en moet bovendien sneller! - -\newskip\leftskipadaption -\newskip\rightskipadaption - -\def\doadaptleftskip#1% - {\dosetleftskipadaption{#1}% - \advance\leftskip \leftskipadaption} - -\def\doadaptrightskip#1% - {\dosetrightskipadaption{#1}% - \advance\rightskip \rightskipadaption} - -\setvalue{@lsa@\v!standard}{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} -\setvalue{@lsa@\v!yes }{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} -\letvalue{@lsa@\v!no }\zeropoint -\letvalue{@lsa@\empty }\zeropoint -\setvalue{@rsa@\v!standard}{\@@slright} -\setvalue{@rsa@\v!yes }{\@@slright} -\letvalue{@rsa@\v!no }\zeropoint -\letvalue{@rsa@\empty }\zeropoint - -\def\dosetleftskipadaption#1% - {\edefconvertedargument\ascii{@lsa@#1}% - \leftskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} - -\def\dosetrightskipadaption#1% - {\edefconvertedargument\ascii{@rsa@#1}% - \rightskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} - -\newcount \noftrackedpagestates -\newif \ifpagestatemismatch -\newcount \realpagestateno -\chardef \frozenpagestate \zerocount - -\def\dotrackpagestate#1#2% - {\ifdoublesided \ifinpagebody \else - \doforcedtrackpagestate{#1}{#2}% - \fi \fi} - -\def\doforcedtrackpagestate#1#2% - {\ifcase\frozenpagestate - \global\advance\noftrackedpagestates\plusone - \global\advance#2\plusone - \lazysavetaggedtwopassdata{#1}{\number\noftrackedpagestates}{\number#2}{\noexpand\realfolio}% - %\llap{\infofont\number\noftrackedpagestates/\number#2}% tracing - \fi} - -\def\doifrightpagestateelse#1#2% - {\ifcase\frozenpagestate - \pagestatemismatchfalse - \realpagestateno\realfolio - \ifinpagebody - \ifdoublesided - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \twopassdatafoundtrue - \fi - \else\ifdoublesided - \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound - \realpagestateno\twopassdata\relax - \ifnum\twopassdata=\realpageno \else - \pagestatemismatchtrue - \fi - \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \else - \twopassdatafoundtrue - \fi\fi - \else - \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \iftwopassdatafound - \@EA\firstoftwoarguments - \else - \@EA\secondoftwoarguments - \fi} - -\def\doifforcedrightpagestateelse#1#2% - {\ifcase\frozenpagestate - \pagestatemismatchfalse - \realpagestateno\realfolio - \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound - \realpagestateno\twopassdata\relax - \ifnum\twopassdata=\realpageno \else - \pagestatemismatchtrue - \fi - \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \else - \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \else - \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse - \fi - \fi - \iftwopassdatafound - \@EA\firstoftwoarguments - \else - \@EA\secondoftwoarguments - \fi} - -\def\freezepagestate {\chardef\frozenpagestate\plusone } -\def\defrostpagestate{\chardef\frozenpagestate\zerocount} - -% we can make more of these on top, but how to deal with mixed frozen states - -\definetwopasslist\s!paragraph \newcount \nofraggedparagraphs - -\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} -\def\doifrightpageelse{\doifrightpagestateelse\s!paragraph\nofraggedparagraphs} - -\newcount\pagesignallevel - -\def\startsignalrightpage % one may do a \postsignalrightplace - {\advance\pagesignallevel\plusone - \presignalrightpage - \let\signalrightpage\relax - \let\presignalrightpage\relax - \let\startsignalrightpage\relax - \doifrightpageelse\donothing\donothing - \freezepagestate} - -\def\stopsignalrightpage - {\ifcase\pagesignallevel\or\postsignalrightpage\fi - \advance\pagesignallevel\minusone} - -\def\setraggedparagraphmode - {\signalrightpage\doifrightpageelse} % move it there - -\ifx\swapmargins\undefined \let\swapmargins\undefined \fi % todo - -\def\doifswappedrightpageelse#1#2% alleen in box construction ! - {\doifrightpageelse - {#1} - {\scratchcounter\realpageno - \realpageno\realpagestateno\relax - \swapmargins - \realpageno\scratchcounter - #2}} - -\newbox\signaledrightpage % this way we can avoid interference, i.e. postpone placement - -\def\presignalrightpage {\global\setbox\signaledrightpage\hbox{\signalrightpage}} -\def\postsignalrightpage{\ifvoid\signaledrightpage\else\box\signaledrightpage\fi} - -% The next feature is is used in: -% -% \definenumber[test][way=bypage] -% -% \def\Test -% {\incrementnumber[test]\rawnumber[test]/% -% \incrementnumber[test]\rawnumber[test]/% -% \incrementnumber[test]\rawnumber[test]\space -% \checkpagechange{oeps}\changedpage{oeps}\space -% \ifpagechanged TRUE\else FALSE\fi} -% -% \Test\page \Test\par \Test\page \Test\par \Test\page \Test\page -% -% (adapted from cont-new.tex:) - -\newif\ifpagechanged \let\lastchangedpage\empty - -\def\docheckpagestatechange#1#2#3% - {\pagechangedfalse - \doforcedtrackpagestate{#2}{#3}% - \findtwopassdata{#2}{\number#3}% - \iftwopassdatafound - \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax - \pagechangedtrue - \fi - \fi - \ifpagechanged - \letgvalue{#2:p:#1}\twopassdata - \globallet\lastchangedpage\twopassdata - \else - \globallet\lastchangedpage\realfolio - \fi} - -\def\changedpagestate#1#2% - {\executeifdefined{#2:p:#1}{0}} - -\def\checkpagechange#1{\docheckpagestatechange{#1}\s!paragraph\nofraggedparagraphs} -\def\changedpage #1{\changedpagestate{#1}\s!paragraph} - -% saved struts - -\ifx\savedstrutbox\undefined \newbox\savedstrutbox \fi - -\def\savestrut {\setbox\savedstrutbox\copy\strutbox} -\def\savedstrut{\copy \savedstrutbox} - -\chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline - -\def\bottomalignlimit{3\lineheight} - -\newif\ifn@rmalbottom -\newif\ifr@ggedbottom -\newif\ifb@selinebottom - -\def\normalbottom - {% \topskip 10pt - \r@ggedbottomfalse} - -\def\raggedbottom - {\chardef\bottomraggedness\zerocount - \n@rmalbottomfalse - \r@ggedbottomtrue - \b@selinebottomfalse - \settopskip} - -\def\alignbottom - {\chardef\bottomraggedness\plusone - \n@rmalbottomtrue - \r@ggedbottomfalse - \b@selinebottomfalse - \settopskip} - -\def\baselinebottom - {\chardef\bottomraggedness\plustwo - \n@rmalbottomfalse - \r@ggedbottomfalse - \b@selinebottomtrue - \settopskip} - -\let\normalbottom=\alignbottom % downward compatible - -% new code, not in use yet - -% for future chinese typo-module: -% -% % \let\raggedleft\veryraggedleft -% % \let\raggedleft\veryraggedright -% -% \startbuffer -% 中中中中中中中中中中中中中中中中中中中中中中中中中% -% 中中中中中中中中中中中中中中中中中中中中中中中中中% -% 中中中中中中中中中中中中中中中中中中中中中中中中中% -% 中中中中中中中中中中中中中中中中中中中中中中中中中% -% \stopbuffer -% -% \framedtext -% [align={broad,flushright},width=90mm] -% {\getbuffer} -% -% \framedtext -% [align={broad,flushleft},width=90mm] -% {\getbuffer} -% -% \framedtext -% [align=middle,width=90mm] -% {\getbuffer} -% -% using just flushleft is not okay here due to the fact that -% leftskip has less stretch than the inter character spacing - -\registerctxluafile{core-spa}{1.001} - -\definesystemattribute[kern-chars] -\definesystemattribute[skip-category] \chardef\skipcategoryattribute \dogetattributeid{skip-category} -\definesystemattribute[skip-penalty] \chardef\skippenaltyattribute \dogetattributeid{skip-penalty} -\definesystemattribute[skip-order] \chardef\skiporderattribute \dogetattributeid{skip-order} -\definesystemattribute[snap-category] -\definesystemattribute[display-math] - -% \start \dosetstretch{.25em} \setuptolerance[tolerant,stretch] \input tufte \endgraf \stop -% \start \dosetstretch{.5em} effe flink doorfietsen \stop - -\def\dosetupgridsnapping % calls too often, only needed in gridsnapping - {\ctxlua{nodes.setsnapvalue(1,\number\openstrutheight,\number\openstrutdepth)}} - -\def\doenablegridsnapping - {\dosetattribute{snap-category}{1}% - \topskip\strutht - \offinterlineskip} - -\def\dodisablegridsnapping - {\doresetattribute{snap-category}% - % reset topskip - \oninterlineskip} - -% experimental code, not yet interfaced: - -% category: -% 0 == discard discard -% 1 == only if larger largest -% 2 == force even if smaller force -% 3 == only take penalty component penalty -% 4 == add to existing skip add -% 5 == disable (ignore following) disable -% 6 == kill whitespace nowhite -% 7 == discard previous back -% -% penalty: larger wins -% order: larger wins -% category:2,order:5,penalty:10000,skip:value|kw -% -% always -- obsolete -% none -- obsolete -% outer -- obsolete -% reset -- obsolete -% \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} - -% todo, in grid mode: vspacing.fixed = false - -\newtoks\everybeforeblankhandling -\newtoks\everyafterblankhandling - -\appendtoks - \blankskip\zeropoint - \attribute\skipcategoryattribute\plusone - \attribute\skippenaltyattribute \attributeunsetvalue - \attribute\skiporderattribute \attributeunsetvalue - \ifblankflexible - \setfalse\blankisfixed - \else - \settrue\blankisfixed - \fi -\to \everybeforeblankhandling - -\appendtoks - \ifconditional\blankisfixed - \blankskip1\blankskip - \else - \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip - \fi -\to \everyafterblankhandling - -\def\setblankcategory#1{\attribute\skipcategoryattribute#1\relax} -\def\setblankorder #1{\attribute\skiporderattribute #1\relax} -\def\setblankpenalty #1{\attribute\skippenaltyattribute #1\relax} -\def\addblankskip#1#2#3{\advance\blankskip#1\dimexpr\ifgridsnapping#3\else#2\fi\relax\relax} -\def\fixedblankskip {\settrue \blankisfixed} % \blankskip1\blankskip} -\def\flexibleblankskip {\setfalse\blankisfixed} % \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip} - -\def\startblankhandling - {\begingroup - \the\everybeforeblankhandling} - -\def\stopblankhandling - {\the\everyafterblankhandling - \vskip\blankskip - \endgroup} - -\def\flushblankhandling - {\the\everyafterblankhandling - \vskip\blankskip - \the\everybeforeblankhandling} - -% % % % - -\def\definevspacingamount - {\dotripleempty\dodefinevspacingamount} - -\def\dodefinevspacingamount[#1][#2][#3]% - {\ctxlua{vspacing.setskip("#1",\!!bs\detokenize{#2}\!!es,\!!bs\detokenize{#3}\!!es)}} - -\def\definevspacing - {\dodoubleempty\dodefinevspacing} - -\def\dodefinevspacing[#1][#2]% - {\ctxlua{vspacing.setmap("#1","#2")}} - -\unexpanded\def\vspacing - {\dosingleempty\dovspacing} - -\def\dovspacing[#1]% - {\ctxlua{vspacing.analyse("\iffirstargument#1\else default\fi")}} - -% category:4 is default - -\definevspacingamount[\v!big] [\bigskipamount] [\openlineheight] -\definevspacingamount[\v!medium] [\medskipamount] [0.50\openlineheight] -\definevspacingamount[\v!small] [\smallskipamount] [0.25\openlineheight] -\definevspacingamount[\v!line] [\openlineheight] [\openlineheight] -\definevspacingamount[\v!halfline][0.50\openlineheight][0.50\openlineheight] -\definevspacingamount[\v!formula] [\medskipamount] [0.50\openlineheight] -\definevspacingamount[\v!white] [\parskip] [\openlineheight] - -\definevspacing[\s!default] [\v!big] -\definevspacing[\v!samepage][penalty:10000] -\definevspacing[\v!max] [category:1] -\definevspacing[\v!force] [category:2] -\definevspacing[\v!disable] [category:5] -\definevspacing[\v!nowhite] [category:6] -\definevspacing[\v!back] [category:7] -\definevspacing[\v!always] [category:0] -\definevspacing[\v!weak] [order:0] -\definevspacing[\v!strong] [order:100] - -\defineblankmethod[\v!samepage]{\writestatus\m!systems{ignoring blank method '\v!samepage'}} -\defineblankmethod[\v!max] {\writestatus\m!systems{ignoring blank method '\v!max'}} -\defineblankmethod[\v!weak] {\writestatus\m!systems{ignoring blank method '\v!weak'}} -\defineblankmethod[\v!strong] {\writestatus\m!systems{ignoring blank method '\v!strong'}} - -% \definevspacing[whatever][4*big] -% \vspacing[2*big,-medium,-3*small,whatever,halfline,order:10,category:4,strong,samepage] -% \vspacing[2*big,category:disable] -% \vspacing[2*big,disable] -% \vspacing[2*big,back] - -% some temporary hacks - -\setfalse\vspacingenabled - -% ! ! ! ! ! later, now each newline does a \par and call to the callback - -\newtoks\everyenablevspacing -\newtoks\everydisablevspacing - -\def\enablevspacing {\the\everyenablevspacing} -\def\disablevspacing{\the\everydisablevspacing} - -\appendtoks - \writestatus\m!systems{! ! enabling vspacing ! !}% - \settrue\vspacingenabled - \ctxlua{vspacing.enable()}% -\to \everyenablevspacing - -\appendtoks - \writestatus\m!systems{! ! disabling vspacing ! !}% - \setfalse\vspacingenabled - \ctxlua{vspacing.disable()}% -\to \everydisablevspacing - -\let\originalblank \blank % we use \original for non-primitives -\let\originalvspacing\vspacing - -\let\setupvspacing\setupblank % for the moment - -% so, the new one will be -% -% \chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline -% -% \def\bottomalignlimit{3\lineheight} % will be settable -% -% \def\raggedbottom {\chardef\bottomraggedness=0 \settopskip} -% \def\alignbottom {\chardef\bottomraggedness=1 \settopskip} -% \def\baselinebottom{\chardef\bottomraggedness=2 \settopskip} -% -% \let\normalbottom =\alignbottom - -% \hyphenpenalty = ( 2.5 * \hsize ) / \raggedness -% \tolerance >= 1500 % was 200 -% \raggedness = 2 .. 6\bodyfontsize - -\chardef\raggedstatus=0 % normal left center right - -\def\leftraggedness {2\bodyfontsize} -\def\rightraggedness {2\bodyfontsize} -\def\middleraggedness {6\bodyfontsize} - -\def\middleraggedness {.5\hsize} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} - -% oeps, hsize can be 0pt in which case we get a strange division - -\def\middleraggedness {\ifdim\hsize=\zeropoint6\bodyfontsize\else.5\hsize\fi} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} - -%D More hyphenation control, will be combined with align -%D setup. - -\def\nohyphens - {\ifx\dohyphens\relax - \edef\dohyphens - {\hyphenpenalty\the\hyphenpenalty - \exhyphenpenalty\the\exhyphenpenalty\relax}% - \fi - \hyphenpenalty\plustenthousand - \exhyphenpenalty\plustenthousand} - -\let\dohyphens\relax - -%D To prevent unwanted side effects, we also have to check -%D for hyphens here: - -\newskip\@@raggedskipa -\newskip\@@raggedskipb - -\def\setraggedness#1% - {\ifnum\tolerance<1500\relax % small values have - \tolerance1500\relax % unwanted side effects - \fi - \ifx\dohyphens\relax - % this code will be reconsidered / kind of fuzzy (and old) - \@@raggedskipa 2.5\hsize - \@@raggedskipb #1\relax - \divide\@@raggedskipa \@@raggedskipb - \hyphenpenalty\@@raggedskipa - \fi} - -\let\updateraggedskips\relax - -\def\setraggedskips#1#2#3#4#5#6#7% never change this name - {\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% - \updateraggedskips} - -\def\dosetraggedskips#1#2#3#4#5#6#7% - {\chardef \raggedstatus#1\relax - \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 - \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 - \spaceskip #4\relax - \xspaceskip #5\relax - \parfillskip\zeropoint\!!plus#6\relax - \parindent #7\relax} - -% \def\notragged% -% {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} - -% older (context) names: - -\let\spaceamount \interwordspace -\let\emspaceamount\emwidth - -% tracing: - -\def\doshowpardata#1% - {\ifx#1\relax\else - \hbox{\string#1: \the#1}\endgraf - \expandafter\doshowpardata - \fi} - -\def\showpardata - {\edef\thepardata - {\hbox{font: \fontname\font}\endgraf - \doshowpardata - \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace - \hsize \vsize - \leftskip \rightskip - \spaceskip \xspaceskip - \parindent \parfillskip - \hyphenpenalty \exhyphenpenalty - \displaywidowpenalty \widowpenalty \clubpenalty \brokenpenalty - \doublehyphendemerits \finalhyphendemerits \adjdemerits - \relax}% - \begingroup - \dontshowcomposition - \inleftmargin{\vsmash - {\switchtobodyfont[7pt,tt]% - \framed[\c!align=\v!right]{\thepardata}}}% - \endgroup} - -\def\startshowpardata - {\begingroup - \showcomposition - \showstruts\tracepositionstrue \tracingparagraphs\maxdimen - \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} - -\def\stopshowpardata - {\endgraf - \endgroup} - -% \defineXMLenvironment[showpardata] \startshowpardata \stopshowpardata -% \defineXMLsingular [showpardata] \showpardata - -% defaults - -\def\raggedfillamount {1fil} -\def\raggedhalffillamount{.5fil} -\def\raggedspaceamount {\interwordspace} % {.3333em} -\def\raggedxspaceamount {.5em} - -\def\notragged - {\chardef\raggedstatus\zerocount - \leftskip 1\leftskip - \rightskip 1\rightskip - \spaceskip \zeropoint - \xspaceskip \zeropoint - \parfillskip\zeropoint\!!plus\raggedfillamount\relax - \let\updateraggedskips\relax} % new - -\let\forgetragged\notragged - -\def\raggedleft - {\setraggedness\leftraggedness - \setraggedskips1\leftraggedness\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\def\raggedcenter - {\setraggedness\middleraggedness - \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -%D We used to have: -%D -%D \starttyping -%D \def\raggedright -%D {\setraggedness\rightraggedness -%D \setraggedskips{3}{0em}{\rightraggedness}{.3333em}{.5em}{0em}{\parindent}} -%D \stoptyping -%D -%D However, the next alternative, suggested by Taco, is better. - -\def\raggedright - {\setraggedness\rightraggedness - \setraggedskips3\zeropoint\rightraggedness\raggedspaceamount - \raggedxspaceamount\raggedfillamount\parindent} - -\def\veryraggedleft - {\setraggedskips1\raggedfillamount\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -%D When we want the last line to have a natural width: -%D -%D \starttyping -%D \def\veryraggedleft% -%D {\setraggedskips{1}{1fil}{0em}{.3333em}{.5em}{0em}{-1fil}} -%D \stoptyping -%D -%D but this one is not accepted by the macros. - -\def\veryraggedcenter - {\setraggedskips2\raggedfillamount\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\def\veryraggedright - {\setraggedskips3\zeropoint\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\parindent} - -\def\ttraggedright - {\tttf - \setraggedskips3\zeropoint\rightraggedness - \zeropoint\zeropoint\zeropoint\parindent} % \ctxparindent - -%D A bonus one: - -\def\raggedwidecenter - {\setraggedness\middleraggedness - \setraggedskips2\raggedhalffillamount\raggedhalffillamount - \raggedspaceamount\raggedxspaceamount\zeropoint\zeropoint} - -\newif\if@@asragged \@@asraggedtrue % old method - -% todo -% -% \setuplayout[grid=yes,lines=44] \showgrid -% \starttext -% test \vfill test \endgraf \strut \endgraf \vskip-\lineheight \removedepth \pagina test -% \stoptext - -% \setupalign[reset,new,right,old] - -\def\@@align@@rl{\if!!donea\veryraggedleft \else\raggedleft \fi} -\def\@@align@@rr{\if!!donea\veryraggedright \else\raggedright \fi} -\def\@@align@@rc{\if!!donea\veryraggedcenter\else\raggedcenter\fi} - -\setvalue{@@ngila@@\v!broad }{\!!doneatrue} -\setvalue{@@ngila@@\v!wide }{\!!donebtrue} - -\def\installalign#1#2{\setvalue{@@align@@#1}{#2}} % can be used for overloads - -\installalign \v!new {\@@asraggedfalse} -\installalign \v!old {\@@asraggedtrue} -\installalign \empty {} - -\installalign \v!line {\baselinebottom} -\installalign \v!bottom {\raggedbottom} -\installalign \v!height {\normalbottom} -\installalign \v!width {\notragged} -\installalign \v!normal {\notragged} -\installalign \v!yes {\notragged} -\installalign \v!no {\raggedright} -\installalign \v!inner {\if@@asragged \setraggedparagraphmode\@@align@@rl\@@align@@rr \else - \setraggedparagraphmode\@@align@@rr\@@align@@rl \fi} -\installalign \v!outer {\if@@asragged \setraggedparagraphmode\@@align@@rr\@@align@@rl \else - \setraggedparagraphmode\@@align@@rl\@@align@@rr \fi} -\installalign \v!left {\if@@asragged\@@align@@rl\else\@@align@@rr\fi} -\installalign \v!right {\if@@asragged\@@align@@rr\else\@@align@@rl\fi} -\installalign \v!middle {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!flushleft {\if!!donea\veryraggedright \else\raggedright\fi} -\installalign \v!flushright {\if!!donea\veryraggedleft \else\raggedleft \fi} -\installalign \v!flushouter {\setraggedparagraphmode\raggedleft\raggedright} -\installalign \v!flushinner {\setraggedparagraphmode\raggedright\raggedleft} -\installalign \v!center {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!hanging {\enableprotruding} -\installalign \v!nothanging {\disableprotruding} -\installalign \v!hz {\enableadjusting} -\installalign \v!nohz {\disableadjusting} -\installalign \v!spacing {\enablespacehandling \enablekernhandling} -\installalign \v!nospacing {\disablespacehandling\disablekernhandling} -\installalign \v!hyphenated {\dohyphens} -\installalign \v!nothyphenated {\nohyphens} -\installalign \v!new {\@@asraggedfalse} % so new will give you consistency -\installalign \v!reset {\notragged\normalbottom} - -\installalign \v!tolerant {\tolerance3000 \relax} -\installalign \v!verytolerant {\tolerance4500 \relax} -\installalign \v!stretch {\emergencystretch\bodyfontsize} - -\installalign \v!grid {\doenablegridsnapping } % only mkiv -\installalign \v!nogrid {\dodisablegridsnapping} % only mkiv - -\installalign \v!righttoleft {\lefttoright} -\installalign \v!lefttoright {\righttoleft} -\installalign {l2r} {\lefttoright} -\installalign {r2l} {\righttoleft} - -\newcount\hyphenminoffset - -\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi - -\def\lesshyphens - {\advance\hyphenminoffset\plusone - \sethyphenationvariables} - -\def\morehyphens - {\ifcase\hyphenminoffset \else - \advance\hyphenminoffset\minusone - \fi - \sethyphenationvariables} - -\installalign \v!lesshyphenation {\lesshyphens} -\installalign \v!morehyphenation {\morehyphens} - -\def\dodosetupalign#1{\csname @@align@@#1\endcsname} -\def\dodosetupngila#1{\csname @@ngila@@#1\endcsname} - -\def\setupalign - {\dosingleargument\dosetupalign} - -\def\dosetupalign[#1]% can be made faster by checking for defined #1 - {\!!doneafalse - \!!donebfalse - \processcommacommand[#1]\dodosetupngila - \processcommacommand[#1]\dodosetupalign} - -% \setupalign[flushleft] \input ward \par % lijnlinks -% \setupalign[right] \input ward \par - -% \setupalign[flushright] \input ward \par % lijnrechts -% \setupalign[left] \input ward \par - -% \setupalign[middle] \input ward \par % centreer -% \setupalign[center] \input ward \par - -\def\startalignment - {\bgroup - \setupalign} - -\def\stopalignment - {\par - \egroup} - -\chardef\alignstrutmode=1 - -% see later for the real definition, which in the simple case is: - -\newtoks \everyleftofalignedline -\newtoks \everyrightofalignedline - -\def\shiftalignedline#1#2#3#4% left, right, inner, outer - {\rightorleftpageaction - {\everyleftofalignedline {\hskip\dimexpr#1+#3\relax}% - \everyrightofalignedline{\hskip\dimexpr#2+#4\relax}} - {\everyleftofalignedline {\hskip\dimexpr#1+#4\relax}% - \everyrightofalignedline{\hskip\dimexpr#2+#3\relax}}} - -\def\doalignline#1#2% \\ == newline - {\noindentation % was \noindent - \dontleavehmode % added in marrakesch at TUG 2006\begingroup - \begingroup - \setlocalhsize % new - \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% - \dowithnextbox - {\hbox to \localhsize - {\ifcase\alignstrutmode\or\strut\fi - \the\everyleftofalignedline - #1\unhbox\nextbox#2\relax - \the\everyrightofalignedline}% - \endgroup} - \hbox} - -% plain commands - -\ifx\undefined\line \def\line {\hbox to\hsize} \fi -\ifx\undefined\leftline \def\leftline #1{\line{#1\hss}} \fi -\ifx\undefined\rightline \def\rightline #1{\line{\hss#1}} \fi -\ifx\undefined\centerline \def\centerline#1{\line{\hss#1\hss}} \fi - -% directe commando's - -\def\leftaligned {\doalignline \relax \hss } -\def\midaligned {\doalignline \hss \hss } -\def\rightaligned{\doalignline \hss \relax} - -\let\centeraligned\midaligned - -\def\regelbegrensd#1{\limitatetext{#1}{\hsize}{\unknown}} % to be translated - -% indirecte commando's - -\letvalue{\s!do\v!line\v!left }\leftaligned -\letvalue{\s!do\v!line\v!right }\rightaligned -\letvalue{\s!do\v!line\v!middle }\midaligned -\letvalue{\s!do\v!line\v!flushleft }\rightaligned -\letvalue{\s!do\v!line\v!flushright}\leftaligned -\letvalue{\s!do\v!line\v!center }\midaligned - -\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} - -%D Experimental: - -\def\doxalignline#1#2#3#4#5#6% - {\noindentation % was \noindent - \dontleavehmode % added in marrakesch at TUG 2006\begingroup - \begingroup - \setlocalhsize - \def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient - \dowithnextbox - {%\noindent moved up - \hbox to \localhsize - {#1\hskip\ifdone#2\else#3\fi#4% - \hbox to \localhsize - {\the\everyleftofalignedline - \ifcase\alignstrutmode\or\strut\fi - \ifdone#5\unhbox\nextbox#6\else#6\unhbox\nextbox#5\fi - \the\everyrightofalignedline}% - \hss}% - \endgroup} - \hbox} - -\def\doxcheckline - {\signalrightpage\doifrightpageelse\donetrue\donefalse} - -\setvalue{\s!do\v!line\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } -\setvalue{\s!do\v!line\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} -\setvalue{\s!do\v!line\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } -\setvalue{\s!do\v!line\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} -\setvalue{\s!do\v!line\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } -\setvalue{\s!do\v!line\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} -\setvalue{\s!do\v!line\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } -\setvalue{\s!do\v!line\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} - -\setvalue{\s!do\v!line\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} -\setvalue{\s!do\v!line\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } -\setvalue{\s!do\v!line\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} -\setvalue{\s!do\v!line\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } - -% ! ! ! beware, redefining \doalignline gives the wrong results ! ! ! -% -% \def\doalignline{\doxalignline\donefalse++\zeropoint} - -%D Better: - -\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} - -\def\alignedline#1#2% setting default - {\csname\s!do\v!line\ifcsname\s!do\v!line#1\endcsname#1\else#2\fi\endcsname} - -%D ... - -\def\dosetuptolerance[#1]% - {\doifinsetelse\v!vertical{#1}% - {\normalexpanded{\noexpand\processallactionsinset[#1]} - [ \v!verystrict=>\def\bottomtolerance{}, - \v!strict=>\def\bottomtolerance{.050}, - \v!tolerant=>\def\bottomtolerance{.075}, - \v!verytolerant=>\def\bottomtolerance{.100}]}% - {\normalexpanded{\noexpand\processallactionsinset[#1]} - [ \v!stretch=>\emergencystretch\bodyfontsize, - \v!space=>\spaceskip.5em\!!plus.25em\!!minus.25em\relax, - \v!verystrict=>\tolerance 200, - \v!strict=>\tolerance1500, - \v!tolerant=>\tolerance3000, - \v!verytolerant=>\tolerance4500]}} - -\def\setuptolerance - {\dosingleargument\dosetuptolerance} - -% \def\woordrechts -% {\groupedcommand{\hfill\hbox}{\parfillskip\zeropoint}} - -% beware: \wordright{whatever\kern-\rightskip} should work! -% so, no funny boxing here - -\def\dowordright[#1]% - {% don't change - \groupedcommand - {\removeunwantedspaces - \hfill - \allowbreak % changed back from \hskip\zeropoint - \strut - \hfill - \quad % decent spacing - \hbox} - {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}% - \parfillskip\zeropoint - %\finalhyphendemerits\zerocount % yes or no - \par}} - -\def\wordright - {\dosingleempty\dowordright} - -% \dorecurse{5}{something } \wordright{--someone} \endgraf -% \dorecurse{6}{something } \wordright{--someone} \endgraf -% \dorecurse{7}{something } \wordright{--someone} \endgraf -% -% \dorecurse{5}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{6}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{7}{something } \wordright{--someone else entirely} \endgraf -% -% \wordright[\rightskip]{whatever} - -% \simplealignedbox{2cm}{right}{x} - -\setvalue{\s!simple\c!align\v!right }#1#2{\hbox to #1{#2\hss}} -\setvalue{\s!simple\c!align\v!left }#1#2{\hbox to #1{\hss#2}} -\setvalue{\s!simple\c!align\v!flushright }#1#2{\hbox to #1{\hss#2}} -\setvalue{\s!simple\c!align\v!flushleft }#1#2{\hbox to #1{#2\hss}} -\setvalue{\s!simple\c!align\v!middle }#1#2{\hbox to #1{\hss#2\hss}} - -\def\simplealignedbox#1{\executeifdefined{\s!simple\c!align#1}{\getvalue{\s!simple\c!align\v!right}}} - -%D \macros -%D {pushindentation,popindentation} -%D -%D The pushing and popping is done by: - -\newbox\indentationboxA -\newbox\indentationboxB - -\def\pushindentation - {\bgroup - \ifhmode - \unskip - \setbox\indentationboxA\lastbox % get \strut if present - \unskip - \setbox\indentationboxB\lastbox % get \indent generated box - \unskip - \else - \hskip\zeropoint % switch to horizontal mode - \unskip - \setbox\indentationboxA\lastbox % get \indent generated box - \setbox\indentationboxB\emptybox - \fi} - -\def\popindentation - {\box\indentationboxB\box\indentationboxA % put back the boxes - \egroup} - -%D The only complication lays in \type{\strut}. In \PLAIN\ -%D \TEX\ a \type{\strut} is defined as: -%D -%D \starttyping -%D \def\strut% -%D {\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} -%D \stoptyping -%D -%D But what is a \type{\strut}? Normally it's a rule of width -%D zero, but when made visual, it's a rule and a negative skip. -%D The mechanism for putting things in the margins described -%D here cannot handle this situation very well. One -%D characteristic of \type{\strut} is that the \type{\unhcopy} -%D results in entering horizontal mode, which in return leads -%D to some indentation. -%D -%D To serve our purpose a bit better, the macro \type{\strut} -%D can be redefined as: -%D -%D \starttyping -%D \def\strut -%D {\relax\ifmmode\else\hskip0pt\fi\copy\strutbox} -%D \stoptyping -%D -%D Or more compatible: -%D -%D \starttyping -%D \def\strut -%D {\relax\ifmmode -%D \copy\strutbox -%D \else -%D \bgroup\setbox\strutbox=\normalhbox{\box\strutbox}\unhcopy\strutbox\egroup -%D \fi} -%D \stoptyping -%D -%D In \CONTEXT\ however we save some processing time by putting -%D an extra \type{\hbox} around the \type{\strutbox}. - -% moved from page-lin.tex to here (due to visualization added -% in august 2003) -% -% \unexpanded \def\crlf -% {\ifhmode\unskip\else\strut\fi\ifcase\raggedstatus\hfil\fi\break} - -\unexpanded \def\crlf - {\ifhmode - \unskip - \prewordbreak\crlfplaceholder - \ifcase\raggedstatus\hfil\or\or\or\hfil\fi - \break - \else - \crlfplaceholder - \endgraf - \fi} - -\def\crlfplaceholder - {\strut} - -\def\settestcrlf - {\def\crlfplaceholder - {\hbox to \zeropoint - {\strut{\infofont\kern.25em}\lohi{\infofont CR}{\infofont LF}\hss}}} - -%D \starttyping -%D % \setuplayout[gridgrid=yes] \showgrid -%D -%D \startbuffer -%D test 1\crlf -%D test 2\crlf -%D -%D \crlf test 3 -%D -%D test 4\crlf -%D test 5 -%D -%D \crlf -%D \crlf -%D \crlf -%D test 6 -%D \stopbuffer -%D -%D \hbox -%D {\hsize5em -%D \ruledvtop{\getbuffer}\enspace -%D \ruledvtop{\showstruts\getbuffer}\enspace -%D \hsize15em \setuptyping[before=,after=]% -%D \ruledvtop{\typebuffer}} -%D \stoptyping - -\def\justonespace - {\removelastspace\space} % \removeunwantedspaces\space - -\def\ignorecrlf - {\let\crlf\justonespace\let\\\crlf} - -\def\showstruts - {\setteststrut - \settestcrlf} - -\def\definehspace - {\dotripleempty\dodefinehspace} - -\def\dodefinehspace[#1][#2][#3]% #1 = optional namespace - {\ifthirdargument - \setvalue{\??hs#1:#2}{#3}% - \else - \setvalue{\??hs:#1}{#2}% - \fi} - -\unexpanded\def\hspace - {\dodoubleempty\dohspace} - -\def\dohspace[#1][#2]% - {\ifsecondargument - \dodohspace[#1][#2]% - \else\iffirstargument - \hspace[][#1]% - \else - \hspace[][\s!default]% - \fi\fi} - -\def\dodohspace[#1][#2]% - {\ifhmode - \removeunwantedspaces - \hskip\hspaceamount{#1}{#2}% - \expandafter\ignorespaces - \fi} - -\def\hspaceamount#1#2% - {\executeifdefined{\??hs#1:#2}{\executeifdefined{\??hs:#2}\zeropoint}} - -\definehspace [\v!small] [.25\emspaceamount] -\definehspace [\v!medium] [.5\emspaceamount] -\definehspace [\v!big] [1\emspaceamount] -\definehspace [\v!normal] [1\spaceamount] -\definehspace [\v!default] [\spaceamount] - -%D Taken from Taco's math module (cq. \AMS\ macros), but -%D adapted to \type {\hspace}: - -\unexpanded\def\textormathspace #1#2#3{\ifmmode\mskip#1#2\else\kern #1\hspaceamount\empty{#3}\fi\relax} -\unexpanded\def\breakabletextormathspace#1#2#3{\ifmmode\mskip#1#2\else\hskip#1\hspaceamount\empty{#3}\fi\relax} - -\newmuskip\hairmuskip \hairmuskip=.15mu - -\unexpanded\def\hairspace {\textormathspace+\hairmuskip{.5}} -\unexpanded\def\thinspace {\textormathspace+\thinmuskip 1} -\unexpanded\def\medspace {\textormathspace+\medmuskip 2} -\unexpanded\def\thickspace {\textormathspace+\thickmuskip3} -\unexpanded\def\neghairspace {\textormathspace-\thinmuskip{.5}} -\unexpanded\def\negthinspace {\textormathspace-\thinmuskip 1} -\unexpanded\def\negmedspace {\textormathspace-\medmuskip 2} -\unexpanded\def\negthickspace{\textormathspace-\thickmuskip3} - -% needed for unicode: - -\unexpanded\def\breakablethinspace {\breakabletextormathspace+\thinmuskip 1} - -\unexpanded\def\twoperemspace {\hskip\dimexpr\emwidth/2\relax} % == \enspace -\unexpanded\def\threeperemspace {\hskip\dimexpr\emwidth/3\relax} -\unexpanded\def\fourperemspace {\hskip\dimexpr\emwidth/4\relax} -\unexpanded\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} % goodie -\unexpanded\def\sixperemspace {\hskip\dimexpr\emwidth/6\relax} -\unexpanded\def\figurespace {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this -\unexpanded\def\punctuationspace {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} -\unexpanded\def\ideographicspace {\hskip\dimexpr\emwidth/1\relax} -\unexpanded\def\ideographichalffillspace{\hskip\dimexpr\emwidth/2\relax} -%unexpanded\def\nobreakspace {\penalty\plustenthousand\space} -\unexpanded\def\nobreakspace {\penalty\plustenthousand\kern\interwordspace} -\unexpanded\def\narrownobreakspace {\penalty\plustenthousand\thinspace} -%unexpanded\def\zerowidthnobreakspace {\penalty\plustenthousand\hskip\zeropoint} -\unexpanded\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} -\unexpanded\def\zerowidthspace {\hskip\zeropoint} - -\definehspace[.5][.1250\emspaceamount] % could also be [.1250\spaceamount] -\definehspace[1] [.1667\emspaceamount] -\definehspace[2] [.2222\emspaceamount] -\definehspace[3] [.2777\emspaceamount] - -\let \, \thinspace -\let \: \medspace -\let \; \thickspace -\let \! \negthinspace - -% this will become an alternative bunch of \blank settings -% -% \startlines -% \scratchskip=.23pt plus 10pt minus 4pt \relax \number\scratchskip \space \the\scratchskip -% \setsimplifiedskip\scratchskip1 \number\scratchskip \space \the\scratchskip -% \setsimplifiedskip\scratchskip2 \number\scratchskip \space \the\scratchskip -% \getsimplifiedskip\scratchskip\scratchcounter \number\scratchcounter -% \stoplines -% -% \hrule width10cm \endgraf -% \discardedskip{10pt} -% \retainedskip {4pt} -% \discardedskip {5pt} -% \hrule width10cm \endgraf -% \blockedskip{0pt} -% \discardedskip{10pt} -% \retainedskip {4pt} -% \discardedskip {5pt} -% \hrule width10cm \endgraf -% \frozenskip {4cm} -% \hrule width10cm \endgraf -% \vskip10pt -% \hrule width10cm \endgraf - -\newskip\simplifiedskip -\newskip\simplifiedcounter - -\chardef\@@discardedskip1 -\chardef\@@retainedskip 2 -\chardef\@@forcedskip 3 -\chardef\@@blockedskip 4 -\chardef\@@frozenskip 5 % after heads, no break - -\def\setsimplifiedskip#1#2% - {#1\dimexpr(10\dimexpr(#1/10)) plus \gluestretch#1 minus \glueshrink#1\relax - \advance#1\numexpr(#2)sp\relax} - -\def\getsimplifiedskip#1#2% - {\simplifiedskip#1\relax - \ifzeropt\simplifiedskip % \ifdim\simplifiedskip=\zeropoint - #2\zerocount - \else - \simplifiedcounter\dimexpr10\dimexpr#1/10\relax\relax - \advance\simplifiedskip-\simplifiedcounter - #2\number\simplifiedskip\relax - \fi} - -\def\conditionalskip#1#2% - {\scratchskip#1\relax - \setsimplifiedskip\scratchskip#2\relax - \vskip\scratchskip\relax} - -\def\defrostskip - {\scratchskip\lastskip\penalty50000\normalvskip-\scratchskip\penalty50000\relax} - -\def\frozenskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \fi} - -\def\discardedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@discardedskip - \or % discard - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@discardedskip - \fi - \or % retain - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@discardedskip - \fi - \or % forced - \conditionalskip{#1}\@@discardedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -\def\retainedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@retainedskip - \or % discard - \normalvskip-\lastskip - \conditionalskip{#1}\@@retainedskip - \or % retain - \ifdim\lastskip>#1\else - \normalvskip-\lastskip - \conditionalskip{#1}\@@retainedskip - \fi - \or % forced - \conditionalskip{#1}\@@retainedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -\def\forcedskip#1% - {\endgraf - \ifvmode - \conditionalskip{#1}\@@forcedskip - \fi} - -\def\blockedskip#1% - {\endgraf - \ifvmode - \getsimplifiedskip\lastskip\scratchcounter - \ifcase\scratchcounter - \conditionalskip{#1}\@@blockedskip - \or % discard - \conditionalskip{#1}\@@blockedskip - \or % retain - \conditionalskip{#1}\@@blockedskip - \or % forced - \conditionalskip{#1}\@@blockedskip - \or % ignored - \or % frozen - \ifdim\lastskip>#1\else - \defrostskip - \conditionalskip{#1}\@@frozenskip - \fi - \else\ifdim#1=\zeropoint\else - \vskip#1\relax - \fi\fi - \fi} - -% beware, changing this will break some code (like pos/backgrounds) - -\newtoks\everyfirstparagraphintro -\newtoks\everynextparagraphintro -\newtoks\@@everyparagraphtoks - -\chardef\everyparagraphintro\zerocount - -\def\setupparagraphintro - {\dodoubleempty\dosetupparagraphintro} - -\def\dosetupparagraphintro[#1][#2]% - {\processallactionsinset - [#1] - [ \v!reset=>\global\chardef\everyparagraphintro\zerocount - \global\everyfirstparagraphintro\emptytoks - \global\everynextparagraphintro \emptytoks, - \v!first=>\global\chardef\everyparagraphintro\plusone - \doglobal\appendtoks#2\to\everyfirstparagraphintro, - \v!next=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plusone\fi - \doglobal\appendtoks#2\to\everynextparagraphintro, - \v!each=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plustwo\fi - \doglobal\appendtoks#2\to\everyfirstparagraphintro - \doglobal\appendtoks#2\to\everynextparagraphintro]} - -%D We can say: -%D -%D \starttyping -%D \setupparagraphintro[first][\index{Knuth}] -%D \stoptyping -%D -%D Maybe more convenient is: -%D -%D \starttyping -%D \flushatparagraph{\index{Zapf}} -%D \stoptyping - -\def\flushatparagraph#1% - {\global\chardef\everyparagraphintro\plusone - \global\appendtoks{#1}\to\everyfirstparagraphintro - \global\let\insertparagraphintro\doinsertparagraphintro} - -\def\doinsertparagraphintro % can be merged with the next - {\ifcase\everyparagraphintro\else\@EA\dodoinsertparagraphintro\fi} - -\def\dodoinsertparagraphintro - {\begingroup - \everypar\emptytoks - \ifcase\everyparagraphintro\relax - % no data - \@@everyparagraphtoks\emptytoks - \or - % first data - \global\chardef\everyparagraphintro\plustwo - \@@everyparagraphtoks\everyfirstparagraphintro - \global\everyfirstparagraphintro\emptytoks - \or - % next data - \@@everyparagraphtoks\everynextparagraphintro - \fi - \the\@@everyparagraphtoks - \global\let\insertparagraphintro\relax - \endgroup} - -\let\insertparagraphintro\relax - -%D \starttyping -%D \setupparagraphintro[first][\hbox to 3.5em{\tt FIRST \hss}] -%D \setupparagraphintro[first][\hbox to 3.5em{\tt TSRIF \hss}] -%D \setupparagraphintro[next] [\hbox to 3.5em{\tt NEXT \hss}] -%D \setupparagraphintro[next] [\hbox to 3.5em{\tt TXEN \hss}] -%D \setupparagraphintro[each] [\hbox to 3.0em{\tt EACH \hss}] -%D \setupparagraphintro[each] [\hbox to 3.0em{\tt HCEA \hss}] -%D -%D some paragraph \par -%D some paragraph \par -%D some paragraph \par -%D -%D \definelabel[parnumber] -%D -%D \setupparagraphintro[reset,each][\inleft{\slxx\parnumber}] -%D -%D some paragraph \par -%D some paragraph \par -%D some paragraph \par -%D \stoptyping - -%D \macros -%D {flushatnextpar} -%D -%D This macro collects data that will be flushed at the next paragraph. -%D By using this macro you can avoid interfering nodes (writes, etc). - -\newbox\postponednodedata -\let\flushpostponednodedata\relax - -\def\flushatnextpar - {\bgroup - \global\let\flushpostponednodedata\doflushpostponednodedata - \dowithnextbox{\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}\hbox} - -\def\doflushpostponednodedata - {\ifvoid\postponednodedata\else - \hbox{\smashedbox\postponednodedata}% - \fi - \global\let\flushpostponednodedata\relax} - -% Very nasty but needed for margin stuff inside colored -% paragraphs. - -\let\normalvadjust\vadjust - -% \def\graphicvadjust % bad, those low level color calls here -% {\dowithnextboxcontent -% {\forgetall} -% {\normalvadjust -% {\unvbox\nextbox -% % corrects for one line paragraphs -% \nointerlineskip -% \kern-\struttotal -% \nointerlineskip -% \verticalstrut}}% -% \vbox} - -\def\graphicvadjust % nasty bidi handling - {\dowithnextboxcontent - {\forgetall} - {\vadjust{\vbox attr \graphicvadjustattribute \plusone - {\unvbox\nextbox - % corrects for one line paragraphs - \nointerlineskip - \kern-\struttotal - \nointerlineskip - \verticalstrut}}}% - \vbox} - -%D This works only in a properly strutted line, and is meant -%D for deeply burried operations, like in heads. - -\def\fakedvadjust - {\dowithnextbox - {\setbox\nextbox\hbox{\llap{\lower\strutdepth\box\nextbox}}% - \smashedbox\nextbox}% - \vtop} - -\def\flexiblespaceamount#1#2#3% - {#1\interwordspace - \!!plus#2\interwordstretch - \!!minus#3\interwordshrink} - -\def\fixedspaceamount#1% - {#1\interwordspace} - -%D This is a dangerous feature because it makes the \TEX\ source -%D less portable, i.e. any parser now needs to apply exactly the -%D same algorithm when it wants to interpret the source. We -%D strongly recommend not to mention this feature in manuals! It's -%D provided for users who are hooked to such a mechanism. -%D -%D \starttyping -%D \setupsorting[logo][next=\autoinsertnextspace] \logo[TEX]{\TeX} -%D -%D bla bla \TEX bla bla \TEX (bla) bla (\TEX) -%D \stoptyping - -\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} - -\def\doautoinsertnextspace % slightly extended version of a user supplied macro - {\ifx\nexttoken \bgroup\else \ifx\nexttoken\begingroup\else - \ifx\nexttoken \egroup\else \ifx\nexttoken \endgroup\else - \ifx\nexttoken \/\else \ifx\nexttoken /\else \ifx\nexttoken ~\else - \ifx\nexttoken \ \else \ifx\nexttoken \blankspace\else \ifx\nexttoken \space\else - \ifx\nexttoken .\else \ifx\nexttoken ,\else - \ifx\nexttoken !\else \ifx\nexttoken ?\else - \ifx\nexttoken :\else \ifx\nexttoken ;\else - \ifx\nexttoken '\else \ifx\nexttoken "\else - \ifx\nexttoken )\else \ifx\nexttoken -\else \ifx\nexttoken |\else - \ifx\nexttoken \%\else \ifx\nexttoken \&\else - \space - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} - -% moved from page-lin - -\def\installspacehandler#1#2% needs to set \obeyedspace - {\setvalue{\??sr#1}{#2}} - -\installspacehandler \v!on - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}% - \let\ =\obeyedspace} - -\installspacehandler \v!yes - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode \normalspace }}% - \let\ =\obeyedspace} - -\installspacehandler \v!off - {\normalspaces - \let\obeyedspace\normalspace - \let\ =\normalspace} - -\installspacehandler \v!fixed - {\obeyspaces - \def\obeyedspace{\mathortext\normalspace{\dontleavehmode\fixedspace}}% - \let\ =\obeyedspace} - -\def\activatespacehandler#1% - {\executeifdefined{\??sr#1}{\activatespacehandler\v!off}} - -% moved from page-lin - -%D When spacing is active we need to handle commands in -%D a special way: -%D -%D \starttyping -%D \setuplines[space=on] -%D -%D \startlines -%D Let's talk about this{\ttsl\gobbleoneargument or}that. -%D \stoplines -%D -%D \startlines -%D Let's talk about this{\getvalue{ttsl}or}that. -%D \stoplines -%D \stoptyping -%D -%D One can indent in several ways: -%D -%D \starttyping -%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even -%D -%D \startlines -%D first -%D second -%D third -%D fourth -%D \stoplines -%D \stoptyping - -\def\setuplines - {\dodoubleargument\getparameters[\??rg]} - -\def\startlines - {\@@rgbefore - \pushmacro\checkindentation - \whitespace - %\page[\v!preference]} gaat mis na koppen, nieuw: later \nobreak - \begingroup - \setupindenting[\@@rgindenting]% - \typesettinglinestrue - \setupwhitespace[\v!none]% - \obeylines - \ignorespaces - \gdef\afterfirstobeyedline % tzt two pass, net als opsomming - {\gdef\afterfirstobeyedline - {\nobreak - \doifnot\@@rgoption\v!packed{\global\let\afterfirstobeyedline\relax}}}% - \def\obeyedline - {\par - \futurelet\next\dobetweenthelines}% - \activatespacehandler\@@rgspace - \GotoPar} - -\def\stoplines - {\endgroup - \popmacro\checkindentation - \@@rgafter} - -\def\dobetweenthelines - {\doifmeaningelse\next\obeyedline - {\@@rginbetween} - {\afterfirstobeyedline}} - -\setuplines - [\c!option=, - \c!before=\blank, - \c!after=\blank, - \c!inbetween=\blank, - \c!indenting=\v!no, - \c!space=\v!default] - -\def\emptylines - {\dosingleempty\doemptylines} - -\def\doemptylines[#1]% - {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} - -\setupwhitespace - [\v!none] - -% still old-fashioned - -\indenting - [\v!never] - -\setupindenting - [\v!none] - -\setupblank - [\v!standard, - \v!big] - -\defineblank[\v!default] [\currentblank] -\defineblank[\v!before] [\v!default] -\defineblank[\v!inbetween][\v!default] -\defineblank[\v!after] [\v!before] - -\setupinterlinespace - [\c!minheight=0pt, % only special purpose - \c!mindepth=0pt, % only special purpose - \c!height=.72, - \c!depth=.28, - \c!top=1.0, - \c!bottom=0.4, - \c!distance=1pt, - \c!line=2.8ex, - \c!stretch=0] - -\setupnarrower - [\c!before=\endgraf, - \c!after=\endgraf, - \c!left=1.5em, - \c!right=1.5em, - \c!middle=1.5em] - -\setuptolerance - [\v!horizontal,\v!verystrict] - -\setuptolerance - [\v!vertical,\v!strict] - -\setupalign - [\v!bottom, - \v!width] - -\setupspacing - [\v!packed] - -\protect \endinput - -\dorecurse{2}{ - $2^{2^{2^{2}}}$ $2_{2_{2_{2}}}^{2^{2^{2^{2^{2^{2^{2^{2^{2}}}}}}}}}$ - \input tufte \inframed {tufte} - \par -} - -\dorecurse{100} { - - \kern \recurselevel pt - - \vbox { - \endgraf \strut first \endgraf - {\dosetattribute{skip-category}{1}\vskip10pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip20pt} - {\dosetattribute{skip-category}{2}\vskip10pt} - \endgraf \strut second \endgraf - } - - \endgraf \strut first \endgraf - {\dosetattribute{skip-category}{1}\vskip10pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip20pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - \endgraf \strut second \endgraf - - {\dosetattribute{skip-category}{0}\vskip10pt} % remove - {\dosetattribute{skip-category}{1}\vskip10pt} % take largest - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\vskip40pt} - {\dosetattribute{skip-category}{1}\dosetattribute{skip-order}{10}\vskip20pt} - {\dosetattribute{skip-category}{4}\dosetattribute{skip-order}{10}\vskip20pt} - {\dosetattribute{skip-category}{1}\vskip60pt} - {\dosetattribute{skip-category}{1}\vskip20pt} - {\dosetattribute{skip-category}{0}\vskip10pt} - - third (no break after this) - - {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip10pt} - {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip20pt} - {\dosetattribute{skip-category}{1}\vskip10pt} - {\dosetattribute{skip-category}{1}\vskip20pt} - - fourth - \vskip10pt - fifth -} diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua index 8b7aa72ef..bd6413f41 100644 --- a/tex/context/base/font-syn.lua +++ b/tex/context/base/font-syn.lua @@ -48,6 +48,20 @@ filters.ttf = fontloader.info filters.ttc = fontloader.info filters.dfont = fontloader.info +function fontloader.fullinfo(...) + local ff = fontloader.open(...) + if ff then + local d = ff and fontloader.to_table(ff) + d.glyphs, d.subfonts, d.gpos, d.gsub, d.lookups = nil, nil, nil, nil, nil + fontloader.close(ff) + return d + else + return nil, "error in loading font" + end +end + +filters.otf = fontloader.fullinfo + function filters.afm(name) -- we could parse the afm file as well, and then report an error but -- it's not worth the trouble @@ -191,7 +205,7 @@ function names.identify(verbose) -- lsr is for kpse end end if result.fontname then - fontname = fontname or result.fontname + fontname = result.fontname or fontname local n = cleanname(result.fontname) if not mapping[n] then mapping[n], nofok = { lower(suffix), fontname, filename, is_sub }, nofok + 1 @@ -199,12 +213,34 @@ function names.identify(verbose) -- lsr is for kpse end if result.familyname and result.weight and result.italicangle == 0 then local madename = result.familyname .. " " .. result.weight - fontname = fontname or madename + fontname = madename or fontname local n = cleanname(fontname) if not mapping[n] and not fallback_mapping[n] then fallback_mapping[n], nofok = { lower(suffix), fontname, filename, is_sub }, nofok + 1 end end + if result.names then + for k, v in ipairs(result.names) do + local lang, names = v.lang, v.names + if lang == "English (US)" then + local family, subfamily, fullnamet = names.family, names.subfamily, names.fullname + local preffamilyname, prefmodifiers, weight = names.preffamilyname, names.prefmodifiers, names.weight + if preffamilyname then + if subfamily then + local n = cleanname(preffamilyname .. " " .. subfamily) + if not mapping[n] and not fallback_mapping[n] then + fallback_mapping[n], nofok = { lower(suffix), fontname, filename, is_sub }, nofok + 1 + end + end + -- okay? + local n = cleanname(preffamilyname) + if not mapping[n] and not fallback_mapping[n] then + fallback_mapping[n], nofok = { lower(suffix), fontname, filename, is_sub }, nofok + 1 + end + end + end + end + end end local trace = verbose or trace_names local skip_paths = filters.paths diff --git a/tex/context/base/math-for.mkiv b/tex/context/base/math-for.mkiv index b8f6beb5e..c8f73a8a3 100644 --- a/tex/context/base/math-for.mkiv +++ b/tex/context/base/math-for.mkiv @@ -53,6 +53,7 @@ \else \getparameters[\??fm][#1]% \fi + \edef\currentformula{#1}% \the\everysetupformulas} %D Not yet cleanup up: diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index ff4d48c1d..eab739d04 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -435,7 +435,7 @@ \xdef\MPlly{#3}% ugly as well \xdef\MPurx{#4}% \xdef\MPury{#5}% - \getobject{MP}{#1}} + \forcecolorhack\getobject{MP}{#1}} % else no proper color intent \long\def\handleuniqueMPgraphic#1#2#3% {\begingroup diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex index 6a6cba5d5..123ff79bd 100644 --- a/tex/context/base/mult-sys.tex +++ b/tex/context/base/mult-sys.tex @@ -517,6 +517,7 @@ \definesystemvariable {mx} % MatriX \definesystemvariable {ng} % parbuilders \definesystemvariable {nh} % new heads (structure) +\definesystemvariable {nn} % structurenumbering \definesystemvariable {nm} % Nummering \definesystemvariable {np} % NaastPlaatsen \definesystemvariable {nr} % Nummeren diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index 04d9cc9a7..807532665 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -1866,9 +1866,9 @@ %D framecolorkaderkleur=DemoBlue, %D rulethickness=2pt] %D \def\status% -%D {backgroundoffset=\framedparameter\c!backgroundoffset\\ -%D frameoffset=\framedparameter\c!frameoffset\\ -%D depth=\framedparameter\c!depth} +%D {backgroundoffset=\the\dimexpr\framedparameter\c!backgroundoffset\relax\\ +%D frameoffset=\the\dimexpr\framedparameter\c!frameoffset\relax\\ +%D depth=\the\dimexpr\framedparameter\c!depth\relax} %D \dontleavehmode \ruledhbox{\framed[backgroundoffset=0pt,frameoffset=0pt]{\status}} %D \vss %D \dontleavehmode \ruledhbox{\framed[backgroundoffset=5pt,frameoffset=0pt]{\status}} diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv index 4df499d84..e13590bbc 100644 --- a/tex/context/base/page-txt.mkiv +++ b/tex/context/base/page-txt.mkiv @@ -197,7 +197,7 @@ \def\dosingletexts#1#2#3#4#5#6% {\bgroup - \defconvertedargument\ascii{#6}% no longer \defconvertedargument + \defconvertedargument\ascii{#6}% no longer \defconvertedargument, this also does not permit \v!pagenumber (i.e. v!) \ifx\ascii\empty\else \dostartattributes{\??tk#1#2}#3#4\empty \placetextlinestrut{\??tk#1}% here ! diff --git a/tex/context/base/s-mod-01.tex b/tex/context/base/s-mod-01.tex index dc695a44d..4454986ce 100644 --- a/tex/context/base/s-mod-01.tex +++ b/tex/context/base/s-mod-01.tex @@ -16,10 +16,19 @@ \usemodule[mod-00,abr-01] +\dontcomplain + \unprotect \setupbodyfont - [10pt,ams] + [10pt] + +\definetypeface + [narrowtt] [tt] + [mono] [modern-cond] [default] [encoding=\defaultencoding] + +\setuptyping[\v!typing][\c!style=\narrowtt] +\setuptype [\v!type] [\c!style=\narrowtt] \mainlanguage [en] @@ -44,7 +53,7 @@ \c!topspace=2cm, \c!header=1.25cm, \c!footer=1.25cm, - \c!height=25cm, + \c!height=middle, \c!style=\ss] \setupsetup @@ -60,9 +69,9 @@ \setuppagenumbering [\c!location=] -\setupfootertexts +\expanded{\setupfootertexts [\v!edge] - [][\v!pagenumber] + [][\v!pagenumber]} \startmode[single] diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv new file mode 100644 index 000000000..47d44e24b --- /dev/null +++ b/tex/context/base/spac-ali.mkiv @@ -0,0 +1,653 @@ +%D \module +%D [ file=spac-ali, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Alignments, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Alignments} + +\unprotect + +% We will not use bodydir and pagedir so we disable them. That way we get +% normal hyperlink support. + +\let\@@bodydir\normalbodydir +\let\@@pagedir\normalpagedir + +\unexpanded\def\bodydir{\afterassignment\do@@bodydir\@@bodydir} \let\normalbodydir\bodydir +\unexpanded\def\pagedir{\afterassignment\do@@pagedir\@@pagedir} \let\normalpagedir\pagedir + +\def\do@@bodydir{\@@bodydir TLT\relax} +\def\do@@pagedir{\@@pagedir TLT\relax} + +% This will become a more advanced layout controller soon: + +\unexpanded\def\lefttoright{\textdir TLT\pardir TLT\relax} +\unexpanded\def\righttoleft{\textdir TRT\pardir TRT\relax} + +\def\dodefinehbox[#1][#2]% + {\setvalue{hbox#1}##1% + {\hbox to #2{\begstrut##1\endstrut\hss}}} + +\def\definehbox + {\dodoubleargument\dodefinehbox} + +\def\iobox#1#2#3#% here #3# is not really needed + {\vbox\bgroup % we want to return a vbox like the others + \hbox\bgroup% we need to pack the signal with the box + \signalrightpage + \dowithnextboxcontent + {\let\\=\endgraf\forgetall\doifrightpageelse#1#2} + {\box\nextbox\egroup\egroup} + \vbox#3} + +\def\obox{\iobox\raggedleft \raggedright} % outerbox +\def\ibox{\iobox\raggedright\raggedleft} % innerbox + +\def\dosetraggedvbox#1% + {\let\raggedbox\vbox + \processfirstactioninset + [#1] + [ \v!left=>\let\raggedbox\lbox, + \v!right=>\let\raggedbox\rbox, + \v!middle=>\let\raggedbox\cbox, + \v!inner=>\let\raggedbox\ibox, + \v!outer=>\let\raggedbox\obox, + \v!flushleft=>\let\raggedbox\rbox, + \v!flushright=>\let\raggedbox\lbox, + \v!center=>\let\raggedbox\cbox, + \v!no=>\def\raggedbox{\vbox\bgroup\raggedright\let\next=}]} + +\def\dosetraggedhbox#1% + {\let\raggedbox\hbox + \processaction % slow + [#1] + [ \v!left=>\def\raggedbox{\doalignedline\v!left }, + \v!right=>\def\raggedbox{\doalignedline\v!right }, + \v!middle=>\def\raggedbox{\doalignedline\v!middle}, + \v!inner=>\def\raggedbox{\doalignedline\v!inner }, + \v!outer=>\def\raggedbox{\doalignedline\v!outer }, + \v!flushleft=>\def\raggedbox{\doalignedline\v!right }, + \v!flushright=>\def\raggedbox{\doalignedline\v!left }, + \v!center=>\def\raggedbox{\doalignedline\v!middle}]} + +\def\dosetraggedcommand#1% + {\normalexpanded{\noexpand\dodosetraggedcommand{#1}}} + +\newtoks\everyraggedcommand + +\def\raggedcommand{\the\everyraggedcommand} + +\def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! + {\everyraggedcommand \emptytoks + \let\raggedtopcommand \empty + \let\raggedbottomcommand\empty + \chardef\raggedoneliner\zerocount + \doifsomething{#1} + {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse + \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse + \!!donectrue + \rawprocesscommalist[#1]\dododosetraggedcommand}} + +\def\dododosetraggedcommand#1% + {\executeifdefined{\@@ragged@@command\string#1}\relax} + +\def\@@ragged@@command{@@raggedcommand} + +\setvalue{\@@ragged@@command\v!hanging }{\appendtoks\enableprotruding \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nothanging }{\appendtoks\disableprotruding \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!hz }{\appendtoks\enableadjusting \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nohz }{\appendtoks\disableadjusting \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!spacing }{\appendtoks\enablespacehandling + \enablekernhandling \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nospacing }{\appendtoks\disablespacehandling + \disablekernhandling \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!hyphenated }{\appendtoks\dohyphens \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nothyphenated}{\appendtoks\nohyphens \to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!tolerant }{\appendtoks\tolerance3000\relax \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!verytolerant}{\appendtoks\tolerance4500\relax \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!stretch }{\appendtoks\emergencystretch\bodyfontsize\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!left}% + {\if!!donea \appendtoks\veryraggedleft\to\everyraggedcommand + \else \appendtoks\raggedleft \to\everyraggedcommand + \fi + \!!donecfalse} + +\setvalue{\@@ragged@@command\v!right}% + {\if!!donea \appendtoks\veryraggedright\to\everyraggedcommand + \else \appendtoks\raggedright \to\everyraggedcommand + \fi + \!!donecfalse} + +\setvalue{\@@ragged@@command\v!middle}% + {\if!!donec + \if!!doneb \appendtoks\raggedwidecenter\to\everyraggedcommand + \else\if!!donea \appendtoks\veryraggedcenter\to\everyraggedcommand + \else \appendtoks\raggedcenter \to\everyraggedcommand + \fi\fi + \!!donecfalse + \else + \let\raggedbottomcommand\vfilll % bonus, pretty strong + \let\raggedtopcommand \vfilll % used with \framed for + \fi} % instance in tables + +\setvalue{\@@ragged@@command\v!flushleft }{\getvalue{\@@ragged@@command\v!right }} +\setvalue{\@@ragged@@command\v!flushright}{\getvalue{\@@ragged@@command\v!left }} +\setvalue{\@@ragged@@command\v!center }{\getvalue{\@@ragged@@command\v!middle}} + +\setvalue{\@@ragged@@command\v!high}% + {\let\raggedbottomcommand\vfilll} % and since we lack a + +\setvalue{\@@ragged@@command\v!low}% + {\let\raggedtopcommand\vfilll} % proper keyword, but + +\setvalue{\@@ragged@@command\v!lohi}% + {\let\raggedbottomcommand\vfilll % we do support the + \let\raggedtopcommand\vfilll} % ugly laho (lohi) + +\setvalue{\@@ragged@@command\v!no}% + {\appendtoks\raggedright\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!yes}% + {\appendtoks\notragged\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!normal}% + {\appendtoks\notragged\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!inner}% not yet perfect + {\signalrightpage % may interfere + \doifrightpageelse + {\getvalue{\@@ragged@@command\v!right}} + {\getvalue{\@@ragged@@command\v!left}}} + +\setvalue{\@@ragged@@command\v!outer}% not yet perfect + {\signalrightpage % may interfere + \doifrightpageelse + {\getvalue{\@@ragged@@command\v!left}} + {\getvalue{\@@ragged@@command\v!right}}} + +\setvalue{\@@ragged@@command\v!lesshyphenation}% + {\appendtoks\lesshyphens\to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!morehyphenation}% + {\appendtoks\morehyphens\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!lefttoright}{\appendtoks\lefttoright\to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!righttoleft}{\appendtoks\righttoleft\to\everyraggedcommand} +\setvalue{\@@ragged@@command l2r}{\appendtoks\lefttoright\to\everyraggedcommand} +\setvalue{\@@ragged@@command r2l}{\appendtoks\righttoleft\to\everyraggedcommand} + +% compare: +% +% \framed[width=4cm,align=no] {\hfil xxx} +% \framed[width=4cm,align=disable]{\hfil xxx} + +\setvalue{\@@ragged@@command\v!disable}% for one liners + {\appendtoks\raggedright\parfillskip\zeropoint\to\everyraggedcommand} + +\chardef\raggedoneliner\zerocount + +\setvalue{\@@ragged@@command\v!line}% + {\chardef\raggedoneliner\plusone} + +% More alignments: + +% \hyphenpenalty = ( 2.5 * \hsize ) / \raggedness +% \tolerance >= 1500 % was 200 +% \raggedness = 2 .. 6\bodyfontsize + +\chardef\raggedstatus=0 % normal left center right + +\def\leftraggedness {2\bodyfontsize} +\def\rightraggedness {2\bodyfontsize} +\def\middleraggedness {6\bodyfontsize} + +\def\middleraggedness {.5\hsize} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} + +% oeps, hsize can be 0pt in which case we get a strange division + +\def\middleraggedness {\ifdim\hsize=\zeropoint6\bodyfontsize\else.5\hsize\fi} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} + +%D More hyphenation control, will be combined with align +%D setup. + +\def\nohyphens + {\ifx\dohyphens\relax + \edef\dohyphens + {\hyphenpenalty\the\hyphenpenalty + \exhyphenpenalty\the\exhyphenpenalty\relax}% + \fi + \hyphenpenalty\plustenthousand + \exhyphenpenalty\plustenthousand} + +\let\dohyphens\relax + +%D To prevent unwanted side effects, we also have to check +%D for hyphens here: + +\newskip\@@raggedskipa +\newskip\@@raggedskipb + +\def\setraggedness#1% + {\ifnum\tolerance<1500\relax % small values have + \tolerance1500\relax % unwanted side effects + \fi + \ifx\dohyphens\relax + % this code will be reconsidered / kind of fuzzy (and old) + \@@raggedskipa 2.5\hsize + \@@raggedskipb #1\relax + \divide\@@raggedskipa \@@raggedskipb + \hyphenpenalty\@@raggedskipa + \fi} + +\let\updateraggedskips\relax + +\def\setraggedskips#1#2#3#4#5#6#7% never change this name + {\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% + \updateraggedskips} + +\def\dosetraggedskips#1#2#3#4#5#6#7% + {\chardef \raggedstatus#1\relax + \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 + \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 + \spaceskip #4\relax + \xspaceskip #5\relax + \parfillskip\zeropoint\!!plus#6\relax + \parindent #7\relax} + +% \def\notragged% +% {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} + +% older (context) names: + +\let\spaceamount \interwordspace +\let\emspaceamount\emwidth + +% tracing: + +\def\doshowpardata#1% + {\ifx#1\relax\else + \hbox{\string#1: \the#1}\endgraf + \expandafter\doshowpardata + \fi} + +\def\showpardata + {\edef\thepardata + {\hbox{font: \fontname\font}\endgraf + \doshowpardata + \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace + \hsize \vsize + \leftskip \rightskip + \spaceskip \xspaceskip + \parindent \parfillskip + \hyphenpenalty \exhyphenpenalty + \displaywidowpenalty \widowpenalty \clubpenalty \brokenpenalty + \doublehyphendemerits \finalhyphendemerits \adjdemerits + \relax}% + \begingroup + \dontshowcomposition + \inleftmargin{\vsmash + {\switchtobodyfont[7pt,tt]% + \framed[\c!align=\v!right]{\thepardata}}}% + \endgroup} + +\def\startshowpardata + {\begingroup + \showcomposition + \showstruts\tracepositionstrue \tracingparagraphs\maxdimen + \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} + +\def\stopshowpardata + {\endgraf + \endgroup} + +% \defineXMLenvironment[showpardata] \startshowpardata \stopshowpardata +% \defineXMLsingular [showpardata] \showpardata + +% defaults + +\def\raggedfillamount {1fil} +\def\raggedhalffillamount{.5fil} +\def\raggedspaceamount {\interwordspace} % {.3333em} +\def\raggedxspaceamount {.5em} + +\def\notragged + {\chardef\raggedstatus\zerocount + \leftskip 1\leftskip + \rightskip 1\rightskip + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parfillskip\zeropoint\!!plus\raggedfillamount\relax + \let\updateraggedskips\relax} % new + +\let\forgetragged\notragged + +\def\raggedleft + {\setraggedness\leftraggedness + \setraggedskips1\leftraggedness\zeropoint\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +\def\raggedcenter + {\setraggedness\middleraggedness + \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +%D We used to have: +%D +%D \starttyping +%D \def\raggedright +%D {\setraggedness\rightraggedness +%D \setraggedskips{3}{0em}{\rightraggedness}{.3333em}{.5em}{0em}{\parindent}} +%D \stoptyping +%D +%D However, the next alternative, suggested by Taco, is better. + +\def\raggedright + {\setraggedness\rightraggedness + \setraggedskips3\zeropoint\rightraggedness\raggedspaceamount + \raggedxspaceamount\raggedfillamount\parindent} + +\def\veryraggedleft + {\setraggedskips1\raggedfillamount\zeropoint\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +%D When we want the last line to have a natural width: +%D +%D \starttyping +%D \def\veryraggedleft% +%D {\setraggedskips{1}{1fil}{0em}{.3333em}{.5em}{0em}{-1fil}} +%D \stoptyping +%D +%D but this one is not accepted by the macros. + +\def\veryraggedcenter + {\setraggedskips2\raggedfillamount\raggedfillamount\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +\def\veryraggedright + {\setraggedskips3\zeropoint\raggedfillamount\raggedspaceamount + \raggedxspaceamount\zeropoint\parindent} + +\def\ttraggedright + {\tttf + \setraggedskips3\zeropoint\rightraggedness + \zeropoint\zeropoint\zeropoint\parindent} % \ctxparindent + +%D A bonus one: + +\def\raggedwidecenter + {\setraggedness\middleraggedness + \setraggedskips2\raggedhalffillamount\raggedhalffillamount + \raggedspaceamount\raggedxspaceamount\zeropoint\zeropoint} + +\newif\if@@asragged \@@asraggedtrue % old method + +% todo +% +% \setuplayout[grid=yes,lines=44] \showgrid +% \starttext +% test \vfill test \endgraf \strut \endgraf \vskip-\lineheight \removedepth \pagina test +% \stoptext + +% \setupalign[reset,new,right,old] + +\def\@@align@@rl{\if!!donea\veryraggedleft \else\raggedleft \fi} +\def\@@align@@rr{\if!!donea\veryraggedright \else\raggedright \fi} +\def\@@align@@rc{\if!!donea\veryraggedcenter\else\raggedcenter\fi} + +\setvalue{@@ngila@@\v!broad }{\!!doneatrue} +\setvalue{@@ngila@@\v!wide }{\!!donebtrue} + +\def\installalign#1#2{\setvalue{@@align@@#1}{#2}} % can be used for overloads + +\installalign \v!new {\@@asraggedfalse} +\installalign \v!old {\@@asraggedtrue} +\installalign \empty {} + +\installalign \v!line {\baselinebottom} +\installalign \v!bottom {\raggedbottom} +\installalign \v!height {\normalbottom} +\installalign \v!width {\notragged} +\installalign \v!normal {\notragged} +\installalign \v!yes {\notragged} +\installalign \v!no {\raggedright} +\installalign \v!inner {\if@@asragged \setraggedparagraphmode\@@align@@rl\@@align@@rr \else + \setraggedparagraphmode\@@align@@rr\@@align@@rl \fi} +\installalign \v!outer {\if@@asragged \setraggedparagraphmode\@@align@@rr\@@align@@rl \else + \setraggedparagraphmode\@@align@@rl\@@align@@rr \fi} +\installalign \v!left {\if@@asragged\@@align@@rl\else\@@align@@rr\fi} +\installalign \v!right {\if@@asragged\@@align@@rr\else\@@align@@rl\fi} +\installalign \v!middle {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} +\installalign \v!flushleft {\if!!donea\veryraggedright \else\raggedright\fi} +\installalign \v!flushright {\if!!donea\veryraggedleft \else\raggedleft \fi} +\installalign \v!flushouter {\setraggedparagraphmode\raggedleft\raggedright} +\installalign \v!flushinner {\setraggedparagraphmode\raggedright\raggedleft} +\installalign \v!center {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} +\installalign \v!hanging {\enableprotruding} +\installalign \v!nothanging {\disableprotruding} +\installalign \v!hz {\enableadjusting} +\installalign \v!nohz {\disableadjusting} +\installalign \v!spacing {\enablespacehandling \enablekernhandling} +\installalign \v!nospacing {\disablespacehandling\disablekernhandling} +\installalign \v!hyphenated {\dohyphens} +\installalign \v!nothyphenated {\nohyphens} +\installalign \v!new {\@@asraggedfalse} % so new will give you consistency +\installalign \v!reset {\notragged\normalbottom} + +\installalign \v!tolerant {\tolerance3000 \relax} +\installalign \v!verytolerant {\tolerance4500 \relax} +\installalign \v!stretch {\emergencystretch\bodyfontsize} + +\installalign \v!grid {\doenablegridsnapping } % only mkiv +\installalign \v!nogrid {\dodisablegridsnapping} % only mkiv + +\installalign \v!righttoleft {\lefttoright} +\installalign \v!lefttoright {\righttoleft} +\installalign {l2r} {\lefttoright} +\installalign {r2l} {\righttoleft} + +\newcount\hyphenminoffset + +\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi + +\def\lesshyphens + {\advance\hyphenminoffset\plusone + \sethyphenationvariables} + +\def\morehyphens + {\ifcase\hyphenminoffset \else + \advance\hyphenminoffset\minusone + \fi + \sethyphenationvariables} + +\installalign \v!lesshyphenation {\lesshyphens} +\installalign \v!morehyphenation {\morehyphens} + +\def\dodosetupalign#1{\csname @@align@@#1\endcsname} +\def\dodosetupngila#1{\csname @@ngila@@#1\endcsname} + +\def\setupalign + {\dosingleargument\dosetupalign} + +\def\dosetupalign[#1]% can be made faster by checking for defined #1 + {\!!doneafalse + \!!donebfalse + \processcommacommand[#1]\dodosetupngila + \processcommacommand[#1]\dodosetupalign} + +% \setupalign[flushleft] \input ward \par % lijnlinks +% \setupalign[right] \input ward \par + +% \setupalign[flushright] \input ward \par % lijnrechts +% \setupalign[left] \input ward \par + +% \setupalign[middle] \input ward \par % centreer +% \setupalign[center] \input ward \par + +\def\startalignment + {\bgroup + \setupalign} + +\def\stopalignment + {\par + \egroup} + +\chardef\alignstrutmode=1 + +% see later for the real definition, which in the simple case is: + +\newtoks \everyleftofalignedline +\newtoks \everyrightofalignedline + +\def\shiftalignedline#1#2#3#4% left, right, inner, outer + {\rightorleftpageaction + {\everyleftofalignedline {\hskip\dimexpr#1+#3\relax}% + \everyrightofalignedline{\hskip\dimexpr#2+#4\relax}} + {\everyleftofalignedline {\hskip\dimexpr#1+#4\relax}% + \everyrightofalignedline{\hskip\dimexpr#2+#3\relax}}} + +\def\doalignline#1#2% \\ == newline + {\noindentation % was \noindent + \dontleavehmode % added in marrakesch at TUG 2006\begingroup + \begingroup + \setlocalhsize % new + \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% + \dowithnextbox + {\hbox to \localhsize + {\ifcase\alignstrutmode\or\strut\fi + \the\everyleftofalignedline + #1\unhbox\nextbox#2\relax + \the\everyrightofalignedline}% + \endgroup} + \hbox} + +% plain commands + +\ifx\undefined\line \def\line {\hbox to\hsize} \fi +\ifx\undefined\leftline \def\leftline #1{\line{#1\hss}} \fi +\ifx\undefined\rightline \def\rightline #1{\line{\hss#1}} \fi +\ifx\undefined\centerline \def\centerline#1{\line{\hss#1\hss}} \fi + +% directe commando's + +\def\leftaligned {\doalignline \relax \hss } +\def\midaligned {\doalignline \hss \hss } +\def\rightaligned{\doalignline \hss \relax} + +\let\centeraligned\midaligned + +\def\regelbegrensd#1{\limitatetext{#1}{\hsize}{\unknown}} % to be translated + +% indirecte commando's + +\letvalue{\s!do\v!line\v!left }\leftaligned +\letvalue{\s!do\v!line\v!right }\rightaligned +\letvalue{\s!do\v!line\v!middle }\midaligned +\letvalue{\s!do\v!line\v!flushleft }\rightaligned +\letvalue{\s!do\v!line\v!flushright}\leftaligned +\letvalue{\s!do\v!line\v!center }\midaligned + +\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} + +%D Experimental: + +\def\doxalignline#1#2#3#4#5#6% + {\noindentation % was \noindent + \dontleavehmode % added in marrakesch at TUG 2006\begingroup + \begingroup + \setlocalhsize + \def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient + \dowithnextbox + {%\noindent moved up + \hbox to \localhsize + {#1\hskip\ifdone#2\else#3\fi#4% + \hbox to \localhsize + {\the\everyleftofalignedline + \ifcase\alignstrutmode\or\strut\fi + \ifdone#5\unhbox\nextbox#6\else#6\unhbox\nextbox#5\fi + \the\everyrightofalignedline}% + \hss}% + \endgroup} + \hbox} + +\def\doxcheckline + {\signalrightpage\doifrightpageelse\donetrue\donefalse} + +\setvalue{\s!do\v!line\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } +\setvalue{\s!do\v!line\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} +\setvalue{\s!do\v!line\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } +\setvalue{\s!do\v!line\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} +\setvalue{\s!do\v!line\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } +\setvalue{\s!do\v!line\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} +\setvalue{\s!do\v!line\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } +\setvalue{\s!do\v!line\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} + +\setvalue{\s!do\v!line\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} +\setvalue{\s!do\v!line\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } +\setvalue{\s!do\v!line\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} +\setvalue{\s!do\v!line\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } + +% ! ! ! beware, redefining \doalignline gives the wrong results ! ! ! +% +% \def\doalignline{\doxalignline\donefalse++\zeropoint} + +%D Better: + +\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} + +\def\alignedline#1#2% setting default + {\csname\s!do\v!line\ifcsname\s!do\v!line#1\endcsname#1\else#2\fi\endcsname} + +% \def\woordrechts +% {\groupedcommand{\hfill\hbox}{\parfillskip\zeropoint}} + +% beware: \wordright{whatever\kern-\rightskip} should work! +% so, no funny boxing here + +\def\dowordright[#1]% + {% don't change + \groupedcommand + {\removeunwantedspaces + \hfill + \allowbreak % changed back from \hskip\zeropoint + \strut + \hfill + \quad % decent spacing + \hbox} + {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}% + \parfillskip\zeropoint + %\finalhyphendemerits\zerocount % yes or no + \par}} + +\def\wordright + {\dosingleempty\dowordright} + +% \dorecurse{5}{something } \wordright{--someone} \endgraf +% \dorecurse{6}{something } \wordright{--someone} \endgraf +% \dorecurse{7}{something } \wordright{--someone} \endgraf +% +% \dorecurse{5}{something } \wordright{--someone else entirely} \endgraf +% \dorecurse{6}{something } \wordright{--someone else entirely} \endgraf +% \dorecurse{7}{something } \wordright{--someone else entirely} \endgraf +% +% \wordright[\rightskip]{whatever} + +% \simplealignedbox{2cm}{right}{x} + +\setvalue{\s!simple\c!align\v!right }#1#2{\hbox to #1{#2\hss}} +\setvalue{\s!simple\c!align\v!left }#1#2{\hbox to #1{\hss#2}} +\setvalue{\s!simple\c!align\v!flushright }#1#2{\hbox to #1{\hss#2}} +\setvalue{\s!simple\c!align\v!flushleft }#1#2{\hbox to #1{#2\hss}} +\setvalue{\s!simple\c!align\v!middle }#1#2{\hbox to #1{\hss#2\hss}} + +\def\simplealignedbox#1{\executeifdefined{\s!simple\c!align#1}{\getvalue{\s!simple\c!align\v!right}}} + +\protect \endinput diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv new file mode 100644 index 000000000..db4f4c2a4 --- /dev/null +++ b/tex/context/base/spac-def.mkiv @@ -0,0 +1,119 @@ +%D \module +%D [ file=spac-def, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Definitions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Definitions} + +\unprotect + +\def\forgeteverypar + {\everypar{\the\neverypar}} + +\def\forgetparindent + {\forgeteverypar + \indentfirstparagraphtrue % recently added + \let\currentindentation\v!none + \ctxparindent\zeropoint + \parindent\zeropoint\relax} + +\def\forgetparskip + {\let\currentwhitespace\v!none + \ctxparskip\zeropoint + \parskip\zeropoint\relax} + +\def\forgetbothskips + {\tolerance1500 + \leftskip\zeropoint + \rightskip\zeropoint\relax} + +\def\forgetspacing + {\emergencystretch\zeropoint} + +\newif\ifforgotten % rather good signal for inner + +\appendtoks \forgottentrue \to \everyforgetall +\appendtoks \forgetragged \to \everyforgetall +\appendtoks \forgetparskip \to \everyforgetall +\appendtoks \forgetparindent \to \everyforgetall +\appendtoks \forgetbothskips \to \everyforgetall +\appendtoks \forgetspacing \to \everyforgetall % i.v.m. funny spacing in pagebody +\appendtoks \spacing\plusone \to \everyforgetall % new per 10/08/2004, else problems in otr / !! needed +\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! + + +\appendtoks \spacing\plusone \to \everybodyfont +\appendtoks \presetnormallineheight \to \everybodyfont +\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant +\appendtoks \setstrut \to \everybodyfont % check if redundant +\appendtoks \settopskip \to \everybodyfont +\appendtoks \setmaxdepth \to \everybodyfont +\appendtoks \simplesetupindenting \to \everybodyfont +\appendtoks \simplesetupblank \to \everybodyfont +\appendtoks \simplesetupwhitespace \to \everybodyfont +%appendtoks \checknotes \to \everybodyfont % not +\appendtoks \simplesetupspacing \to \everybodyfont % nieuw +\appendtoks \setrelativeinterlinespace \to \everybodyfont + +\appendtoks \updateraggedskips \to \everyfontswitch % under test +\prependtoks \let\par\endgraf \to \everypagebody % see \fillinline +\appendtoks \simplesetupspacing \to \everydefinedfont + +\setupwhitespace + [\v!none] + +\indenting + [\v!never] + +\setupindenting + [\v!none] + +\setupvspacing + [\v!standard, + \v!big] + +\definevspacing[\v!default] [\currentblank] +\definevspacing[\v!before] [\v!default] +\definevspacing[\v!inbetween][\v!default] +\definevspacing[\v!after] [\v!before] + +\setupinterlinespace + [\c!minheight=0pt, % only special purpose + \c!mindepth=0pt, % only special purpose + \c!height=.72, + \c!depth=.28, + \c!top=1.0, + \c!bottom=0.4, + \c!distance=1pt, + \c!line=2.8ex, + \c!stretch=0] + +\setupnarrower + [\c!before=\endgraf, + \c!after=\endgraf, + \c!left=1.5em, + \c!right=1.5em, + \c!middle=1.5em] + +\setuptolerance + [\v!horizontal,\v!verystrict] + +\setuptolerance + [\v!vertical,\v!strict] + +\setupalign + [\v!bottom, + \v!width] + +\setupspacing + [\v!packed] + +\protect \endinput diff --git a/tex/context/base/spac-fnt.mkiv b/tex/context/base/spac-fnt.mkiv new file mode 100644 index 000000000..fae32c94b --- /dev/null +++ b/tex/context/base/spac-fnt.mkiv @@ -0,0 +1,91 @@ +%D \module +%D [ file=spac-fnt, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Fonts, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Fonts} + +%D For historic reasons here, will move: + +\unprotect + +\let\dostopattributes\relax % in case these commands end up in an edef + +\unexpanded\def\@@dostopattributes + {\stopcolor + \finishparbasedattributes + \endgroup} + +\unexpanded\def\@@nostopattributes + {\finishparbasedattributes + \endgroup} + +\unexpanded\def\doattributes#1#2#3#4% + {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} + +% An even faster \ETEX\ version: + +\unexpanded\def\dostartattributes#1#2#3% + {\begingroup % geen \bgroup, anders in mathmode lege \hbox + \ifincolor + \ifcsname#1#3\endcsname + \let\dostopattributes\@@dostopattributes + \faststartcolor[\csname#1#3\endcsname]% + \else + \let\dostopattributes\@@nostopattributes + \fi + \else + \let\dostopattributes\@@nostopattributes + \fi + \ifcsname#1#2\endcsname + % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi} + +\unexpanded\def\@@dostopattributes + {\faststopcolor + \finishparbasedattributes + \endgroup} + +\unexpanded\def\@@nostopattributes + {\finishparbasedattributes + \endgroup} + +%D Bonus macro, see core-sec.tex + +\unexpanded\def\dosetfontattribute#1#2% + {\ifcsname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi\empty} + +%D Since this happens a lot, and sometimes large arguments +%D are passed in \type {#4}, we just copy some code: + +\unexpanded\def\doattributes#1#2#3#4% + {\begingroup % geen \bgroup, anders in mathmode lege \hbox + \ifincolor + \ifcsname#1#3\endcsname + \let\dostopattributes\@@dostopattributes + \faststartcolor[\csname#1#3\endcsname]% + \else + \let\dostopattributes\endgroup + \fi + \else + \let\dostopattributes\endgroup + \fi + \ifcsname#1#2\endcsname + % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi + {#4}% + \dostopattributes} + +\protect \endinput diff --git a/tex/context/base/spac-gen.mkii b/tex/context/base/spac-gen.mkii new file mode 100644 index 000000000..4f365b498 --- /dev/null +++ b/tex/context/base/spac-gen.mkii @@ -0,0 +1,4656 @@ +%D \module +%D [ file=core-spa, +%D version=1997.03.31, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Spacing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Core Macros / Spacing} + +% to be sorted out: dependencies, order of initialization / also some dutch code here + +\unprotect + +% some will move to core-var + +\newif \ifgridsnapping +\newif \iffuzzyvskip +\let \fuzzyvskip \gobbleoneargument +\let \removelastfuzzyvskip \relax + +\let \startbaselinecorrection \relax +\let \stopbaselinecorrection \relax +\let \baselinecorrection \relax +\let \offbaselinecorrection \relax + +\appendtoks \spacing 1\to \everybodyfont +\appendtoks \presetnormallineheight \to \everybodyfont +\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant +\appendtoks \setstrut \to \everybodyfont % check if redundant +\appendtoks \settopskip \to \everybodyfont +\appendtoks \setmaxdepth \to \everybodyfont +%appendtoks \spacing 1\to \everybodyfont +\appendtoks \simplesetupindenting \to \everybodyfont +\appendtoks \simplesetupblank \to \everybodyfont +\appendtoks \simplesetupwhitespace \to \everybodyfont +%appendtoks \checknotes \to \everybodyfont % not +\appendtoks \simplesetupspacing \to \everybodyfont % nieuw +\appendtoks \setrelativeinterlinespace \to \everybodyfont + +\appendtoks \updateraggedskips \to \everyfontswitch % under test +\prependtoks \let\par\endgraf \to \everypagebody % see \fillinline +\appendtoks \simplesetupspacing \to \everydefinedfont + +% if you want to hyphenate the first word of a paragraph ... \appendtoks\hskip0pt\to\everypar + +\def\stelfactorenin + {\simplesetupwhitespace + \simplesetupblank + \settopskip + \setmaxdepth} + +\def\softbreak + {\relax\ifhmode\hskip\parfillskip\break\fi} + +\let\poplastnode\relax + +\def\pushlastnode + {\ifdim\lastskip=\zeropoint + \ifnum\lastpenalty=\zerocount + \ifnum\lastkern=\zerocount + \let\poplastnode\relax + \else + \edef\poplastnode{\kern\the\lastkern\relax}\kern-\lastkern % untested + \fi + \else + \edef\poplastnode{\penalty\the\lastpenalty\relax}\nobreak % untested + \fi + \else + \edef\poplastnode{\vskip\the\lastskip\relax}\vskip-\lastskip % \removelastskip + \fi} + +%D The dreadful sequence \type {\bgroup} \unknown\ +%D \type {\carryoverpar} \unknown\ \type {\egroup} is needed +%D when for instance sidefloats are used in combination with +%D something that starts with a group. This is because +%D otherwise the indentation as set (by the output routine) +%D inside the group are forgotten afterwards. (I must +%D not forget its existence). + +\global\let\carriedoverpar\relax + +\def\carryoverpar#1% + {\expanded % \scratchtoks{#1}% + {\noexpand#1% \the\scratchtoks + \hangindent\the\hangindent + \hangafter \the\hangafter + \parskip \the\parskip + \leftskip \the\leftskip + \rightskip \the\rightskip}} + +%D A quick way to determine left|/|middle|/|right states +%D (experimental). + +\setvalue{\??as\v!left }{0} +\setvalue{\??as\v!middle}{1} +\setvalue{\??as\v!right }{2} + +\def\setalignmentswitch#1% + {\chardef\alignmentswitch0\csname\??as#1\endcsname\relax} + +%D There are two ways to influence the interline spacing. The +%D most general and often most consistent way is using +%D +%D \showsetup{setupinterlinespace} +%D +%D For instance +%D +%D \starttyping +%D \setupinterlinespace[line=2.8ex] +%D \stoptyping +%D +%D This setting adapts itself to the bodyfontsize, while for +%D instance saying +%D +%D \starttyping +%D \setupinterlinespace[line=12pt] +%D \stoptyping +%D +%D sets things fixed for all sizes, which is definitely not +%D what we want. Therefore one can also say: +%D +%D \starttyping +%D \definebodyfontenvironment[9pt][interlinespace=11pt] +%D \stoptyping +%D +%D One can still use \type{\setupinterlinespace} (without +%D arguments) to set the interline space according to the +%D current font, e.g. a \type{\bfa}. + +\newif\iflocalinterlinespace + +% font-ini + +\ifx\bodyfontinterlinespecs\undefined + + \let\bodyfontinterlinespecs\empty + \let\bodyfontinterlinespace\empty + +\fi + +\def\presetnormallineheight + {\edef\normallineheight{\@@itline}% +% done elsewhere : \spacing\!!plusone % new per 10/08/2004, else problems in otr / !! needed + \iflocalinterlinespace \else + \doifdefined\bodyfontinterlinespecs + {\doifsomething\bodyfontinterlinespace + {\edef\normallineheight{\bodyfontinterlinespace}}}% + \fi} + +\def\setupspecifiedinterlinespace[#1]% + {\getparameters[\??it][#1]% + \scratchdimen0\@@itheight\points + \advance\scratchdimen 0\@@itdepth\points + \ifdim\scratchdimen>\onepoint + \showmessage\m!layouts{10}{\@@itheight,\@@itdepth}% + \let\@@itheight\strutheightfactor + \let\@@itdepth \strutdepthfactor + \else + \let\strutheightfactor\@@itheight + \let\strutdepthfactor \@@itdepth + \fi + \let\minimumstrutheight \@@itminheight + \let\minimumstrutdepth \@@itmindepth + \let\minimumlinedistance\@@itdistance + \let\normallineheight \@@itline % let ! ! ! ! ! ivm ex + \doifelse\@@ittop\v!height % new, topskip does more bad than good + {\let\topskipfactor \@@itheight} + {\let\topskipfactor \@@ittop }% + \let\maxdepthfactor \@@itbottom + \let\baselinegluefactor \@@itstretch + \setfontparameters % redundant, can be \setstrut, test first + \updateraggedskips} % yes indeed + +% \let\currentrelativeinterlinespace\empty +% +% \def\setuprelativeinterlinespace[#1]% +% {\processallactionsinset +% [#1] +% [ \v!on=>\oninterlineskip, +% \v!off=>\offinterlineskip, +% \v!reset=>\let\currentrelativeinterlinespace\empty +% \setfontparameters,% just \setstrut, test first +% \s!unknown=>\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}% +% \spacing\currentrelativeinterlinespace]} + +% \setupinterlinespace[big] \switchtobodyfont[11pt] -> forgotten +% \setupinterlinespace[auto,big] \switchtobodyfont[11pt] -> remembered + +\let\currentrelativeinterlinespace\empty + +\def\setuprelativeinterlinespace[#1]% + {\processallactionsinset + [#1] + [ \v!on=>\oninterlineskip, + \v!off=>\offinterlineskip, + \v!reset=>\let\currentrelativeinterlinespace\empty + \let\setrelativeinterlinespace\relax + \setfontparameters, + \v!auto=>\let\setrelativeinterlinespace\dosetrelativeinterlinespace, + \s!unknown=>\assignvalue\commalistelement\currentrelativeinterlinespace{1.00}{1.25}{1.50}% + \spacing\currentrelativeinterlinespace]} + +\def\dosetrelativeinterlinespace + {\ifx\currentrelativeinterlinespace\empty\else + \spacing\currentrelativeinterlinespace + \fi} + +\let\setrelativeinterlinespace\relax + +% \appendtoks \setrelativeinterlinespace \to \everybodyfont + +\def\complexsetupinterlinespace[#1]% \commalistelement ipv #1 + {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]} + +\def\setuplocalinterlinespace[#1]% + {\localinterlinespacetrue + \setupinterlinespace[#1]% + \localinterlinespacefalse} + +\def\simplesetupinterlinespace + {\localinterlinespacetrue + \setfontparameters + \updateraggedskips % funny one here + \localinterlinespacefalse} + +\definecomplexorsimple\setupinterlinespace + +% In earlier versions \type{\bigskipamount} was +% \type{\ht\strutbox} and the stretch was plus or minus +% \type{.4\dp\strutbox}. Don't ask me why. The most recent +% implementation is based on a user supplied distance, which +% is by default \type{.75\normalskipamount} where +% \type{\normalskipamount} equals the current baseline +% distance. + +% \lineskiplimit = -\maxdimen -> freezes baselineskip + +% can be conditionals + +\newif\ifblanknowhite \blanknowhitefalse +\newif\ifblankindeed \blankindeedfalse +\newif\ifblankreset \blankresetfalse +\newif\ifblankdisable \blankdisablefalse +\newif\ifblankflexible \blankflexibletrue +\newif\ifblankouter +\newif\ifblankforce +\newif\ifblankgoback + +\newskip\blankskip \blankskip=\bigskipamount +\newskip\blankskipamount + +\def\skipfactor {.75} +\def\skipgluefactor{.25} + +\def\normalskipamount + {\openlineheight + \ifgridsnapping \else \ifblankflexible + \!!plus \skipgluefactor\openlineheight + \!!minus\skipgluefactor\openlineheight + \fi \fi + \relax} + +\def\linedistance {\normalskipamount} +\def\appliedblankskip{\skipfactor\linedistance} +\def\lastblankskip {\blankskip} +\def\currentblank {\v!big} +\def\oldprevdepth {\prevdepth} +\def\newprevdepth {-1001pt} +\def\mindimen {1sp} % was: 0.00002pt + +\newif\iflocalblankfixed +\newif\iflocalblankflexible + +\def\geenblanko{\removelastskip} % will become obsolete + +%%%% pas op, wordt ook in core-pos gebruikt + +\def\doassignsomeskip#1\to#2% ook nog \v!halfline+fuzzysnap + {\doifelse{#1}\v!line + {#2\openlineheight} + {\ifgridsnapping + \assigndimension{#1}{#2}{.25\openlineheight}{.5\openlineheight}\openlineheight + \else + \assigndimension{#1}{#2}\smallskipamount\medskipamount\bigskipamount + \fi}% + \relax} + +% \relax is really needed, else we may loose stretch due to lookahead; somehow +% this bug was introduced a while ago but somehow went unnoticed; fixed 2/7/2008 + +\def\addblankskip#1#2#3{\global\advance\blankskip#1\ifgridsnapping#3\else#2\fi\relax} + +\def\defineblankmethod[#1]#2{\setvalue{\??bo\??bo#1}{#2}} + +\defineblankmethod [\v!big] {\addblankskip+\bigskipamount \openlineheight} +\defineblankmethod [-\v!big] {\addblankskip-\bigskipamount \openlineheight} +\defineblankmethod [\v!medium] {\addblankskip+\medskipamount {.5\openlineheight}} +\defineblankmethod [-\v!medium] {\addblankskip-\medskipamount {.5\openlineheight}} +\defineblankmethod [\v!small] {\addblankskip+\smallskipamount{.25\openlineheight}} +\defineblankmethod [-\v!small] {\addblankskip-\smallskipamount{.25\openlineheight}} +\defineblankmethod [\v!white] {\addblankskip+\parskip \openlineheight} +\defineblankmethod [-\v!white] {\addblankskip-\parskip \openlineheight} +\defineblankmethod [\v!line] {\addblankskip+\openlineheight \openlineheight} +\defineblankmethod [-\v!line] {\addblankskip-\openlineheight \openlineheight} + +\defineblankmethod [\v!formula] {\global\advance\blankskip\medskipamount} +\defineblankmethod [\v!nowhite] {\global\blanknowhitetrue} +\defineblankmethod [\v!disable] {\global\blankdisabletrue} +\defineblankmethod [\v!force] {\global\blankforcetrue} +\defineblankmethod [\v!outer] {\ifvmode\ifinner\blankoutertrue\fi\fi} +\defineblankmethod [\v!reset] {\global\blankresettrue} +\defineblankmethod [\v!flexible] {\global\localblankflexibletrue} +\defineblankmethod [\v!fixed] {\global\localblankfixedtrue} +\defineblankmethod [\v!back] {\global\blankgobacktrue} % {\geenblanko} +\defineblankmethod [\v!halfline] {\ifgridsnapping\global\fuzzyvskiptrue\fi + \global\advance\blankskip .5\lineheight} +\defineblankmethod [\v!none] {\global\blankresettrue} +\defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} +\defineblankmethod[\v!synchronize] {\verticalstrut\vskip-2\lineheight\verticalstrut} + +% \vtop{\blank[synchronize]\blank[line]test} + +\defineblankmethod [\v!always] {\redowhitespace} % experimental + +% happens often, so we speed this up: +% +% \defineblankmethod [2*\v!line] {\addblankskip+{2\openlineheight}{2\openlineheight}} +% \defineblankmethod [2*\v!big] {\addblankskip+{2\bigskipamount }{2\openlineheight}} +% +% no, with 2\whatever we loose the stretch and shrink! Taco's alternative: + +\defineblankmethod + [2*\v!line] + {\addblankskip+\openlineheight\openlineheight + \addblankskip+\openlineheight\openlineheight} + +\defineblankmethod + [2*\v!big] + {\addblankskip+\bigskipamount\openlineheight + \addblankskip+\bigskipamount\openlineheight} + +\def\doblank#1% + {\edefconvertedargument\ascii{#1}% + \ifx\ascii\empty\else + \ifcsname\??bo\??bo\ascii\endcsname % internal def + \csname\??bo\??bo\ascii\endcsname + \else\ifcsname\??bo\ascii\endcsname % user def / slow + \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax + \else + \dorepeatwithcommand[#1]\redoblank + \fi\fi + \fi + \relax} + +\def\redoblank#1% + {\edefconvertedargument\ascii{#1}% + \ifx\ascii\empty\else + \ifcsname\??bo\??bo\ascii\endcsname % internal def + \csname\??bo\??bo\ascii\endcsname + \else\ifcsname\??bo\ascii\endcsname % user def / slow + \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax + \else + \global\advance\blankskip#1\relax + \fi\fi + \fi + \relax} + +\unexpanded\def\blank % the \relax is definitely needed due to the many \if's + {\relax\complexorsimple\doblank} + +\def\complexdoblank + {\flushnotes + \ifmmode + \@EA\nocomplexdoblank + \else + \ifopelkaar + \ifinpagebody + \@EA\@EAEAEA\@EA\docomplexdoblank + \else + \@EA\@EAEAEA\@EA\nocomplexdoblank + \fi + \else + \@EAEAEA\docomplexdoblank + \fi + \fi} + +\def\nocomplexdoblank[#1]% + {% evt blokkeerfalse + \ifmmode\else\par\fi} + +% Overloaded in cont-new! + +\newsignal\noblanksignal + +% \def\doinhibitblank +% {\kern\noblanksignal} + +% \def\inhibitblank% the fast, local way +% {\endgraf\ifvmode\prevdepth\newprevdepth\fi} + +% \def\docomplexdoblank[#1]% pas op \relax's zijn nodig ivm volgende \if +% {\global\blankresetfalse +% \global\blankdisablefalse +% \global\blanknowhitefalse +% \global\localblankflexiblefalse +% \global\localblankfixedfalse +% \global\blankskip\zeropoint +% \global\blankforcefalse +% \global\blankgobackfalse +% \blankouterfalse +% \expanded{\rawprocesscommalist[#1]}\doblank +% \ifdim\blankskip=\zeropoint\relax +% \iflocalblankflexible +% \doglobal\advance\blankskip \currentblank +% \else\iflocalblankfixed +% \doglobal\advance\blankskip \currentblank +% \fi\fi +% \fi +% \ifblankouter +% \else +% \par +% \ifvmode +% \ifblankgoback +% \removelastskip +% \fi +% \ifblankforce +% % dit gaat mis in pos fonts +% % \ifdim\prevdepth>\zeropoint\else ... +% % -1000pt signals top of page or column (\ejectcolumn) +% \bgroup\forgeteverypar\verticalstrut\egroup\kern-\struttotal +% \fi +% \ifblankdisable +% \global\blankindeedfalse +% \ifgridsnapping +% \ifdim\prevdepth<\zeropoint +% % brrr +% \else +% % dirty trick: smaller blanks are ignored after +% % a larger one, so 10 lines is probably safe; first make +% % sure that we honor penalties +% \scratchcounter\lastpenalty +% % now comes the trick (cross our fingers that this works +% % well in multi columns; maybe an ifinner test is needed +% % \vskip-10\lineheight +% % \ifnum\scratchcounter=\zerocount \else \penalty\lastpenalty \fi +% % \vskip 10\lineheight +% % allas, this leads to overfull pages, so we try this: +% \kern-\noblanksignal +% \ifnum\scratchcounter=\zerocount +% \else +% \penalty\lastpenalty +% \fi +% \kern\noblanksignal +% % end-of-dirty-trick +% \fi +% \else +% \ifdim\prevdepth<\zeropoint +% % brrr +% \else +% % ensure at least a proper prevdepth, this should be +% % an option +% \vskip-\prevdepth +% \vskip\strutdepth +% \prevdepth\strutdepth +% \fi +% % the old crappy piece of code +% \edef\oldprevdepth{\the\prevdepth}% +% \prevdepth\newprevdepth +% \fi +% \else +% \global\blankindeedtrue +% \fi +% \ifblankreset +% \global\blankindeedtrue +% \ifgridsnapping +% % let's play safe and not fool around with the depth, if +% % only because it took a lot of effort to sort out the grid +% % stuff in the first place +% \else +% \ifdim\prevdepth=\newprevdepth +% \prevdepth\oldprevdepth +% \fi +% \fi +% \fi +% \ifblankindeed +% \ifdim1\lastskip<1\blankskip\relax +% % else when \blanko[2*groot] + \blanko[3*groot] with parskip +% % equaling 1*groot, gives a groot=\parskip so adding a small +% % value makes it distinguishable; can also be done at parskip +% % setting time (better) +% \global\advance\blankskip \mindimen\relax % = skip +% % test this on 2* + 3* and parskip groot +% \ifblanknowhite +% \global\advance\blankskip -\parskip +% \else +% \ifdim\lastskip=\parskip +% \else % force this due to previous comment +% \ifdim\parskip>\zeropoint\relax +% \ifdim\blankskip<\parskip\relax +% \global\blankskip\zeropoint +% \else +% \global\advance\blankskip -\parskip +% \fi +% \fi +% \fi +% \fi +% \ifblankflexible \else +% \blankskip1\blankskip +% \fi +% \iflocalblankfixed +% \blankskip1\blankskip +% \fi +% \iflocalblankflexible +% \blankskip1\blankskip +% \!!plus\skipgluefactor\blankskip +% \!!minus\skipgluefactor\blankskip +% \fi +% \ifdim\lastkern=\noblanksignal % controled and grid +% \global\blankindeedfalse +% \else\ifgridsnapping\else\ifdim\prevdepth=\newprevdepth +% \global\blankindeedfalse +% \fi\fi\fi +% \ifblankindeed +% \iffuzzyvskip +% \removelastfuzzyvskip +% \fuzzyvskip\blankskip\relax +% \else +% \removelastskip +% \vskip\blankskip\relax +% \fi +% \fi +% \else +% \iffuzzyvskip +% \removelastfuzzyvskip +% \fuzzyvskip\blankskip\relax +% \else +% % new, test this on pascal +% \ifdim\blankskip<\zeropoint +% \advance\blankskip-\lastskip +% \removelastskip +% \ifdim\blankskip>\zeropoint +% \vskip\blankskip +% \else +% \vskip\zeropoint +% \fi +% \else +% % also new +% \ifdim\blankskip=\zeropoint +% \ifblanknowhite +% \geenwitruimte +% \fi +% \fi +% \fi +% \fi +% \fi +% \fi +% \fi +% \fi +% \global\fuzzyvskipfalse +% \presetindentation} + +% goback was broken: + +% \def\doinhibitblank +% {\kern\noblanksignal} + +% \def\inhibitblank% the fast, local way +% {\endgraf\ifvmode\prevdepth\newprevdepth\fi} + +% problem: we cannot look back in the mvl so we need 3 kinds of signals + +\def\noblankpsignal{1010101} + +\def\inhibitgridblank % was doinhibitblank + {\ifvmode\else\endgraf\fi + \ifvmode + \ifnum\lastpenalty<10000 + \kern-\noblanksignal % new + \kern \noblanksignal + \else + \penalty\noblankpsignal + \fi + \fi} + +\def\inhibittextblank % was inhibitblank + {\endgraf + \ifvmode + \prevdepth\newprevdepth + \fi} + +% new macro +% +% \def\inhibitblank % need some work +% {\endgraf +% \ifvmode +% \ifgridsnapping +% \inhibitgridblank +% \else +% % this one spoils the grid +% \inhibittextblank +% \fi +% \fi} + +\def\doinhibitblank{\inhibitgridblank} +\def\inhibitblank {\inhibittextblank} + +% will become obsolete + +\ifx\undefined\savedlastskip \newskip \savedlastskip \fi +\ifx\undefined\savedlastpenalty \newcount\savedlastpenalty \fi + +% beware, prevdepth can have funny values (e.g. mvl value when in box) + +\def\docomplexdoblank[#1]% pas op \relax's zijn nodig ivm volgende \if + {\global\blankresetfalse + \global\blankdisablefalse + \global\blanknowhitefalse + \global\localblankflexiblefalse + \global\localblankfixedfalse + \global\blankforcefalse + \global\blankgobackfalse + \blankouterfalse + \global\blankskip\zeropoint +% +\edefconvertedargument\ascii{#1}% todo fast check for simple +\ifcsname\??bo\??bo\ascii\endcsname % internal def + \csname\??bo\??bo\ascii\endcsname +\else\ifcsname\??bo\ascii\endcsname % user def / slow + \@EA\rawprocesscommalist\@EA[\csname\??bo\ascii\endcsname]\doblank\relax +\else + \expanded{\rawprocesscommalist[#1]}\doblank +\fi\fi +% + \relax % to be sure + \ifdim\blankskip=\zeropoint\relax + \iflocalblankflexible + \doglobal\advance\blankskip \currentblank + \else\iflocalblankfixed + \doglobal\advance\blankskip \currentblank + \fi\fi + \fi + \relax % to be sure + \ifblankouter + % do nothing + \else + \par + \ifvmode + \ifblankgoback + \ifdim\lastskip>\zeropoint \vskip-\lastskip \fi + \savedlastskip\zeropoint + \else\ifdim\lastskip>\zeropoint + \savedlastskip\lastskip + \else % todo: lastnode, dan namelijk geen skip ! + \savedlastskip\zeropoint + \fi\fi + \ifblankforce + % dit gaat mis in pos fonts + % \ifdim\prevdepth>\zeropoint\else ... + % -1000pt signals top of page or column (\ejectcolumn) + \bgroup\forgeteverypar\verticalstrut\egroup\kern-\struttotal + \savedlastskip\zeropoint + \fi + \savedlastpenalty\lastpenalty % hm, now it gets lost + \ifblankdisable + \global\blankindeedfalse % keep this, i.e. disable current too + \ifgridsnapping + \ifdim\prevdepth<\zeropoint + % brrr + \else + % dirty trick: smaller blanks are ignored after a + % larger one, so 10 lines is probably safe; we need + % to make sure that we honor penalties; here comes the + % trick (cross our fingers that this works well in + % multi columns; maybe an ifinner test is needed + % \scratchcounter\lastpenalty + % \vskip-10\lineheight + % \ifnum\scratchcounter=\zerocount \else \penalty\lastpenalty \fi + % \vskip 10\lineheight + % alas, this leads to overfull pages, so we try this: + \inhibitgridblank + \fi + \else + \ifdim\prevdepth<\zeropoint + % brrr + \else + % ensure at least a proper prevdepth, this should be + % an option + \vskip-\prevdepth + \vskip\strutdepth + \prevdepth\strutdepth + \fi + % the old crappy piece of code + \edef\oldprevdepth{\the\prevdepth}% + \prevdepth\newprevdepth % == \inhibittextblank + \fi + \else + \global\blankindeedtrue + \fi + \ifblankreset + \global\blankindeedtrue + \ifgridsnapping + % let's play safe and not fool around with the depth, if + % only because it took a lot of effort to sort out the grid + % stuff in the first place + \else + \ifdim\prevdepth=\newprevdepth + \prevdepth\oldprevdepth + \fi + \fi + \fi + \ifblankindeed + \ifdim1\savedlastskip<1\blankskip\relax + % else when \blank[2*groot] + \blank[3*groot] with parskip + % equaling 1*groot, gives a groot=\parskip so adding a small + % value makes it distinguishable; can also be done at parskip + % setting time (better) + \global\advance\blankskip \mindimen\relax % = skip + % test this on 2* + 3* and parskip groot + \ifblanknowhite + \global\advance\blankskip -\parskip + \else + \ifdim\savedlastskip=\parskip + \else % force this due to previous comment + \ifdim\parskip>\zeropoint\relax + \ifdim\blankskip<\parskip\relax + \global\blankskip\zeropoint + \else + \global\advance\blankskip -\parskip + \fi + \fi + \fi + \fi + \ifblankflexible \else + \blankskip1\blankskip + \fi + \iflocalblankfixed + \blankskip1\blankskip + \fi + \iflocalblankflexible + \blankskip1\blankskip + \!!plus \skipgluefactor\blankskip + \!!minus\skipgluefactor\blankskip + \fi + \ifdim\lastkern=\noblanksignal\relax % controlled and grid + \global\blankindeedfalse + \else\ifnum\savedlastpenalty=\noblankpsignal\relax % controlled and grid + \global\blankindeedfalse + \else\ifgridsnapping\else\ifdim\prevdepth=\newprevdepth + \global\blankindeedfalse + \fi\fi\fi\fi + \ifblankindeed + \iffuzzyvskip + \removelastfuzzyvskip + \fuzzyvskip\blankskip\relax + \else + \relax\ifdim\savedlastskip=\zeropoint\else + \vskip-\savedlastskip + \fi + \vskip\blankskip\relax + \fi + \fi + \else + \iffuzzyvskip + \removelastfuzzyvskip + \fuzzyvskip\blankskip\relax + \else + % new, test this on pascal + \ifdim\blankskip<\zeropoint + \relax\ifdim\savedlastskip=\zeropoint\else + \advance\blankskip-\savedlastskip + \vskip-\savedlastskip + \fi + \ifdim\blankskip>\zeropoint + \vskip\blankskip + \else + \vskip\zeropoint + \fi + \else + % also new + \ifdim\blankskip=\zeropoint + \ifblanknowhite + \nowhitespace + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \global\fuzzyvskipfalse + \presetindentation} + +%D For a long time we had: +%D +%D \starttyping +%D \def\simpledoblank% +%D {\doifelse{\currentwhitespace}{\v!geen} +%D {\blank[\currentblank]} +%D {\blank[\currentwhitespace]}} +%D \stoptyping +%D +%D But Berend de Boer wanted more control, so now we have: + +\def\simpledoblank % ... + {\doifelse\currentwhitespace\v!none + {\blank[\currentblank]} + {\blank[\s!default]}} + +%D Another useful definition would be: +%D +%D \starttyping +%D \defineblank +%D [\s!default] +%D [\v!groot] +%D \stoptyping + +\def\dosetupblank#1% amount are an plain inheritance + {\bigskipamount#1\relax + \ifblankflexible \else + \bigskipamount1\bigskipamount + \fi + \medskipamount \bigskipamount \divide\medskipamount \plustwo + \smallskipamount\bigskipamount \divide\smallskipamount\plusfour}% + +\def\complexsetupblank[#1]% more \let's -> this also wil become installable + {\ifgridsnapping + \blankflexiblefalse + \else + \ExpandFirstAfter\processallactionsinset + [#1] + [ \v!flexible=>\blankflexibletrue, + \v!fixed=>\blankflexiblefalse]% + \fi + \ExpandFirstAfter\processallactionsinset + [#1] + [ \v!flexible=>\dosetupblank\appliedblankskip, + \v!fixed=>\dosetupblank\appliedblankskip, + \v!line=>\edef\appliedblankskip{\linedistance}% + \dosetupblank\appliedblankskip, + \v!halfline=>\scratchskip.5\linedistance + \edef\appliedblankskip{\the\scratchskip}% + \dosetupblank\appliedblankskip, + \v!big=>\ifgridsnapping + \edef\appliedblankskip{\linedistance}% + \dosetupblank\appliedblankskip + \fi + \let\currentblank\v!big, + \v!medium=>\let\currentblank\v!medium, + \v!small=>\let\currentblank\v!small, + \v!global=>\let\currentblank\v!global, + \v!normal=>\dosetupblank\appliedblankskip, + \v!standard=>\edef\appliedblankskip{\skipfactor\linedistance}% + \dosetupblank\appliedblankskip, + \s!default=>\dosetupblank\appliedblankskip, + \s!unknown=>\let\appliedblankskip\commalistelement + \dosetupblank\appliedblankskip]% + \simplesetupwhitespace} + +% \definecomplexorsimpleempty\setupblank +% +% speed gain: 60 sec -> 30 sec + +\definecomplexorsimple\setupblank + +\def\simplesetupblank % == snelle \setupblank[\s!default] + {\ifgridsnapping + \blankflexiblefalse + \fi + \dosetupblank\appliedblankskip + % \let\deblanko\v!big + \simplesetupwhitespace} + +\def\restorestandardblank% \v!standard + {\edef\appliedblankskip{\skipfactor\linedistance}% + \dosetupblank\appliedblankskip + }%\let\deblanko\v!big} + +\def\dodefineblank[#1][#2]% + {\def\docommand##1{\setvalue{\??bo##1}{#2}}% + \processcommalist[#1]\docommand} + +\def\defineblank + {\dodoubleargument\dodefineblank} + +\def\savecurrentblank + {\edef\restorecurrentblank + {\bigskipamount\the\bigskipamount + \medskipamount\the\medskipamount + \smallskipamount\the\smallskipamount + \noexpand\def\noexpand\currentblank{\currentblank}% + \ifblankflexible + \noexpand\blankflexibletrue + \else + \noexpand\blankflexiblefalse + \fi}} + +%D Now. + +\defineblank [\s!default] [\v!white] +\defineblank [\v!height] [\strutheight] +\defineblank [\v!depth] [\strutdepth] + +% old implementation +% +% \let\currentindentation=\empty +% +% \newdimen\ctxparindent +% +% \newif\ifindentfirstparagraph % \indentfirstparagraphtrue +% +% \def\presetindentation +% {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} +% +% \definecomplexorsimple\setupindenting +% +% \def\complexsetupindenting[#1]% +% {\processallactionsinset +% [#1] +% [ \v!first=>\indentfirstparagraphtrue, +% \v!next=>\indentfirstparagraphfalse, +% \s!default=>\simplesetupindenting, +% \s!unknown=>\edef\currentindentation{\commalistelement}% +% \simplesetupindenting]} +% +% \def\simplesetupindenting +% {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}% +% \parindent\ctxparindent\relax} +% +% \def\indenting % watch out: \dodo and no \do +% {\dosingleargument\dodoindenting} +% +% \def\dodoindenting[#1]% oeps, we needed a commalist handler here! +% {\edef\currentindenting{#1}% +% \processcommacommand[#1]\dododoindenting} +% +% \def\dododoindenting#1% +% {\executeifdefined{\??in:#1}\donothing} +% +% \let\currentindenting\empty +% +% \def\defineindentingmethod[#1]#2% +% {\setvalue{\??in:#1}{#2}} +% +% \defineindentingmethod [\v!no] {\parindent\ctxparindent\noindent} +% \defineindentingmethod [\v!not] {\parindent\ctxparindent\noindent} +% +% \defineindentingmethod [\v!first] {\indentfirstparagraphtrue} +% \defineindentingmethod [\v!next] {\indentfirstparagraphfalse} +% +% \defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! +% \defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! +% +% \defineindentingmethod [\v!never] {\parindent\zeropoint\relax} % no \indent ! +% +% \def\noindenting{\indenting[\v!no,\v!next]} % was \nietinspringen +% \def\doindenting{\indenting[\v!yes,\v!first]} % was \welinspringen +% +% \def\dochecknextindentation#1% internal one +% {\checknextindentation[\getvalue{#1\c!indentnext}]} +% +% \def\checknextindentation[#1]% +% {\processaction[#1][%\v!keep=>, +% \v!yes=>\doindentation, +% \v!no=>\noindentation, +% \v!auto=>\autoindentation]} +% +% \def\doindentation% too simple +% {\gdef\checkindentation{\global\indentationtrue}} +% +% \ifx\autoindentation\undefined +% \let\autoindentation\relax +% \fi +% +% \newif\ifindentation \indentationtrue % documenteren, naar buiten +% +% \let\checkindentation=\relax +% +% \def\donoindentation +% {\ifdim\parindent=\zeropoint \else +% \bgroup \setbox\scratchbox\lastbox \egroup +% \fi} +% +% \def\noindentation % made global +% {\ifinpagebody \else +% \global\indentationfalse +% \gdef\checkindentation +% {\donoindentation +% \gdef\checkindentation{\global\indentationtrue}}% +% \fi} +% +% \def\nonoindentation % bv bij floats +% {\ifinpagebody \else +% \global\indentationtrue +% \gdef\checkindentation{\global\indentationtrue}% +% \fi} +% +% \def\indentation +% {\ifvmode \ifdim\parindent=\zeropoint \else +% % was : \hskip\parindent +% % can be: \indent +% % but we test: +% \noindent\hskip\parindent +% \fi \fi} + +\let\currentindentation\empty % amount/keyword +% \let\normalindentation \empty % used for reinstating normal indentation +\let\currentindenting \empty % method + +\newdimen\ctxparindent + +\newif\ifindentfirstparagraph % \indentfirstparagraphtrue + +\chardef\indentingtoggle\zerocount + +%D After a blank or comparable situation (left side floats) we +%D need to check if the next paragraph has to be indented. + +\def\presetindentation + {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} + +%D This sets up the (normally) global indentation behavior as well +%D as the amounts. + +\definecomplexorsimple\setupindenting + +% \def\complexsetupindenting[#1]% +% {\edef\currentindenting{#1}% +% \indentfirstparagraphtrue +% \parindent\ctxparindent +% \chardef\indentingtoggle\zerocount +% \processcommalist[#1]\docomplexsetupindenting +% \ifindentfirstparagraph\else\noindentation\fi % added +% \toggleindentation} + +\indentfirstparagraphtrue +\parindent\ctxparindent +\chardef\indentingtoggle\zerocount + +% \newtoks\savedeverypar \savedeverypar\everypar +% \def\restoreeverypar{\everypar\savedeverypar} + +% we need a better everypar model: for each option a switch, which we +% set to false with \forgetall and can enable when needed (context 4); +% that way we can control the order of execution of options + +\def\checkeverypar % currently a hack + {\ifzeropt\parindent\else + \doifsometokselse\everypar\donothing{\appendtoks\checkindentation\to\everypar}% + \fi} + +\def\complexsetupindenting[#1]% + {\edef\currentindenting{#1}% + \doifsomething\currentindenting % handy when a parameter is passed + {% not here: \indentfirstparagraphtrue + % not here: \parindent\ctxparindent + % not here: \chardef\indentingtoggle\zerocount + % we use commacommand in order to catch #1 being a command (expanded parameter) + \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc + \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest + \checkeverypar % only when non-empty #1 + \ifindentfirstparagraph\else\noindentation\fi % added + \toggleindentation}} + +\def\docomplexsetupindentingA#1% + {\edefconvertedargument\!!stringa{#1}% + \doifundefined{\??in:\!!stringa}% + {\edef\currentindentation{#1}% + \let\normalindentation\currentindentation + \simplesetupindenting}} + +\def\docomplexsetupindentingB#1% + {\edefconvertedargument\!!stringa{#1}% catch #1=\somedimen + \executeifdefined{\??in:\!!stringa}\donothing} + +\def\simplesetupindenting % empty case, a it strange, needed this way? + {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} + +\def\indenting % kind of obsolete + {\dosingleargument\complexsetupindenting} + +% use \noindentation to suppress next indentation + +\def\defineindentingmethod[#1]#2% + {\setvalue{\??in:#1}{#2}} + +\defineindentingmethod [\v!no] {\parindent\zeropoint}% was: \ctxparindent\noindent} +\defineindentingmethod [\v!not] {\parindent\zeropoint}% was: \ctxparindent\noindent} + +\defineindentingmethod [\v!first] {\indentfirstparagraphtrue} +\defineindentingmethod [\v!next] {\indentfirstparagraphfalse} + +\defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! +\defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! + +\defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! + \chardef\indentingtoggle\zerocount} + +\defineindentingmethod [\v!odd] {\chardef\indentingtoggle\plusone} +\defineindentingmethod [\v!even] {\chardef\indentingtoggle\plustwo} + +\defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else + \let\currentindentation\normalindentation + \simplesetupindenting + \fi} + +\defineindentingmethod [\v!reset] {\indentfirstparagraphtrue + \parindent\zeropoint + \chardef\indentingtoggle\zerocount} + +\def\noindenting{\indenting[\v!no, \v!next ]} +\def\doindenting{\indenting[\v!yes,\v!first]} + +%D This one sets up the local indentation behaviour (i.e. either or not +%D a next paragraph will be indented). + +\def\dochecknextindentation#1% internal one + {\checknextindentation[\getvalue{#1\c!indentnext}]} + +\def\checknextindentation[#1]% + {\processaction + [#1] + [%\v!keep=>, + \v!yes=>\doindentation, + \v!no=>\noindentation, + \v!auto=>\autoindentation]} + +%D Here come the handlers. + +\newif\ifindentation \indentationtrue % documenteren, naar buiten + +\let\checkindentation\relax + +\ifx\autoindentation\undefined \let\autoindentation\relax \fi % hook + +\def\doindentation + {\gdef\checkindentation{\global\indentationtrue}} + +\def\noindentation % made global + {\ifinpagebody \else + \global\indentationfalse + \gdef\checkindentation + {\donoindentation + \gdef\checkindentation{\global\indentationtrue}}% + \fi} + +\def\nonoindentation % bv bij floats + {\ifinpagebody \else + \global\indentationtrue + \gdef\checkindentation{\global\indentationtrue}% + \fi} + +\def\donoindentation + {\ifdim\parindent=\zeropoint \else + \bgroup \setbox\scratchbox\lastbox \egroup + \fi} + +\def\indentation + {\ifvmode \ifdim\parindent=\zeropoint \else + % was : \hskip\parindent + % can be: \indent + % but we test: + \noindent\hskip\parindent + \fi \fi} + +\def\toggleindentation + {\ifcase\indentingtoggle + % nothing + \or + \notoggleindentation + \or + \dotoggleindentation + \fi} + +\def\dokillindentation + {\gdef\checkindentation{\global\indentationfalse\donoindentation}} + +\def\dotoggleindentation + {\gdef\checkindentation{\global\indentationfalse\notoggleindentation\donoindentation}} + +\def\notoggleindentation + {\gdef\checkindentation{\global\indentationtrue\dotoggleindentation}} + +\appendtoks + \pushmacro\checkindentation + \pushmacro\ifindentation +\to \everypushsomestate + +\appendtoks + \popmacro\ifindentation + \popmacro\checkindentation +\to \everypopsomestate + +% we need to save the state if we want to adapt behaviour to empty lines +% +% \def\setlasthvmode +% {\global\chardef\savedhvmode\ifhmode\plusone\else\ifvmode\plustwo\else\zerocount\fi\fi} +% +% \def\resetlasthvmode +% {\global\chardef\savedhvmode\zerocount} +% +% \chardef\savedhvmode\zerocount + +% This is a user requested hack (using the auto-hook). + +\chardef\recheckindentationmode\zerocount + +\def\dontrechecknextindentation + {\global\chardef\recheckindentationmode\zerocount} + +\def\dorechecknextindentation + {\ifcase\recheckindentationmode + % nothing + \or + \dontrechecknextindentation + \expandafter\doautoindentation + \fi} + +\def\doautoindentation + {\doifnextcharelse\par\donothing\noindentation} + +\def\autoindentation + {\global\chardef\recheckindentationmode\plusone} + +%D An example of usage: +%D +%D \starttyping +%D \setupindenting[small,yes] +%D +%D \setupitemize [indentnext=auto] +%D \setuptyping [indentnext=auto] +%D \setupformulas[indentnext=auto] +%D +%D \input tufte +%D +%D \startitemize +%D \item itemize +%D \stopitemize +%D \input tufte +%D +%D \startitemize +%D \item itemize +%D \stopitemize +%D +%D \input tufte +%D +%D \startitemize +%D \item itemize +%D \stopitemize +%D +%D \page +%D +%D \input tufte +%D +%D \starttyping +%D verbatim +%D \stoptyping +%D \input tufte +%D +%D \starttyping +%D verbatim +%D \stoptyping +%D +%D \input tufte +%D +%D \starttyping +%D verbatim +%D \stoptyping +%D +%D \page +%D +%D \input tufte +%D +%D \startformula +%D a = b +%D \stopformula +%D \input tufte +%D +%D \startformula +%D a = b +%D \stopformula +%D +%D \input tufte +%D +%D \startformula +%D a = b +%D \stopformula + + +%D \macros +%D {frenchspacing,nonfrenchspacing} +%D +%D Smehow \type{\frenchspacing} can lead to hyphenation between +%D dashes so we now have \type {\newfrenchspacing} (moved from +%D \type {syst-chr}). + +%D Hm ... todo: + +\sfcode`\)=0 +\sfcode`\'=0 +\sfcode`\]=0 + +\def\setfrenchspacing#1% + {\sfcode`\.#1 \sfcode`\,#1\relax + \sfcode`\?#1 \sfcode`\!#1\relax + \sfcode`\:#1 \sfcode`\;#1\relax} + +\def\frenchspacing + {\setfrenchspacing{1000}} + +\def\resetfrenchspacing + {\sfcode`\.3000 \sfcode`\,1250 + \sfcode`\?3000 \sfcode`\!3000 + \sfcode`\:2000 \sfcode`\;1500 } + +\def\frenchspacing {\setfrenchspacing{1000}} +\def\newfrenchspacing{\setfrenchspacing{1050}} +\def\nonfrenchspacing{\resetfrenchspacing} + +\def\definespacingmethod[#1]#2{\setvalue{\??sg\??sg#1}{#2}} + +\definespacingmethod[\v!packed]{\newfrenchspacing} +\definespacingmethod[\v!broad ]{\nonfrenchspacing} + +\def\complexsetupspacing[#1]% + {\executeifdefined{\??sg\??sg#1}\relax + \updateraggedskips} + +\def\simplesetupspacing + {\updateraggedskips} + +\definecomplexorsimple\setupspacing + +% \dorecurse{100}{\recurselevel\spacefactor 800 \space} \par +% \dorecurse{100}{\recurselevel\spacefactor1200 \space} \par +% \dorecurse{100}{\recurselevel\spacefactor 800 \normalspaceprimitive} \par +% \dorecurse{100}{\recurselevel\spacefactor1200 \normalspaceprimitive} \par + +% When we don't add the % here, we effectively get \ and +% since we have by default \def\^^M{\ } we get into a loop. + +\let\normalspaceprimitive=\ % space-comment is really needed + +\unexpanded\def\ {\mathortext\normalspaceprimitive\space} % no \dontleavehmode\space (else no frenchspacing) + +\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\space} + +\letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later + +\def\space { } +\def\removelastspace{\ifhmode\unskip\fi} +\def\nospace {\removelastspace\ignorespaces} + +% in tables we need: +% +% \def\fixedspace {\hskip.5em\relax} +% +% but, since not all fonts have .5em digits: + +\unexpanded\def\fixedspace + {\setbox\scratchbox\normalhbox{\mathortext{0}{0}}% + \hskip\wd\scratchbox\relax} + +\def\fixedspaces + {\letcatcodecommand \ctxcatcodes `\~ \fixedspace} + +\def\removeunwantedspaces + {\ifhmode % we also need to unskip 0pt skips + \unskip\unskip\unskip\unskip\unskip + \unskip\unskip\unskip\unskip\unskip + \fi} + +\appendtoks\let~\space\to\simplifiedcommands + +% still not fixed in aleph / luatex +% +% \def\removeunwantedspaces +% {\ifhmode \ifnum\lastnodetype=\@@gluenode +% \unskip \@EAEAEA\removeunwantedspaces +% \fi \fi} + +%D For old time sake, will disappear soon. + +\let\hardespatie\fixedspace +\let\geenspatie \nospace + +% \startbuffer +% \startlines \tt \fixedspaces +% 0~1~~2~~~3~~~~4~~~~~5 +% 0~~~~~~~~~~~~~~~~~~~5 +% $0~1~~2~~~3~~~~4~~~~~5$ +% $0~~~~~~~~~~~~~~~~~~~5$ +% \stoplines +% +% \starttabulate[|~|] +% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \NR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \NR +% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \NR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \NR +% \stoptabulate +% +% \starttable[||] +% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \AR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \AR +% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \AR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \AR +% \stoptable +% \stopbuffer +% +% \setupbodyfont[cmr] \getbuffer +% \setupbodyfont[lbr] \getbuffer + +\def\packed + {\nointerlineskip} + +\def\godown[#1]% + {\relax + \ifhmode\endgraf\fi + \ifvmode\nointerlineskip\vskip#1\relax\fi} + +%D A couple of plain macros: + +\ifx\thinspace\undefined + + \def\thinspace {\kern .16667em } + \def\negthinspace{\kern-.16667em } + \def\enspace {\kern .5em } + + \def\thinspace {\kern .16667\emwidth} + \def\negthinspace{\kern-.16667\emwidth} + \def\enspace {\kern .5\emwidth} + +\fi + +\ifx\quad\undefined + + \def\enskip{\hskip.5em\relax} + \def\quad {\hskip 1em\relax} + \def\qquad {\hskip 2em\relax} + + \def\enskip{\hskip.5\emwidth} + \def\quad {\hskip \emwidth} + \def\qquad {\hskip 2\emwidth} + +\fi + +\let\emspace\quad + +\ifx\smallskip\undefined + + \def\smallskip{\vskip\smallskipamount} + \def\medskip {\vskip\medskipamount} + \def\bigskip {\vskip\bigskipamount} + +\fi + +\ifx\allowbreak\undefined + + \def\break {\penalty\ifhmode-\plustenthousand\else\ejectpenalty\fi} + \def\nobreak {\penalty \plustenthousand} + \def\allowbreak{\penalty \zeropoint} + \def\filbreak {\par\vfil\penalty-200\vfilneg} + \def\goodbreak {\par\penalty-500 } + +\fi + +%D Made slightly more readable: + +\ifx\vglue\undefined + + \def\vglue {\afterassignment\dovglue\scratchskip=} + \def\hglue {\afterassignment\dohglue\scratchskip=} + \def\topglue{\nointerlineskip\vglue-\topskip\vglue} + + \def\dovglue + {\par + \scratchdimen\prevdepth + \hrule\!!height\zeropoint + \nobreak\vskip\scratchskip + \prevdepth\scratchdimen} + + \def\dohglue + {\dontleavehmode % \leavevmode + \scratchcounter\spacefactor + \vrule\!!width\zeropoint + \nobreak\hskip\scratchskip + \spacefactor\scratchcounter} + +\fi + +\ifx\eject\undefined + + \def\eject{\par\break} + +\fi + +\ifx\supereject\undefined + + \def\supereject{\par\penalty\superpenalty} + +\fi + +\ifx\dosupereject\undefined + + \def\dosupereject + {\ifnum\insertpenalties>\zerocount % something is being held over + \line{} + \kern-\topskip + \nobreak + \vfill\supereject + \fi} + +\fi + +%D We adapt plain's \type {\removelastskip} a bit: + +\ifx\removelastskip\undefined + + \def\removelastskip + {\ifvmode \ifdim\lastskip=\zeropoint \else + \vskip-\lastskip + \fi \fi} + +\fi + +\ifx\smallbreak\undefined + +\def\smallbreak + {\par + \ifdim\lastskip<\smallskipamount + \removelastskip + \penalty-50 + \smallskip + \fi} + +\def\medbreak + {\par + \ifdim\lastskip<\medskipamount + \removelastskip + \penalty-100 + \medskip + \fi} + +\def\bigbreak + {\par + \ifdim\lastskip<\bigskipamount + \removelastskip + \penalty-200 + \bigskip + \fi} + +\fi + +\newskip\ctxparskip \ctxparskip\zeropoint + +\newconditional \flexiblewhitespace \settrue\flexiblewhitespace + +\def\blankokleinmaat {\smallskipamount} +\def\blankomiddelmaat {\medskipamount} +\def\blankogrootmaat {\bigskipamount} +\def\currentwhitespace {\zeropoint} + +\definecomplexorsimple\setupwhitespace + +% \def\simplesetupwhitespace +% {\doifnot\currentwhitespace\v!none\dosetupwhitespace} +% +% \def\complexsetupwhitespace[#1]% +% {\doifelsenothing{#1} +% {\simplesetupwhitespace} +% {\edef\currentwhitespace{#1}% +% \dosetupwhitespace}} +% +% \def\dosetupwhitespace +% {\processcommacommand[\currentwhitespace]\dowhitespacemethod +% \dodosetupwhitespace} + +\def\simplesetupwhitespace + {\doifnot\currentwhitespace\v!none\dosetupwhitespace} + +\def\complexsetupwhitespace[#1]% + {\edef\nextcurrentwhitespace{#1}% + \ifx\nextcurrentwhitespace\empty + \simplesetupwhitespace + \else + \let\currentwhitespace\nextcurrentwhitespace + \dosetupwhitespace + \fi} + +\def\dosetupwhitespace % quick test for no list + {\doifdefinedelse{\??ws\??ws\currentwhitespace}% no ifcsname due to nested \lineheight + {\getvalue{\??ws\??ws\currentwhitespace}}% + {\processcommacommand[\currentwhitespace]\dowhitespacemethod}% + \ifgridsnapping + \setfalse\flexiblewhitespace + \ifdim\ctxparskip>\zeropoint + \ctxparskip + \ifcase\baselinegridmode + \baselineskip % normal ! ! ! ! !! + \or + \ifdim\scratchdimen=\baselineskip % maybe range + \baselineskip % normal ! ! ! ! !! + \else + \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax + \fi + \else + \baselineskip % normal ! ! ! ! !! + \fi + \fi + \else + \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi + \fi + \parskip\ctxparskip} + +\chardef\baselinegridmode=0 % option in layout / 1=permit_half_lines + +\def\dodosetupwhitespace + {\ifgridsnapping + \setfalse\flexiblewhitespace + \ctxparskip1\ctxparskip + \ifdim\ctxparskip>\zeropoint + \ifcase\baselinegridmode + \ctxparskip\baselineskip % normal ! ! ! ! !! + \or + \ifdim\scratchdimen=\baselineskip % maybe range + \ctxparskip\baselineskip % normal ! ! ! ! !! + \else + \ctxparskip\numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax + \fi + \else + \ctxparskip\baselineskip % normal ! ! ! ! !! + \fi + \fi + \else + \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi + \fi + \parskip\ctxparskip} + +\definesystemvariable {ws} % whitespace + +\def\definewhitespacemethod[#1]#2{\setvalue{\??ws\??ws#1}{#2}} + +\definewhitespacemethod [\v!fix] {} +\definewhitespacemethod [\v!fixed] {\setfalse\flexiblewhitespace} +\definewhitespacemethod [\v!flexible] {\settrue\flexiblewhitespace} +\definewhitespacemethod [\v!line] {\ctxparskip \baselineskip} +\definewhitespacemethod [\v!halfline] {\ctxparskip.5\baselineskip} +\definewhitespacemethod [\v!none] {\ctxparskip \zeropoint} +\definewhitespacemethod [\v!big] {\ctxparskip \bigskipamount} +\definewhitespacemethod [\v!medium] {\ctxparskip \medskipamount} +\definewhitespacemethod [\v!small] {\ctxparskip \smallskipamount} + +\definewhitespacemethod [\s!default] {\simplesetupwhitespace} % {\stelwitruimteopnieuwin} + +% \def\dowhitespacemethod#1% +% {\executeifdefined{\??ws\??ws#1}{\ctxparskip#1}\relax} + +\def\dowhitespacemethod#1% \doifdefined because of \lineheight + {\doifdefinedelse{\??ws\??ws#1}{\getvalue{\??ws\??ws#1}}{\ctxparskip#1}\relax} + +\def\nowhitespace + {\ifdim\parskip>\zeropoint\relax + \ifdim\lastskip=-\parskip + \else + \vskip-\parskip + \fi + \fi} + +\def\nowhitespaceunlessskip + {\ifdim\lastskip>\zeropoint \else + \nowhitespace + \fi} + +\def\redowhitespace + {\ifdim\lastskip>-\parskip \else + \vskip\parskip + \fi} + +\def\savecurrentwhitespace + {\edef\restorecurrentwhitespace + {\ctxparskip\the\ctxparskip + \parskip\the\parskip + \noexpand\def\noexpand\currentwhitespace{\currentwhitespace}% + \ifconditional\flexiblewhitespace + \noexpand\settrue\flexiblewhitespace + \else + \noexpand\setfalse\flexiblewhitespace + \fi}} + +% deze variant is nodig binnen \startopelkaar +% steeds testen: +% +% \hoofdstuk{..} +% \plaatslijst[..] +% \hoofdstuk{..} +% \input tufte +% +% met/zonder witruimte + +\def\whitespace + {\par + \ifdim\parskip>\zeropoint\relax + %\ifdim\lastskip>\parskip \else + % \removelastskip interferes with blanko blokkeer en klein + \vskip\parskip + %\fi + \fi} + +\def\nonoblanko[#1]% + {\par} + +\def\noblanko + {\dosingleempty\nonoblanko} + +% De onderstaande macro handelt ook de situatie dat er geen +% tekst tussen \start ... \stop is geplaatst. Daartoe wordt de +% laatste skip over de lege tekst heen gehaald. Dit komt goed +% van pas bij het plaatsen van (mogelijk lege) lijsten. + +\newif\ifopelkaar + +\newsignal \noparskipsignal % \def\noparskipsignal {0.00001pt} +\def\lastdoneparskip {0pt} + +\def\startpacked + {\dosingleempty\dostartpacked} + +\def\dostartpacked[#1]% nesting afvangen + {\par + \ifvmode + \edef\lastdoneparskip {\the\lastskip}% + \edef\lastdoneprevdepth{\the\prevdepth}% zeer recent toegevoegd + \ifdim\prevdepth=-\thousandpoint % toegevoegd omdat binnen + \else % een vbox een extra skip + \whitespace % ongewenst is; dit kan + \baselinecorrection %% zie in \placeregister[n=1] + \vskip\noparskipsignal % waarschijnlijk ook in + \fi % blanko blokkeer + \bgroup + \doifelse{#1}\v!blank + \opelkaarfalse + \opelkaartrue + \blank[\v!disable] % dit is nog niet ok, gaat fout + \setupwhitespace[\v!none] % bovenin vtop (dwz, baseline) + \fi} + +\def\stoppacked + {\par + \ifvmode + \egroup + \ifdim\lastskip=\noparskipsignal\relax + \removelastskip + \nowhitespace + \vskip-\lastdoneparskip + \vskip+\lastdoneparskip + \prevdepth-\lastdoneprevdepth % zeer recent toegevoegd + \fi + \fi} + +\def\startunpacked + {\blank + \leavevmode + \bgroup} + +\def\stopunpacked + {\egroup + \blank} + +% De onderstaande macro's moeten nog eens nader worden uitgewerkt. +% Ze spelen een rol bij de spatiering rond omkaderde teksten +% en/of boxen zonder diepte. + +\def\toonregelcorrectie{\showbaselinecorrection} +\def\regelcorrectie {\baselinecorrection} + +% \prevdepth crosses pageboundaries! +% +% todo: a version that works ok inside a box + +\let\doaroundlinecorrection\relax + +\def\startlinecorrection + {\dodoubleempty\dostartlinecorrection} + +\def\dostartlinecorrection[#1][#2]% #2 gobbles spaces + {\bgroup + \processaction + [#1] + [ \v!blank=>\let\doaroundlinecorrection\blank, + \s!default=>\let\doaroundlinecorrection\relax, + \s!unknown=>{\def\doaroundlinecorrection{\blank[#1]}}]% + \doaroundlinecorrection + \startbaselinecorrection + \offbaselinecorrection + \ignorespaces} + +\def\stoplinecorrection + {\stopbaselinecorrection + \doaroundlinecorrection + \egroup} + +\def\correctwhitespace + {\dowithnextbox + {\startbaselinecorrection + \flushnextbox + \stopbaselinecorrection}% + \vbox} + +\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}} +\def\horizontalstrut{\normalhbox {\strut}} + +% Hieronder volgen enkele instellingen en macro's ten behoeve +% van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en +% 0.28 zijn ooit eens ontleend aan INRS-TEX en moeten wellicht +% nog eens instelbaar worden. +% +% \lineheight : de hoogte van een regel +% \spacing{getal} : instellen interlinie +% \normalbaselines : instellen regelafstend +% +% \setstrut : instellen \strut +% \setnostrut : resetten \strut, \endstrut, \begstrut +% +% \setteststrut : instellen zichtbare struts +% \resetteststrut : instellen onzichtbare struts +% +% \setfontparameters : instellen na fontset +% +% De hoogte van een regel (\lineheight) is gelijk aan de +% som van de hoogte (\ht) en diepte (\dp) van \strutbox. +% +% \strut : denkbeeldig blokje met hoogte en diepte +% +% Een \hbox kan als deze aan het begin van een regel staat +% een breedte \hsize krijgen. Dit is soms te voorkomen met het +% commando \leavevmode. Binnen een \vbox geeft dit echter +% niet altijd het gewenste resultaat, vandaar het commando +% +% \leaveoutervmode + +% Pas op: niet zomaar \topskip en \baselineskip aanpassen +% en zeker niet \widowpenalty. Dit kan ernstige gevolgen +% hebben voor kolommen. +% +% Enige glue kan op zich geen kwaad, echter als blanko=vast, +% dan moet ook de rek 0 zijn. Binnen kolommen is rek ook +% niet bepaald mooi. Een hele kleine waarde (0.025) voldoet, +% omdat een positieve glue eindeloos rekbaar is. + +\newdimen\strutdimen +\newdimen\lineheight +\newdimen\openlineheight +\newdimen\openstrutheight +\newdimen\openstrutdepth +\newdimen\topskipgap +\newdimen\struttotal + +\def\strutheightfactor {.72} +\def\strutdepthfactor {.28} + +\def\baselinefactor {2.8} +\def\baselinegluefactor {0} + +\def\minimumstrutheight {0pt} +\def\minimumstrutdepth {0pt} + +\def\normallineheight {\baselinefactor ex} +\def\minimumlinedistance {\lineskip} + +\def\strutheight {0pt} +\def\strutdepth {0pt} +\def\strutwidth {0pt} + +\def\spacingfactor {1} + +\def\topskipfactor {1.0} +\def\maxdepthfactor {0.5} + +\def\systemtopskipfactor {\topskipfactor} +\def\systemmaxdepthfactor {\maxdepthfactor} + +% De onderstaande definitie wordt in de font-module overruled + +\ifdefined\globalbodyfontsize\else + \newdimen\globalbodyfontsize + \globalbodyfontsize=12pt +\fi + +\ifx\normalizedbodyfontsize\undefined + \def\normalizedbodyfontsize{12pt} +\fi + +% door een \dimen. Dit is geen probleem omdat (1) de default +% korpsgrootte 12pt is en (2) de fonts nog niet geladen zijn +% en de instellingen bij het laden nogmaals plaatsvinden. + +% \def\topskipcorrection +% {\ifdim\topskip>\openstrutheight +% % == \vskip\topskipgap +% \vskip\topskip +% \vskip-\openstrutheight +% \fi +% \verticalstrut +% \vskip-\struttotal} + +\def\topskipcorrection + {\simpletopskipcorrection + \vskip-\struttotal + \verticalstrut} + +\def\simpletopskipcorrection + {\ifdim\topskip>\openstrutheight + % == \vskip\topskipgap + \vskip\topskip + \vskip-\openstrutheight + \fi} + +% \def\settopskip % the extra test is needed for the lbr family +% {\topskip\systemtopskipfactor\globalbodyfontsize +% \ifgridsnapping \else +% \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi +% \fi +% \relax % the skip +% \topskipgap\topskip +% \advance\topskipgap -\openstrutheight\relax +% \ifdim\topskip<\strutheightfactor\openlineheight +% \topskip\strutheightfactor\openlineheight\relax +% \fi} + +\def\settopskip % the extra test is needed for the lbr family + {\topskip\systemtopskipfactor\globalbodyfontsize + \ifgridsnapping \else + \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi + \fi + \relax % the skip + \topskipgap\topskip + \advance\topskipgap -\openstrutheight\relax +\ifdim\minimumstrutheight>\zeropoint + \ifdim\topskip<\minimumstrutheight + \topskip\minimumstrutheight\relax + \fi +\else + \ifdim\topskip<\strutheightfactor\openlineheight + \topskip\strutheightfactor\openlineheight\relax + \fi +\fi} + +\def\setmaxdepth + {\maxdepth\systemmaxdepthfactor\globalbodyfontsize} + +\def\normalbaselines + {\baselineskip \normalbaselineskip + \lineskip \normallineskip + \lineskiplimit\normallineskiplimit} + +% \def\setnormalbaselines +% {\ifdim\normallineheight>\zeropoint +% \lineheight\normallineheight +% \fi +% \openlineheight\spacingfactor\lineheight +% \openstrutheight\strutheightfactor\openlineheight +% \openstrutdepth \strutdepthfactor \openlineheight +% \normalbaselineskip\openlineheight +% \!!plus\baselinegluefactor\openlineheight +% \!!minus\baselinegluefactor\openlineheight +% \normallineskip\minimumlinedistance\relax % \onepoint\relax +% \normallineskiplimit\zeropoint\relax +% \normalbaselines} + +\def\setnormalbaselines + {\ifdim\normallineheight>\zeropoint + \lineheight\normallineheight + \fi + \openlineheight\spacingfactor\lineheight + \openstrutheight \ifdim\minimumstrutheight>\zeropoint + \minimumstrutheight % new + \else + \strutheightfactor\openlineheight + \fi + \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth % new + \else + \strutdepthfactor \openlineheight + \fi + \ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint + \openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new + \fi + \normalbaselineskip\openlineheight + \ifgridsnapping\else + \!!plus \baselinegluefactor\openlineheight + \!!minus\baselinegluefactor\openlineheight + \fi + \normallineskip\minimumlinedistance\relax % \onepoint\relax + \normallineskiplimit\zeropoint\relax + \normalbaselines} + +% \def\setspacingfactor#1\to#2\by#3\\% +% {\strutdimen#2\points +% \strutdimen#3\strutdimen +% \edef#1{\withoutpt\the\strutdimen}} +% +% \def\spacing#1% +% {\ifgridsnapping +% %\doifnot{#1}{1}{\showmessage\m!layouts{11}{#1}}% +% \ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{#1}\fi +% \edef\spacingfactor{1}% +% \else +% \edef\spacingfactor{#1}% +% \fi +% \setspacingfactor\systemtopskipfactor \to\topskipfactor \by#1\\% why no \spacingfactor ? +% \setspacingfactor\systemmaxdepthfactor\to\maxdepthfactor\by#1\\% why no \spacingfactor ? +% \setnormalbaselines +% \setstrut} +% +% \def\setspacingfactor#1#2#3% +% {\edef#1{\withoutpt\the\dimexpr#2\points*#3\relax}} + +\def\spacing#1% + {\ifgridsnapping + \ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{#1}\fi + \edef\spacingfactor{1}% + \else + \edef\spacingfactor{#1}% + \fi + %\setspacingfactor\systemtopskipfactor \topskipfactor {#1}% why no \spacingfactor ? + %\setspacingfactor\systemmaxdepthfactor\maxdepthfactor{#1}% why no \spacingfactor ? + \edef\systemtopskipfactor {\withoutpt\the\dimexpr#1\dimexpr\topskipfactor \points}% + \edef\systemmaxdepthfactor{\withoutpt\the\dimexpr#1\dimexpr\maxdepthfactor\points}% + \setnormalbaselines + \setstrut} + +%D Sometimes one needs to freeze the interlinespacing +%D +%D \starttyping +%D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf} +%D \stoptyping + +\let\restoreinterlinespace\relax + +\def\saveinterlinespace + {\edef\restoreinterlinespace + {\lineheight \the\lineheight + \openstrutheight \the\openstrutheight + \openstrutdepth \the\openstrutdepth + \openlineheight \the\openlineheight + \normalbaselineskip \the\normalbaselineskip + \normallineskip \the\normallineskip + \normallineskiplimit\the\normallineskiplimit + \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}% + \noexpand\normalbaselines}} + +% plain definition: +% +% \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} +% +% could be: +% +% \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} + +\ifx\strutbox\undefined + + \newbox\strutbox + + \setbox\strutbox=\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint} + + %\def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} + \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} + +\fi + +\let\normalstrut\strut + +% The double \hbox construction enables us to \backtrack +% boxes. + +% \def\setstrutdimen#1#2#3% % een strut is n.m maal ex +% {\strutdimen\normallineheight % wat niet per se \lineheight +% \strutdimen#2\strutdimen % is omdat een strut lokaal +% \strutdimen#3\strutdimen % kan afwijken van de globale +% \edef#1{\the\strutdimen}} % macro % strut + +% \def\setstrutdimen#1#2#3% % een strut is n.m maal ex +% {\strutdimen\normallineheight % wat niet per se \lineheight +% \strutdimen#2\strutdimen % is omdat een strut lokaal +% \strutdimen#3\strutdimen % kan afwijken van de globale +% \edef#1{\the\strutdimen}} % macro % strut + +% \def\setstrut +% {\setstrutdimen\strutheight\strutheightfactor\spacingfactor +% \setstrutdimen\strutdepth \strutdepthfactor \spacingfactor +% \let\strut=\normalstrut +% \setbox\strutbox=\normalhbox +% {\normalhbox +% {\vrule +% \!!width \strutwidth +% \!!height \strutheight +% \!!depth \strutdepth +% \normalkern-\strutwidth}}} + +% \def\setstrut +% {\setstrutdimen\strutheight\strutheightfactor\spacingfactor +% \setstrutdimen\strutdepth \strutdepthfactor \spacingfactor +% \dosetstrut} + +% \def\setstrut +% {\strutdimen\normallineheight +% \strutdimen\strutheightfactor\strutdimen +% \strutdimen\spacingfactor\strutdimen +% \edef\strutheight{\the\strutdimen}% +% \strutdimen\normallineheight +% \ifgridsnapping +% \advance\strutdimen-\strutheight +% \else +% \strutdimen\strutdepthfactor\strutdimen +% \strutdimen\spacingfactor\strutdimen +% \fi +% \edef\strutdepth{\the\strutdimen}% +% \dosetstrut} + +% interesting, strutdepth is 4.05064pt vs 4.05066pt depending on grid +% nasty rounding problem + +% \def\setstrut +% {% height +% \strutdimen\normallineheight +% \ifdim\minimumstrutheight>\zeropoint +% \strutdimen\minimumstrutheight +% \else +% \strutdimen\strutheightfactor\strutdimen +% \fi +% \strutdimen\spacingfactor\strutdimen +% \edef\strutheight{\the\strutdimen}% +% % depth +% \strutdimen\normallineheight +% \ifgridsnapping +% \ifdim\minimumstrutdepth>\zeropoint +% \strutdimen\minimumstrutdepth +% \else +% \advance\strutdimen-\strutheight +% \fi +% \else +% \ifdim\minimumstrutdepth>\zeropoint +% \strutdimen\minimumstrutdepth +% \else +% \strutdimen\strutdepthfactor\strutdimen +% \fi +% \strutdimen\spacingfactor\strutdimen +% \fi +% \edef\strutdepth{\the\strutdimen}% +% % finish +% \dosetstrut} + +% \def\setstrut +% {% height +% \ifdim\minimumstrutheight>\zeropoint +% \edef\strutheight{\the\dimexpr\spacingfactor\dimexpr\minimumstrutheight}% +% \else +% \edef\strutheight{\the\dimexpr\spacingfactor\dimexpr\strutheightfactor\dimexpr\normallineheight}% +% \fi +% % depth +% \ifgridsnapping +% \ifdim\minimumstrutdepth>\zeropoint +% \edef\strutdepth{\the\dimexpr\minimumstrutdepth}% +% \else +% \edef\strutdepth{\the\dimexpr\normallineheight-\strutheight}% +% \fi +% \else +% \ifdim\minimumstrutdepth>\zeropoint +% \edef\strutdepth{\the\dimexpr\spacingfactor\dimexpr\minimumstrutdepth}% +% \else +% \edef\strutdepth{\the\dimexpr\spacingfactor\dimexpr\strutdepthfactor\dimexpr\normallineheight}% +% \fi +% \fi +% % finish +% \dosetstrut} + +\unexpanded\def\setstrut + {% height + \edef\strutheight + {\the\dimexpr\spacingfactor\dimexpr + \ifdim\minimumstrutheight>\zeropoint + \minimumstrutheight + \else + \strutheightfactor\dimexpr\normallineheight + \fi}% + % depth + \edef\strutdepth + {\the\dimexpr + \ifgridsnapping + \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth + \else + \normallineheight-\strutheight + \fi + \else + \spacingfactor\dimexpr + \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth + \else + \strutdepthfactor\dimexpr\normallineheight + \fi + \fi}% + % finish + \dosetstrut} + +\unexpanded\def\setcharstrut#1% + {\setbox\strutbox\normalhbox{#1}% + \edef\strutheight{\the\strutht}% + \edef\strutdepth {\the\strutdp}% + \dosetstrut} + +% \def\setfontstrut +% {\setcharstrut{(}} +% +% better, since some fonts have small (but descending Q etc) + +\unexpanded\def\setfontstrut + {\setcharstrut{(gplQT}} + +\unexpanded\def\setcapstrut% could be M, but Q has descender + {\setcharstrut{Q}} + +%D Handy for math (used in mathml): + +\def\charhtstrut + {\begingroup + \setcharstrut{GJY}% + \vrule\!!width\zeropoint\!!depth\zeropoint\!!height\strutht + \endgroup} + +\def\chardpstrut + {\begingroup + \setcharstrut{gjy}% + \vrule\!!width\zeropoint\!!depth\strutdp\!!height\zeropoint + \endgroup} + +%D Centered looks nicer: + +% \def\dosetstrut +% {\let\strut\normalstrut +% \setbox\strutbox\normalhbox +% {\normalhbox to \zeropoint +% {% \hss % new, will be option +% \vrule +% \!!width \strutwidth +% \!!height\strutheight +% \!!depth \strutdepth +% \hss}}% +% \struttotal\dimexpr\strutht+\strutdp\relax} +% +% because of all the callbacks in mkiv, we avoid unnecessary boxes ... +% maybe use an attribute so that we can tag boxes that don't need a +% treatment; tests with using an attribute so far have shown that +% it's slower because testing the attribute takes time too + +\def\dosetstrut + {\let\strut\normalstrut + \ifdim\strutwidth=\zeropoint + \setbox\strutbox\normalhbox + {\vrule + \!!width \zeropoint + \!!height\strutheight + \!!depth \strutdepth}% + \else + \setbox\strutbox\normalhbox + {\normalhbox to \zeropoint + {% \hss % new, will be option + \vrule + \!!width \strutwidth + \!!height\strutheight + \!!depth \strutdepth + \hss}}% + \fi + \struttotal\dimexpr\strutht+\strutdp\relax} + +%D The dimen \type {\struttotal} holds the exact size of the +%D strut; occasionally a one scaled point difference can show +%D up with the lineheight. + +%D Sometimes a capstrut comes in handy +%D +%D \starttabulate[|Tl|l|l|] +%D \NC yes \NC normal strut \NC {\showstruts\setupstrut[yes]\strut} \NC \NR +%D \NC no \NC no strut \NC {\showstruts\setupstrut[no]\strut} \NC \NR +%D \NC kap \NC a capital strut (i.e. Q) \NC {\showstruts\setupstrut[cap]\strut} \NC \NR +%D \NC A B \unknown \NC a character strut (e.g. A) \NC {\showstruts\setupstrut[A]\strut} \NC \NR +%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR +%D \stoptabulate + +\def\setupstrut + {\dosingleempty\dosetupstrut} + +\def\dosetupstrut[#1]% yet undocumented, todo: fontstrut + {\processaction + [#1] + [ \v!yes=>\setstrut, + \v!auto=>\setautostrut, + \v!no=>\setnostrut, + \v!cap=>\setcapstrut, + \v!fit=>\setfontstrut, + \v!line=>\setstrut, + \s!default=>\setstrut, + \s!unknown=>\setcharstrut\commalistelement]} + +\def\setteststrut + {\def\strutwidth{.8pt}% + \setstrut} + +\def\autostrutfactor{1.1} + +\def\setautostrut + {\begingroup + \setbox\scratchbox\copy\strutbox + \setstrut + \ifdim\ht\strutbox>\autostrutfactor\ht\scratchbox + \endgroup \setstrut + \else\ifdim\dp\strutbox>\autostrutfactor\dp\scratchbox + \endgroup \setstrut + \else + \endgroup + \fi\fi} + +% simple version +% +% \def\begstrut +% {\relax\ifcase\strutht\else +% \strut +% \normalpenalty\plustenthousand +% \normalhskip\zeropoint +% \ignorespaces +% \fi} +% +% \def\endstrut +% {\relax\ifhmode\ifcase\strutht\else +% \removeunwantedspaces +% \normalpenalty\plustenthousand +% \normalhskip\zeropoint +% \strut +% \fi\fi} + +% when enabled, sigstruts will remove themselves if nothing +% goes inbetween + +\newsignal\strutsignal \setfalse\sigstruts + +\def\begstrut + {\relax\ifcase\strutht\else + \ifconditional\sigstruts + \noindent\horizontalstrut + \normalpenalty\plustenthousand + \normalhskip-\strutsignal + \normalhskip\strutsignal + \else + \strut + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \fi + \expandafter \ignorespaces + \fi} + +\def\endstrut + {\relax\ifhmode\ifcase\strutht\else + \ifconditional\sigstruts + \ifdim\lastskip=\strutsignal + \unskip\unskip\unpenalty\setbox\scratchbox\lastbox + \else + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \strut + \fi + \else + \removeunwantedspaces + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \strut + \fi + \fi\fi} + +\newbox\nostrutbox \setbox\nostrutbox\normalhbox{} % {\normalhbox{}} + +\def\setnostrut + {\setbox\strutbox\copy\nostrutbox + \let\strut\empty + \let\endstrut\empty + \let\begstrut\empty + \let\crlfplaceholder\empty} + +% unsave: +% +% \def\pseudostrut +% {\bgroup +% \setnostrut +% \normalstrut +% \egroup} +% +% try: +% +% \startchemie +% \chemie[ONE,Z0,SB15,MOV1,SB15,Z0][C,C] +% \stopchemie +% +% so: + +\def\pseudostrut + {\noindent} % better: \dontleavehmode + +\let\pseudobegstrut\pseudostrut + +\let\pseudoendstrut\removeunwantedspaces + +\def\resetteststrut + {\let\strutwidth\zeropoint + \setstrut} + +\ifx\setfontparameters\undefined + % problems ! ! ! ! + \def\setfontparameters{\the\everybodyfont} +\fi + +%D Handy: + +\def\baselinedistance{\the\lineheight} + +%D We need \type{\normaloffinterlineskip} because the new +%D definition contains an assignment, and |<|don't ask me +%D why|>| this assignment gives troubles in for instance the +%D visual debugger. + +%D The plain ones: + +\def\offinterlineskip + {\baselineskip-\thousandpoint + \lineskip\zeropoint + \lineskiplimit\maxdimen} + +\def\nointerlineskip + {\prevdepth-\thousandpoint} + +\let\normaloffinterlineskip=\offinterlineskip % knuth's original + +%D My own one: + +\def\offinterlineskip + {\ifdim\baselineskip>\zeropoint + \edef\oninterlineskip + {\baselineskip\the\baselineskip + \lineskip\the\lineskip + \lineskiplimit\the\lineskiplimit + \let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}% + \else + \let\oninterlineskip\setnormalbaselines + \fi + \normaloffinterlineskip} + +\let\oninterlineskip=\relax + +\def\leaveoutervmode + {\ifvmode\ifinner\else + \leavevmode + \fi\fi} + +% We stellen enkele penalties anders in dan Plain TEX: + +% oud +% +% \widowpenalty=\defaultwidowpenalty\relax +% \clubpenalty =\defaultclubpenalty \relax + +\def\resetpenalties#1% + {\ifx#1\undefined\else + #1\minusone + \fi} + +\def\setpenalties#1#2#3% + {\ifx#1\undefined\else % space before #3 prevents lookahead problems, needed when #3=text + #1\numexpr#2+\plusone\relax\space\doexpandedrecurse{\the\numexpr#2\relax}{ #3}\zerocount\relax + \fi} + +\def\doexpandedrecurse#1#2% + {\ifnum#1>\zerocount#2\@EA\doexpandedrecurse\@EA{\the\numexpr#1-1\relax}{#2}\fi} + +%D \macros +%D {keeplinestogether} +%D +%D Dirty hack, needed in margin content that can run of a page. + +\def\keeplinestogether#1% + {\xdef\restoreinterlinepenalty{\global\resetpenalties\interlinepenalties}% + \global\setpenalties\interlinepenalties{#1}\plustenthousand} + +\newif\ifgridsnapping % to be sure + +\def\defaultwidowpenalty {2000} % was: 1000 +\def\defaultclubpenalty {2000} % was: 800 +\def\defaultdisplaywidowpenalty {50} +\def\defaultbrokenpenalty {100} + +\def\defaultgridwidowpenalty {0} +\def\defaultgridclubpenalty {0} +\def\defaultgriddisplaywidowpenalty {0} +\def\defaultgridbrokenpenalty {0} + +% The original approach: +% +% \def\setdefaultpenalties +% {\ifgridsnapping +% \widowpenalty\defaultgridwidowpenalty +% \clubpenalty \defaultgridclubpenalty +% \else +% \widowpenalty\defaultwidowpenalty +% \clubpenalty \defaultclubpenalty +% \fi} +% +% However, we will use setups: + +% to be documented + +\def\nopenalties + {\widowpenalty \zerocount + \clubpenalty \zerocount + \brokenpenalty \zerocount + \doublehyphendemerits\zerocount + \finalhyphendemerits \zerocount + \adjdemerits \zerocount} + +\def\setdefaultpenalties + {\directsetup{\systemsetupsprefix\s!default}} + +\startsetups [\systemsetupsprefix\s!reset] + \resetpenalties\widowpenalties + \resetpenalties\clubpenalties + \resetpenalties\interlinepenalties +\stopsetups + +% we use \directsetup because it's faster and we know there is no csl + +\startsetups [\systemsetupsprefix\s!default] + + \directsetup{\systemsetupsprefix\s!reset} + + \widowpenalty \defaultwidowpenalty + \clubpenalty \defaultclubpenalty + \displaywidowpenalty\defaultdisplaywidowpenalty + \brokenpenalty \defaultbrokenpenalty + +\stopsetups + +\startsetups [\v!grid] [\systemsetupsprefix\s!default] + + \directsetup{\systemsetupsprefix\s!reset} + + \widowpenalty \defaultgridwidowpenalty + \clubpenalty \defaultgridclubpenalty + \displaywidowpenalty\defaultgriddisplaywidowpenalty + \brokenpenalty \defaultgridbrokenpenalty + +\stopsetups + +% as an illustration: + +\startsetups [\systemsetupsprefix\v!strict] + + \directsetup{\systemsetupsprefix\s!reset} + + \setpenalties\widowpenalties2\maxdimen + \setpenalties\clubpenalties 2\maxdimen + \brokenpenalty \maxdimen + +\stopsetups + +\setdefaultpenalties % will happen later in \setuplayout + +% Suggested by GB (not the name -): + +\def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize} % D.A.'s value + +% Bovendien definieren we enkele extra \fill's: + +\def\hfilll{\hskip\zeropoint\!!plus1filll\relax} +\def\vfilll{\vskip\zeropoint\!!plus1filll\relax} + +% De onderstaande hulpmacro's moeten nog eens instelbaar worden +% gemaakt. + +\def\tfskipsize{1em\relax} +\def\tfkernsize{1ex\relax} + +\def\tfskip{\dotfskip\tfskipsize} +\def\tfkern{\dotfkern\tfkernsize} + +\def\dotfskip#1{{\tf\hskip#1}} +\def\dotfkern#1{{\tf\kern #1}} + +% needs a proper \definenarrower or installnarrower + +\newskip\ctxleftskip +\newskip\ctxrightskip +\newskip\ctxmidskip + +\def\dosinglenarrower#1% + {\processaction + [#1] + [ \v!left=>\global\advance\ctxleftskip \@@slleft, + \v!middle=>\global\advance\ctxmidskip \@@slmiddle, + \v!right=>\global\advance\ctxrightskip \@@slright, + \v!reset=>\global\ctxleftskip \zeropoint + \global\ctxmidskip \zeropoint + \global\ctxrightskip\zeropoint, + \v!none=>, + \s!unknown=>\global\advance\ctxmidskip \commalistelement]} + +% \def\donarrower[#1]% hm, can be dorepeat directly +% {\processaction +% [#1] +% [ \v!left=>\global\advance\ctxleftskip \@@slleft, +% \v!middle=>\global\advance\ctxmidskip \@@slmiddle, +% \v!right=>\global\advance\ctxrightskip \@@slright, +% \v!none=>,% handy for delimitedtexts +% \s!unknown=>{\dorepeatwithcommand[#1]\dosinglenarrower}]} + +\def\donarrower[#1]% hm, can be dorepeat directly + {\dorepeatwithcommand[#1]\dosinglenarrower} + +\def\complexstartnarrower[#1]% + {\@@slbefore % was hard coded \par + \bgroup + \global\ctxleftskip \zeropoint + \global\ctxrightskip\zeropoint + \global\ctxmidskip \zeropoint + \processcommalistwithparameters[#1]\donarrower + \advance\leftskip \ctxleftskip + \advance\rightskip \ctxrightskip + \advance\leftskip \ctxmidskip + \advance\rightskip \ctxmidskip + \seteffectivehsize} + +% todo: definenarrower + +\def\simplestartnarrower + {\startnarrower[\v!middle]} + +\definecomplexorsimple\startnarrower + +\def\stopnarrower + {\@@slafter % was hard coded \par / needed, else skips forgotten + \egroup} + +\def\setupnarrower + {\dodoubleargument\getparameters[\??sl]} + +\newdimen\@@effectivehsize \def\effectivehsize {\hsize} +\newdimen\@@effectiveleftskip \def\effectiveleftskip {\leftskip} +\newdimen\@@effectiverightskip \def\effectiverightskip{\rightskip} + +\def\seteffectivehsize + {\setlocalhsize + \@@effectivehsize \localhsize + \@@effectiveleftskip \leftskip + \@@effectiverightskip \rightskip + \let\effectivehsize \@@effectivehsize + \let\effectiveleftskip \@@effectiveleftskip + \let\effectiverightskip\@@effectiverightskip} + +\def\dodefinehbox[#1][#2]% + {\setvalue{hbox#1}##1% + {\hbox to #2{\begstrut##1\endstrut\hss}}} + +\def\definehbox + {\dodoubleargument\dodefinehbox} + +\def\iobox#1#2#3#% here #3# is not really needed + {\vbox\bgroup % we want to return a vbox like the others + \hbox\bgroup% we need to pack the signal with the box + \signalrightpage + \dowithnextboxcontent + {\let\\=\endgraf\forgetall\doifrightpageelse#1#2} + {\box\nextbox\egroup\egroup} + \vbox#3} + +\def\obox{\iobox\raggedleft \raggedright} % outerbox +\def\ibox{\iobox\raggedright\raggedleft} % innerbox + +\def\dosetraggedvbox#1% + {\let\raggedbox\vbox + \processfirstactioninset + [#1] + [ \v!left=>\let\raggedbox\lbox, + \v!right=>\let\raggedbox\rbox, + \v!middle=>\let\raggedbox\cbox, + \v!inner=>\let\raggedbox\ibox, + \v!outer=>\let\raggedbox\obox, + \v!flushleft=>\let\raggedbox\rbox, + \v!flushright=>\let\raggedbox\lbox, + \v!center=>\let\raggedbox\cbox, + \v!no=>\def\raggedbox{\vbox\bgroup\raggedright\let\next=}]} + +\def\dosetraggedhbox#1% + {\let\raggedbox\hbox + \processaction % slow + [#1] + [ \v!left=>\def\raggedbox{\doalignedline\v!left }, + \v!right=>\def\raggedbox{\doalignedline\v!right }, + \v!middle=>\def\raggedbox{\doalignedline\v!middle}, + \v!inner=>\def\raggedbox{\doalignedline\v!inner }, + \v!outer=>\def\raggedbox{\doalignedline\v!outer }, + \v!flushleft=>\def\raggedbox{\doalignedline\v!right }, + \v!flushright=>\def\raggedbox{\doalignedline\v!left }, + \v!center=>\def\raggedbox{\doalignedline\v!middle}]} + +\def\dosetraggedcommand#1% + {\expanded{\dodosetraggedcommand{#1}}} + +% \def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! +% {\let\raggedcommand \relax +% \let\raggedtopcommand \empty +% \let\raggedbottomcommand\empty +% \chardef\raggedoneliner\zerocount +% \doifsomething{#1} +% {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse +% \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse +% \!!donectrue +% \rawprocesscommalist[#1]\dododosetraggedcommand}} + +\newtoks\everyraggedcommand + +\def\raggedcommand{\the\everyraggedcommand} + +\def\dodosetraggedcommand#1% beware: #1=empty is ignored, keep that! + {\everyraggedcommand \emptytoks + \let\raggedtopcommand \empty + \let\raggedbottomcommand\empty + \chardef\raggedoneliner\zerocount + \doifsomething{#1} + {\doifinsetelse\v!broad{#1}\!!doneatrue\!!doneafalse + \doifinsetelse\v!wide {#1}\!!donebtrue\!!donebfalse + \!!donectrue + \rawprocesscommalist[#1]\dododosetraggedcommand}} + +\def\dododosetraggedcommand#1% + {\executeifdefined{\@@ragged@@command\string#1}\relax} + +\def\@@ragged@@command{@@raggedcommand} + +\setvalue{\@@ragged@@command\v!hanging }{\appendtoks\enableprotruding \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nothanging }{\appendtoks\disableprotruding \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!hz }{\appendtoks\enableadjusting \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nohz }{\appendtoks\disableadjusting \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!spacing }{\appendtoks\enablespacehandling + \enablekernhandling \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nospacing }{\appendtoks\disablespacehandling + \disablekernhandling \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!hyphenated }{\appendtoks\dohyphens \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!nothyphenated}{\appendtoks\nohyphens \to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!tolerant }{\appendtoks\tolerance3000\relax \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!verytolerant}{\appendtoks\tolerance4500\relax \to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!stretch }{\appendtoks\emergencystretch\bodyfontsize\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!left}% + {\if!!donea \appendtoks\veryraggedleft\to\everyraggedcommand + \else \appendtoks\raggedleft \to\everyraggedcommand + \fi + \!!donecfalse} + +\setvalue{\@@ragged@@command\v!right}% + {\if!!donea \appendtoks\veryraggedright\to\everyraggedcommand + \else \appendtoks\raggedright \to\everyraggedcommand + \fi + \!!donecfalse} + +\setvalue{\@@ragged@@command\v!middle}% + {\if!!donec + \if!!doneb \appendtoks\raggedwidecenter\to\everyraggedcommand + \else\if!!donea \appendtoks\veryraggedcenter\to\everyraggedcommand + \else \appendtoks\raggedcenter \to\everyraggedcommand + \fi\fi + \!!donecfalse + \else + \let\raggedbottomcommand\vfilll % bonus, pretty strong + \let\raggedtopcommand \vfilll % used with \framed for + \fi} % instance in tables + +\setvalue{\@@ragged@@command\v!flushleft }{\getvalue{\@@ragged@@command\v!right }} +\setvalue{\@@ragged@@command\v!flushright}{\getvalue{\@@ragged@@command\v!left }} +\setvalue{\@@ragged@@command\v!center }{\getvalue{\@@ragged@@command\v!middle}} + +\setvalue{\@@ragged@@command\v!high}% + {\let\raggedbottomcommand\vfilll} % and since we lack a + +\setvalue{\@@ragged@@command\v!low}% + {\let\raggedtopcommand\vfilll} % proper keyword, but + +\setvalue{\@@ragged@@command\v!lohi}% + {\let\raggedbottomcommand\vfilll % we do support the + \let\raggedtopcommand\vfilll} % ugly laho (lohi) + +\setvalue{\@@ragged@@command\v!no}% + {\appendtoks\raggedright\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!yes}% + {\appendtoks\notragged\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!normal}% + {\appendtoks\notragged\to\everyraggedcommand} + +\setvalue{\@@ragged@@command\v!inner}% not yet perfect + {\signalrightpage % may interfere + \doifrightpageelse + {\getvalue{\@@ragged@@command\v!right}} + {\getvalue{\@@ragged@@command\v!left}}} + +\setvalue{\@@ragged@@command\v!outer}% not yet perfect + {\signalrightpage % may interfere + \doifrightpageelse + {\getvalue{\@@ragged@@command\v!left}} + {\getvalue{\@@ragged@@command\v!right}}} + +\setvalue{\@@ragged@@command\v!lesshyphenation}% + {\appendtoks\lesshyphens\to\everyraggedcommand} +\setvalue{\@@ragged@@command\v!morehyphenation}% + {\appendtoks\morehyphens\to\everyraggedcommand} + +% compare: +% +% \framed[width=4cm,align=no] {\hfil xxx} +% \framed[width=4cm,align=disable]{\hfil xxx} + +\setvalue{\@@ragged@@command\v!disable}% for one liners + {\appendtoks\raggedright\parfillskip\zeropoint\to\everyraggedcommand} + +\chardef\raggedoneliner\zerocount + +\setvalue{\@@ragged@@command\v!line}% + {\chardef\raggedoneliner\plusone} + +%D Unofficial, may disappear. Now handled directly in the +%D core-rul module. + +% \def\@@startraggedoneliner +% {\ifcase\raggedoneliner\else +% \dontleavehmode\hbox to \hsize \bgroup % hsize added, else useless +% \ifcase\raggedstatus\or\hss\or\hss\fi +% \ignorespaces +% \bgroup +% \aftergroup\removeunwantedspaces +% \fi} + +% \def\@@stopraggedoneliner +% {\ifcase\raggedoneliner\else +% \egroup +% \ifcase\raggedstatus\or\or\hss\or\hss\fi +% \egroup +% \ignorespaces % ? ? ? +% \fi} + +% \def\@@handleoneliner +% {\ifcase\raggedoneliner\else +% \@@startraggedoneliner +% \aftergroup\@@stopraggedoneliner +% \fi} + +% Nog doen: +% +% \goodbreak -> \allowbreak en \dosomebreak{..} in koppen +% +% bij koppen zowieso: \blanko[reset] + +% Nog in commando verwerken: +% +% \voorkeur … la \blanko +% +% Om ongewenste witruimte te voorkomen kan met \dosomebreak{\break} +% een \penalty voor witruimte worden geplaatst. + +\def\removelastskip % a redefinition of plain + {\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi} + +% first version: +% +% \def\dosomebreak#1% +% {\scratchskip\lastskip +% \removelastskip +% %\type{#1}% +% #1\relax +% \ifdim\scratchskip=\zeropoint \else +% \vskip\scratchskip +% \fi} +% +% don't change the next improvement: + +% \def\dosomebreak#1% +% {\endgraf % beware, this forces a newline +% \ifvmode +% \ifdim\lastskip=\zeropoint +% #1\relax +% \else +% \scratchskip\lastskip +% \removelastskip +% #1\relax +% \vskip\scratchskip +% \fi +% \fi} + +% beter, vooral in \vbox; nog in \pagina toepassen s! + +\def\doifoutervmode#1% + {\ifvmode\ifinner\else#1\fi\fi} + +\ifx\dosomebreak\undefined % defined in mkiv + + \def\dosomebreak#1% + {\doifoutervmode + {\scratchskip\lastskip + \removelastskip + %\leavevmode\type{#1}% + #1\relax + \ifdim\scratchskip=\zeropoint % else interference with footnotes + \else + \vskip\scratchskip + \fi}} + +\fi + +\def\forgeteverypar + {\everypar{\the\neverypar}} + +%\def\forgetparindent +% {\forgeteverypar +% \indentfirstparagraphtrue % recently added +% \setupindenting[\v!geen]} + +%\def\forgetparskip +% {\setupwhitespace[\v!geen]} + +\def\forgetparindent + {\forgeteverypar + \indentfirstparagraphtrue % recently added + \let\currentindentation\v!none + \ctxparindent\zeropoint + \parindent\zeropoint\relax} + +\def\forgetparskip + {\let\currentwhitespace\v!none + \ctxparskip\zeropoint + \parskip\zeropoint\relax} + +\def\forgetbothskips + {\tolerance1500 + \leftskip\zeropoint + \rightskip\zeropoint\relax} + +\def\forgetspacing + {\emergencystretch\zeropoint} + +\newif\ifforgotten % rather good signal for inner + +\appendtoks \forgottentrue \to \everyforgetall +\appendtoks \forgetragged \to \everyforgetall +\appendtoks \forgetparskip \to \everyforgetall +\appendtoks \forgetparindent \to \everyforgetall +\appendtoks \forgetbothskips \to \everyforgetall +\appendtoks \forgetspacing \to \everyforgetall % i.v.m. funny spacing in pagebody +\appendtoks \spacing\!!plusone \to \everyforgetall % new per 10/08/2004, else problems in otr / !! needed +\appendtoks \everypar\emptytoks \to \everyforgetall % indeed! + +\def\localvbox#1#% + {\vbox#1\bgroup + \forgetparskip + \setlocalhsize + \hsize\localhsize + \forgetparindent + \forgetbothskips + \forgeteverypar + \let\next=} + +% ach ja, hoort niet hier + +% \unexpanded\def\dostartattributes#1#2#3% +% {\begingroup % geen \bgroup, anders in mathmode lege \hbox +% \doifdefinedelse{#1#2} +% {\def\fontattribute{\getvalue{#1#2}}} +% {\let\fontattribute=\empty}% +% \doifdefinedelse{#1#3} +% {\def\colorattribute{\getvalue{#1#3}}} +% {\let\colorattribute=\empty}% +% \startcolor[\colorattribute]% +% \@EA\doconvertfont\@EA{\fontattribute}} +% +% \unexpanded\def\dostopattributes% +% {\stopcolor +% \endgroup} +% +% \unexpanded\def\doattributes#1#2#3#4% +% {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} + +%D A hardly faster implementation follows. We cannot use +%D \type {csname} testing since the first argument can be +%D anything, even a raw fontswitch. No a real improvement +%D (some 5 seconds on 260 seconds for the maps bibliography). + +\let\dostopattributes\relax % in case these commands end up in an edef + +\unexpanded\def\dostartattributes#1#2#3% + {\begingroup % geen \bgroup, anders in mathmode lege \hbox + \ifcsname#1#3\endcsname + \let\dostopattributes\@@dostopattributes + \startcolor[\csname#1#3\endcsname]% + \else + \let\dostopattributes\@@nostopattributes + \fi + \ifcsname#1#2\endcsname + \expandafter\doconvertfont + \else + \expandafter\gobbleoneargument + \fi{\csname#1#2\endcsname}} + +\newconditional \parbasedattributes + +\def\finishparbasedattributes + {\ifconditional\parbasedattributes + \setfalse\parbasedattributes + \par + \fi} + +\def\dostopparbasedattributes + {\settrue\parbasedattributes + \dostopattributes} + +\unexpanded\def\@@dostopattributes + {\stopcolor + \finishparbasedattributes + \endgroup} + +\unexpanded\def\@@nostopattributes + {\finishparbasedattributes + \endgroup} + +\unexpanded\def\doattributes#1#2#3#4% + {\dostartattributes{#1}{#2}{#3}{#4}\dostopattributes} + +% An even faster \ETEX\ version: + +\unexpanded\def\dostartattributes#1#2#3% + {\begingroup % geen \bgroup, anders in mathmode lege \hbox + \ifincolor + \ifcsname#1#3\endcsname + \let\dostopattributes\@@dostopattributes + \faststartcolor[\csname#1#3\endcsname]% + \else + \let\dostopattributes\@@nostopattributes + \fi + \else + \let\dostopattributes\@@nostopattributes + \fi + \ifcsname#1#2\endcsname + % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi} + +\unexpanded\def\@@dostopattributes + {\faststopcolor + \finishparbasedattributes + \endgroup} + +\unexpanded\def\@@nostopattributes + {\finishparbasedattributes + \endgroup} + +%D Bonus macro, see core-sec.tex + +\unexpanded\def\dosetfontattribute#1#2% + {\ifcsname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi\empty} + +%D Since this happens a lot, and sometimes large arguments +%D are passed in \type {#4}, we just copy some code: + +\unexpanded\def\doattributes#1#2#3#4% + {\begingroup % geen \bgroup, anders in mathmode lege \hbox + \ifincolor + \ifcsname#1#3\endcsname + \let\dostopattributes\@@dostopattributes + \faststartcolor[\csname#1#3\endcsname]% + \else + \let\dostopattributes\endgroup + \fi + \else + \let\dostopattributes\endgroup + \fi + \ifcsname#1#2\endcsname + % \@EAEAEA\doconvertfont\@EA\@EA\csname#1#2\endcsname + \@EA\doconvertfont\csname#1#2\@EA\endcsname + \fi + {#4}% + \dostopattributes} + +% Kan vaker worden toegepast en moet bovendien sneller! + +\newskip\leftskipadaption +\newskip\rightskipadaption + +\def\doadaptleftskip#1% + {\dosetleftskipadaption{#1}% + \advance\leftskip \leftskipadaption} + +\def\doadaptrightskip#1% + {\dosetrightskipadaption{#1}% + \advance\rightskip \rightskipadaption} + +\setvalue{@lsa@\v!standard}{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} +\setvalue{@lsa@\v!yes }{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} +\letvalue{@lsa@\v!no }\zeropoint +\letvalue{@lsa@\empty }\zeropoint +\setvalue{@rsa@\v!standard}{\@@slright} +\setvalue{@rsa@\v!yes }{\@@slright} +\letvalue{@rsa@\v!no }\zeropoint +\letvalue{@rsa@\empty }\zeropoint + +% not safe for 2\parindent +% +% \def\dosetleftskipadaption#1% +% {\leftskipadaption +% \ifcsname @lsa@#1\endcsname +% \csname @lsa@#1\endcsname +% \else +% #1% +% \fi +% \relax} + +\def\dosetleftskipadaption#1% + {\edefconvertedargument\ascii{@lsa@#1}% + \leftskipadaption + \ifcsname\ascii\endcsname + \csname\ascii\endcsname + \else + #1% + \fi + \relax} + +\def\dosetrightskipadaption#1% + {\edefconvertedargument\ascii{@rsa@#1}% + \rightskipadaption + \ifcsname\ascii\endcsname + \csname\ascii\endcsname + \else + #1% + \fi + \relax} + +\newcount \noftrackedpagestates +\newif \ifpagestatemismatch +\newcount \realpagestateno +\chardef \frozenpagestate \zerocount + +\def\dotrackpagestate#1#2% + {\ifdoublesided \ifinpagebody \else + \doforcedtrackpagestate{#1}{#2}% + \fi \fi} + +\def\doforcedtrackpagestate#1#2% + {\ifcase\frozenpagestate + \global\advance\noftrackedpagestates\plusone + \global\advance#2\plusone + \lazysavetaggedtwopassdata{#1}{\number\noftrackedpagestates}{\number#2}{\noexpand\realfolio}% + %\llap{\infofont\number\noftrackedpagestates/\number#2}% tracing + \fi} + +\def\doifrightpagestateelse#1#2% + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \ifinpagebody + \ifdoublesided + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \twopassdatafoundtrue + \fi + \else\ifdoublesided + \findtwopassdata{#1}{\number#2}% + \iftwopassdatafound + \realpagestateno\twopassdata\relax + \ifnum\twopassdata=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\twopassdata\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \else + \twopassdatafoundtrue + \fi\fi + \else + \ifodd\realpagestateno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \iftwopassdatafound + \@EA\firstoftwoarguments + \else + \@EA\secondoftwoarguments + \fi} + +\def\doifforcedrightpagestateelse#1#2% + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \findtwopassdata{#1}{\number#2}% + \iftwopassdatafound + \realpagestateno\twopassdata\relax + \ifnum\twopassdata=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\twopassdata\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \else + \ifodd\realpagestateno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \iftwopassdatafound + \@EA\firstoftwoarguments + \else + \@EA\secondoftwoarguments + \fi} + +\def\freezepagestate {\chardef\frozenpagestate\plusone } +\def\defrostpagestate{\chardef\frozenpagestate\zerocount} + +% we can make more of these on top, but how to deal with mixed frozen states + +\definetwopasslist\s!paragraph \newcount \nofraggedparagraphs + +\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} +\def\doifrightpageelse{\doifrightpagestateelse\s!paragraph\nofraggedparagraphs} + +\newcount\pagesignallevel + +\def\startsignalrightpage % one may do a \postsignalrightplace + {\advance\pagesignallevel\plusone + \presignalrightpage + \let\signalrightpage\relax + \let\presignalrightpage\relax + \let\startsignalrightpage\relax + \doifrightpageelse\donothing\donothing + \freezepagestate} + +\def\stopsignalrightpage + {\ifcase\pagesignallevel\or\postsignalrightpage\fi + \advance\pagesignallevel\minusone} + +\def\setraggedparagraphmode + {\signalrightpage\doifrightpageelse} % move it there + +\ifx\swapmargins\undefined \let\swapmargins\undefined \fi % todo + +\def\doifswappedrightpageelse#1#2% alleen in box construction ! + {\doifrightpageelse + {#1} + {\scratchcounter\realpageno + \realpageno\realpagestateno\relax + \swapmargins + \realpageno\scratchcounter + #2}} + +\newbox\signaledrightpage % this way we can avoid interference, i.e. postpone placement + +\def\presignalrightpage {\global\setbox\signaledrightpage\hbox{\signalrightpage}} +\def\postsignalrightpage{\ifvoid\signaledrightpage\else\box\signaledrightpage\fi} + +% The next feature is is used in: +% +% \definenumber[test][way=bypage] +% +% \def\Test +% {\incrementnumber[test]\rawnumber[test]/% +% \incrementnumber[test]\rawnumber[test]/% +% \incrementnumber[test]\rawnumber[test]\space +% \checkpagechange{oeps}\changedpage{oeps}\space +% \ifpagechanged TRUE\else FALSE\fi} +% +% \Test\page \Test\par \Test\page \Test\par \Test\page \Test\page +% +% (adapted from cont-new.tex:) + +\newif\ifpagechanged \let\lastchangedpage\empty + +\def\docheckpagestatechange#1#2#3% + {\pagechangedfalse + \doforcedtrackpagestate{#2}{#3}% + \findtwopassdata{#2}{\number#3}% + \iftwopassdatafound + \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax + \pagechangedtrue + \fi + \fi + \ifpagechanged + \letgvalue{#2:p:#1}\twopassdata + \globallet\lastchangedpage\twopassdata + \else + \globallet\lastchangedpage\realfolio + \fi} + +\def\changedpagestate#1#2% + {\executeifdefined{#2:p:#1}{0}} + +\def\checkpagechange#1{\docheckpagestatechange{#1}\s!paragraph\nofraggedparagraphs} +\def\changedpage #1{\changedpagestate{#1}\s!paragraph} + +% saved struts + +\ifx\savedstrutbox\undefined \newbox\savedstrutbox \fi + +\def\savestrut {\setbox\savedstrutbox\copy\strutbox} +\def\savedstrut{\copy \savedstrutbox} + +% De onderstaande macro's zijn opgenomen in Plain TeX. +% +% \def\raggedright% +% {\rightskip\zeropoint plus2em \spaceskip.3333em \xspaceskip.5em\relax} +% +% \def\ttraggedright% +% {\tttf\rightskip\zeropoint plus2em\relax} +% +% \newif\ifr@ggedbottom +% +% \def\raggedbottom% +% {\topskip 10\points plus60\points \r@ggedbottomtrue} +% +% \def\normalbottom% +% {\topskip 10\points \r@ggedbottomfalse} +% +% en worden hieronder wat aangepast. + +% the three boolean will become obsolete some day in favour +% of \bottomraggedness + +\chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline + +\def\bottomalignlimit{3\lineheight} + +\newif\ifn@rmalbottom +\newif\ifr@ggedbottom +\newif\ifb@selinebottom + +\def\normalbottom + {% \topskip 10pt + \r@ggedbottomfalse} + +\def\raggedbottom + {\chardef\bottomraggedness\zerocount + \n@rmalbottomfalse + \r@ggedbottomtrue + \b@selinebottomfalse + \settopskip} + +\def\alignbottom + {\chardef\bottomraggedness\plusone + \n@rmalbottomtrue + \r@ggedbottomfalse + \b@selinebottomfalse + \settopskip} + +\def\baselinebottom + {\chardef\bottomraggedness\plustwo + \n@rmalbottomfalse + \r@ggedbottomfalse + \b@selinebottomtrue + \settopskip} + +\let\normalbottom=\alignbottom % downward compatible + +% so, the new one will be +% +% \chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline +% +% \def\bottomalignlimit{3\lineheight} % will be settable +% +% \def\raggedbottom {\chardef\bottomraggedness=0 \settopskip} +% \def\alignbottom {\chardef\bottomraggedness=1 \settopskip} +% \def\baselinebottom{\chardef\bottomraggedness=2 \settopskip} +% +% \let\normalbottom =\alignbottom + +% \hyphenpenalty = ( 2.5 * \hsize ) / \raggedness +% \tolerance >= 1500 % was 200 +% \raggedness = 2 .. 6\bodyfontsize + +\chardef\raggedstatus=0 % normal left center right + +\def\leftraggedness {2\bodyfontsize} +\def\rightraggedness {2\bodyfontsize} +\def\middleraggedness {6\bodyfontsize} + +\def\middleraggedness {.5\hsize} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} + +% oeps, hsize can be 0pt in which case we get a strange division + +\def\middleraggedness {\ifdim\hsize=\zeropoint6\bodyfontsize\else.5\hsize\fi} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} + +%D More hyphenation control, will be combined with align +%D setup. + +\def\nohyphens + {\ifx\dohyphens\relax + \edef\dohyphens + {\hyphenpenalty\the\hyphenpenalty + \exhyphenpenalty\the\exhyphenpenalty\relax}% + \fi + \hyphenpenalty\plustenthousand + \exhyphenpenalty\plustenthousand} + +\let\dohyphens\relax + +%D To prevent unwanted side effects, we also have to check +%D for hyphens here: + +% \def\setraggedness#1% +% {\ifnum\tolerance<1500\relax % small values have +% \tolerance1500\relax % unwanted side effects +% \fi +% \spaceskip2.5\hsize % we misuse these registers +% \xspaceskip#1\relax % for temporary storage; +% \divide\spaceskip \xspaceskip % they are changed anyway +% \ifx\dohyphens\relax +% \hyphenpenalty\spaceskip % \else no hyphens is active +% \fi} + +\newskip\@@raggedskipa +\newskip\@@raggedskipb + +\def\setraggedness#1% + {\ifnum\tolerance<1500\relax % small values have + \tolerance1500\relax % unwanted side effects + \fi + \ifx\dohyphens\relax + % this code will be reconsidered / kind of fuzzy (and old) + \@@raggedskipa 2.5\hsize + \@@raggedskipb #1\relax + \divide\@@raggedskipa \@@raggedskipb + \hyphenpenalty\@@raggedskipa + \fi} + +\let\updateraggedskips\relax + +\def\setraggedskips#1#2#3#4#5#6#7% never change this name + {\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% + \updateraggedskips} + +\def\dosetraggedskips#1#2#3#4#5#6#7% + {\chardef \raggedstatus#1\relax + \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 + \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 + \spaceskip #4\relax + \xspaceskip #5\relax + \parfillskip\zeropoint\!!plus#6\relax + \parindent #7\relax} + +% \def\notragged% +% {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} + +% older (context) names: + +\let\spaceamount \interwordspace +\let\emspaceamount\emwidth + +% tracing: + +\def\doshowpardata#1% + {\ifx#1\relax\else + \hbox{\string#1: \the#1}\endgraf + \expandafter\doshowpardata + \fi} + +\def\showpardata + {\edef\thepardata + {\hbox{font: \fontname\font}\endgraf + \doshowpardata + \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace + \hsize \vsize + \leftskip \rightskip + \spaceskip \xspaceskip + \parindent \parfillskip + \hyphenpenalty \exhyphenpenalty + \displaywidowpenalty \widowpenalty \clubpenalty \brokenpenalty + \doublehyphendemerits \finalhyphendemerits \adjdemerits + \relax}% + \begingroup + \dontshowcomposition + \inleftmargin{\vsmash + {\switchtobodyfont[7pt,tt]% + \framed[\c!align=\v!right]{\thepardata}}}% + \endgroup} + +\def\startshowpardata + {\begingroup + \showcomposition + \showstruts\tracepositionstrue \tracingparagraphs\maxdimen + \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} + +\def\stopshowpardata + {\endgraf + \endgroup} + +% \defineXMLenvironment[showpardata] \startshowpardata \stopshowpardata +% \defineXMLsingular [showpardata] \showpardata + +% defaults + +\def\raggedfillamount {1fil} +\def\raggedhalffillamount{.5fil} +\def\raggedspaceamount {\interwordspace} % {.3333em} +\def\raggedxspaceamount {.5em} + +\def\notragged + {\chardef\raggedstatus\zerocount + \leftskip 1\leftskip + \rightskip 1\rightskip + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parfillskip\zeropoint\!!plus\raggedfillamount\relax + \let\updateraggedskips\relax} % new + +\let\forgetragged\notragged + +\def\raggedleft + {\setraggedness\leftraggedness + \setraggedskips1\leftraggedness\zeropoint\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +\def\raggedcenter + {\setraggedness\middleraggedness + \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +%D We used to have: +%D +%D \starttyping +%D \def\raggedright +%D {\setraggedness\rightraggedness +%D \setraggedskips{3}{0em}{\rightraggedness}{.3333em}{.5em}{0em}{\parindent}} +%D \stoptyping +%D +%D However, the next alternative, suggested by Taco, is better. + +\def\raggedright + {\setraggedness\rightraggedness + \setraggedskips3\zeropoint\rightraggedness\raggedspaceamount + \raggedxspaceamount\raggedfillamount\parindent} + +\def\veryraggedleft + {\setraggedskips1\raggedfillamount\zeropoint\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +%D When we want the last line to have a natural width: +%D +%D \starttyping +%D \def\veryraggedleft% +%D {\setraggedskips{1}{1fil}{0em}{.3333em}{.5em}{0em}{-1fil}} +%D \stoptyping +%D +%D but this one is not accepted by the macros. + +\def\veryraggedcenter + {\setraggedskips2\raggedfillamount\raggedfillamount\raggedspaceamount + \raggedxspaceamount\zeropoint\zeropoint} + +\def\veryraggedright + {\setraggedskips3\zeropoint\raggedfillamount\raggedspaceamount + \raggedxspaceamount\zeropoint\parindent} + +\def\ttraggedright + {\tttf + \setraggedskips3\zeropoint\rightraggedness + \zeropoint\zeropoint\zeropoint\parindent} % \ctxparindent + +%D A bonus one: + +\def\raggedwidecenter + {\setraggedness\middleraggedness + \setraggedskips2\raggedhalffillamount\raggedhalffillamount + \raggedspaceamount\raggedxspaceamount\zeropoint\zeropoint} + +\newif\if@@asragged \@@asraggedtrue % old method + +% todo +% +% \setuplayout[grid=yes,lines=44] \showgrid +% \starttext +% test \vfill test \endgraf \strut \endgraf \vskip-\lineheight \removedepth \pagina test +% \stoptext + +% \setupalign[reset,new,right,old] + +\def\@@align@@rl{\if!!donea\veryraggedleft \else\raggedleft \fi} +\def\@@align@@rr{\if!!donea\veryraggedright \else\raggedright \fi} +\def\@@align@@rc{\if!!donea\veryraggedcenter\else\raggedcenter\fi} + +\setvalue{@@ngila@@\v!broad }{\!!doneatrue} +\setvalue{@@ngila@@\v!wide }{\!!donebtrue} + +\def\installalign#1#2{\setvalue{@@align@@#1}{#2}} % can be used for overloads + +\installalign \v!new {\@@asraggedfalse} +\installalign \v!old {\@@asraggedtrue} +\installalign \empty {} + +\installalign \v!line {\baselinebottom} +\installalign \v!bottom {\raggedbottom} +\installalign \v!height {\normalbottom} +\installalign \v!width {\notragged} +\installalign \v!normal {\notragged} +\installalign \v!yes {\notragged} +\installalign \v!no {\raggedright} +\installalign \v!inner {\if@@asragged \setraggedparagraphmode\@@align@@rl\@@align@@rr \else + \setraggedparagraphmode\@@align@@rr\@@align@@rl \fi} +\installalign \v!outer {\if@@asragged \setraggedparagraphmode\@@align@@rr\@@align@@rl \else + \setraggedparagraphmode\@@align@@rl\@@align@@rr \fi} +\installalign \v!left {\if@@asragged\@@align@@rl\else\@@align@@rr\fi} +\installalign \v!right {\if@@asragged\@@align@@rr\else\@@align@@rl\fi} +\installalign \v!middle {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} +\installalign \v!flushleft {\if!!donea\veryraggedright \else\raggedright\fi} +\installalign \v!flushright {\if!!donea\veryraggedleft \else\raggedleft \fi} +\installalign \v!flushouter {\setraggedparagraphmode\raggedleft\raggedright} +\installalign \v!flushinner {\setraggedparagraphmode\raggedright\raggedleft} +\installalign \v!center {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} +\installalign \v!hanging {\enableprotruding} +\installalign \v!nothanging {\disableprotruding} +\installalign \v!hz {\enableadjusting} +\installalign \v!nohz {\disableadjusting} +\installalign \v!spacing {\enablespacehandling \enablekernhandling} +\installalign \v!nospacing {\disablespacehandling\disablekernhandling} +\installalign \v!hyphenated {\dohyphens} +\installalign \v!nothyphenated {\nohyphens} +\installalign \v!new {\@@asraggedfalse} % so new will give you consistency +\installalign \v!reset {\notragged\normalbottom} + +\installalign \v!tolerant {\tolerance3000 \relax} +\installalign \v!verytolerant {\tolerance4500 \relax} +\installalign \v!stretch {\emergencystretch\bodyfontsize} + +\newcount\hyphenminoffset + +\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi + +\def\lesshyphens + {\advance\hyphenminoffset\plusone + \sethyphenationvariables} + +\def\morehyphens + {\ifcase\hyphenminoffset \else + \advance\hyphenminoffset\minusone + \fi + \sethyphenationvariables} + +\installalign \v!lesshyphenation {\lesshyphens} +\installalign \v!morehyphenation {\morehyphens} + +\def\dodosetupalign#1{\csname @@align@@#1\endcsname} +\def\dodosetupngila#1{\csname @@ngila@@#1\endcsname} + +\def\setupalign + {\dosingleargument\dosetupalign} + +\def\dosetupalign[#1]% can be made faster by checking for defined #1 + {\!!doneafalse + \!!donebfalse + \processcommacommand[#1]\dodosetupngila + \processcommacommand[#1]\dodosetupalign} + +% \setupalign[flushleft] \input ward \par % lijnlinks +% \setupalign[right] \input ward \par + +% \setupalign[flushright] \input ward \par % lijnrechts +% \setupalign[left] \input ward \par + +% \setupalign[middle] \input ward \par % centreer +% \setupalign[center] \input ward \par + +\def\startalignment + {\bgroup + \setupalign} + +\def\stopalignment + {\par + \egroup} + +\chardef\alignstrutmode=1 + +% see later for the real definition, which in the simple case is: + +\newtoks \everyleftofalignedline +\newtoks \everyrightofalignedline + +\def\shiftalignedline#1#2#3#4% left, right, inner, outer + {\rightorleftpageaction + {\everyleftofalignedline {\hskip\dimexpr#1+#3\relax}% + \everyrightofalignedline{\hskip\dimexpr#2+#4\relax}} + {\everyleftofalignedline {\hskip\dimexpr#1+#4\relax}% + \everyrightofalignedline{\hskip\dimexpr#2+#3\relax}}} + +% \def\doalignline#1#2% \\ == newline +% {\begingroup +% \setlocalhsize % new +% \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% +% \dowithnextbox +% {\noindentation % was \noindent +% \dontleavehmode % added in marrakesch at TUG 2006 +% \hbox to \localhsize +% {\ifcase\alignstrutmode\or\strut\fi +% \the\everyleftofalignedline +% #1\unhbox\nextbox#2\relax +% \the\everyrightofalignedline}% +% \endgroup} +% \hbox} + +\def\doalignline#1#2% \\ == newline + {\noindentation % was \noindent + \dontleavehmode % added in marrakesch at TUG 2006\begingroup + \begingroup + \setlocalhsize % new + \def\\{\egroup\par\doalignline{#1}{#2}\bgroup}% + \dowithnextbox + {\hbox to \localhsize + {\ifcase\alignstrutmode\or\strut\fi + \the\everyleftofalignedline + #1\unhbox\nextbox#2\relax + \the\everyrightofalignedline}% + \endgroup} + \hbox} + +% plain commands + +\ifx\undefined\line \def\line {\hbox to\hsize} \fi +\ifx\undefined\leftline \def\leftline #1{\line{#1\hss}} \fi +\ifx\undefined\rightline \def\rightline #1{\line{\hss#1}} \fi +\ifx\undefined\centerline \def\centerline#1{\line{\hss#1\hss}} \fi + +% directe commando's + +\def\leftaligned {\doalignline \relax \hss } +\def\midaligned {\doalignline \hss \hss } +\def\rightaligned{\doalignline \hss \relax} + +\let\centeraligned\midaligned + +\def\regelbegrensd#1{\limitatetext{#1}{\hsize}{\unknown}} % to be translated + +% indirecte commando's + +\letvalue{\s!do\v!line\v!left }\leftaligned +\letvalue{\s!do\v!line\v!right }\rightaligned +\letvalue{\s!do\v!line\v!middle }\midaligned +\letvalue{\s!do\v!line\v!flushleft }\rightaligned +\letvalue{\s!do\v!line\v!flushright}\leftaligned +\letvalue{\s!do\v!line\v!center }\midaligned + +\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} + +%D Experimental: + +% simple version +% +% \def\doxalignline#1#2% +% {\bgroup +% \setlocalhsize +% \def\\{\egroup\par\doxalignline{#1}{#2}\bgroup}% inefficient +% \dowithnextbox +% {\noindent\hbox to \localhsize +% {\ifcase\alignstrutmode\or\strut\fi +% \signalrightpage +% \doifrightpageelse{#1\unhbox\nextbox#2}{#2\unhbox\nextbox#1}}% +% \egroup} +% \hbox} +% +% \setvalue{\s!do\v!regel\v!binnen}{\doxalignline\relax\hss} +% \setvalue{\s!do\v!regel\v!buiten}{\doxalignline\hss\relax} +% +% more extensive: + +\def\doxalignline#1#2#3#4#5#6% + {\noindentation % was \noindent + \dontleavehmode % added in marrakesch at TUG 2006\begingroup + \begingroup + \setlocalhsize + \def\\{\egroup\par\doxalignline#1#2#3#4#5#6\bgroup}% inefficient + \dowithnextbox + {%\noindent moved up + \hbox to \localhsize + {#1\hskip\ifdone#2\else#3\fi#4% + \hbox to \localhsize + {\the\everyleftofalignedline + \ifcase\alignstrutmode\or\strut\fi + \ifdone#5\unhbox\nextbox#6\else#6\unhbox\nextbox#5\fi + \the\everyrightofalignedline}% + \hss}% + \endgroup} + \hbox} + +\def\doxcheckline + {\signalrightpage\doifrightpageelse\donetrue\donefalse} + +\setvalue{\s!do\v!line\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } +\setvalue{\s!do\v!line\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} +\setvalue{\s!do\v!line\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } +\setvalue{\s!do\v!line\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} +\setvalue{\s!do\v!line\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } +\setvalue{\s!do\v!line\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} +\setvalue{\s!do\v!line\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } +\setvalue{\s!do\v!line\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} + +\setvalue{\s!do\v!line\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} +\setvalue{\s!do\v!line\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } +\setvalue{\s!do\v!line\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} +\setvalue{\s!do\v!line\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } + +% ! ! ! beware, redefining \doalignline gives the wrong results ! ! ! +% +% \def\doalignline{\doxalignline\donefalse++\zeropoint} + +%D Better: + +\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} + +% \def\alignedline#1#2% setting default +% {\csname +% \s!do\v!line +% \ifundefined{\s!do\v!line#1}#2\else#1\fi +% \endcsname} + +\def\alignedline#1#2% setting default + {\csname\s!do\v!line\ifcsname\s!do\v!line#1\endcsname#1\else#2\fi\endcsname} + +%D ... + +\def\dosetuptolerance[#1]% + {\doifinsetelse\v!vertical{#1}% + {\ExpandFirstAfter\processallactionsinset + [#1] + [ \v!verystrict=>\def\bottomtolerance{}, + \v!strict=>\def\bottomtolerance{.050}, + \v!tolerant=>\def\bottomtolerance{.075}, + \v!verytolerant=>\def\bottomtolerance{.100}]}% + {\ExpandFirstAfter\processallactionsinset + [#1] + [ \v!stretch=>\emergencystretch\bodyfontsize, + \v!space=>\spaceskip.5em\!!plus.25em\!!minus.25em\relax, + \v!verystrict=>\tolerance 200, + \v!strict=>\tolerance1500, + \v!tolerant=>\tolerance3000, + \v!verytolerant=>\tolerance4500]}} + +\def\setuptolerance + {\dosingleargument\dosetuptolerance} + +% \def\woordrechts +% {\groupedcommand{\hfill\hbox}{\parfillskip\zeropoint}} + +% beware: \wordright{whatever\kern-\rightskip} should work! +% so, no funny boxing here + +\def\dowordright[#1]% + {% don't change + \groupedcommand + {\removeunwantedspaces + \hfill + \allowbreak % changed back from \hskip\zeropoint + \strut + \hfill + \quad % decent spacing + \hbox} + {\doifelse{#1}\v!right{\kern-\rightskip}{\doifsomething{#1}{\kern-#1}}% + \parfillskip\zeropoint + %\finalhyphendemerits\zerocount % yes or no + \par}} + +\def\wordright + {\dosingleempty\dowordright} + +% \dorecurse{5}{something } \wordright{--someone} \endgraf +% \dorecurse{6}{something } \wordright{--someone} \endgraf +% \dorecurse{7}{something } \wordright{--someone} \endgraf +% +% \dorecurse{5}{something } \wordright{--someone else entirely} \endgraf +% \dorecurse{6}{something } \wordright{--someone else entirely} \endgraf +% \dorecurse{7}{something } \wordright{--someone else entirely} \endgraf +% +% \wordright[\rightskip]{whatever} + +% \simplealignedbox{2cm}{right}{x} + +\setvalue{\s!simple\c!align\v!right }#1#2{\hbox to #1{#2\hss}} +\setvalue{\s!simple\c!align\v!left }#1#2{\hbox to #1{\hss#2}} +\setvalue{\s!simple\c!align\v!flushright }#1#2{\hbox to #1{\hss#2}} +\setvalue{\s!simple\c!align\v!flushleft }#1#2{\hbox to #1{#2\hss}} +\setvalue{\s!simple\c!align\v!middle }#1#2{\hbox to #1{\hss#2\hss}} + +\def\simplealignedbox#1{\executeifdefined{\s!simple\c!align#1}{\getvalue{\s!simple\c!align\v!right}}} + +%D \macros +%D {pushindentation,popindentation} +%D +%D The pushing and popping is done by: + +\newbox\indentationboxA +\newbox\indentationboxB + +\def\pushindentation + {\bgroup + \ifhmode + \unskip + \setbox\indentationboxA\lastbox % get \strut if present + \unskip + \setbox\indentationboxB\lastbox % get \indent generated box + \unskip + \else + \hskip\zeropoint % switch to horizontal mode + \unskip + \setbox\indentationboxA\lastbox % get \indent generated box + \setbox\indentationboxB\emptybox + \fi} + +\def\popindentation + {\box\indentationboxB\box\indentationboxA % put back the boxes + \egroup} + +%D The only complication lays in \type{\strut}. In \PLAIN\ +%D \TEX\ a \type{\strut} is defined as: +%D +%D \starttyping +%D \def\strut% +%D {\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} +%D \stoptyping +%D +%D But what is a \type{\strut}? Normally it's a rule of width +%D zero, but when made visual, it's a rule and a negative skip. +%D The mechanism for putting things in the margins described +%D here cannot handle this situation very well. One +%D characteristic of \type{\strut} is that the \type{\unhcopy} +%D results in entering horizontal mode, which in return leads +%D to some indentation. +%D +%D To serve our purpose a bit better, the macro \type{\strut} +%D can be redefined as: +%D +%D \starttyping +%D \def\strut +%D {\relax\ifmmode\else\hskip0pt\fi\copy\strutbox} +%D \stoptyping +%D +%D Or more compatible: +%D +%D \starttyping +%D \def\strut +%D {\relax\ifmmode +%D \copy\strutbox +%D \else +%D \bgroup\setbox\strutbox=\normalhbox{\box\strutbox}\unhcopy\strutbox\egroup +%D \fi} +%D \stoptyping +%D +%D In \CONTEXT\ however we save some processing time by putting +%D an extra \type{\hbox} around the \type{\strutbox}. + +% moved from page-lin.tex to here (due to visualization added +% in august 2003) +% +% \unexpanded \def\crlf +% {\ifhmode\unskip\else\strut\fi\ifcase\raggedstatus\hfil\fi\break} + +\unexpanded \def\crlf + {\ifhmode + \unskip + \prewordbreak\crlfplaceholder + \ifcase\raggedstatus\hfil\or\or\or\hfil\fi + \break + \else + \crlfplaceholder + \endgraf + \fi} + +\def\crlfplaceholder + {\strut} + +\def\settestcrlf + {\def\crlfplaceholder + {\hbox to \zeropoint + {\strut{\infofont\kern.25em}\lohi{\infofont CR}{\infofont LF}\hss}}} + +%D \starttyping +%D % \setuplayout[gridgrid=yes] \showgrid +%D +%D \startbuffer +%D test 1\crlf +%D test 2\crlf +%D +%D \crlf test 3 +%D +%D test 4\crlf +%D test 5 +%D +%D \crlf +%D \crlf +%D \crlf +%D test 6 +%D \stopbuffer +%D +%D \hbox +%D {\hsize5em +%D \ruledvtop{\getbuffer}\enspace +%D \ruledvtop{\showstruts\getbuffer}\enspace +%D \hsize15em \setuptyping[before=,after=]% +%D \ruledvtop{\typebuffer}} +%D \stoptyping + +\def\opeenregel % to be used grouped + {\def\crlf{\removelastspace\space}\let\\\crlf} + +\def\showstruts + {\setteststrut + \settestcrlf} + +\def\definehspace + {\dotripleempty\dodefinehspace} + +\def\dodefinehspace[#1][#2][#3]% #1 = optional namespace + {\ifthirdargument + \setvalue{\??hs#1:#2}{#3}% + \else + \setvalue{\??hs:#1}{#2}% + \fi} + +\unexpanded\def\hspace + {\dodoubleempty\dohspace} + +%\def\dohspace[#1][#2]% +% {\ifhmode +% \removeunwantedspaces +% \hskip +% \ifsecondargument +% \hspaceamount{#1}{#2}% +% \else +% \hspaceamount\empty{\iffirstargument#1\else\s!default\fi}% +% \fi +% \expandafter\ignorespaces +% \fi} + +\def\dohspace[#1][#2]% + {\ifsecondargument + \dodohspace[#1][#2]% + \else\iffirstargument + \hspace[][#1]% + \else + \hspace[][\s!default]% + \fi\fi} + +% \def\dodohspace[#1][#2#3]% +% {\ifhmode +% \removeunwantedspaces +% \doifelse{#2}{-} +% {{\scratchskip\hspaceamount{#1}{#3}\hskip-\scratchskip}} +% {\hskip\hspaceamount{#1}{#2#3}}% +% \expandafter\ignorespaces +% \fi} +% +% not needed, tex handles -- as + + +\def\dodohspace[#1][#2]% + {\ifhmode + \removeunwantedspaces + \hskip\hspaceamount{#1}{#2}% + \expandafter\ignorespaces + \fi} + +\def\hspaceamount#1#2% + {\executeifdefined{\??hs#1:#2}{\executeifdefined{\??hs:#2}\zeropoint}} + +\definehspace [\v!small] [.25\emspaceamount] +\definehspace [\v!medium] [.5\emspaceamount] +\definehspace [\v!big] [1\emspaceamount] +\definehspace [\v!normal] [1\spaceamount] +\definehspace [\v!default] [\spaceamount] + +%D Taken from Taco's math module (cq. \AMS\ macros), but +%D adapted to \type {\hspace}: + +\unexpanded\def\textormathspace#1#2#3% + {\ifmmode\mskip#1#2\else\kern#1\hspaceamount\empty{#3}\fi\relax} + +\newmuskip\hairmuskip \hairmuskip=.15mu + +\def\hairspace {\textormathspace+\hairmuskip{.5}} +\def\thinspace {\textormathspace+\thinmuskip 1} +\def\medspace {\textormathspace+\medmuskip 2} +\def\thickspace {\textormathspace+\thickmuskip3} +\def\neghairspace {\textormathspace-\thinmuskip{.5}} +\def\negthinspace {\textormathspace-\thinmuskip 1} +\def\negmedspace {\textormathspace-\medmuskip 2} +\def\negthickspace{\textormathspace-\thickmuskip3} + +% needed for unicode: + +\def\twoperemspace {\hskip\dimexpr\emwidth/2\relax} % == \enspace +\def\threeperemspace {\hskip\dimexpr\emwidth/3\relax} +\def\fourperemspace {\hskip\dimexpr\emwidth/4\relax} +\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} % goodie +\def\sixperemspace {\hskip\dimexpr\emwidth/6\relax} +\def\figurespace {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this +\def\punctuationspace {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} +\def\ideographicspace {\hskip\dimexpr\emwidth/1\relax} +\def\ideographichalffillspace{\hskip\dimexpr\emwidth/2\relax} +%def\nobreakspace {\penalty\plustenthousand\space} +\def\nobreakspace {\penalty\plustenthousand\kern\interwordspace} +\def\narrownobreakspace {\penalty\plustenthousand\thinspace} +%def\zerowidthnobreakspace {\penalty\plustenthousand\hskip\zeropoint} +\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} +\def\zerowidthspace {\hskip\zeropoint} + +\definehspace[.5][.1250\emspaceamount] % could also be [.1250\spaceamount] +\definehspace[1] [.1667\emspaceamount] +\definehspace[2] [.2222\emspaceamount] +\definehspace[3] [.2777\emspaceamount] + +\let \, \thinspace +\let \: \medspace +\let \; \thickspace +\let \! \negthinspace + +% this will become an alternative bunch of \blank settings +% +% \startlines +% \scratchskip=.23pt plus 10pt minus 4pt \relax \number\scratchskip \space \the\scratchskip +% \setsimplifiedskip\scratchskip1 \number\scratchskip \space \the\scratchskip +% \setsimplifiedskip\scratchskip2 \number\scratchskip \space \the\scratchskip +% \getsimplifiedskip\scratchskip\scratchcounter \number\scratchcounter +% \stoplines +% +% \hrule width10cm \endgraf +% \discardedskip{10pt} +% \retainedskip {4pt} +% \discardedskip {5pt} +% \hrule width10cm \endgraf +% \blockedskip{0pt} +% \discardedskip{10pt} +% \retainedskip {4pt} +% \discardedskip {5pt} +% \hrule width10cm \endgraf +% \frozenskip {4cm} +% \hrule width10cm \endgraf +% \vskip10pt +% \hrule width10cm \endgraf + +% ! ! ! etex only, evt splitskip macro gebruiken (syst-new) + +\newskip\simplifiedskip +\newskip\simplifiedcounter + +\chardef\@@discardedskip1 +\chardef\@@retainedskip 2 +\chardef\@@forcedskip 3 +\chardef\@@blockedskip 4 +\chardef\@@frozenskip 5 % after heads, no break + +\def\setsimplifiedskip#1#2% + {#1\dimexpr(10\dimexpr(#1/10)) plus \gluestretch#1 minus \glueshrink#1\relax + \advance#1\numexpr(#2)sp\relax} + +\def\getsimplifiedskip#1#2% + {\simplifiedskip#1\relax + \ifzeropt\simplifiedskip % \ifdim\simplifiedskip=\zeropoint + #2\zerocount + \else + \simplifiedcounter\dimexpr10\dimexpr#1/10\relax\relax + \advance\simplifiedskip-\simplifiedcounter + #2\number\simplifiedskip\relax + \fi} + +\def\conditionalskip#1#2% + {\scratchskip#1\relax + \setsimplifiedskip\scratchskip#2\relax + \vskip\scratchskip\relax} + +\def\defrostskip + {\scratchskip\lastskip\penalty50000\normalvskip-\scratchskip\penalty50000\relax} + +\def\frozenskip#1% + {\endgraf + \ifvmode + \getsimplifiedskip\lastskip\scratchcounter + \ifdim\lastskip>#1\else + \defrostskip + \conditionalskip{#1}\@@frozenskip + \fi + \fi} + +\def\discardedskip#1% + {\endgraf + \ifvmode + \getsimplifiedskip\lastskip\scratchcounter + \ifcase\scratchcounter + \conditionalskip{#1}\@@discardedskip + \or % discard + \ifdim\lastskip>#1\else + \normalvskip-\lastskip + \conditionalskip{#1}\@@discardedskip + \fi + \or % retain + \ifdim\lastskip>#1\else + \normalvskip-\lastskip + \conditionalskip{#1}\@@discardedskip + \fi + \or % forced + \conditionalskip{#1}\@@discardedskip + \or % ignored + \or % frozen + \ifdim\lastskip>#1\else + \defrostskip + \conditionalskip{#1}\@@frozenskip + \fi + \else\ifdim#1=\zeropoint\else + \vskip#1\relax + \fi\fi + \fi} + +\def\retainedskip#1% + {\endgraf + \ifvmode + \getsimplifiedskip\lastskip\scratchcounter + \ifcase\scratchcounter + \conditionalskip{#1}\@@retainedskip + \or % discard + \normalvskip-\lastskip + \conditionalskip{#1}\@@retainedskip + \or % retain + \ifdim\lastskip>#1\else + \normalvskip-\lastskip + \conditionalskip{#1}\@@retainedskip + \fi + \or % forced + \conditionalskip{#1}\@@retainedskip + \or % ignored + \or % frozen + \ifdim\lastskip>#1\else + \defrostskip + \conditionalskip{#1}\@@frozenskip + \fi + \else\ifdim#1=\zeropoint\else + \vskip#1\relax + \fi\fi + \fi} + +\def\forcedskip#1% + {\endgraf + \ifvmode + \conditionalskip{#1}\@@forcedskip + \fi} + +\def\blockedskip#1% + {\endgraf + \ifvmode + \getsimplifiedskip\lastskip\scratchcounter + \ifcase\scratchcounter + \conditionalskip{#1}\@@blockedskip + \or % discard + \conditionalskip{#1}\@@blockedskip + \or % retain + \conditionalskip{#1}\@@blockedskip + \or % forced + \conditionalskip{#1}\@@blockedskip + \or % ignored + \or % frozen + \ifdim\lastskip>#1\else + \defrostskip + \conditionalskip{#1}\@@frozenskip + \fi + \else\ifdim#1=\zeropoint\else + \vskip#1\relax + \fi\fi + \fi} + +% beware, changing this will break some code (like pos/backgrounds) + +\newtoks\everyfirstparagraphintro +\newtoks\everynextparagraphintro +\newtoks\@@everyparagraphtoks + +\chardef\everyparagraphintro\zerocount + +\def\setupparagraphintro + {\dodoubleempty\dosetupparagraphintro} + +\def\dosetupparagraphintro[#1][#2]% + {\processallactionsinset + [#1] + [ \v!reset=>\global\chardef\everyparagraphintro\zerocount + \global\everyfirstparagraphintro\emptytoks + \global\everynextparagraphintro \emptytoks, + \v!first=>\global\chardef\everyparagraphintro\plusone + \doglobal\appendtoks#2\to\everyfirstparagraphintro, + \v!next=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plusone\fi + \doglobal\appendtoks#2\to\everynextparagraphintro, + \v!each=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plustwo\fi + \doglobal\appendtoks#2\to\everyfirstparagraphintro + \doglobal\appendtoks#2\to\everynextparagraphintro]} + +%D We can say: +%D +%D \starttyping +%D \setupparagraphintro[first][\index{Knuth}] +%D \stoptyping +%D +%D Maybe more convenient is: +%D +%D \starttyping +%D \flushatparagraph{\index{Zapf}} +%D \stoptyping + +\def\flushatparagraph#1% + {\global\chardef\everyparagraphintro\plusone + \global\appendtoks{#1}\to\everyfirstparagraphintro} + +% \def\doinsertparagraphintro +% {\ifcase\everyparagraphintro\relax +% % no data +% \@@everyparagraphtoks\emptytoks +% \or +% % first data +% \global\chardef\everyparagraphintro\plustwo +% \@@everyparagraphtoks\everyfirstparagraphintro +% \global\everyfirstparagraphintro\emptytoks +% \or +% % next data +% \@@everyparagraphtoks\everynextparagraphintro +% \fi +% \the\@@everyparagraphtoks} + +\def\doinsertparagraphintro + {\begingroup + \everypar\emptytoks + \ifcase\everyparagraphintro\relax + % no data + \@@everyparagraphtoks\emptytoks + \or + % first data + \global\chardef\everyparagraphintro\plustwo + \@@everyparagraphtoks\everyfirstparagraphintro + \global\everyfirstparagraphintro\emptytoks + \or + % next data + \@@everyparagraphtoks\everynextparagraphintro + \fi + \the\@@everyparagraphtoks + \endgroup} + +\def\insertparagraphintro + {\ifcase\everyparagraphintro\else\@EA\doinsertparagraphintro\fi} + +% \appendtoksonce\insertparagraphintro\to\everypar % should come last + +%D \starttyping +%D \setupparagraphintro[first][\hbox to 3.5em{\tt FIRST \hss}] +%D \setupparagraphintro[first][\hbox to 3.5em{\tt TSRIF \hss}] +%D \setupparagraphintro[next] [\hbox to 3.5em{\tt NEXT \hss}] +%D \setupparagraphintro[next] [\hbox to 3.5em{\tt TXEN \hss}] +%D \setupparagraphintro[each] [\hbox to 3.0em{\tt EACH \hss}] +%D \setupparagraphintro[each] [\hbox to 3.0em{\tt HCEA \hss}] +%D +%D some paragraph \par +%D some paragraph \par +%D some paragraph \par +%D +%D \definelabel[parnumber] +%D +%D \setupparagraphintro[reset,each][\inleft{\slxx\parnumber}] +%D +%D some paragraph \par +%D some paragraph \par +%D some paragraph \par +%D \stoptyping + +%D \macros +%D {flushatnextpar} +%D +%D This macro collects data that will be flushed at the next paragraph. +%D By using this macro you can avoid interfering nodes (writes, etc). + +\newbox \postponednodedata + +\def\flushatnextpar + {\bgroup + \dowithnextbox + {\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}% + \hbox} + +\def\flushpostponednodedata + {\ifvoid\postponednodedata\else + \hbox{\smashedbox\postponednodedata}% + \fi} + +% Very nasty but needed for margin stuff inside colored +% paragraphs. + +\let\normalvadjust\vadjust + +% \def\graphicvadjust % bad, those low level color calls here +% {\dowithnextbox +% {\normalvadjust +% {\dostartgraphicgroup +% \localstarttextcolor +% \unvbox\nextbox +% \localstoptextcolor +% \dostopgraphicgroup}}% +% \vbox} + +% test this prikkels/pascal margin text before heads (mode +% 1) as well as uitwerkingen (mode 2) + +%chardef\graphicvadjustmode=0 % fake +%chardef\graphicvadjustmode=1 % normal +\chardef\graphicvadjustmode=2 % normal + compensate (== default) + +\def\graphicvadjust % bad, those low level color calls here + {\dowithnextboxcontent + {\forgetall} + {\ifcase\graphicvadjustmode \@EA \fakedvadjust \else \@EA\normalvadjust \fi + {\dostartgraphicgroup % don't ask + \localstarttextcolor + \unvbox\nextbox + \localstoptextcolor % don't ask + \dostopgraphicgroup + \ifcase\graphicvadjustmode \or \or + % corrects for one line paragraphs + \nointerlineskip + \kern-\struttotal + \nointerlineskip + \verticalstrut + \fi}}% + \vbox} + +%D This works only in a properly strutted line, and is meant +%D for deeply burried operations, like in heads. + +\def\fakedvadjust + {\dowithnextbox + {\setbox\nextbox\hbox{\llap{\lower\strutdepth\box\nextbox}}% + \smashedbox\nextbox}% + \vtop} + +\def\flexiblespaceamount#1#2#3% + {#1\interwordspace + \!!plus#2\interwordstretch + \!!minus#3\interwordshrink} + +\def\fixedspaceamount#1% + {#1\interwordspace} + +%D This is a dangerous feature because it makes the \TEX\ source +%D less portable, i.e. any parser now needs to apply exactly the +%D same algorithm when it wants to interpret the source. We +%D strongly recommend not to mention this feature in manuals! It's +%D provided for users who are hooked to such a mechanism. +%D +%D \starttyping +%D \setupsorting[logo][next=\autoinsertnextspace] \logo[TEX]{\TeX} +%D +%D bla bla \TEX bla bla \TEX (bla) bla (\TEX) +%D \stoptyping + +\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} + +\def\doautoinsertnextspace % slightly extended version of a user supplied macro + {\ifx\nexttoken \bgroup\else \ifx\nexttoken\begingroup\else + \ifx\nexttoken \egroup\else \ifx\nexttoken \endgroup\else + \ifx\nexttoken \/\else \ifx\nexttoken /\else \ifx\nexttoken ~\else + \ifx\nexttoken \ \else \ifx\nexttoken \blankspace\else \ifx\nexttoken \space\else + \ifx\nexttoken .\else \ifx\nexttoken ,\else + \ifx\nexttoken !\else \ifx\nexttoken ?\else + \ifx\nexttoken :\else \ifx\nexttoken ;\else + \ifx\nexttoken '\else \ifx\nexttoken "\else + \ifx\nexttoken )\else \ifx\nexttoken -\else \ifx\nexttoken |\else + \ifx\nexttoken \%\else \ifx\nexttoken \&\else + \space + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} + +% moved from page-lin + +\def\installspacehandler#1#2% needs to set \obeyedspace + {\setvalue{\??sr#1}{#2}} + +\installspacehandler \v!on + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}% + \let\ =\obeyedspace} + +\installspacehandler \v!yes + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode \normalspace }}% + \let\ =\obeyedspace} + +\installspacehandler \v!off + {\normalspaces + \let\obeyedspace\normalspace + \let\ =\normalspace} + +\installspacehandler \v!fixed + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode\fixedspace}}% + \let\ =\obeyedspace} + +\def\activatespacehandler#1% + {\executeifdefined{\??sr#1}{\activatespacehandler\v!off}} + +% moved from page-lin + +%D When spacing is active we need to handle commands in +%D a special way: +%D +%D \starttyping +%D \setuplines[space=on] +%D +%D \startlines +%D Let's talk about this{\ttsl\gobbleoneargument or}that. +%D \stoplines +%D +%D \startlines +%D Let's talk about this{\getvalue{ttsl}or}that. +%D \stoplines +%D \stoptyping +%D +%D One can indent in several ways: +%D +%D \starttyping +%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even +%D +%D \startlines +%D first +%D second +%D third +%D fourth +%D \stoplines +%D \stoptyping + +\def\setuplines + {\dodoubleargument\getparameters[\??rg]} + +\def\startlines + {\@@rgbefore + \pushmacro\checkindentation + \whitespace + %\page[\v!preference]} gaat mis na koppen, nieuw: later \nobreak + \begingroup + \setupindenting[\@@rgindenting]% + \typesettinglinestrue + \setupwhitespace[\v!none]% + \obeylines + \ignorespaces + \gdef\afterfirstobeyedline % tzt two pass, net als opsomming + {\gdef\afterfirstobeyedline + {\nobreak + \doifnot\@@rgoption\v!packed{\global\let\afterfirstobeyedline\relax}}}% + \def\obeyedline + {\par + \futurelet\next\dobetweenthelines}% + \activatespacehandler\@@rgspace + \GotoPar} + +\def\stoplines + {\endgroup + \popmacro\checkindentation + \@@rgafter} + +\def\dobetweenthelines + {\doifmeaningelse\next\obeyedline + {\@@rginbetween} + {\afterfirstobeyedline}} + +\setuplines + [\c!option=, + \c!before=\blank, + \c!after=\blank, + \c!inbetween=\blank, + \c!indenting=\v!no, + \c!space=\v!default] + +\def\emptylines + {\dosingleempty\doemptylines} + +\def\doemptylines[#1]% + {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} + +\setupwhitespace + [\v!none] + +% still old-fashioned + +\indenting + [\v!never] + +\setupindenting + [\v!none] + +\setupblank + [\v!standard, + \v!big] + +\defineblank[\v!default] [\currentblank] +\defineblank[\v!before] [\v!default] +\defineblank[\v!inbetween][\v!default] +\defineblank[\v!after] [\v!before] + +\setupinterlinespace + [\c!minheight=0pt, % only special purpose + \c!mindepth=0pt, % only special purpose + \c!height=.72, + \c!depth=.28, + \c!top=1.0, + \c!bottom=0.4, + \c!distance=1pt, + \c!line=2.8ex, + \c!stretch=0] + +\setupnarrower + [\c!before=\endgraf, + \c!after=\endgraf, + \c!left=1.5em, + \c!right=1.5em, + \c!middle=1.5em] + +\setuptolerance + [\v!horizontal,\v!verystrict] + +\setuptolerance + [\v!vertical,\v!strict] + +\setupalign + [\v!bottom, + \v!width] + +\setupspacing + [\v!packed] + +\protect \endinput diff --git a/tex/context/base/spac-grd.lua b/tex/context/base/spac-grd.lua new file mode 100644 index 000000000..81e0c6e16 --- /dev/null +++ b/tex/context/base/spac-grd.lua @@ -0,0 +1,41 @@ +-- educational: snapper + +--~ function demo_snapper(head,where) -- snap_category 105 / nodes.snapvalue = { [1] = { 8*65536, 4*65536, 12*65536 } } +--~ if head then +--~ local current, tail, dummy = head, nil, nil +--~ while current do +--~ local id = current.id +--~ if id == glue and current.subtype == 2 then +--~ local sn = has_attribute(current,snap_category) +--~ if sn then +--~ local sv = nodes.snapvalues[sn] +--~ if sv then +--~ head, current, dummy = node.delete(head, current) +--~ free_node(dummy) +--~ else +--~ current = current.next +--~ end +--~ else +--~ current = current.next +--~ end +--~ else +--~ if id == hlist and where == 'hmode_par' and current.list then +--~ local sn = has_attribute(current.list,snap_category) +--~ if sn then +--~ local sv = nodes.snapvalues[sn] +--~ if sv then +--~ local height, depth, lineheight = sv[1], sv[2], sv[3] +--~ current.height = math.ceil((current.height-height)/lineheight)*lineheight + height +--~ current.depth = math.ceil((current.depth -depth )/lineheight)*lineheight + depth +--~ end +--~ end +--~ end +--~ current = current.next +--~ end +--~ tail = current +--~ end +--~ end +--~ return head +--~ end + +--~ callback.register('buildpage_filter', demo_snapper) diff --git a/tex/context/base/spac-grd.mkii b/tex/context/base/spac-grd.mkii new file mode 100644 index 000000000..249e2e430 --- /dev/null +++ b/tex/context/base/spac-grd.mkii @@ -0,0 +1,1074 @@ +%D \module +%D [ file=core-grd, +%D version=1998.03.10, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Grid Snapping (Experimental), +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Core Macros / Grid Snapping} + +\unprotect + +%D Moved from supp-box: + +%D \macros +%D {startbaselinecorrection,baselinecorrection, +%D showbaselinecorrection,offbaselinecorrection} +%D +%D Spacing around ruled boxes can get pretty messed up. The +%D next macro tries as good as possible to fix this. +%D +%D \startbuffer[1] +%D \startbaselinecorrection +%D \ruledhbox{Rule Brittanica} +%D \stopbaselinecorrection +%D \stopbuffer +%D +%D \typebuffer[1] +%D +%D The macros put some white space around the box: +%D +%D \getbuffer[1] +%D +%D A simple alternative is \type {\baselinecorrection}, which +%D only looks at the previous line. +%D +%D \startbuffer[2] +%D \baselinecorrection +%D \ruledhbox{Rule Brittanica} +%D \baselinecorrection +%D \stopbuffer +%D +%D \typebuffer[2] +%D +%D This time the last preceding line gets a correction,% +%D dependant on the depth. +%D +%D \getbuffer[2] +%D +%D One can make the correction visible by saying \type +%D {\showbaselinecorrection}. Part of the correction is +%D calculated from the dimensions of a~(. One can disble the +%D correction by calling \type {\offbaselinecorrection}. +%D +%D When visualize the first example looks like: +%D +%D {\showbaselinecorrection\getbuffer[1]} +%D +%D and the second one comes out as: +%D +%D {\showbaselinecorrection\getbuffer[2]} + +% \definecolor[GridLineColor][red] +% \definecolor[GridTextColor][blue] + +\definepalet + [grid] + [ one=red, + two=green, + three=blue, + four=gray] + +\def\setbaselinecorrections + {\setbox0\hbox{\setstrut\strut}% + \setbox2\hbox{(}% + \dimen0\ht0\advance\dimen0 -\ht2 + \ifdim\dimen0<\zeropoint\dimen0\zeropoint\fi + \dimen2\dp0\advance\dimen2 -\dp2 + \ifdim\dimen2<\zeropoint\dimen2\zeropoint\fi + \edef\thetopbaselinecorrection {\the\dimen0}\dimen0-\dimen0 + \edef\thebotbaselinecorrection {\the\dimen2}\dimen2-\dimen2 + \edef\thenegtopbaselinecorrection{\the\dimen0}% + \edef\thenegbotbaselinecorrection{\the\dimen2}} + +\def\dotopbaselinecorrection {\kern\thetopbaselinecorrection} +\def\dobotbaselinecorrection {\kern\thebotbaselinecorrection} +\def\donegtopbaselinecorrection{\kern\thenegtopbaselinecorrection} +\def\donegbotbaselinecorrection{\kern\thenegbotbaselinecorrection} + +\def\showbaselinecorrection + {\def\dobaselinecorrection % visualization is not watertight! + {\bgroup +\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi + \setbox0\null + \wd0\hsize + \dp0\strutdp + \nointerlineskip + \forgetall + \ruledvbox{\box0}% + \egroup + \prevdepth\strutdp}% + \def\dotopbaselinecorrection + {\hrule\!!height\thetopbaselinecorrection}% + \def\dobotbaselinecorrection + {\hrule\!!height\thebotbaselinecorrection}} + +\def\dobaselinecorrection + {\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi + \kern\strutdp + \prevdepth\strutdp} + +% \def\baselinecorrection +% {\endgraf +% \ifvmode +% \ifdim\prevdepth<\maxdimen +% \ifdim\prevdepth<\zeropoint \else +% \ifdim\prevdepth<\strutdp +% \dobaselinecorrection +% \fi +% \fi +% \fi +% \fi} + +\def\baselinecorrection + {\endgraf + \ifvmode + \ifdim\prevdepth<\maxdimen + \ifdim\prevdepth<\zeropoint \else + \ifdim\prevdepth<\strutdepth \relax + \pushlastnode + \dobaselinecorrection + \poplastnode + \fi + \fi + \fi + \fi} + +\def\pagebaselinecorrection + {\ifdim\pagegoal<\maxdimen + \ifdim\pagetotal>\lineheight % or \topskip + \scratchdimen\pagetotal + \advance\scratchdimen\lineheight + \ifdim\scratchdimen<\pagegoal + \baselinecorrection + \fi + \fi + \fi} + +% Beware, keep this one as it is, see for instance module +% m-steps.tex, where we apply a \localhsize to the \vbox, in +% order to follow narrower and side floats ! + +% \def\startbaselinecorrection +% {\baselinecorrection +% \ifvmode +% \bgroup +% \setbox\scratchbox\vbox\bgroup +% \ignorespaces +% \let\stopbaselinecorrection\dostopbaselinecorrection +% \else +% \let\stopbaselinecorrection\relax +% \fi} + +% \def\dostopbaselinecorrection % I have to check columns yet. +% {\endgraf +% \egroup +% \topbaselinecorrection +% \box\scratchbox +% \botbaselinecorrection +% \egroup} + +% \let\stopbaselinecorrection=\relax + +\def\startbaselinecorrection + {\bgroup + \let\stopbaselinecorrection\egroup + \ifcase\baselinecorrectionmode + \or % normal + \baselinecorrection + \ifvmode + \setbox\scratchbox\vbox\bgroup\ignorespaces + \let\stopbaselinecorrection\donormalstopbaselinecorrection + \fi + \or % off + \or % force + \baselinecorrection + \ifvmode + \setbox\scratchbox\vbox\bgroup\ignorespaces + \let\stopbaselinecorrection\doforcedstopbaselinecorrection + \fi + \fi} + +\let\stopbaselinecorrection\relax + +\def\donormalstopbaselinecorrection % I have to check columns yet. + {\egroup + \topbaselinecorrection + \box\scratchbox + \botbaselinecorrection + \egroup} + +\def\doforcedstopbaselinecorrection % I have to check columns yet. + {\egroup + \forcedtopbaselinecorrection + \box\scratchbox + \forcedbotbaselinecorrection + \egroup} + +%D We do a bit more checking than needed. The pageborder check +%D is not needed, but I want to look the visualization as good +%D as possible too. + +% \def\offbaselinecorrection % Can be used inside correction. +% {\def\startbaselinecorrection{\bgroup\let\stopbaselinecorrection\egroup}} + +\chardef\baselinecorrectionmode\plusone + +\def\onbaselinecorrection {\chardef\baselinecorrectionmode\plusone } +\def\offbaselinecorrection {\chardef\baselinecorrectionmode\plustwo } +\def\forcebaselinecorrection{\chardef\baselinecorrectionmode\plusthree} + +%D \macros +%D {topbaselinecorrection,botbaselinecorrection} +%D +%D The actual top and bottom corrections are implemented as: + +% \def\topbaselinecorrection +% {\ifvmode \ifdim\pagegoal<\maxdimen +% \bgroup +% \setbaselinecorrections +% \whitespace +% \nointerlineskip +% \dotopbaselinecorrection +% \egroup +% \fi \fi} + + +\def\topbaselinecorrection + {\ifvmode \ifdim\pagegoal<\maxdimen + \forcedtopbaselinecorrection + \fi \fi} + +\def\forcedtopbaselinecorrection + {\ifvmode + \bgroup + \setbaselinecorrections + \whitespace + \nointerlineskip + \dotopbaselinecorrection + \egroup + \fi} + +\def\botbaselinecorrection + {\ifvmode + \bgroup + \setbaselinecorrections + \dobotbaselinecorrection + \allowbreak % new, otherwise problems when many in a row + \prevdepth\strutdp + \egroup + \fi} + +\let\forcedbotbaselinecorrection\botbaselinecorrection + +%D Still very experimental and therefore undocumented. + +\newif\ifgridsnapping % UNDER DEVELOPMENT, USE WITH CARE +\newif\ifforcepresnap \forcepresnaptrue % false in mixed single/double +\newif\ifstrutsnapping \strutsnappingtrue % sometimes handy to be false + +\def\positiveextrasnap {\gdef\extrasnapsign{+}} +\def\negativeextrasnap {\gdef\extrasnapsign{-}} + +\def\extrasnapreset {\global\chardef\@@extrasnap0 + \positiveextrasnap} +\def\extrasnapbefore {\global\chardef\@@extrasnap1 } +\def\extrasnaparound {\global\chardef\@@extrasnap2 } +\def\extrasnapafter {\global\chardef\@@extrasnap3 } + +\def\enablepresnapcorrection {\global\chardef\@@presnap\zerocount} +\def\disablepresnapcorrection {\global\chardef\@@presnap\plusone} + +\extrasnapreset \enablepresnapcorrection + +\newif\iftracegridsnapping +\newif\ifshowgridboxes +\newif\ifshowfuzzyskips + +\let\showgridboxes\showgridboxestrue + +\def\showgridsnapping + {\tracegridsnappingtrue + \showgridboxestrue} + +\chardef\@@alignsnap =0 +\chardef\@@alignsnapbox =0 +\chardef\@@alignsnapmethod=0 + +\let\presnapskip \!!zeropoint \def\presnap {-} +\let\postsnapskip\!!zeropoint \let\postsnap\presnap + +\newcount\currentgridsnap + +\def\tracedsnapping + {\iftracegridsnapping + \llap + {\startlayoutcomponent{gridsnaps}{grid snaps}% + \infofont + \global\advance\currentgridsnap\plusone + \color[grid:three]{\vl\presnapskip + \vl\presnap + \vl\postsnap + \ifcase\@@alignsnapbox\relax + \vl\ifcase\@@extrasnap + 00\or + \extrasnapsign0\or + \extrasnapsign\extrasnapsign\or + 0\extrasnapsign\fi + \fi + \vl\the\currentgridsnap\vl}% + \stoplayoutcomponent}% + \fi} + +\def\snaptogrid% [#1]#2 -> #2 == \hbox|\vbox + {\dosingleempty\dosnaptogrid} + +% \def\dosnaptogrid[#1]% +% {\ifgridsnapping +% \iffirstargument\doifsomething{#1}{\verplaatsopgrid[#1]}\fi +% \expandafter\dodosnaptogrid +% \fi} + +% \def\dosnaptogrid[#1]% +% {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up +% \ifgridsnapping +% \iffirstargument\doifsomething{#1}{\moveongrid[#1]}\fi +% \expandafter\dodosnaptogrid +% \fi} + +\def\dosnaptogrid[#1]% + {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up + \doifinsetelse\v!force{#1}% + {\moveongrid[#1]% + \dodosnaptogrid} + {\ifgridsnapping + \doifsomething{#1}{\moveongrid[#1]}% + \expandafter\dodosnaptogrid + \fi}} + +% \def\forcedpresnapcorrection % test this on 'details' +% {\ifforcepresnap +% \ifvmode \else \par \fi % new +% % we don't want top of page space when 'top' option +% %\verticalstrut\nobreak\vskip-\struttotal +% %\verticalstrut\vskip-\struttotal +% % nobreak really needed +% \allowbreak\verticalstrut\nobreak\vskip-\struttotal +% %\ifdim\pagetotal>\topskip \else +% % eigenlijk signal +% %\writestatus{grid}{removing dummy at top of page}% +% %\bgroup +% %\output{\setbox\scratchbox\box255}% +% %\penalty\outputpenalty +% %\egroup +% %\fi +% \fi} + +\def\forcedpresnapcorrection % test this on 'details' + {\ifforcepresnap + \ifvmode \else \par \fi % new + % we don't want top of page space when 'top' option + % \verticalstrut\nobreak\vskip-\struttotal + % \verticalstrut\vskip-\struttotal + % \nobreak really needed + % \dosomebreak\allowbreak % no: spoils heads, so only under know situation, not in snapper + \verticalstrut + \nobreak + \vskip-\struttotal + %\ifdim\pagetotal>\topskip \else + % eigenlijk signal + %\writestatus{grid}{removing dummy at top of page}% + %\bgroup + %\output{\setbox\scratchbox\box255}% + %\penalty\outputpenalty + %\egroup + %\fi + \fi} + +\def\setgridtracebox#1[#2]% % maybe reverse the order + {\setbox\nextbox#1% + {\hbox + {\hbox to \zeropoint + {\startlayoutcomponent{gridsnaps}{grid snaps}% + \color[grid:#2]{\ruledhbox{\fakebox\nextbox}}% + \stoplayoutcomponent + \hss}% + \flushnextbox}}} + +\newif\ifboxedsnapping \boxedsnappingtrue + +\chardef\depthsnapmethod \plusone % downward compatible, minus one line +\chardef\heightsnapmethod\plusone % downward compatible, minus one line + +\def\dodosnaptogrid + {\dowithnextbox + {\bgroup + \ifcase\@@alignsnapmethod \or + % we're dealing with text with a possible big depth/height + \chardef\depthsnapmethod \plustwo + \chardef\heightsnapmethod\plustwo + \fi + \ifdim\nextboxht<\textheight % handle special case (like page fig) + \ifcase\@@alignsnapbox\relax + \ifcase\@@alignsnap\else % 1=top 2=high 3=middle 4=low + \ifshowgridboxes + \setgridtracebox\hbox[two]% + \fi + %\getnoflines{\nextboxht}% + \getnoflines\nextboxht + \setbox\nextbox\vbox to \noflines\lineheight + {\ifnum\@@alignsnap=1 \kern\lineheight\kern-\topskip\fi + \ifnum\@@alignsnap>2 \vfill\fi + \flushnextbox + \ifnum\@@alignsnap<4 \vfill\fi}% + \fi + \ifshowgridboxes + \setgridtracebox\hbox[three]% + \fi + \forgetall + \par + \ifvbox\nextbox + \setbox\nextbox\hbox{\flushnextbox}% don't ask + \fi + \scratchskip\lastskip + \edef\presnapskip{\the\lastskip}% + % mixing single/double columns sometimes goes wrong, + % check 'som' document + \ifinsidecolumns + \forcepresnaptrue + \fi + \forcedpresnapcorrection + \ifdim\nextboxht>\strutht + \scratchdimen\nextboxht + \ifcase\@@presnap\relax + \ifdim\scratchskip>\zeropoint\relax + \scratchcounter\scratchskip + \advance\scratchcounter -\openlineheight + \ifnum\scratchcounter<0 + \scratchcounter-\scratchcounter + \fi + \ifnum\scratchcounter<10 % \lastkip is about \openlineheight + \advance\scratchdimen -\openstrutdepth + \edef\presnapskip{*\presnapskip}% + \else\ifdim\scratchskip>\openlineheight + %<\openlineheight \else + \advance\scratchdimen -\openstrutdepth + \edef\presnapskip{*\presnapskip}% + \fi\fi + \fi + \fi + % \getnoflines\scratchdimen % maybe raw ? + % \advance\noflines -1 + \ifcase\heightsnapmethod + % raw + \or + \advance\scratchdimen-\lineheight % tight (default) + \or + \advance\scratchdimen-\strutheight % fit (text) + \or + \advance\scratchdimen-\strutheight % tolerant + \advance\scratchdimen-\roundingeps + \fi + \getnoflines\scratchdimen + \ifnum\noflines>0 + \scratchdimen\noflines\lineheight + \else + \scratchdimen\zeropoint + \fi + \else + \scratchdimen\zeropoint + \fi + \ifnum\@@extrasnap=1 \advance\scratchdimen \extrasnapsign \lineheight \fi + \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi + \edef\presnap{\the\scratchdimen}% + \ifstrutsnapping + \ifboxedsnapping + \getrawnoflines\scratchdimen + \advance\scratchdimen-\noflines\lineheight + \vskip\scratchdimen % disappears at top of page + \dorecurse\noflines{\verticalstrut\nobreak}% + \else \ifdim\scratchdimen=\zeropoint + % nothing to skip + \else % disappears at top of page + \vskip\scratchdimen + \fi \fi + \fi + \ifdim\nextboxdp>\strutdp + % \getnoflines\nextboxdp + % \advance\noflines \minusone + \scratchdimen\nextboxdp\relax + \ifcase\depthsnapmethod + % raw + \or + \advance\scratchdimen-\lineheight % tight (default) + \or + \advance\scratchdimen-\strutdepth % fit (text) + \or + \advance\scratchdimen-\strutdepth % tolerant + \advance\scratchdimen-\roundingeps + \fi + \getnoflines\scratchdimen + \ifnum\noflines>0 + \scratchdimen\noflines\lineheight + \else + \scratchdimen\zeropoint + \fi + \else + \scratchdimen\zeropoint + \fi + \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi + \ifnum\@@extrasnap=3 \advance\scratchdimen \extrasnapsign \lineheight \fi + \edef\postsnap{\the\scratchdimen}% + \ifstrutsnapping + \nextboxht\strutht + \nextboxdp\strutdp + \else + \scratchdimen\presnap + \advance\scratchdimen \strutht + \nextboxht\scratchdimen + \scratchdimen\postsnap + \advance\scratchdimen \strutdp + \nextboxdp\scratchdimen + \fi + \hbox{\tracedsnapping\flushnextbox}% + \ifstrutsnapping + \ifdim\scratchdimen=\zeropoint\else\vskip\scratchdimen\fi + \fi + \else + \scratchdimen\nextboxht\relax + \ifcase\@@alignsnapbox + % can't happen here + \or + \getrawnoflines\scratchdimen + \else + \getnoflines \scratchdimen + \fi + \scratchdimen\noflines\lineheight\relax + \advance\scratchdimen-\strutdepth + % spoils the whole game (fit/broad/line) + % \ifnum\pagetotal>\zeropoint \else % disable this as option + % \advance\scratchdimen-\strutheight + % \advance\scratchdimen+\topskip + % \fi + \dimen0=\scratchdimen + \dimen2=\strutdepth + \ifshowgridboxes + \setgridtracebox\hbox[two]% + \fi + \nextboxdp\strutdp + \dimen4=\nextboxht + \dimen6=\nextboxdp + \iftracegridsnapping + \setbox\scratchbox\hbox + {\scratchdimen\@@alignsnapamount\relax + \ifdim\scratchdimen<\zeropoint + \tracedgridamount\zeropoint{-\scratchdimen}% + \else + \tracedgridamount\scratchdimen\zeropoint + \fi}% + \smashbox\scratchbox + \setbox\nextbox\hbox{\box\scratchbox\flushnextbox}% + \fi + \setbox\nextbox\hbox + {\scratchdimen\@@alignsnapamount\relax + \ifcase\@@alignsnapdepth\or + % don't change this ever ! + \ifdim\dimen0<\lineheight + % otherwise it is ok, but ending up inside + % the next paragraph is seldom what we want, + % so we move one line up + \advance\scratchdimen-\lineheight + \advance\scratchdimen\strutheight + \else + % otherwise we can move down to the + % baseline + \advance\scratchdimen\dimen6 % == \strutdepth + \fi + \fi + \lower\scratchdimen\flushnextbox}% + \nextboxht\dimen4 + \nextboxdp\dimen6 + \ifnum\@@alignsnap<4 % 4 = regel + \setbox\nextbox\vbox to \scratchdimen + {\forgetall + \ifnum\@@alignsnap>2 \vfill\fi % 3 4 + \flushnextbox + \nointerlineskip % \offinterlineskip + \ifnum\@@alignsnap<4 \vfill\fi % 2 3 + \kern\zeropoint}% + \fi + \ifshowgridboxes + \setgridtracebox\vbox[three]% + \fi + \scratchdimen\@@alignsnapamount + \edef\presnapskip{\the\scratchdimen}% + \ifnum\@@alignsnap>2 \def\presnap {+}\fi + \ifnum\@@alignsnap<4 \def\postsnap{+}\fi + \setbox\nextbox\hbox{\tracedsnapping\flushnextbox}% + \par + \nextboxht\dimen0 + \nextboxdp\dimen2 + \forcedpresnapcorrection + \nointerlineskip + \flushnextbox + \fi + \else + \setbox\nextbox\vbox to \textheight + {\ifdim\nextboxdp=\zeropoint + \hbox{\lower\strutdepth\flushnextbox} + \else % this branch is yet untested + \vss + \hbox{\lower\nextboxdp\flushnextbox} + \vskip-\strutdepth + \fi}% + \nextboxdp\strutdepth + \flushnextbox + \fi + \extrasnapreset + \enablepresnapcorrection + \global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount + \egroup}} + +\def\tracedgridamount#1#2% + {\startlayoutcomponent{gridsnaps}{grid snaps}% + \color[grid:four]{\vrule\!!width\nextboxwd\!!height#1\!!depth#2}% + \stoplayoutcomponent} + +\def\snaptomathgrid % probably not working ok, also kind of obsolete + {\ifgridsnapping + \dowithnextbox + {\blank[\v!line]\snaptogrid\vbox{\flushnextbox}\blank[\v!line]} + \vbox\bgroup + \forgetdisplayskips + \@EA\let\@EA\next + \fi} + +\def\topsnaptogrid + {\ifgridsnapping + \dowithnextbox + {\scratchdimen\nextboxht + \advance\scratchdimen -\strutht + \advance\scratchdimen \topskip + \nextboxht\scratchdimen + \nextboxdp\zeropoint + \flushnextbox + \kern\lineheight + \kern-\topskip + \nointerlineskip} + \hbox + \fi} + +% \def\centertogrid % meant for special situations +% {\ifgridsnapping +% \dowithnextboxcontent +% {\ignorespaces} +% {\bgroup +% \par +% \scratchdimen\nextboxht +% \advance\scratchdimen \nextboxdp +% \getnoflines\scratchdimen +% \setbox\nextbox\vbox to \noflines\lineheight +% {\forgetall +% \vskip\zeropoint \!!plus \nextboxht +% \copy\nextbox +% \kern.5\strutdp % VOORLOPIGE WAARDE +% \vskip\zeropoint \!!plus \nextboxdp}% +% \noindent\snaptogrid\vbox{\flushnextbox}% +% \egroup} +% \vbox % was \hbox +% \fi} + +% The next implementation is sub-optimal +% +% \def\centertogrid % usage: see ie pascal / stepcharts +% {\snaptogrid[\v!midden,.5\strutdp]\vbox} + +\def\centertogrid % meant for special situations + {\ifgridsnapping + \dowithnextboxcontent + {\ignorespaces} + {\bgroup + \par + \scratchdimen\nextboxht + \advance\scratchdimen \nextboxdp + \getnoflines\scratchdimen + \setbox\nextbox\vbox to \noflines\lineheight + {\forgetall + \vss + \topbaselinecorrection + \copy\nextbox + \botbaselinecorrection + \vss}% + \setbox\nextbox\hbox{\lower\strutdp\flushnextbox}% + \forgeteverypar % new per 3/4/2008, prevents duplicate pos nodes resulting in extra whitespace + \noindent\snaptogrid\vbox{\flushnextbox}% + \egroup} + \vbox % was \hbox + \fi} + +% testbed for \centertogrid +% +% \strut Bruggetje +% \startlinecorrection +% \startcombination +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination[2*2] +% {\framed{test}} {} {\framed{test}} {} +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination[2*2] +% {\framed{test}} {} {\framed{test}} {} +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination[2*2] +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination[2*2] +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection + +\ifx\startbaselinecorrection\undefined \wait \fi % change order + +\let\normalstartbaselinecorrection=\startbaselinecorrection + +\def\startbaselinecorrection + {\ifgridsnapping + \centertogrid\bgroup + \let\stopbaselinecorrection\egroup + \else + \normalstartbaselinecorrection + \fi} + +\chardef\gridboxlinenomode\plusone +\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame + +\def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi} +\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth} + +\def\setgridbox#1#2#3% + {\setbox#1\gridboxvbox to #3 % given size + {\forgetall + \resetteststrut + \offinterlineskip + \hsize#2% + \baselinerulefalse + \gridboxvbox % calculated size + {\getrawnoflines{#3}% \getnoflines{#3}% + \vskip\topskip + \vskip-\strutht + \scratchdimen#2\advance\scratchdimen \lineheight + \dorecurse\noflines + {\strut + \hskip-.5\lineheight + \ifcase\gridboxlinenomode\or + \rlap + {\hskip.2\bodyfontsize\hskip\scratchdimen + \infofont\hbox to 1em{\hss\recurselevel}}% + \or + \llap + {\infofont\hbox to 1em{\hss\recurselevel}% + \hskip.2\bodyfontsize}% + \fi + \vrule + \!!height \gridboxwidth + \!!depth \gridboxwidth + \!!width \scratchdimen + \par}} + \vfill}} + +%D Some intervention macros: + +\def\gridwarning#1{\message{[beware of #1 extra snap]}} + +\global\let\@@alignsnapamount\!!zeropoint +\global\chardef\@@alignsnapdepth0 + +\def\@@unknowngriddisplacement + {\global\chardef\@@alignsnapbox\plusthree + \global\let\@@alignsnapamount\commalistelement} + +\def\domoveongrid[#1]% + {\ifgridsnapping\doifsomething{#1}{\dodomoveongrid[#1]}\fi} + +\def\dodomoveongrid[#1]% some day : speed up + {\global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount + \global\chardef\@@alignsnapdepth\zerocount + \global\chardef\@@alignsnapmethod\zerocount + \global\let\@@alignsnapamount\!!zeropoint + \donefalse + \expanded{\processallactionsinset[#1]} + [\v!standard=>, + \v!normal=>, % to be sure + \v!yes=>, % to be sure + \v!top=>\gridwarning+\positiveextrasnap\extrasnapbefore, + \v!bottom=>\gridwarning+\positiveextrasnap\extrasnapafter, + \v!both=>\positiveextrasnap\extrasnaparound, + -\v!top=>\gridwarning-\negativeextrasnap\extrasnapbefore, + -\v!bottom=>\gridwarning-\negativeextrasnap\extrasnapafter, + -\v!both=>\negativeextrasnap\extrasnaparound, + \v!text=>\global\chardef\@@alignsnapmethod\plusone, % accurate calculations + \v!page=>\global\chardef\@@alignsnap\plusone, % topskip + \v!high=>\global\chardef\@@alignsnap\plustwo, + \v!middle=>\global\chardef\@@alignsnap\plusthree, + \v!low=>\global\chardef\@@alignsnap\plusfour, + \v!fit=>\global\chardef\@@alignsnapbox\plusone, % new + \v!broad=>\global\chardef\@@alignsnapbox\plustwo, % new + \v!depth=>\global\chardef\@@alignsnapdepth\plusone, % new + \v!line=>\global\chardef\@@alignsnapbox\plusthree +% \global\chardef\@@alignsnapdepth\plusone + \global\chardef\@@alignsnap\plusfour, + \v!reset=>\positiveextrasnap\extrasnapreset, + \v!none=>\global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount, + \v!force=>, % turns on grid snapping even when not on + \s!default=>, + \s!unknown=>\@@unknowngriddisplacement]} + +\def\moveongrid + {\dosingleempty\domoveongrid} + +\def\doplaceongrid[#1]% + {\domoveongrid[#1]\snaptogrid\vbox} + +\def\placeongrid + {\dosingleempty\doplaceongrid} + +%D Snapping is rather robust as long as we use whole lines. +%D Half lines of white space can however be handled when they +%D come in pairs. The corrections needed when crossing page +%D boundaries in the middle of such a pair, are handled by +%D macros that are (named) sort of fuzzy. This fuzzy mechanism +%D was written as an extension to the grid typesetting needed +%D for typesetting (part of) the \MAPS. +%D +%D \starttyping +%D \setuptyping +%D [before={\blank[halfline]}, +%D after={\blank[halfline]}] +%D \stoptyping + +\newif \iffuzzyvskip +\newif \iffuzzysnapdone +\newif \iffuzzysnapping +\newif \iffuzzysnapped +\chardef \fuzzysnappedleft=0 % ==1 when fuzzybegin still open +\newpersistentmark\fuzzymark % (!) +\newcount \fuzzymarker +\newbox \fuzzysnapbox +\newbox \fuzzysnapsplit + +\def\dosyncfuzzyvskip + {\ifvmode\ifdim\lastskip<\lineheight\ifdim\lastskip>\zeropoint + \bgroup % - added 28/2/2003: check this, there was no - + \endgraf\forgetall\verticalstrut\nobreak\vskip-\struttotal + \egroup + \fi\fi\fi} + +\def\fuzzyvskip#1% + {\iffuzzysnapdone + \dosyncfuzzyvskip % NEWER + \endfuzzysnapping + \vskip#1\relax + \global\fuzzysnapdonefalse + \else + \vskip#1\relax + \beginfuzzysnapping + \global\fuzzysnapdonetrue + \fi} + +\def\setfuzzymark#1#2#3% #1/#2 => error recovery + {\ifgridsnapping + \global\fuzzysnappingtrue + \global\advance\fuzzymarker \ifodd\fuzzymarker#1\else#2\fi + \nobreak + \ifshowfuzzyskips + \hbox{\color[grid:three] + {\llap{\infofont#3\vl\the\fuzzymarker}\nobreak + \vrule\!!width\hsize\!!height.1\lineheight}} + \nobreak + \fi + %[\the\fuzzymarker] + %\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% + \expandafter\rawsetmark\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% + \nobreak + \fi} + +\def\beginfuzzysnapping{\setfuzzymark21\v!start} % odd +\def\endfuzzysnapping {\setfuzzymark12\v!stop } % even + +\def\removelastfuzzyvskip + {\ifgridsnapping + \iffuzzysnapping + \ifdim\lastskip<\openlineheight + \else + \removelastskip + \fi + \else + \removelastskip + \fi + \else + \removelastskip + \fi} + +\def\docheckfuzzysnap#1% + {\bgroup + \dontcomplain + \setbox\fuzzysnapbox\copy#1\relax + \setbox\fuzzysnapsplit\vsplit\fuzzysnapbox to 1\lineheight + \let\topfuzzymark\empty % indeed here ... no real mark + \getsplitmarks\fuzzymark +% \ifcase0\topfuzzymark + \ifcase0\rawgetsplittopmark\fuzzymark + \global\chardef\fuzzysnappedleft\zerocount + \global\fuzzysnappedfalse +% \else\ifodd\topfuzzymark + \else\ifodd\rawgetsplittopmark\fuzzymark + \global\chardef\fuzzysnappedleft\plusone + \global\fuzzysnappedtrue + \else + \global\chardef\fuzzysnappedleft=2 + \global\fuzzysnappedtrue + \fi\fi + \iffuzzysnapped \else + \doloop + {\ifvoid\fuzzysnapbox + \exitloop + \else + \setbox\fuzzysnapsplit=\vsplit\fuzzysnapbox to \lineheight + %\let\topfuzzymark=\empty % ... but not here + \getsplitmarks\fuzzymark +% \ifcase0\topfuzzymark + \ifcase0\rawgetsplittopmark\fuzzymark + % continue +% \else\ifodd\topfuzzymark + \else\ifodd\rawgetsplittopmark\fuzzymark + \exitloop + \else + \global\chardef\fuzzysnappedleft\plusone + \global\fuzzysnappedtrue + \exitloop + \fi\fi + \fi}% + \fi + \egroup} + +\def\getfuzzysnapcorrection#1% + {\global\let\presnapcorrection \relax + \global\let\postsnapcorrection\relax + \ifgridsnapping\iffuzzysnapping + \docheckfuzzysnap{#1}% + \iffuzzysnapped + \iftracegridsnapping + \gdef\presnapcorrection + {\color[grid:four]{\hrule\!!height.5\openlineheight\!!width\hsize}}% + \else + \gdef\presnapcorrection{\kern.5\openlineheight}% + \fi + \gdef\postsnapcorrection{\kern-.5\openlineheight}% get the height ok + \fi + \fi\fi} + +\def\fuzzysnappedbox#1#2% \box \unvbox + {\getfuzzysnapcorrection{#2}% + \presnapcorrection + #1#2% + \postsnapcorrection} + +\def\adaptfuzzypagegoal + {\ifgridsnapping\iffuzzysnapping\ifcase\fuzzysnappedleft\or % see dopagecontents + \scratchdimen\pagegoal + \advance\scratchdimen -.5\openlineheight + \global\pagegoal\scratchdimen + \global\advance\vsize -.5\openlineheight + \global\chardef\fuzzysnappedleft0 + \fi\fi\fi} + +%D New, experimental, used in caption snapping: +%D +%D \starttyping +%D \startcolumnset +%D +%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=top] +%D +%D \placefigure [lrtb] {\dorecurse{5}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D \placefigure [lrtb] {\dorecurse{15}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D +%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=bottom] +%D +%D \placefigure [rltb] {\dorecurse{5}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D \placefigure [rltb] {\dorecurse{15}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D +%D \input thuan +%D +%D \stopcolumnset +%D \stoptyping + +\def\moveboxontogrid#1#2#3% box method firstlineht % experimental ! ! ! + {\doifsomething{#2} + {\getnoflines{\ht#1}% no depth taken into account, depth preserved + \scratchdimen\noflines\lineheight + \advance\scratchdimen-\strutdp + \bgroup + \advance\scratchdimen-\onepoint % be a bit tolerant + \ifdim\scratchdimen>\ht#1\relax + \egroup + \doif{#2}\v!top {\setbox#1\vbox to \scratchdimen{\vskip-#3\vskip\strutht\box#1\vfill}}% + \doif{#2}\v!bottom{\setbox#1\vbox to \scratchdimen{\vfill\box#1\removedepth}}% + \dp#1\strutdp + \else + \egroup + \ht#1\scratchdimen + \dp#1\strutdp + \fi}} + +%D New: + +\let\checkgridsnapping\relax + +\protect \endinput diff --git a/tex/context/base/spac-grd.mkiv b/tex/context/base/spac-grd.mkiv new file mode 100644 index 000000000..3fa47de57 --- /dev/null +++ b/tex/context/base/spac-grd.mkiv @@ -0,0 +1,1095 @@ +%D \module +%D [ file=spac-grd, +%D version=2009.10.16, % 1998.03.10, was core-grd.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Grid Snapping, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Grid Snapping} + +\unprotect + +\newif \iffuzzyvskip + +%D Helpers: + +\let\poplastnode\relax + +\def\pushlastnode + {\ifdim\lastskip=\zeropoint + \ifnum\lastpenalty=\zerocount + \ifnum\lastkern=\zerocount + \let\poplastnode\relax + \else + \edef\poplastnode{\kern\the\lastkern\relax}\kern-\lastkern % untested + \fi + \else + \edef\poplastnode{\penalty\the\lastpenalty\relax}\nobreak % untested + \fi + \else + \edef\poplastnode{\vskip\the\lastskip\relax}\vskip-\lastskip % \removelastskip + \fi} + +%D Moved from supp-box: + +%D \macros +%D {startbaselinecorrection,baselinecorrection, +%D showbaselinecorrection,offbaselinecorrection} +%D +%D Spacing around ruled boxes can get pretty messed up. The +%D next macro tries as good as possible to fix this. +%D +%D \startbuffer[1] +%D \startbaselinecorrection +%D \ruledhbox{Rule Brittanica} +%D \stopbaselinecorrection +%D \stopbuffer +%D +%D \typebuffer[1] +%D +%D The macros put some white space around the box: +%D +%D \getbuffer[1] +%D +%D A simple alternative is \type {\baselinecorrection}, which +%D only looks at the previous line. +%D +%D \startbuffer[2] +%D \baselinecorrection +%D \ruledhbox{Rule Brittanica} +%D \baselinecorrection +%D \stopbuffer +%D +%D \typebuffer[2] +%D +%D This time the last preceding line gets a correction,% +%D dependant on the depth. +%D +%D \getbuffer[2] +%D +%D One can make the correction visible by saying \type +%D {\showbaselinecorrection}. Part of the correction is +%D calculated from the dimensions of a~(. One can disble the +%D correction by calling \type {\offbaselinecorrection}. +%D +%D When visualize the first example looks like: +%D +%D {\showbaselinecorrection\getbuffer[1]} +%D +%D and the second one comes out as: +%D +%D {\showbaselinecorrection\getbuffer[2]} + +% \definecolor[GridLineColor][red] +% \definecolor[GridTextColor][blue] + +\let\thetopbaselinecorrection \!!zeropoint +\let\thebotbaselinecorrection \!!zeropoint +\let\thenegtopbaselinecorrection\!!zeropoint +\let\thenegbotbaselinecorrection\!!zeropoint + +\definepalet + [grid] + [ one=red, + two=green, + three=blue, + four=gray] + +\def\setbaselinecorrections + {\setbox0\hbox{\setstrut\strut}% + \setbox2\hbox{(}% + \dimen0\ht0\advance\dimen0 -\ht2 + \ifdim\dimen0<\zeropoint\dimen0\zeropoint\fi + \dimen2\dp0\advance\dimen2 -\dp2 + \ifdim\dimen2<\zeropoint\dimen2\zeropoint\fi + \edef\thetopbaselinecorrection {\the\dimen0}\dimen0-\dimen0 + \edef\thebotbaselinecorrection {\the\dimen2}\dimen2-\dimen2 + \edef\thenegtopbaselinecorrection{\the\dimen0}% + \edef\thenegbotbaselinecorrection{\the\dimen2}} + +\def\dotopbaselinecorrection {\kern\thetopbaselinecorrection} +\def\dobotbaselinecorrection {\kern\thebotbaselinecorrection} +\def\donegtopbaselinecorrection{\kern\thenegtopbaselinecorrection} +\def\donegbotbaselinecorrection{\kern\thenegbotbaselinecorrection} + +\def\showbaselinecorrection + {\def\dobaselinecorrection % visualization is not watertight! + {\bgroup +\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi + \setbox0\null + \wd0\hsize + \dp0\strutdp + \nointerlineskip + \forgetall + \ruledvbox{\box0}% + \egroup + \prevdepth\strutdp}% + \def\dotopbaselinecorrection + {\hrule\!!height\thetopbaselinecorrection}% + \def\dobotbaselinecorrection + {\hrule\!!height\thebotbaselinecorrection}} + +\def\dobaselinecorrection + {\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi + \kern\strutdp + \prevdepth\strutdp} + +% \def\baselinecorrection +% {\endgraf +% \ifvmode +% \ifdim\prevdepth<\maxdimen +% \ifdim\prevdepth<\zeropoint \else +% \ifdim\prevdepth<\strutdp +% \dobaselinecorrection +% \fi +% \fi +% \fi +% \fi} + +\def\baselinecorrection + {\endgraf + \ifvmode + \ifdim\prevdepth<\maxdimen + \ifdim\prevdepth<\zeropoint \else + \ifdim\prevdepth<\strutdepth \relax + \pushlastnode + \dobaselinecorrection + \poplastnode + \fi + \fi + \fi + \fi} + +\def\pagebaselinecorrection + {\ifdim\pagegoal<\maxdimen + \ifdim\pagetotal>\lineheight % or \topskip + \scratchdimen\pagetotal + \advance\scratchdimen\lineheight + \ifdim\scratchdimen<\pagegoal + \baselinecorrection + \fi + \fi + \fi} + +% Beware, keep this one as it is, see for instance module +% m-steps.tex, where we apply a \localhsize to the \vbox, in +% order to follow narrower and side floats ! + +% \def\startbaselinecorrection +% {\baselinecorrection +% \ifvmode +% \bgroup +% \setbox\scratchbox\vbox\bgroup +% \ignorespaces +% \let\stopbaselinecorrection\dostopbaselinecorrection +% \else +% \let\stopbaselinecorrection\relax +% \fi} + +% \def\dostopbaselinecorrection % I have to check columns yet. +% {\endgraf +% \egroup +% \topbaselinecorrection +% \box\scratchbox +% \botbaselinecorrection +% \egroup} + +% \let\stopbaselinecorrection=\relax + +\def\startbaselinecorrection + {\bgroup + \let\stopbaselinecorrection\egroup + \ifcase\baselinecorrectionmode + \or % normal + \baselinecorrection + \ifvmode + \setbox\scratchbox\vbox\bgroup\ignorespaces + \let\stopbaselinecorrection\donormalstopbaselinecorrection + \fi + \or % off + \or % force + \baselinecorrection + \ifvmode + \setbox\scratchbox\vbox\bgroup\ignorespaces + \let\stopbaselinecorrection\doforcedstopbaselinecorrection + \fi + \fi} + +\let\stopbaselinecorrection\relax + +\def\donormalstopbaselinecorrection % I have to check columns yet. + {\egroup + \topbaselinecorrection + \box\scratchbox + \botbaselinecorrection + \egroup} + +\def\doforcedstopbaselinecorrection % I have to check columns yet. + {\egroup + \forcedtopbaselinecorrection + \box\scratchbox + \forcedbotbaselinecorrection + \egroup} + +%D We do a bit more checking than needed. The pageborder check +%D is not needed, but I want to look the visualization as good +%D as possible too. + +% \def\offbaselinecorrection % Can be used inside correction. +% {\def\startbaselinecorrection{\bgroup\let\stopbaselinecorrection\egroup}} + +\chardef\baselinecorrectionmode\plusone + +\def\onbaselinecorrection {\chardef\baselinecorrectionmode\plusone } +\def\offbaselinecorrection {\chardef\baselinecorrectionmode\plustwo } +\def\forcebaselinecorrection{\chardef\baselinecorrectionmode\plusthree} + +%D \macros +%D {topbaselinecorrection,botbaselinecorrection} +%D +%D The actual top and bottom corrections are implemented as: + +% \def\topbaselinecorrection +% {\ifvmode \ifdim\pagegoal<\maxdimen +% \bgroup +% \setbaselinecorrections +% \whitespace +% \nointerlineskip +% \dotopbaselinecorrection +% \egroup +% \fi \fi} + + +\def\topbaselinecorrection + {\ifvmode \ifdim\pagegoal<\maxdimen + \forcedtopbaselinecorrection + \fi \fi} + +\def\forcedtopbaselinecorrection + {\ifvmode + \bgroup + \setbaselinecorrections + \whitespace + \nointerlineskip + \dotopbaselinecorrection + \egroup + \fi} + +\def\botbaselinecorrection + {\ifvmode + \bgroup + \setbaselinecorrections + \dobotbaselinecorrection + \allowbreak % new, otherwise problems when many in a row + \prevdepth\strutdp + \egroup + \fi} + +\let\forcedbotbaselinecorrection\botbaselinecorrection + +%D Still very experimental and therefore undocumented. + +\newif\ifgridsnapping % UNDER DEVELOPMENT, USE WITH CARE +\newif\ifforcepresnap \forcepresnaptrue % false in mixed single/double +\newif\ifstrutsnapping \strutsnappingtrue % sometimes handy to be false + +\def\positiveextrasnap {\gdef\extrasnapsign{+}} +\def\negativeextrasnap {\gdef\extrasnapsign{-}} + +\def\extrasnapreset {\global\chardef\@@extrasnap0 + \positiveextrasnap} +\def\extrasnapbefore {\global\chardef\@@extrasnap1 } +\def\extrasnaparound {\global\chardef\@@extrasnap2 } +\def\extrasnapafter {\global\chardef\@@extrasnap3 } + +\def\enablepresnapcorrection {\global\chardef\@@presnap\zerocount} +\def\disablepresnapcorrection {\global\chardef\@@presnap\plusone} + +\extrasnapreset \enablepresnapcorrection + +\newif\iftracegridsnapping +\newif\ifshowgridboxes +\newif\ifshowfuzzyskips + +\let\showgridboxes\showgridboxestrue + +\def\showgridsnapping + {\tracegridsnappingtrue + \showgridboxestrue} + +\chardef\@@alignsnap =0 +\chardef\@@alignsnapbox =0 +\chardef\@@alignsnapmethod=0 + +\let\presnapskip \!!zeropoint \def\presnap {-} +\let\postsnapskip\!!zeropoint \let\postsnap\presnap + +\newcount\currentgridsnap + +\def\tracedsnapping + {\iftracegridsnapping + \llap + {\setlayoutcomponentattribute\v!grid\v!test + \hbox \layoutcomponentboxattribute + {\infofont + \global\advance\currentgridsnap\plusone + \color[grid:three] + {\vl\presnapskip + \vl\presnap + \vl\postsnap + \ifcase\@@alignsnapbox\relax\vl\ifcase\@@extrasnap00\or\extrasnapsign0\or\extrasnapsign\extrasnapsign\or0\extrasnapsign\fi\fi + \vl\the\currentgridsnap\vl}}}% + \fi} + +\def\snaptogrid% [#1]#2 -> #2 == \hbox|\vbox + {\dosingleempty\dosnaptogrid} + +% \def\dosnaptogrid[#1]% +% {\ifgridsnapping +% \iffirstargument\doifsomething{#1}{\verplaatsopgrid[#1]}\fi +% \expandafter\dodosnaptogrid +% \fi} + +% \def\dosnaptogrid[#1]% +% {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up +% \ifgridsnapping +% \iffirstargument\doifsomething{#1}{\moveongrid[#1]}\fi +% \expandafter\dodosnaptogrid +% \fi} + +\def\dosnaptogrid[#1]% + {\resetlastlinewidth % maybe in more places, otherwise spacing gets messed up + \doifinsetelse\v!force{#1}% + {\moveongrid[#1]% + \dodosnaptogrid} + {\ifgridsnapping + \doifsomething{#1}{\moveongrid[#1]}% + \expandafter\dodosnaptogrid + \fi}} + +% \def\forcedpresnapcorrection % test this on 'details' +% {\ifforcepresnap +% \ifvmode \else \par \fi % new +% % we don't want top of page space when 'top' option +% %\verticalstrut\nobreak\vskip-\struttotal +% %\verticalstrut\vskip-\struttotal +% % nobreak really needed +% \allowbreak\verticalstrut\nobreak\vskip-\struttotal +% %\ifdim\pagetotal>\topskip \else +% % eigenlijk signal +% %\writestatus{grid}{removing dummy at top of page}% +% %\bgroup +% %\output{\setbox\scratchbox\box255}% +% %\penalty\outputpenalty +% %\egroup +% %\fi +% \fi} + +\def\forcedpresnapcorrection % test this on 'details' + {\ifforcepresnap + \ifvmode \else \par \fi % new + % we don't want top of page space when 'top' option + % \verticalstrut\nobreak\vskip-\struttotal + % \verticalstrut\vskip-\struttotal + % \nobreak really needed + % \dosomebreak\allowbreak % no: spoils heads, so only under know situation, not in snapper + \verticalstrut + \nobreak + \vskip-\struttotal + %\ifdim\pagetotal>\topskip \else + % eigenlijk signal + %\writestatus{grid}{removing dummy at top of page}% + %\bgroup + %\output{\setbox\scratchbox\box255}% + %\penalty\outputpenalty + %\egroup + %\fi + \fi} + +\def\setgridtracebox#1[#2]% % maybe reverse the order + {\setbox\nextbox#1% + {\hbox + {\hbox to \zeropoint + {\setlayoutcomponentattribute\v!grid\v!test + \color[grid:#2]{\ruledhbox \layoutcomponentboxattribute {\fakebox\nextbox}}% + \hss}% + \flushnextbox}}} + +\newif\ifboxedsnapping \boxedsnappingtrue + +\chardef\depthsnapmethod \plusone % downward compatible, minus one line +\chardef\heightsnapmethod\plusone % downward compatible, minus one line + +\def\dodosnaptogrid + {\dowithnextbox + {\bgroup + \ifcase\@@alignsnapmethod \or + % we're dealing with text with a possible big depth/height + \chardef\depthsnapmethod \plustwo + \chardef\heightsnapmethod\plustwo + \fi + \ifdim\nextboxht<\textheight % handle special case (like page fig) + \ifcase\@@alignsnapbox\relax + \ifcase\@@alignsnap\else % 1=top 2=high 3=middle 4=low + \ifshowgridboxes + \setgridtracebox\hbox[two]% + \fi + %\getnoflines{\nextboxht}% + \getnoflines\nextboxht + \setbox\nextbox\vbox to \noflines\lineheight + {\ifnum\@@alignsnap=1 \kern\lineheight\kern-\topskip\fi + \ifnum\@@alignsnap>2 \vfill\fi + \flushnextbox + \ifnum\@@alignsnap<4 \vfill\fi}% + \fi + \ifshowgridboxes + \setgridtracebox\hbox[three]% + \fi + \forgetall + \par + \ifvbox\nextbox + \setbox\nextbox\hbox{\flushnextbox}% don't ask + \fi + \scratchskip\lastskip + \edef\presnapskip{\the\lastskip}% + % mixing single/double columns sometimes goes wrong, + % check 'som' document + \ifinsidecolumns + \forcepresnaptrue + \fi + \forcedpresnapcorrection + \ifdim\nextboxht>\strutht + \scratchdimen\nextboxht + \ifcase\@@presnap\relax + \ifdim\scratchskip>\zeropoint\relax + \scratchcounter\scratchskip + \advance\scratchcounter -\openlineheight + \ifnum\scratchcounter<0 + \scratchcounter-\scratchcounter + \fi + \ifnum\scratchcounter<10 % \lastkip is about \openlineheight + \advance\scratchdimen -\openstrutdepth + \edef\presnapskip{*\presnapskip}% + \else\ifdim\scratchskip>\openlineheight + %<\openlineheight \else + \advance\scratchdimen -\openstrutdepth + \edef\presnapskip{*\presnapskip}% + \fi\fi + \fi + \fi + % \getnoflines\scratchdimen % maybe raw ? + % \advance\noflines -1 + \ifcase\heightsnapmethod + % raw + \or + \advance\scratchdimen-\lineheight % tight (default) + \or + \advance\scratchdimen-\strutheight % fit (text) + \or + \advance\scratchdimen-\strutheight % tolerant + \advance\scratchdimen-\roundingeps + \fi + \getnoflines\scratchdimen + \ifnum\noflines>0 + \scratchdimen\noflines\lineheight + \else + \scratchdimen\zeropoint + \fi + \else + \scratchdimen\zeropoint + \fi + \ifnum\@@extrasnap=1 \advance\scratchdimen \extrasnapsign \lineheight \fi + \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi + \edef\presnap{\the\scratchdimen}% + \ifstrutsnapping + \ifboxedsnapping + \getrawnoflines\scratchdimen + \advance\scratchdimen-\noflines\lineheight + \vskip\scratchdimen % disappears at top of page + \dorecurse\noflines{\verticalstrut\nobreak}% + \else \ifdim\scratchdimen=\zeropoint + % nothing to skip + \else % disappears at top of page + \vskip\scratchdimen + \fi \fi + \fi + \ifdim\nextboxdp>\strutdp + % \getnoflines\nextboxdp + % \advance\noflines \minusone + \scratchdimen\nextboxdp\relax + \ifcase\depthsnapmethod + % raw + \or + \advance\scratchdimen-\lineheight % tight (default) + \or + \advance\scratchdimen-\strutdepth % fit (text) + \or + \advance\scratchdimen-\strutdepth % tolerant + \advance\scratchdimen-\roundingeps + \fi + \getnoflines\scratchdimen + \ifnum\noflines>0 + \scratchdimen\noflines\lineheight + \else + \scratchdimen\zeropoint + \fi + \else + \scratchdimen\zeropoint + \fi + \ifnum\@@extrasnap=2 \advance\scratchdimen \extrasnapsign.5\lineheight \fi + \ifnum\@@extrasnap=3 \advance\scratchdimen \extrasnapsign \lineheight \fi + \edef\postsnap{\the\scratchdimen}% + \ifstrutsnapping + \nextboxht\strutht + \nextboxdp\strutdp + \else + \scratchdimen\presnap + \advance\scratchdimen \strutht + \nextboxht\scratchdimen + \scratchdimen\postsnap + \advance\scratchdimen \strutdp + \nextboxdp\scratchdimen + \fi + \hbox{\tracedsnapping\flushnextbox}% + \ifstrutsnapping + \ifdim\scratchdimen=\zeropoint\else\vskip\scratchdimen\fi + \fi + \else + \scratchdimen\nextboxht\relax + \ifcase\@@alignsnapbox + % can't happen here + \or + \getrawnoflines\scratchdimen + \else + \getnoflines \scratchdimen + \fi + \scratchdimen\noflines\lineheight\relax + \advance\scratchdimen-\strutdepth + % spoils the whole game (fit/broad/line) + % \ifnum\pagetotal>\zeropoint \else % disable this as option + % \advance\scratchdimen-\strutheight + % \advance\scratchdimen+\topskip + % \fi + \dimen0=\scratchdimen + \dimen2=\strutdepth + \ifshowgridboxes + \setgridtracebox\hbox[two]% + \fi + \nextboxdp\strutdp + \dimen4=\nextboxht + \dimen6=\nextboxdp + \iftracegridsnapping + \setbox\scratchbox\hbox + {\scratchdimen\@@alignsnapamount\relax + \ifdim\scratchdimen<\zeropoint + \tracedgridamount\zeropoint{-\scratchdimen}% + \else + \tracedgridamount\scratchdimen\zeropoint + \fi}% + \smashbox\scratchbox + \setbox\nextbox\hbox{\box\scratchbox\flushnextbox}% + \fi + \setbox\nextbox\hbox + {\scratchdimen\@@alignsnapamount\relax + \ifcase\@@alignsnapdepth\or + % don't change this ever ! + \ifdim\dimen0<\lineheight + % otherwise it is ok, but ending up inside + % the next paragraph is seldom what we want, + % so we move one line up + \advance\scratchdimen-\lineheight + \advance\scratchdimen\strutheight + \else + % otherwise we can move down to the + % baseline + \advance\scratchdimen\dimen6 % == \strutdepth + \fi + \fi + \lower\scratchdimen\flushnextbox}% + \nextboxht\dimen4 + \nextboxdp\dimen6 + \ifnum\@@alignsnap<4 % 4 = regel + \setbox\nextbox\vbox to \scratchdimen + {\forgetall + \ifnum\@@alignsnap>2 \vfill\fi % 3 4 + \flushnextbox + \nointerlineskip % \offinterlineskip + \ifnum\@@alignsnap<4 \vfill\fi % 2 3 + \kern\zeropoint}% + \fi + \ifshowgridboxes + \setgridtracebox\vbox[three]% + \fi + \scratchdimen\@@alignsnapamount + \edef\presnapskip{\the\scratchdimen}% + \ifnum\@@alignsnap>2 \def\presnap {+}\fi + \ifnum\@@alignsnap<4 \def\postsnap{+}\fi + \setbox\nextbox\hbox{\tracedsnapping\flushnextbox}% + \par + \nextboxht\dimen0 + \nextboxdp\dimen2 + \forcedpresnapcorrection + \nointerlineskip + \flushnextbox + \fi + \else + \setbox\nextbox\vbox to \textheight + {\ifdim\nextboxdp=\zeropoint + \hbox{\lower\strutdepth\flushnextbox} + \else % this branch is yet untested + \vss + \hbox{\lower\nextboxdp\flushnextbox} + \vskip-\strutdepth + \fi}% + \nextboxdp\strutdepth + \flushnextbox + \fi + \extrasnapreset + \enablepresnapcorrection + \global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount + \egroup}} + +\def\tracedgridamount#1#2% + {\startcolor[grid:four]% + \setlayoutcomponentattribute\v!grid\v!test + \hbox \layoutcomponentboxattribute{\vrule\!!width\nextboxwd\!!height#1\!!depth#2}% + \stopcolor} + +\def\snaptomathgrid % probably not working ok, also kind of obsolete + {\ifgridsnapping + \dowithnextbox + {\blank[\v!line]\snaptogrid\vbox{\flushnextbox}\blank[\v!line]} + \vbox\bgroup + \forgetdisplayskips + \@EA\let\@EA\next + \fi} + +\def\topsnaptogrid + {\ifgridsnapping + \dowithnextbox + {\scratchdimen\nextboxht + \advance\scratchdimen -\strutht + \advance\scratchdimen \topskip + \nextboxht\scratchdimen + \nextboxdp\zeropoint + \flushnextbox + \kern\lineheight + \kern-\topskip + \nointerlineskip} + \hbox + \fi} + +% \def\centertogrid % meant for special situations +% {\ifgridsnapping +% \dowithnextboxcontent +% {\ignorespaces} +% {\bgroup +% \par +% \scratchdimen\nextboxht +% \advance\scratchdimen \nextboxdp +% \getnoflines\scratchdimen +% \setbox\nextbox\vbox to \noflines\lineheight +% {\forgetall +% \vskip\zeropoint \!!plus \nextboxht +% \copy\nextbox +% \kern.5\strutdp % VOORLOPIGE WAARDE +% \vskip\zeropoint \!!plus \nextboxdp}% +% \noindent\snaptogrid\vbox{\flushnextbox}% +% \egroup} +% \vbox % was \hbox +% \fi} + +% The next implementation is sub-optimal +% +% \def\centertogrid % usage: see ie pascal / stepcharts +% {\snaptogrid[\v!midden,.5\strutdp]\vbox} + +\def\centertogrid % meant for special situations + {\ifgridsnapping + \dowithnextboxcontent + {\ignorespaces} + {\bgroup + \par + \scratchdimen\nextboxht + \advance\scratchdimen \nextboxdp + \getnoflines\scratchdimen + \setbox\nextbox\vbox to \noflines\lineheight + {\forgetall + \vss + \topbaselinecorrection + \copy\nextbox + \botbaselinecorrection + \vss}% + \setbox\nextbox\hbox{\lower\strutdp\flushnextbox}% + \forgeteverypar % new per 3/4/2008, prevents duplicate pos nodes resulting in extra whitespace + \noindent\snaptogrid\vbox{\flushnextbox}% + \egroup} + \vbox % was \hbox + \fi} + +% testbed for \centertogrid +% +% \strut Bruggetje +% \startlinecorrection +% \startcombination +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination[2*2] +% {\framed{test}} {} {\framed{test}} {} +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination[2*2] +% {\framed{test}} {} {\framed{test}} {} +% {\framed{test}} {} {\framed{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection +% \startcombination[2*2] +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection +% \strut Bruggetje +% \startlinecorrection[blank] +% \startcombination[2*2] +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% {\framed[lines=1]{test}} {} {\framed[lines=1]{test}} {} +% \stopcombination +% \stoplinecorrection + +\ifx\startbaselinecorrection\undefined \wait \fi % change order + +\let\normalstartbaselinecorrection=\startbaselinecorrection + +\def\startbaselinecorrection + {\ifgridsnapping + \centertogrid\bgroup + \let\stopbaselinecorrection\egroup + \else + \normalstartbaselinecorrection + \fi} + +\chardef\gridboxlinenomode\plusone +\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame + +\def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi} +\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth} + +\def\setgridbox#1#2#3% + {\setbox#1\gridboxvbox to #3 % given size + {\forgetall + \resetteststrut + \offinterlineskip + \hsize#2% + \baselinerulefalse + \gridboxvbox % calculated size + {\getrawnoflines{#3}% \getnoflines{#3}% + \vskip\topskip + \vskip-\strutht + \scratchdimen#2\advance\scratchdimen \lineheight + \dorecurse\noflines + {\strut + \hskip-.5\lineheight + \ifcase\gridboxlinenomode\or + \rlap + {\hskip.2\bodyfontsize\hskip\scratchdimen + \infofont\hbox to 1em{\hss\recurselevel}}% + \or + \llap + {\infofont\hbox to 1em{\hss\recurselevel}% + \hskip.2\bodyfontsize}% + \fi + \vrule + \!!height \gridboxwidth + \!!depth \gridboxwidth + \!!width \scratchdimen + \par}} + \vfill}} + +%D Some intervention macros: + +\def\gridwarning#1{\message{[beware of #1 extra snap]}} + +\global\let\@@alignsnapamount\!!zeropoint +\global\chardef\@@alignsnapdepth0 + +\def\@@unknowngriddisplacement + {\global\chardef\@@alignsnapbox\plusthree + \global\let\@@alignsnapamount\commalistelement} + +\def\domoveongrid[#1]% + {\ifgridsnapping\doifsomething{#1}{\dodomoveongrid[#1]}\fi} + +\def\dodomoveongrid[#1]% some day : speed up + {\global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount + \global\chardef\@@alignsnapdepth\zerocount + \global\chardef\@@alignsnapmethod\zerocount + \global\let\@@alignsnapamount\!!zeropoint + \donefalse + \expanded{\processallactionsinset[#1]} + [\v!standard=>, + \v!normal=>, % to be sure + \v!yes=>, % to be sure + \v!top=>\gridwarning+\positiveextrasnap\extrasnapbefore, + \v!bottom=>\gridwarning+\positiveextrasnap\extrasnapafter, + \v!both=>\positiveextrasnap\extrasnaparound, + -\v!top=>\gridwarning-\negativeextrasnap\extrasnapbefore, + -\v!bottom=>\gridwarning-\negativeextrasnap\extrasnapafter, + -\v!both=>\negativeextrasnap\extrasnaparound, + \v!text=>\global\chardef\@@alignsnapmethod\plusone, % accurate calculations + \v!page=>\global\chardef\@@alignsnap\plusone, % topskip + \v!high=>\global\chardef\@@alignsnap\plustwo, + \v!middle=>\global\chardef\@@alignsnap\plusthree, + \v!low=>\global\chardef\@@alignsnap\plusfour, + \v!fit=>\global\chardef\@@alignsnapbox\plusone, % new + \v!broad=>\global\chardef\@@alignsnapbox\plustwo, % new + \v!depth=>\global\chardef\@@alignsnapdepth\plusone, % new + \v!line=>\global\chardef\@@alignsnapbox\plusthree +% \global\chardef\@@alignsnapdepth\plusone + \global\chardef\@@alignsnap\plusfour, + \v!reset=>\positiveextrasnap\extrasnapreset, + \v!none=>\global\chardef\@@alignsnap\zerocount + \global\chardef\@@alignsnapbox\zerocount, + \v!force=>, % turns on grid snapping even when not on + \s!default=>, + \s!unknown=>\@@unknowngriddisplacement]} + +\def\moveongrid + {\dosingleempty\domoveongrid} + +\def\doplaceongrid[#1]% + {\domoveongrid[#1]\snaptogrid\vbox} + +\def\placeongrid + {\dosingleempty\doplaceongrid} + +%D Snapping is rather robust as long as we use whole lines. +%D Half lines of white space can however be handled when they +%D come in pairs. The corrections needed when crossing page +%D boundaries in the middle of such a pair, are handled by +%D macros that are (named) sort of fuzzy. This fuzzy mechanism +%D was written as an extension to the grid typesetting needed +%D for typesetting (part of) the \MAPS. +%D +%D \starttyping +%D \setuptyping +%D [before={\blank[halfline]}, +%D after={\blank[halfline]}] +%D \stoptyping + +\newif \iffuzzyvskip +\newif \iffuzzysnapdone +\newif \iffuzzysnapping +\newif \iffuzzysnapped +\chardef \fuzzysnappedleft=0 % ==1 when fuzzybegin still open +\newpersistentmark\fuzzymark % (!) +\newcount \fuzzymarker +\newbox \fuzzysnapbox +\newbox \fuzzysnapsplit + +\def\dosyncfuzzyvskip + {\ifvmode\ifdim\lastskip<\lineheight\ifdim\lastskip>\zeropoint + \bgroup % - added 28/2/2003: check this, there was no - + \endgraf\forgetall\verticalstrut\nobreak\vskip-\struttotal + \egroup + \fi\fi\fi} + +\def\fuzzyvskip#1% + {\iffuzzysnapdone + \dosyncfuzzyvskip % NEWER + \endfuzzysnapping + \vskip#1\relax + \global\fuzzysnapdonefalse + \else + \vskip#1\relax + \beginfuzzysnapping + \global\fuzzysnapdonetrue + \fi} + +\def\setfuzzymark#1#2#3% #1/#2 => error recovery + {\ifgridsnapping + \global\fuzzysnappingtrue + \global\advance\fuzzymarker \ifodd\fuzzymarker#1\else#2\fi + \nobreak + \ifshowfuzzyskips + \hbox{\color[grid:three] + {\llap{\infofont#3\vl\the\fuzzymarker}\nobreak + \vrule\!!width\hsize\!!height.1\lineheight}} + \nobreak + \fi + %[\the\fuzzymarker] + %\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% + \expandafter\rawsetmark\expandafter\fuzzymark\expandafter{\the\fuzzymarker}% + \nobreak + \fi} + +\def\beginfuzzysnapping{\setfuzzymark21\v!start} % odd +\def\endfuzzysnapping {\setfuzzymark12\v!stop } % even + +\def\removelastfuzzyvskip + {\ifgridsnapping + \iffuzzysnapping + \ifdim\lastskip<\openlineheight + \else + \removelastskip + \fi + \else + \removelastskip + \fi + \else + \removelastskip + \fi} + +\def\docheckfuzzysnap#1% + {\bgroup + \dontcomplain + \setbox\fuzzysnapbox\copy#1\relax + \setbox\fuzzysnapsplit\vsplit\fuzzysnapbox to 1\lineheight + \let\topfuzzymark\empty % indeed here ... no real mark + \getsplitmarks\fuzzymark +% \ifcase0\topfuzzymark + \ifcase0\rawgetsplittopmark\fuzzymark + \global\chardef\fuzzysnappedleft\zerocount + \global\fuzzysnappedfalse +% \else\ifodd\topfuzzymark + \else\ifodd\rawgetsplittopmark\fuzzymark + \global\chardef\fuzzysnappedleft\plusone + \global\fuzzysnappedtrue + \else + \global\chardef\fuzzysnappedleft=2 + \global\fuzzysnappedtrue + \fi\fi + \iffuzzysnapped \else + \doloop + {\ifvoid\fuzzysnapbox + \exitloop + \else + \setbox\fuzzysnapsplit=\vsplit\fuzzysnapbox to \lineheight + %\let\topfuzzymark=\empty % ... but not here + \getsplitmarks\fuzzymark +% \ifcase0\topfuzzymark + \ifcase0\rawgetsplittopmark\fuzzymark + % continue +% \else\ifodd\topfuzzymark + \else\ifodd\rawgetsplittopmark\fuzzymark + \exitloop + \else + \global\chardef\fuzzysnappedleft\plusone + \global\fuzzysnappedtrue + \exitloop + \fi\fi + \fi}% + \fi + \egroup} + +\def\getfuzzysnapcorrection#1% + {\global\let\presnapcorrection \relax + \global\let\postsnapcorrection\relax + \ifgridsnapping\iffuzzysnapping + \docheckfuzzysnap{#1}% + \iffuzzysnapped + \iftracegridsnapping + \gdef\presnapcorrection + {\color[grid:four]{\hrule\!!height.5\openlineheight\!!width\hsize}}% + \else + \gdef\presnapcorrection{\kern.5\openlineheight}% + \fi + \gdef\postsnapcorrection{\kern-.5\openlineheight}% get the height ok + \fi + \fi\fi} + +\def\fuzzysnappedbox#1#2% \box \unvbox + {\getfuzzysnapcorrection{#2}% + \presnapcorrection + #1#2% + \postsnapcorrection} + +\def\adaptfuzzypagegoal + {\ifgridsnapping\iffuzzysnapping\ifcase\fuzzysnappedleft\or % see dopagecontents + \scratchdimen\pagegoal + \advance\scratchdimen -.5\openlineheight + \global\pagegoal\scratchdimen + \global\advance\vsize -.5\openlineheight + \global\chardef\fuzzysnappedleft0 + \fi\fi\fi} + +%D New, experimental, used in caption snapping: +%D +%D \starttyping +%D \startcolumnset +%D +%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=top] +%D +%D \placefigure [lrtb] {\dorecurse{5}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D \placefigure [lrtb] {\dorecurse{15}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D +%D \setupcaption[figure][style=\tfx\setupinterlinespace,inbetween=,grid=bottom] +%D +%D \placefigure [rltb] {\dorecurse{5}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D \placefigure [rltb] {\dorecurse{15}{green gras}} +%D {\externalfigure[dummy][width=\textwidth,height=3cm,grid=height]} +%D +%D \input thuan +%D +%D \stopcolumnset +%D \stoptyping + +\def\moveboxontogrid#1#2#3% box method firstlineht % experimental ! ! ! + {\doifsomething{#2} + {\getnoflines{\ht#1}% no depth taken into account, depth preserved + \scratchdimen\noflines\lineheight + \advance\scratchdimen-\strutdp + \bgroup + \advance\scratchdimen-\onepoint % be a bit tolerant + \ifdim\scratchdimen>\ht#1\relax + \egroup + \doif{#2}\v!top {\setbox#1\vbox to \scratchdimen{\vskip-#3\vskip\strutht\box#1\vfill}}% + \doif{#2}\v!bottom{\setbox#1\vbox to \scratchdimen{\vfill\box#1\removedepth}}% + \dp#1\strutdp + \else + \egroup + \ht#1\scratchdimen + \dp#1\strutdp + \fi}} + +%D New: + +\let\checkgridsnapping\relax + +\protect \endinput diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv new file mode 100644 index 000000000..7dd036a22 --- /dev/null +++ b/tex/context/base/spac-hor.mkiv @@ -0,0 +1,821 @@ +%D \module +%D [ file=spac-hor, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Horizontal, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Horizontal} + +\unprotect + +\let\currentindentation\empty % amount/keyword +\let\currentindenting \empty % method + +\newdimen\ctxparindent + +\newif\ifindentfirstparagraph % \indentfirstparagraphtrue + +\chardef\indentingtoggle\zerocount + +%D After a blank or comparable situation (left side floats) we +%D need to check if the next paragraph has to be indented. + +\def\presetindentation + {\doifoutervmode{\ifindentfirstparagraph\else\noindentation\fi}} + +%D This sets up the (normally) global indentation behavior as well +%D as the amounts. + +\definecomplexorsimple\setupindenting + +\indentfirstparagraphtrue +\parindent\ctxparindent +\chardef\indentingtoggle\zerocount + +% we need a better everypar model: for each option a switch, which we +% set to false with \forgetall and can enable when needed (context 4); +% that way we can control the order of execution of options + +\def\checkeverypar % currently a hack + {\ifzeropt\parindent\else + \doifsometokselse\everypar\donothing{\appendtoks\checkindentation\to\everypar}% + \fi} + +\def\complexsetupindenting[#1]% + {\edef\currentindenting{#1}% + \doifsomething\currentindenting % handy when a parameter is passed + {% not here: \indentfirstparagraphtrue + % not here: \parindent\ctxparindent + % not here: \chardef\indentingtoggle\zerocount + % we use commacommand in order to catch #1 being a command (expanded parameter) + \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc + \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest + \checkeverypar % only when non-empty #1 + \ifindentfirstparagraph\else\noindentation\fi % added + \toggleindentation}} + +\def\docomplexsetupindentingA#1% + {\edefconvertedargument\!!stringa{#1}% can this be doen differently now? + \ifcsname\??in:\!!stringa\endcsname \else + \edef\currentindentation{#1}% + \let\normalindentation\currentindentation + \simplesetupindenting + \fi} + +\def\docomplexsetupindentingB#1% + {\edefconvertedargument\!!stringa{#1}% catch #1=\somedimen + \executeifdefined{\??in:\!!stringa}\donothing} + +\def\simplesetupindenting % empty case, a it strange, needed this way? + {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} + +\def\indenting % kind of obsolete + {\dosingleargument\complexsetupindenting} + +% use \noindentation to suppress next indentation + +\def\defineindentingmethod[#1]#2% + {\setvalue{\??in:#1}{#2}} + +\defineindentingmethod [\v!no] {\parindent\zeropoint}% was: \ctxparindent\noindent} +\defineindentingmethod [\v!not] {\parindent\zeropoint}% was: \ctxparindent\noindent} + +\defineindentingmethod [\v!first] {\indentfirstparagraphtrue} +\defineindentingmethod [\v!next] {\indentfirstparagraphfalse} + +\defineindentingmethod [\v!yes] {\parindent\ctxparindent\relax} % no \indent ! +\defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! + +\defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! + \chardef\indentingtoggle\zerocount} + +\defineindentingmethod [\v!odd] {\chardef\indentingtoggle\plusone} +\defineindentingmethod [\v!even] {\chardef\indentingtoggle\plustwo} + +\defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else + \let\currentindentation\normalindentation + \simplesetupindenting + \fi} + +\defineindentingmethod [\v!reset] {\indentfirstparagraphtrue + \parindent\zeropoint + \chardef\indentingtoggle\zerocount} + +\def\noindenting{\indenting[\v!no, \v!next ]} +\def\doindenting{\indenting[\v!yes,\v!first]} + +%D This one sets up the local indentation behaviour (i.e. either or not +%D a next paragraph will be indented). + +\def\dochecknextindentation#1% internal one + {\checknextindentation[\csname#1\c!indentnext\endcsname]} + +\setvalue{\??in->\s!empty}{} +\setvalue{\??in->\v!yes }{\doindentation} +\setvalue{\??in->\v!no }{\noindentation} +\setvalue{\??in->\v!auto }{\autoindentation} + +\def\checknextindentation[#1]% + {\csname\??in->\ifcsname\??in->#1\endcsname#1\else\s!empty\fi\endcsname} + +%D Here come the handlers. + +\newif\ifindentation \indentationtrue % documenteren, naar buiten + +\let\checkindentation\relax + +\ifx\autoindentation\undefined \let\autoindentation\relax \fi % hook + +\def\doindentation + {\gdef\checkindentation{\global\indentationtrue}} + +\def\noindentation % made global + {\ifinpagebody \else + \global\indentationfalse + \gdef\checkindentation + {\donoindentation + \gdef\checkindentation{\global\indentationtrue}}% + \fi} + +\def\nonoindentation % bv bij floats + {\ifinpagebody \else + \global\indentationtrue + \gdef\checkindentation{\global\indentationtrue}% + \fi} + +\def\donoindentation + {\ifdim\parindent=\zeropoint \else + \bgroup \setbox\scratchbox\lastbox \egroup + \fi} + +\def\indentation + {\ifvmode \ifdim\parindent=\zeropoint \else + % was : \hskip\parindent + % can be: \indent + % but we test: + \noindent\hskip\parindent + \fi \fi} + +\def\toggleindentation + {\ifcase\indentingtoggle + % nothing + \or + \notoggleindentation + \or + \dotoggleindentation + \fi} + +\def\dokillindentation + {\gdef\checkindentation{\global\indentationfalse\donoindentation}} + +\def\dotoggleindentation + {\gdef\checkindentation{\global\indentationfalse\notoggleindentation\donoindentation}} + +\def\notoggleindentation + {\gdef\checkindentation{\global\indentationtrue\dotoggleindentation}} + +\appendtoks + \pushmacro\checkindentation + \pushmacro\ifindentation +\to \everypushsomestate + +\appendtoks + \popmacro\ifindentation + \popmacro\checkindentation +\to \everypopsomestate + +% we need to save the state if we want to adapt behaviour to empty lines +% +% \def\setlasthvmode +% {\global\chardef\savedhvmode\ifhmode\plusone\else\ifvmode\plustwo\else\zerocount\fi\fi} +% +% \def\resetlasthvmode +% {\global\chardef\savedhvmode\zerocount} +% +% \chardef\savedhvmode\zerocount + +% This is a user requested hack (using the auto-hook). + +\chardef\recheckindentationmode\zerocount + +\def\dontrechecknextindentation + {\global\chardef\recheckindentationmode\zerocount} + +\def\dorechecknextindentation + {\ifcase\recheckindentationmode + % nothing + \or + \dontrechecknextindentation + \expandafter\doautoindentation + \fi} + +\def\doautoindentation + {\doifnextcharelse\par\donothing\noindentation} + +\def\autoindentation + {\global\chardef\recheckindentationmode\plusone} + +%D An example of usage: +%D +%D \starttyping +%D \setupindenting[small,yes] +%D +%D \setupitemize [indentnext=auto] +%D \setuptyping [indentnext=auto] +%D \setupformulas[indentnext=auto] +%D +%D \input tufte \startitemize \item itemize \stopitemize +%D \input tufte \startitemize \item itemize \stopitemize +%D \input tufte \startitemize \item itemize \stopitemize +%D +%D \page +%D +%D \input tufte +%D \starttyping +%D verbatim +%D \stoptyping +%D +%D \input tufte +%D \starttyping +%D verbatim +%D \stoptyping +%D +%D \input tufte +%D \starttyping +%D verbatim +%D \stoptyping +%D +%D \page +%D +%D \input tufte \startformula a = b \stopformula +%D \input tufte \startformula a = b \stopformula +%D \input tufte \startformula a = b \stopformula +%D \stoptyping + +\def\softbreak + {\relax\ifhmode\hskip\parfillskip\break\fi} + +%D {frenchspacing,nonfrenchspacing} +%D +%D Smehow \type{\frenchspacing} can lead to hyphenation between +%D dashes so we now have \type {\newfrenchspacing} (moved from +%D \type {syst-chr}). + +%D Hm ... todo: + +\sfcode`\)=0 +\sfcode`\'=0 +\sfcode`\]=0 + +\def\setfrenchspacing#1% + {\sfcode`\.#1 \sfcode`\,#1\relax + \sfcode`\?#1 \sfcode`\!#1\relax + \sfcode`\:#1 \sfcode`\;#1\relax} + +\def\frenchspacing + {\setfrenchspacing{1000}} + +\def\resetfrenchspacing + {\sfcode`\.3000 \sfcode`\,1250 + \sfcode`\?3000 \sfcode`\!3000 + \sfcode`\:2000 \sfcode`\;1500 } + +\def\frenchspacing {\setfrenchspacing{1000}} +\def\newfrenchspacing{\setfrenchspacing{1050}} +\def\nonfrenchspacing{\resetfrenchspacing} + +\def\definespacingmethod[#1]#2{\setvalue{\??sg\??sg#1}{#2}} + +\definespacingmethod[\v!packed]{\newfrenchspacing} +\definespacingmethod[\v!broad ]{\nonfrenchspacing} + +\def\complexsetupspacing[#1]% + {\executeifdefined{\??sg\??sg#1}\relax + \updateraggedskips} + +\def\simplesetupspacing + {\updateraggedskips} + +\definecomplexorsimple\setupspacing + +% \dorecurse{100}{\recurselevel\spacefactor 800 \space} \par +% \dorecurse{100}{\recurselevel\spacefactor1200 \space} \par +% \dorecurse{100}{\recurselevel\spacefactor 800 \normalspaceprimitive} \par +% \dorecurse{100}{\recurselevel\spacefactor1200 \normalspaceprimitive} \par + +% When we don't add the % here, we effectively get \ and +% since we have by default \def\^^M{\ } we get into a loop. + +\let\normalspaceprimitive=\ % space-comment is really needed + +% hm ... + +\unexpanded\def\ {\mathortext\normalspaceprimitive\space} % no \dontleavehmode\space (else no frenchspacing) + +% Because I strip spaces at the end of lines (in the editor) we need a bit of +% a trick to define slash+newline, so \ and \ are the same + +\ctxlua{tex.sprint(tex.ctxcatcodes,"\string\\unexpanded\string\\def\string\\\string\n{\string\\ }")} + +\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\mathortext\ \space} % no space in math + +\letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later + +\def\space { } +\def\removelastspace{\ifhmode\unskip\fi} +\def\nospace {\removelastspace\ignorespaces} + +% in tables we need: +% +% \def\fixedspace {\hskip.5em\relax} +% +% but, since not all fonts have .5em digits: + +\unexpanded\def\fixedspace + {\setbox\scratchbox\normalhbox{\mathortext{0}{0}}% + \hskip\wd\scratchbox\relax} + +\def\fixedspaces + {\letcatcodecommand \ctxcatcodes `\~ \fixedspace} + +\appendtoks\let~\space\to\simplifiedcommands + +% \def\removeunwantedspaces +% {\ifhmode % we also need to unskip 0pt skips +% \unskip\unskip\unskip\unskip\unskip +% \unskip\unskip\unskip\unskip\unskip +% \fi} + +\unexpanded\def\removeunwantedspaces + {\ifhmode + \expandafter \doremoveunwantedspace + \fi} + +\def\doremoveunwantedspace + {\ifnum\lastnodetype=\@@gluenode + \unskip \expandafter\doremoveunwantedspace + \fi} + +% \startbuffer +% \startlines \tt \fixedspaces +% 0~1~~2~~~3~~~~4~~~~~5 +% 0~~~~~~~~~~~~~~~~~~~5 +% $0~1~~2~~~3~~~~4~~~~~5$ +% $0~~~~~~~~~~~~~~~~~~~5$ +% \stoplines +% +% \starttabulate[|~|] +% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \NR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \NR +% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \NR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \NR +% \stoptabulate +% +% \starttable[||] +% \NC 0~1~~2~~~3~~~~4~~~~~5 \NC \AR \NC 0~~~~~~~~~~~~~~~~~~~5 \NC \AR +% \NC $0~1~~2~~~3~~~~4~~~~~5$ \NC \AR \NC $0~~~~~~~~~~~~~~~~~~~5$ \NC \AR +% \stoptable +% \stopbuffer +% +% \setupbodyfont[cmr] \getbuffer +% \setupbodyfont[lbr] \getbuffer + +%D A couple of plain macros: + +\ifx\thinspace\undefined + + \def\thinspace {\kern .16667\emwidth} + \def\negthinspace{\kern-.16667\emwidth} + \def\enspace {\kern .5\emwidth} + +\fi + +\ifx\quad\undefined + + \def\enskip{\hskip.5\emwidth} + \def\quad {\hskip \emwidth} + \def\qquad {\hskip 2\emwidth} + +\fi + +\let\emspace\quad + +% Suggested by GB (not the name -): + +\def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize} % D.A.'s value + +% Bovendien definieren we enkele extra \fill's: + +\def\hfilll{\hskip\zeropoint\!!plus1filll\relax} +\def\vfilll{\vskip\zeropoint\!!plus1filll\relax} + +% De onderstaande hulpmacro's moeten nog eens instelbaar worden +% gemaakt. + +\def\tfskipsize{1em\relax} +\def\tfkernsize{1ex\relax} + +\def\tfskip{\dotfskip\tfskipsize} +\def\tfkern{\dotfkern\tfkernsize} + +\def\dotfskip#1{{\tf\hskip#1}} +\def\dotfkern#1{{\tf\kern #1}} + +% needs a proper \definenarrower or installnarrower + +\newskip\ctxleftskip +\newskip\ctxrightskip +\newskip\ctxmidskip + +\def\dosinglenarrower#1% + {\processaction + [#1] + [ \v!left=>\global\advance\ctxleftskip \@@slleft, + \v!middle=>\global\advance\ctxmidskip \@@slmiddle, + \v!right=>\global\advance\ctxrightskip \@@slright, + \v!reset=>\global\ctxleftskip \zeropoint + \global\ctxmidskip \zeropoint + \global\ctxrightskip\zeropoint, + \v!none=>, + \s!unknown=>\global\advance\ctxmidskip \commalistelement]} + +\def\donarrower[#1]% hm, can be dorepeat directly + {\dorepeatwithcommand[#1]\dosinglenarrower} + +\def\complexstartnarrower[#1]% + {\@@slbefore % was hard coded \par + \bgroup + \global\ctxleftskip \zeropoint + \global\ctxrightskip\zeropoint + \global\ctxmidskip \zeropoint + \processcommalistwithparameters[#1]\donarrower + \advance\leftskip \ctxleftskip + \advance\rightskip \ctxrightskip + \advance\leftskip \ctxmidskip + \advance\rightskip \ctxmidskip + \seteffectivehsize} + +% todo: definenarrower + +\def\simplestartnarrower + {\startnarrower[\v!middle]} + +\definecomplexorsimple\startnarrower + +\def\stopnarrower + {\@@slafter % was hard coded \par / needed, else skips forgotten + \egroup} + +\def\setupnarrower + {\dodoubleargument\getparameters[\??sl]} + +\newdimen\@@effectivehsize \def\effectivehsize {\hsize} +\newdimen\@@effectiveleftskip \def\effectiveleftskip {\leftskip} +\newdimen\@@effectiverightskip \def\effectiverightskip{\rightskip} + +\def\seteffectivehsize + {\setlocalhsize + \@@effectivehsize \localhsize + \@@effectiveleftskip \leftskip + \@@effectiverightskip \rightskip + \let\effectivehsize \@@effectivehsize + \let\effectiveleftskip \@@effectiveleftskip + \let\effectiverightskip\@@effectiverightskip} + +\newskip\leftskipadaption +\newskip\rightskipadaption + +\def\doadaptleftskip#1% + {\dosetleftskipadaption{#1}% + \advance\leftskip \leftskipadaption} + +\def\doadaptrightskip#1% + {\dosetrightskipadaption{#1}% + \advance\rightskip \rightskipadaption} + +\setvalue{@lsa@\v!standard}{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} +\setvalue{@lsa@\v!yes }{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} +\letvalue{@lsa@\v!no }\zeropoint +\letvalue{@lsa@\empty }\zeropoint +\setvalue{@rsa@\v!standard}{\@@slright} +\setvalue{@rsa@\v!yes }{\@@slright} +\letvalue{@rsa@\v!no }\zeropoint +\letvalue{@rsa@\empty }\zeropoint + +\def\dosetleftskipadaption#1% + {\edefconvertedargument\ascii{@lsa@#1}% + \leftskipadaption + \ifcsname\ascii\endcsname + \csname\ascii\endcsname + \else + #1% + \fi + \relax} + +\def\dosetrightskipadaption#1% + {\edefconvertedargument\ascii{@rsa@#1}% + \rightskipadaption + \ifcsname\ascii\endcsname + \csname\ascii\endcsname + \else + #1% + \fi + \relax} + +%D Tolerance: + +\def\dosetuptolerance[#1]% + {\doifinsetelse\v!vertical{#1}% + {\normalexpanded{\noexpand\processallactionsinset[#1]} + [ \v!verystrict=>\def\bottomtolerance{}, + \v!strict=>\def\bottomtolerance{.050}, + \v!tolerant=>\def\bottomtolerance{.075}, + \v!verytolerant=>\def\bottomtolerance{.100}]}% + {\normalexpanded{\noexpand\processallactionsinset[#1]} + [ \v!stretch=>\emergencystretch\bodyfontsize, + \v!space=>\spaceskip.5em\!!plus.25em\!!minus.25em\relax, + \v!verystrict=>\tolerance 200, + \v!strict=>\tolerance1500, + \v!tolerant=>\tolerance3000, + \v!verytolerant=>\tolerance4500]}} + +\def\setuptolerance + {\dosingleargument\dosetuptolerance} + +%D \macros +%D {pushindentation,popindentation} +%D +%D The pushing and popping is done by: + +\newbox\indentationboxA +\newbox\indentationboxB + +\def\pushindentation + {\bgroup + \ifhmode + \unskip + \setbox\indentationboxA\lastbox % get \strut if present + \unskip + \setbox\indentationboxB\lastbox % get \indent generated box + \unskip + \else + \hskip\zeropoint % switch to horizontal mode + \unskip + \setbox\indentationboxA\lastbox % get \indent generated box + \setbox\indentationboxB\emptybox + \fi} + +\def\popindentation + {\box\indentationboxB\box\indentationboxA % put back the boxes + \egroup} + +%D The only complication lays in \type{\strut}. In \PLAIN\ +%D \TEX\ a \type{\strut} is defined as: +%D +%D \starttyping +%D \def\strut% +%D {\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} +%D \stoptyping +%D +%D But what is a \type{\strut}? Normally it's a rule of width +%D zero, but when made visual, it's a rule and a negative skip. +%D The mechanism for putting things in the margins described +%D here cannot handle this situation very well. One +%D characteristic of \type{\strut} is that the \type{\unhcopy} +%D results in entering horizontal mode, which in return leads +%D to some indentation. +%D +%D To serve our purpose a bit better, the macro \type{\strut} +%D can be redefined as: +%D +%D \starttyping +%D \def\strut +%D {\relax\ifmmode\else\hskip0pt\fi\copy\strutbox} +%D \stoptyping +%D +%D Or more compatible: +%D +%D \starttyping +%D \def\strut +%D {\relax\ifmmode +%D \copy\strutbox +%D \else +%D \bgroup\setbox\strutbox=\normalhbox{\box\strutbox}\unhcopy\strutbox\egroup +%D \fi} +%D \stoptyping +%D +%D In \CONTEXT\ however we save some processing time by putting +%D an extra \type{\hbox} around the \type{\strutbox}. + +% moved from page-lin.tex to here (due to visualization added +% in august 2003) +% +% \unexpanded \def\crlf +% {\ifhmode\unskip\else\strut\fi\ifcase\raggedstatus\hfil\fi\break} + +\unexpanded \def\crlf + {\ifhmode + \unskip + \prewordbreak\crlfplaceholder + \ifcase\raggedstatus\hfil\or\or\or\hfil\fi + \break + \else + \crlfplaceholder + \endgraf + \fi} + +\def\crlfplaceholder + {\strut} + +\def\settestcrlf + {\def\crlfplaceholder + {\hbox to \zeropoint + {\strut{\infofont\kern.25em}\lohi{\infofont CR}{\infofont LF}\hss}}} + +%D \starttyping +%D % \setuplayout[gridgrid=yes] \showgrid +%D +%D \startbuffer +%D test 1\crlf +%D test 2\crlf +%D +%D \crlf test 3 +%D +%D test 4\crlf +%D test 5 +%D +%D \crlf +%D \crlf +%D \crlf +%D test 6 +%D \stopbuffer +%D +%D \hbox +%D {\hsize5em +%D \ruledvtop{\getbuffer}\enspace +%D \ruledvtop{\showstruts\getbuffer}\enspace +%D \hsize15em \setuptyping[before=,after=]% +%D \ruledvtop{\typebuffer}} +%D \stoptyping + +\def\justonespace + {\removelastspace\space} % \removeunwantedspaces\space + +\def\ignorecrlf + {\let\crlf\justonespace\let\\\crlf} + +\def\definehspace + {\dotripleempty\dodefinehspace} + +\def\dodefinehspace[#1][#2][#3]% #1 = optional namespace + {\ifthirdargument + \setvalue{\??hs#1:#2}{#3}% + \else + \setvalue{\??hs:#1}{#2}% + \fi} + +\unexpanded\def\hspace + {\dodoubleempty\dohspace} + +\def\dohspace[#1][#2]% + {\ifsecondargument + \dodohspace[#1][#2]% + \else\iffirstargument + \hspace[][#1]% + \else + \hspace[][\s!default]% + \fi\fi} + +\def\dodohspace[#1][#2]% + {\ifhmode + \removeunwantedspaces + \hskip\hspaceamount{#1}{#2}% + \expandafter\ignorespaces + \fi} + +\def\hspaceamount#1#2% + {\executeifdefined{\??hs#1:#2}{\executeifdefined{\??hs:#2}\zeropoint}} + +\definehspace [\v!small] [.25\emspaceamount] +\definehspace [\v!medium] [.5\emspaceamount] +\definehspace [\v!big] [1\emspaceamount] +\definehspace [\v!normal] [1\spaceamount] +\definehspace [\v!default] [\spaceamount] + +%D Taken from Taco's math module (cq. \AMS\ macros), but +%D adapted to \type {\hspace}: + +\unexpanded\def\textormathspace #1#2#3{\ifmmode\mskip#1#2\else\kern #1\hspaceamount\empty{#3}\fi\relax} +\unexpanded\def\breakabletextormathspace#1#2#3{\ifmmode\mskip#1#2\else\hskip#1\hspaceamount\empty{#3}\fi\relax} + +\newmuskip\hairmuskip \hairmuskip=.15mu + +\unexpanded\def\hairspace {\textormathspace+\hairmuskip{.5}} +\unexpanded\def\thinspace {\textormathspace+\thinmuskip 1} +\unexpanded\def\medspace {\textormathspace+\medmuskip 2} +\unexpanded\def\thickspace {\textormathspace+\thickmuskip3} +\unexpanded\def\neghairspace {\textormathspace-\thinmuskip{.5}} +\unexpanded\def\negthinspace {\textormathspace-\thinmuskip 1} +\unexpanded\def\negmedspace {\textormathspace-\medmuskip 2} +\unexpanded\def\negthickspace{\textormathspace-\thickmuskip3} + +% needed for unicode: + +\unexpanded\def\breakablethinspace {\breakabletextormathspace+\thinmuskip 1} + +\unexpanded\def\twoperemspace {\hskip\dimexpr\emwidth/2\relax} % == \enspace +\unexpanded\def\threeperemspace {\hskip\dimexpr\emwidth/3\relax} +\unexpanded\def\fourperemspace {\hskip\dimexpr\emwidth/4\relax} +\unexpanded\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} % goodie +\unexpanded\def\sixperemspace {\hskip\dimexpr\emwidth/6\relax} +\unexpanded\def\figurespace {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this +\unexpanded\def\punctuationspace {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} +\unexpanded\def\ideographicspace {\hskip\dimexpr\emwidth/1\relax} +\unexpanded\def\ideographichalffillspace{\hskip\dimexpr\emwidth/2\relax} +%unexpanded\def\nobreakspace {\penalty\plustenthousand\space} +\unexpanded\def\nobreakspace {\penalty\plustenthousand\kern\interwordspace} +\unexpanded\def\narrownobreakspace {\penalty\plustenthousand\thinspace} +%unexpanded\def\zerowidthnobreakspace {\penalty\plustenthousand\hskip\zeropoint} +\unexpanded\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} +\unexpanded\def\zerowidthspace {\hskip\zeropoint} + +\definehspace[.5][.1250\emspaceamount] % could also be [.1250\spaceamount] +\definehspace[1] [.1667\emspaceamount] +\definehspace[2] [.2222\emspaceamount] +\definehspace[3] [.2777\emspaceamount] + +\let \, \thinspace +\let \: \medspace +\let \; \thickspace +\let \! \negthinspace + +\def\flexiblespaceamount#1#2#3% + {#1\interwordspace + \!!plus#2\interwordstretch + \!!minus#3\interwordshrink} + +\def\fixedspaceamount#1% + {#1\interwordspace} + +%D This is a dangerous feature because it makes the \TEX\ source +%D less portable, i.e. any parser now needs to apply exactly the +%D same algorithm when it wants to interpret the source. We +%D strongly recommend not to mention this feature in manuals! It's +%D provided for users who are hooked to such a mechanism. +%D +%D \starttyping +%D \setupsorting[logo][next=\autoinsertnextspace] \logo[TEX]{\TeX} +%D +%D bla bla \TEX bla bla \TEX (bla) bla (\TEX) +%D \stoptyping + +\def\autoinsertnextspace{\futurelet\nexttoken\doautoinsertnextspace} + +\def\doautoinsertnextspace % slightly extended version of a user supplied macro + {\ifx\nexttoken \bgroup\else \ifx\nexttoken\begingroup\else + \ifx\nexttoken \egroup\else \ifx\nexttoken \endgroup\else + \ifx\nexttoken \/\else \ifx\nexttoken /\else \ifx\nexttoken ~\else + \ifx\nexttoken \ \else \ifx\nexttoken \blankspace\else \ifx\nexttoken \space\else + \ifx\nexttoken .\else \ifx\nexttoken ,\else + \ifx\nexttoken !\else \ifx\nexttoken ?\else + \ifx\nexttoken :\else \ifx\nexttoken ;\else + \ifx\nexttoken '\else \ifx\nexttoken "\else + \ifx\nexttoken )\else \ifx\nexttoken -\else \ifx\nexttoken |\else + \ifx\nexttoken \%\else \ifx\nexttoken \&\else + \space + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} + +% moved from page-lin + +\def\installspacehandler#1#2% needs to set \obeyedspace + {\setvalue{\??sr#1}{#2}} + +\installspacehandler \v!on + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}% + \let\ =\obeyedspace} + +\installspacehandler \v!yes + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode \normalspace }}% + \let\ =\obeyedspace} + +\installspacehandler \v!off + {\normalspaces + \let\obeyedspace\normalspace + \let\ =\normalspace} + +\installspacehandler \v!fixed + {\obeyspaces + \def\obeyedspace{\mathortext\normalspace{\dontleavehmode\fixedspace}}% + \let\ =\obeyedspace} + +\def\activatespacehandler#1% + {\executeifdefined{\??sr#1}{\activatespacehandler\v!off}} + +\protect \endinput diff --git a/tex/context/base/spac-pag.mkiv b/tex/context/base/spac-pag.mkiv new file mode 100644 index 000000000..c32992351 --- /dev/null +++ b/tex/context/base/spac-pag.mkiv @@ -0,0 +1,201 @@ +%D \module +%D [ file=spac-pag, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Pages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Pages} + +\unprotect + +%D A quick way to determine left|/|middle|/|right states +%D (experimental). + +\setvalue{\??as\v!left }{0} +\setvalue{\??as\v!middle}{1} +\setvalue{\??as\v!right }{2} + +\def\setalignmentswitch#1% + {\chardef\alignmentswitch0\csname\??as#1\endcsname\relax} + +%D + +\newcount \noftrackedpagestates +\newif \ifpagestatemismatch +\newcount \realpagestateno +\chardef \frozenpagestate \zerocount + +\def\dotrackpagestate#1#2% + {\ifdoublesided \ifinpagebody \else + \doforcedtrackpagestate{#1}{#2}% + \fi \fi} + +\def\doforcedtrackpagestate#1#2% + {\ifcase\frozenpagestate + \global\advance\noftrackedpagestates\plusone + \global\advance#2\plusone + \lazysavetaggedtwopassdata{#1}{\number\noftrackedpagestates}{\number#2}{\noexpand\realfolio}% + %\llap{\infofont\number\noftrackedpagestates/\number#2}% tracing + \fi} + +\def\doifrightpagestateelse#1#2% + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \ifinpagebody + \ifdoublesided + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \twopassdatafoundtrue + \fi + \else\ifdoublesided + \findtwopassdata{#1}{\number#2}% + \iftwopassdatafound + \realpagestateno\twopassdata\relax + \ifnum\twopassdata=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\twopassdata\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \else + \twopassdatafoundtrue + \fi\fi + \else + \ifodd\realpagestateno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \iftwopassdatafound + \@EA\firstoftwoarguments + \else + \@EA\secondoftwoarguments + \fi} + +\def\doifforcedrightpagestateelse#1#2% + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \findtwopassdata{#1}{\number#2}% + \iftwopassdatafound + \realpagestateno\twopassdata\relax + \ifnum\twopassdata=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\twopassdata\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \else + \ifodd\realpageno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \else + \ifodd\realpagestateno\relax + \twopassdatafoundtrue \else \twopassdatafoundfalse + \fi + \fi + \iftwopassdatafound + \@EA\firstoftwoarguments + \else + \@EA\secondoftwoarguments + \fi} + +\def\freezepagestate {\chardef\frozenpagestate\plusone } +\def\defrostpagestate{\chardef\frozenpagestate\zerocount} + +% we can make more of these on top, but how to deal with mixed frozen states + +\definetwopasslist\s!paragraph \newcount \nofraggedparagraphs + +\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} +\def\doifrightpageelse{\doifrightpagestateelse\s!paragraph\nofraggedparagraphs} + +\newcount\pagesignallevel + +\def\startsignalrightpage % one may do a \postsignalrightplace + {\advance\pagesignallevel\plusone + \presignalrightpage + \let\signalrightpage\relax + \let\presignalrightpage\relax + \let\startsignalrightpage\relax + \doifrightpageelse\donothing\donothing + \freezepagestate} + +\def\stopsignalrightpage + {\ifcase\pagesignallevel\or\postsignalrightpage\fi + \advance\pagesignallevel\minusone} + +\def\setraggedparagraphmode + {\signalrightpage\doifrightpageelse} % move it there + +\ifx\swapmargins\undefined \let\swapmargins\undefined \fi % todo + +\def\doifswappedrightpageelse#1#2% alleen in box construction ! + {\doifrightpageelse + {#1} + {\scratchcounter\realpageno + \realpageno\realpagestateno\relax + \swapmargins + \realpageno\scratchcounter + #2}} + +\newbox\signaledrightpage % this way we can avoid interference, i.e. postpone placement + +\def\presignalrightpage {\global\setbox\signaledrightpage\hbox{\signalrightpage}} +\def\postsignalrightpage{\ifvoid\signaledrightpage\else\box\signaledrightpage\fi} + +% The next feature is is used in: +% +% \definenumber[test][way=bypage] +% +% \def\Test +% {\incrementnumber[test]\rawnumber[test]/% +% \incrementnumber[test]\rawnumber[test]/% +% \incrementnumber[test]\rawnumber[test]\space +% \checkpagechange{oeps}\changedpage{oeps}\space +% \ifpagechanged TRUE\else FALSE\fi} +% +% \Test\page \Test\par \Test\page \Test\par \Test\page \Test\page +% +% (adapted from cont-new.tex:) + +\newif\ifpagechanged \let\lastchangedpage\empty + +\def\docheckpagestatechange#1#2#3% + {\pagechangedfalse + \doforcedtrackpagestate{#2}{#3}% + \findtwopassdata{#2}{\number#3}% + \iftwopassdatafound + \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax + \pagechangedtrue + \fi + \fi + \ifpagechanged + \letgvalue{#2:p:#1}\twopassdata + \globallet\lastchangedpage\twopassdata + \else + \globallet\lastchangedpage\realfolio + \fi} + +\def\changedpagestate#1#2% + {\executeifdefined{#2:p:#1}{0}} + +\def\checkpagechange#1{\docheckpagestatechange{#1}\s!paragraph\nofraggedparagraphs} +\def\changedpage #1{\changedpagestate{#1}\s!paragraph} + +\protect \endinput diff --git a/tex/context/base/spac-par.mkiv b/tex/context/base/spac-par.mkiv new file mode 100644 index 000000000..92ea945f7 --- /dev/null +++ b/tex/context/base/spac-par.mkiv @@ -0,0 +1,206 @@ +%D \module +%D [ file=spac-par, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Paragraphs, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Paragraphs} + +\unprotect + + +%D The dreadful sequence \type {\bgroup} \unknown\ +%D \type {\carryoverpar} \unknown\ \type {\egroup} is needed +%D when for instance sidefloats are used in combination with +%D something that starts with a group. This is because +%D otherwise the indentation as set (by the output routine) +%D inside the group are forgotten afterwards. (I must +%D not forget its existence). + +\global\let\carriedoverpar\relax + +\def\carryoverpar#1% + {\normalexpanded % \scratchtoks{#1}% + {\noexpand#1% \the\scratchtoks + \hangindent\the\hangindent + \hangafter \the\hangafter + \parskip \the\parskip + \leftskip \the\leftskip + \rightskip \the\rightskip}} + + +\newconditional \parbasedattributes + +\def\finishparbasedattributes + {\ifconditional\parbasedattributes + \setfalse\parbasedattributes + \par + \fi} + +\def\dostopparbasedattributes + {\settrue\parbasedattributes + \dostopattributes} + +% beware, changing this will break some code (like pos/backgrounds) + +\newtoks\everyfirstparagraphintro +\newtoks\everynextparagraphintro +\newtoks\@@everyparagraphtoks + +\chardef\everyparagraphintro\zerocount + +\def\setupparagraphintro + {\dodoubleempty\dosetupparagraphintro} + +\def\dosetupparagraphintro[#1][#2]% + {\processallactionsinset + [#1] + [ \v!reset=>\global\chardef\everyparagraphintro\zerocount + \global\everyfirstparagraphintro\emptytoks + \global\everynextparagraphintro \emptytoks, + \v!first=>\global\chardef\everyparagraphintro\plusone + \doglobal\appendtoks#2\to\everyfirstparagraphintro, + \v!next=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plusone\fi + \doglobal\appendtoks#2\to\everynextparagraphintro, + \v!each=>\ifcase\everyparagraphintro\global\chardef\everyparagraphintro\plustwo\fi + \doglobal\appendtoks#2\to\everyfirstparagraphintro + \doglobal\appendtoks#2\to\everynextparagraphintro]} + +%D We can say: +%D +%D \starttyping +%D \setupparagraphintro[first][\index{Knuth}] +%D \stoptyping +%D +%D Maybe more convenient is: +%D +%D \starttyping +%D \flushatparagraph{\index{Zapf}} +%D \stoptyping + +\def\flushatparagraph#1% + {\global\chardef\everyparagraphintro\plusone + \global\appendtoks{#1}\to\everyfirstparagraphintro + \global\let\insertparagraphintro\doinsertparagraphintro} + +\def\doinsertparagraphintro % can be merged with the next + {\ifcase\everyparagraphintro\else\@EA\dodoinsertparagraphintro\fi} + +\def\dodoinsertparagraphintro + {\begingroup + \everypar\emptytoks + \ifcase\everyparagraphintro\relax + % no data + \@@everyparagraphtoks\emptytoks + \or + % first data + \global\chardef\everyparagraphintro\plustwo + \@@everyparagraphtoks\everyfirstparagraphintro + \global\everyfirstparagraphintro\emptytoks + \or + % next data + \@@everyparagraphtoks\everynextparagraphintro + \fi + \the\@@everyparagraphtoks + \global\let\insertparagraphintro\relax + \endgroup} + +\let\insertparagraphintro\relax + +%D \starttyping +%D \setupparagraphintro[first][\hbox to 3.5em{\tt FIRST \hss}] +%D \setupparagraphintro[first][\hbox to 3.5em{\tt TSRIF \hss}] +%D \setupparagraphintro[next] [\hbox to 3.5em{\tt NEXT \hss}] +%D \setupparagraphintro[next] [\hbox to 3.5em{\tt TXEN \hss}] +%D \setupparagraphintro[each] [\hbox to 3.0em{\tt EACH \hss}] +%D \setupparagraphintro[each] [\hbox to 3.0em{\tt HCEA \hss}] +%D +%D some paragraph \par +%D some paragraph \par +%D some paragraph \par +%D +%D \definelabel[parnumber] +%D +%D \setupparagraphintro[reset,each][\inleft{\slxx\parnumber}] +%D +%D some paragraph \par +%D some paragraph \par +%D some paragraph \par +%D \stoptyping + +%D \macros +%D {flushatnextpar} +%D +%D This macro collects data that will be flushed at the next paragraph. +%D By using this macro you can avoid interfering nodes (writes, etc). + +\newbox\postponednodedata +\let\flushpostponednodedata\relax + +\def\flushatnextpar + {\bgroup + \global\let\flushpostponednodedata\doflushpostponednodedata + \dowithnextbox{\global\setbox\postponednodedata\hbox{\box\postponednodedata\box\nextbox}\egroup}\hbox} + +\def\doflushpostponednodedata + {\ifvoid\postponednodedata\else + \hbox{\smashedbox\postponednodedata}% + \fi + \global\let\flushpostponednodedata\relax} + +% Very nasty but needed for margin stuff inside colored +% paragraphs. + +\let\normalvadjust\vadjust + +% \def\graphicvadjust % bad, those low level color calls here +% {\dowithnextboxcontent +% {\forgetall} +% {\normalvadjust +% {\unvbox\nextbox +% % corrects for one line paragraphs +% \nointerlineskip +% \kern-\struttotal +% \nointerlineskip +% \verticalstrut}}% +% \vbox} + +\def\graphicvadjust % nasty bidi handling + {\dowithnextboxcontent + {\forgetall} + {\vadjust{\vbox attr \graphicvadjustattribute \plusone + {\unvbox\nextbox + % corrects for one line paragraphs + \nointerlineskip + \kern-\struttotal + \nointerlineskip + \verticalstrut}}}% + \vbox} + +%D This works only in a properly strutted line, and is meant +%D for deeply burried operations, like in heads. + +\def\fakedvadjust + {\dowithnextbox + {\setbox\nextbox\hbox{\llap{\lower\strutdepth\box\nextbox}}% + \smashedbox\nextbox}% + \vtop} + +\def\localvbox#1#% + {\vbox#1\bgroup + \forgetparskip + \setlocalhsize + \hsize\localhsize + \forgetparindent + \forgetbothskips + \forgeteverypar + \let\next=} + +\protect \endinput diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua new file mode 100644 index 000000000..16291df27 --- /dev/null +++ b/tex/context/base/spac-ver.lua @@ -0,0 +1,732 @@ +if not modules then modules = { } end modules ['spac-ver'] = { + version = 1.001, + comment = "companion to spac-ver.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- this code dates from the beginning and is kind of experimental; it +-- will be optimized and improved soon + +local next, type = next, type +local format, gmatch, concat = string.format, string.gmatch, table.concat +local texsprint, texlists = tex.sprint, tex.lists + +local ctxcatcodes = tex.ctxcatcodes +local variables = interfaces.variables + +local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming + +-- vertical space handler + +local trace_vbox_vspacing = false trackers.register("nodes.vbox_vspacing", function(v) trace_vbox_vspacing = v end) +local trace_page_vspacing = false trackers.register("nodes.page_vspacing", function(v) trace_page_vspacing = v end) +local trace_collect_vspacing = false trackers.register("nodes.collect_vspacing", function(v) trace_collect_vspacing = v end) +local trace_vspacing = false trackers.register("nodes.vspacing", function(v) trace_vspacing = v end) + +local skip_category = attributes.private('skip-category') +local skip_penalty = attributes.private('skip-penalty') +local skip_order = attributes.private('skip-order') +local snap_category = attributes.private('snap-category') +local display_math = attributes.private('display-math') + +local has_attribute = node.has_attribute +local unset_attribute = node.unset_attribute +local set_attribute = node.set_attribute +local find_node_tail = node.tail +local free_node = node.free +local copy_node = node.copy +local traverse_nodes = node.traverse +local insert_node_before = node.insert_before +local insert_node_after = node.insert_after +local remove_node = nodes.remove +local make_penalty_node = nodes.penalty +local count_nodes = nodes.count +local node_ids_to_string = nodes.ids_to_string +local hpack_node = node.hpack + +local glyph = node.id("glyph") +local penalty = node.id("penalty") +local kern = node.id("kern") +local glue = node.id('glue') +local hlist = node.id('hlist') +local vlist = node.id('vlist') +local adjust = node.id('adjust') + +vspacing = vspacing or { } + +vspacing.categories = { + [0] = 'discard', + [1] = 'largest', + [2] = 'force' , + [3] = 'penalty', + [4] = 'add' , + [5] = 'disable', + [6] = 'nowhite', + [7] = 'goback', +} + +local categories = vspacing.categories + +function vspacing.tocategories(str) + local t = { } + for s in gmatch(str,"[^, ]") do + local n = tonumber(s) + if n then + t[categories[n]] = true + else + t[b] = true + end + end + return t +end + +function vspacing.tocategory(str) + if type(str) == "string" then + return set.tonumber(vspacing.tocategories(str)) + else + return set.tonumber({ [categories[str]] = true }) + end +end + +vspacing.data = vspacing.data or { } +vspacing.data.map = vspacing.data.map or { } +vspacing.data.skip = vspacing.data.skip or { } + +storage.register("vspacing/data/map", vspacing.data.map, "vspacing.data.map") +storage.register("vspacing/data/skip", vspacing.data.skip, "vspacing.data.skip") + +do -- todo: interface.variables + + local function logger(c,s) + logs.report("vspacing",s) + texsprint(c,s) + end + + vspacing.fixed = false + + local map = vspacing.data.map + local skip = vspacing.data.skip + + local multiplier = lpeg.C(lpeg.S("+-")^0 * lpeg.R("09")^1) * lpeg.P("*") + local category = lpeg.P(":") * lpeg.C(lpeg.P(1)^1) + local keyword = lpeg.C((1-category)^1) + local splitter = (multiplier + lpeg.Cc(1)) * keyword * (category + lpeg.Cc(false)) + + local k_fixed, k_flexible, k_category, k_penalty, k_order = variables.fixed, variables.flexible, "category", "penalty", "order" + + local function analyse(str,oldcategory,texsprint) +--~ print(table.serialize(map)) +--~ print(table.serialize(skip)) + for s in gmatch(str,"([^ ,]+)") do + local amount, keyword, detail = splitter:match(s) + if not keyword then + logs.report("vspacing","unknown directive: %s",s) + else + local mk = map[keyword] + if mk then + category = analyse(mk,category,texsprint) + elseif keyword == k_fixed then + texsprint(ctxcatcodes,"\\fixedblankskip") + elseif keyword == k_flexible then + texsprint(ctxcatcodes,"\\flexibleblankskip") + elseif keyword == k_category then + local category = tonumber(detail) + if category then + texsprint(ctxcatcodes,format("\\setblankcategory{%s}",category)) + if category ~= oldcategory then + texsprint(ctxcatcodes,"\\flushblankhandling") + oldcategory = category + end + end + elseif keyword == k_order and detail then + local order = tonumber(detail) + if order then + texsprint(ctxcatcodes,format("\\setblankorder{%s}",order)) + end + elseif keyword == k_penalty and detail then + local penalty = tonumber(detail) + if penalty then + texsprint(ctxcatcodes,format("\\setblankpenalty{%s}",penalty)) + texsprint(ctxcatcodes,"\\flushblankhandling") + end + else + amount = tonumber(amount) or 1 + local sk = skip[keyword] + if sk then + texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,sk[1],sk[2] or sk[1])) + else -- no check + texsprint(ctxcatcodes,format("\\addblankskip{%s}{%s}{%s}",amount,keyword,keyword)) + end + end + end + end + return category + end + + function vspacing.analyse(str) + local texsprint = (trace_vspacing and logger) or texsprint + texsprint(ctxcatcodes,"\\startblankhandling") + analyse(str,1,texsprint) + texsprint(ctxcatcodes,"\\stopblankhandling") + end + + -- + + function vspacing.setmap(from,to) + map[from] = to + end + + function vspacing.setskip(key,value,grid) + if value ~= "" then + if grid == "" then grid = value end + skip[key] = { value, grid } + end + end + +end + +-- implementation + +nodes.snapvalues = { } + +function nodes.setsnapvalue(n,ht,dp) + nodes.snapvalues[n] = { ht, dp, ht+dp } +end + +local trace_list, tracing_info, before, after = { }, false, "", "" + +local function glue_to_string(glue) + local spec = glue.spec + if spec then + local t = { } + t[#t+1] = aux.strip_zeros(number.topoints(spec.width)) + if spec.stretch_order and spec.stretch_order ~= 0 then + t[#t+1] = format("plus -%sfi%s",spec.stretch/65536,string.rep("l",math.abs(spec.stretch_order)-1)) + elseif spec.stretch and spec.stretch ~= 0 then + t[#t+1] = format("plus %s",aux.strip_zeros(number.topoints(spec.stretch))) + end + if spec.shrink_order and spec.shrink_order ~= 0 then + t[#t+1] = format("minus -%sfi%s",spec.shrink/65536,string.rep("l",math.abs(spec.shrink_order)-1)) + elseif spec.shrink and spec.shrink ~= 0 then + t[#t+1] = format("minus %s",aux.strip_zeros(number.topoints(spec.shrink))) + end + return concat(t," ") + else + return "[0pt]" + end +end + +local function nodes_to_string(head) + local current, t = head, { } + while current do + local id = current.id + local ty = node.type(id) + if id == penalty then + t[#t+1] = format("%s:%s",ty,current.penalty) + elseif id == glue then + if current.spec then + t[#t+1] = format("%s:%s",ty,aux.strip_zeros(number.topoints(current.spec.width))) + else + t[#t+1] = format("%s:[0pt]",ty) + end + elseif id == kern then + t[#t+1] = format("%s:%s",ty,aux.strip_zeros(number.topoints(current.kern))) + else + t[#t+1] = ty + end + current = current.next + end + return concat(t," + ") +end + +local function reset_tracing(head) + trace_list, tracing_info, before, after = { }, false, nodes_to_string(head), "" +end + +local function trace_skip(str,sc,so,sp,data) + trace_list[#trace_list+1] = { "skip", format("%s | %s | category %s | order %s | penalty %s", str, glue_to_string(data), sc or "-", so or "-", sp or "-") } + tracing_info = true +end + +local function trace_natural(str,data) + trace_list[#trace_list+1] = { "skip", format("%s | %s", str, glue_to_string(data)) } + tracing_info = true +end + +local function trace_info(message, where, what) + trace_list[#trace_list+1] = { "info", format("%s: %s/%s",message,where,what) } +end + +local function trace_node(what) + local nt = node.type(what.id) + local tl = trace_list[#trace_list] + if tl[1] == "node" then + trace_list[#trace_list] = { "node", tl[2] .. " + " .. nt } + else + trace_list[#trace_list+1] = { "node", nt } + end +end + +local function trace_done(str,data) + if data.id == penalty then + trace_list[#trace_list+1] = { "penalty", format("%s | %s", str, data.penalty) } + else + trace_list[#trace_list+1] = { "glue", format("%s | %s", str, glue_to_string(data)) } + end + tracing_info = true +end + +local function show_tracing(head) + if tracing_info then + after = nodes_to_string(head) + for i=1,#trace_list do + local tag, text = unpack(trace_list[i]) + if tag == "info" then + logs.report("collapse",text) + else + logs.report("collapse"," %s: %s",tag,text) + end + end + logs.report("collapse","before: %s",before) + logs.report("collapse","after : %s",after) + end +end + +-- alignment box begin_of_par vmode_par hmode_par insert penalty before_display after_display + +local user_skip = 0 +local line_skip = 1 +local baseline_skip = 2 +local par_skip = 3 +local above_display_skip = 4 +local below_display_skip = 5 +local above_display_short_skip = 6 +local below_display_short_skip = 7 +local left_skip_code = 8 +local right_skip_code = 9 +local top_skip_code = 10 +local split_top_skip_code = 11 +local tab_skip_code = 12 +local space_skip_code = 13 +local xspace_skip_code = 14 +local par_fill_skip_code = 15 +local thin_mu_skip_code = 16 +local med_mu_skip_code = 17 +local thick_mu_skip_code = 18 + +local skips = { + [ 0] = "user_skip", + [ 1] = "line_skip", + [ 2] = "baseline_skip", + [ 3] = "par_skip", + [ 4] = "above_display_skip", + [ 5] = "below_display_skip", + [ 6] = "above_display_short_skip", + [ 7] = "below_display_short_skip", + [ 8] = "left_skip_code", + [ 9] = "right_skip_code", + [10] = "top_skip_code", + [11] = "split_top_skip_code", + [12] = "tab_skip_code", + [13] = "space_skip_code", + [14] = "xspace_skip_code", + [15] = "par_fill_skip_code", + [16] = "thin_mu_skip_code", + [17] = "med_mu_skip_code", + [18] = "thick_mu_skip_code", +} + +local free_glue_node = free_node +local free_glue_spec = free_node +local discard, largest, force, penalty, add, disable, nowhite, goback = 0, 1, 2, 3, 4, 5, 6, 7 + +local function collapser(head,where,what,trace) -- maybe also pass tail + if trace then + reset_tracing(head) + trace_info("start analyzing",where,what) + end + local current = head + local glue_order, glue_data = 0, nil + local penalty_order, penalty_data, natural_penalty = 0, nil, nil + local parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false + while current do + local id = current.id -- has each node a subtype ? + if id == glue and current.subtype == 0 then -- todo, other subtypes, like math + local sc = has_attribute(current,skip_category) -- has no default, no unset (yet) + local so = has_attribute(current,skip_order ) or 1 -- has 1 default, no unset (yet) + local sp = has_attribute(current,skip_penalty ) -- has no degault, no unset (yet) + if not sc then + if glue_data then + if trace then trace_done("flush",glue_data) end + head, current = nodes.before(head,current,glue_data) + if trace then trace_natural("natural",current) end + else + -- not look back across head + local previous = current.prev + if previous and previous.id == glue and previous.subtype == 0 then + local ps = previous.spec + if ps then + local cs = current.spec + if cs and ps.stretch_order == 0 and ps.shrink_order == 0 and cs.stretch_order == 0 and cs.shrink_order == 0 then + local pw, pp, pm = ps.width, ps.stretch, ps.shrink + local cw, cp, cm = cs.width, cs.stretch, cs.shrink + ps.width, ps.stretch, ps.shrink = pw + cw, pp + cp, pm + cm + if trace then trace_natural("removed",current) end + head, current = remove_node(head, current, true) + current = previous + if trace then trace_natural("collapsed",current) end + else + if trace then trace_natural("filler",current) end + end + else + if trace then trace_natural("natural (no prev spec)",current) end + end + else + if trace then trace_natural("natural (no prev)",current) end + end + end + glue_order, glue_data = 0, nil + if current then + current = current.next + end + else + if sc == disable then + ignore_following = true + if trace then trace_skip("disable",sc,so,sp,current) end + head, current = remove_node(head, current, true) + elseif sc == nowhite then + ignore_whitespace = true + head, current = remove_node(head, current, true) + elseif sc == discard then + if trace then trace_skip("discard",sc,so,sp,current) end + head, current = remove_node(head, current, true) + else + if sp then + if not penalty_data then + penalty_data = sp + elseif penalty_order < so then + penalty_order, penalty_data = so, sp + elseif penalty_order == so and sp > penalty_data then + penalty_data = sp + end + end + if ignore_following then + if trace then trace_skip("disabled",sc,so,sp,current) end + head, current = remove_node(head, current, true) + elseif not glue_data then + if trace then trace_skip("assign",sc,so,sp,current) end + glue_order = so + head, current, glue_data = remove_node(head, current) + elseif glue_order < so then + if trace then trace_skip("force",sc,so,sp,current) end + glue_order = so + free_glue_node(glue_data) + head, current, glue_data = remove_node(head, current) + elseif glue_order == so then + -- is now exclusive, maybe support goback as combi, else why a set + if sc == largest then + local cs, gs = current.spec, glue_data.spec + local cw = (cs and cs.width) or 0 + local gw = (gs and gs.width) or 0 + if cw > gw then + if trace then trace_skip('largest',sc,so,sp,current) end + free_glue_node(glue_data) -- also free spec + head, current, glue_data = remove_node(head, current) + else + if trace then trace_skip('remove smallest',sc,so,sp,current) end + head, current = remove_node(head, current, true) + end + elseif sc == goback then + if trace then trace_skip('goback',sc,so,sp,current) end + free_glue_node(glue_data) -- also free spec + head, current, glue_data = remove_node(head, current) + elseif sc == force then + -- todo: inject kern + if trace then trace_skip('force',sc,so,sp,current) end + free_glue_node(glue_data) -- also free spec + head, current, glue_data = remove_node(head, current) + elseif sc == penalty then + if trace then trace_skip('penalty',sc,so,sp,current) end + free_glue_node(glue_data) -- also free spec + glue_data = nil + head, current = remove_node(head, current, true) + elseif sc == add then + if trace then trace_skip('add',sc,so,sp,current) end + local old, new = glue_data.spec, current.spec + old.width = old.width + new.width + old.stretch = old.stretch + new.stretch + old.shrink = old.shrink + new.shrink + -- toto: order + head, current = remove_node(head, current, true) + else + if trace then trace_skip("unknown",sc,so,sp,current) end + head, current = remove_node(head, current, true) + end + else + if trace then trace_skip("unknown",sc,so,sp,current) end + head, current = remove_node(head, current, true) + end + end + end + elseif id == penalty then + --~ natural_penalty = current.penalty + --~ if trace then trace_done("removed penalty",current) end + --~ head, current = remove_node(head, current, true) + current = current.next + elseif id == glue and current.subtype == 2 then + local sn = has_attribute(current,snap_category) + if sn then + -- local sv = nodes.snapvalues[sn] + -- if sv then + if trace then trace_natural("removed baselineskip",current) end + head, current = remove_node(head, current, true) + -- else + -- current = current.next + -- end + else + if trace then trace_natural("keep baselineskip",current) end + current = current.next + end + elseif id == glue and current.subtype == 3 then + -- parskip always comes later + if ignore_whitespace then + if trace then trace_natural("ignored parskip",current) end + head, current = remove_node(head,current,true) + elseif glue_data then + local ps, gs = current.spec, glue_data.spec + if ps and gs and ps.width > gs.width then + -- free_glue_spec(glue_data.spec) -- result in double free + glue_data.spec = copy_node(ps) + if trace then trace_natural("taking parskip",current) end + else + if trace then trace_natural("removed parskip",current) end + end + head, current = remove_node(head, current,true) + else + if trace then trace_natural("honored parskip",current) end + head, current, glue_data = remove_node(head, current) + end + --~ if trace then trace_natural("removed parskip",current) end + --~ current.spec = nil + --~ current = current.next + else +-- reversed + if penalty_data then + local p = make_penalty_node(penalty_data) + if trace then trace_done("flushed",p) end + head, current = insert_node_before(head,current,p) + -- penalty_data = nil + end + if glue_data then + if trace then trace_done("flushed",glue_data) end + head, current = insert_node_before(head,current,glue_data) + -- glue_order, glue_data = 0, nil + end + if trace then trace_node(current) end + if id == hlist and where == 'hmode_par' then + local list = current.list + if list then + local sn = has_attribute(list,snap_category) + if sn then + local sv = nodes.snapvalues[sn] + if sv then + local height, depth, lineheight = sv[1], sv[2], sv[3] + -- is math.ceil really needed? + current.height = math.ceil((current.height-height)/lineheight)*lineheight + height + current.depth = math.ceil((current.depth -depth )/lineheight)*lineheight + depth + end + end + end + end + glue_order, glue_data = 0, nil + penalty_order, penalty_data, natural_penalty = 0, nil, nil + parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false + current = current.next + end + end + if trace then trace_info("stop analyzing",where,what) end + --~ if natural_penalty and (not penalty_data or natural_penalty > penalty_data) then + --~ penalty_data = natural_penalty + --~ end + if trace and (glue_data or penalty_data) then + trace_info("start flushing",where,what) + end + local tail + if penalty_data then + tail = find_node_tail(head) + local p = make_penalty_node(penalty_data) + if trace then trace_done("result",p) end + head, tail = insert_node_after(head,tail,p) + end + if glue_data then + if not tail then tail = find_node_tail(head) end + if trace then trace_done("result",glue_data) end + head, tail = insert_node_after(head,tail,glue_data) + end + if trace then + if glue_data or penalty_data then + trace_info("stop flushing",where,what) + end + show_tracing(head) + end + return head, true +end + +-- alignment after_output end box new_graf vmode_par hmode_par insert penalty before_display after_display +-- \par -> vmode_par +-- +-- status.best_page_break +-- tex.lists.best_page_break +-- tex.lists.best_size (natural size to best_page_break) +-- tex.lists.least_page_cost (badness of best_page_break) +-- tex.lists.page_head +-- tex.lists.contrib_head + +local stackhead, stacktail, stackhack = nil, nil, false + +local function report(message,lst) + logs.report("vspacing",message,count_nodes(lst,true),node_ids_to_string(lst)) +end + +function nodes.handle_page_spacing(where) + local newhead = texlists.contrib_head + if newhead then + starttiming(vspacing) + local newtail = find_node_tail(newhead) + local flush = false + for n in traverse_nodes(newhead) do -- we could just look for glue nodes + local id = n.id + if id == glue then + if n.subtype == 0 then + if has_attribute(n,skip_category) then + stackhack = true + else + flush = true + end + else + -- tricky + end + else + flush = true + end + end + if flush then + if stackhead then + if trace_collect_vspacing then report("appending %s nodes to stack (final): %s",newhead) end + stacktail.next = newhead + newhead.prev = stacktail + newhead = stackhead + stackhead, stacktail = nil, nil + end + if stackhack then + stackhack = false + if trace_collect_vspacing then report("processing %s nodes: %s",newhead) end + texlists.contrib_head = collapser(newhead,"page",where,trace_page_vspacing) + else + if trace_collect_vspacing then report("flushing %s nodes: %s",newhead) end + texlists.contrib_head = newhead + end + else + if stackhead then + if trace_collect_vspacing then report("appending %s nodes to stack (intermediate): %s",newhead) end + stacktail.next = newhead + newhead.prev = stacktail + else + if trace_collect_vspacing then report("storing %s nodes in stack (initial): %s",newhead) end + stackhead = newhead + end + stacktail = newtail + texlists.contrib_head = nil + end + stoptiming(vspacing) + end +end + +local ignore = table.tohash { + "split_keep", + "split_off", + -- "vbox", +} + +function nodes.handle_vbox_spacing(head,where) + if head and not ignore[where] and head.next then + starttiming(vspacing) + head = collapser(head,"vbox",where,trace_vbox_vspacing) + stoptiming(vspacing) + end + return head +end + +statistics.register("v-node processing time", function() + if statistics.elapsedindeed(vspacing) then + return format("%s seconds", statistics.elapsedtime(vspacing)) + end +end) + +-- these are experimental callback definitions that definitely will +-- be moved elsewhere as part of a chain of vnode handling + +function vspacing.enable() + callback.register('vpack_filter', nodes.handle_vbox_spacing) -- enabled per 2009/10/16 + callback.register('buildpage_filter', nodes.handle_page_spacing) +end + +function vspacing.disable() + callback.register('vpack_filter', nil) + callback.register('buildpage_filter', nil) +end + +vspacing.enable() + +-- we will split this module hence the locals + +local attribute = attributes.private('graphicvadjust') + +local hlist = node.id('hlist') +local vlist = node.id('vlist') + +local remove_node = nodes.remove +local hpack_node = node.hpack +local has_attribute = node.has_attribute + +function nodes.repackage_graphicvadjust(head,groupcode) -- we can make an actionchain for mvl only + if groupcode == "" then -- mvl only + local h, p, done = head, nil, false + while h do + local id = h.id + if id == hlist or id == vlist then + local a = has_attribute(h,attribute) + if a then + if p then + local n + head, h, n = remove_node(head,h) + local pl = p.list + if n.width ~= 0 then + n = hpack_node(n,0,'exactly') + end + if pl then + pl.prev = n + n.next = pl + end + p.list = n + done = true + else + -- can't happen + end + else + p = h + h = h.next + end + else + h = h.next + end + end + return head, done + else + return head, false + end +end + +--~ tasks.appendaction("finalizers", "lists", "nodes.repackage_graphicvadjust") diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv new file mode 100644 index 000000000..8e612579d --- /dev/null +++ b/tex/context/base/spac-ver.mkiv @@ -0,0 +1,1485 @@ +%D \module +%D [ file=spac-ver, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Vertical, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Vertical} + +\unprotect + +\registerctxluafile{spac-ver}{1.001} + +\newskip\blankskip \blankskip=\bigskipamount + +\def\skipfactor {.75} +\def\skipgluefactor{.25} + +\def\normalskipamount + {\openlineheight + \ifgridsnapping \else \ifblankflexible + \!!plus \skipgluefactor\openlineheight + \!!minus\skipgluefactor\openlineheight + \fi \fi + \relax} + +\def\linedistance {\normalskipamount} +\def\appliedblankskip{\skipfactor\linedistance} +\def\lastblankskip {\blankskip} +\def\currentblank {\v!big} +\def\oldprevdepth {\prevdepth} +\def\newprevdepth {-1001pt} +\def\mindimen {1sp} % was: 0.00002pt + +%D There are two ways to influence the interline spacing. The +%D most general and often most consistent way is using +%D +%D \showsetup{setupinterlinespace} +%D +%D For instance +%D +%D \starttyping +%D \setupinterlinespace[line=2.8ex] +%D \stoptyping +%D +%D This setting adapts itself to the bodyfontsize, while for +%D instance saying +%D +%D \starttyping +%D \setupinterlinespace[line=12pt] +%D \stoptyping +%D +%D sets things fixed for all sizes, which is definitely not +%D what we want. Therefore one can also say: +%D +%D \starttyping +%D \definebodyfontenvironment[9pt][interlinespace=11pt] +%D \stoptyping +%D +%D One can still use \type{\setupinterlinespace} (without +%D arguments) to set the interline space according to the +%D current font, e.g. a \type{\bfa}. + +\newif\iflocalinterlinespace + +% font-ini + +\ifx\bodyfontinterlinespecs\undefined + + \let\bodyfontinterlinespecs\empty + \let\bodyfontinterlinespace\empty + +\fi + +\def\presetnormallineheight + {\edef\normallineheight{\@@itline}% +% done elsewhere : \spacing\!!plusone % new per 10/08/2004, else problems in otr / !! needed + \iflocalinterlinespace \else + \doifdefined\bodyfontinterlinespecs + {\doifsomething\bodyfontinterlinespace + {\edef\normallineheight{\bodyfontinterlinespace}}}% + \fi} + +\def\setupspecifiedinterlinespace[#1]% + {\getparameters[\??it][#1]% + \scratchdimen0\@@itheight\points + \advance\scratchdimen 0\@@itdepth\points + \ifdim\scratchdimen>\onepoint + \showmessage\m!layouts{10}{\@@itheight,\@@itdepth}% + \let\@@itheight\strutheightfactor + \let\@@itdepth \strutdepthfactor + \else + \let\strutheightfactor\@@itheight + \let\strutdepthfactor \@@itdepth + \fi + \let\minimumstrutheight \@@itminheight + \let\minimumstrutdepth \@@itmindepth + \let\minimumlinedistance\@@itdistance + \let\normallineheight \@@itline % let ! ! ! ! ! ivm ex + \doifelse\@@ittop\v!height % new, topskip does more bad than good + {\let\topskipfactor \@@itheight} + {\let\topskipfactor \@@ittop }% + \let\maxdepthfactor \@@itbottom + \let\baselinegluefactor \@@itstretch + \setfontparameters % redundant, can be \setstrut, test first + \updateraggedskips} % yes indeed + +\let\currentrelativeinterlinespace\empty + +\def\setuprelativeinterlinespace[#1]% + {\processallactionsinset + [#1] + [ \v!on=>\oninterlineskip, + \v!off=>\offinterlineskip, + \v!reset=>\let\currentrelativeinterlinespace\empty + \let\setrelativeinterlinespace\relax + \setfontparameters, + \v!auto=>\let\setrelativeinterlinespace\dosetrelativeinterlinespace, + \s!unknown=>\assignvalue\commalistelement\currentrelativeinterlinespace{1.00}{1.25}{1.50}% + \spacing\currentrelativeinterlinespace]} + +\def\dosetrelativeinterlinespace + {\ifx\currentrelativeinterlinespace\empty\else + \spacing\currentrelativeinterlinespace + \fi} + +\let\setrelativeinterlinespace\relax + +% \appendtoks \setrelativeinterlinespace \to \everybodyfont + +\def\complexsetupinterlinespace[#1]% \commalistelement ipv #1 + {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]} + +\def\setuplocalinterlinespace[#1]% + {\localinterlinespacetrue + \setupinterlinespace[#1]% + \localinterlinespacefalse} + +\def\simplesetupinterlinespace + {\localinterlinespacetrue + \setfontparameters + \updateraggedskips % funny one here + \localinterlinespacefalse} + +\definecomplexorsimple\setupinterlinespace + +\def\removelastskip % a redefinition of plain + {\ifvmode\ifdim\lastskip=\zeropoint\else\vskip-\lastskip\fi\fi} + +\def\doifoutervmode#1% + {\ifvmode\ifinner\else#1\fi\fi} + +\ifx\dosomebreak\undefined % defined in mkiv + + \def\dosomebreak#1% + {\doifoutervmode + {\scratchskip\lastskip + \removelastskip + %\leavevmode\type{#1}% + #1\relax + \ifdim\scratchskip=\zeropoint % else interference with footnotes + \else + \vskip\scratchskip + \fi}} + +\fi + +\def\packed + {\nointerlineskip} + +\def\godown[#1]% + {\relax + \ifhmode\endgraf\fi + \ifvmode\nointerlineskip\vskip#1\relax\fi} + +\ifx\smallskip\undefined + + \def\smallskip{\vskip\smallskipamount} + \def\medskip {\vskip\medskipamount} + \def\bigskip {\vskip\bigskipamount} + +\fi + +\ifx\allowbreak\undefined + + \def\break {\penalty\ifhmode-\plustenthousand\else\ejectpenalty\fi} + \def\nobreak {\penalty \plustenthousand} + \def\allowbreak{\penalty \zeropoint} + \def\filbreak {\par\vfil\penalty-200\vfilneg} + \def\goodbreak {\par\penalty-500 } + +\fi + +%D Made slightly more readable: + +\ifx\vglue\undefined + + \def\vglue {\afterassignment\dovglue\scratchskip=} + \def\hglue {\afterassignment\dohglue\scratchskip=} + \def\topglue{\nointerlineskip\vglue-\topskip\vglue} + + \def\dovglue + {\par + \scratchdimen\prevdepth + \hrule\!!height\zeropoint + \nobreak\vskip\scratchskip + \prevdepth\scratchdimen} + + \def\dohglue + {\dontleavehmode % \leavevmode + \scratchcounter\spacefactor + \vrule\!!width\zeropoint + \nobreak\hskip\scratchskip + \spacefactor\scratchcounter} + +\fi + +\ifx\eject\undefined + + \def\eject{\par\break} + +\fi + +\ifx\supereject\undefined + + \def\supereject{\par\penalty\superpenalty} + +\fi + +\ifx\dosupereject\undefined + + \def\dosupereject + {\ifnum\insertpenalties>\zerocount % something is being held over + \line{} + \kern-\topskip + \nobreak + \vfill\supereject + \fi} + +\fi + +%D We adapt plain's \type {\removelastskip} a bit: + +\ifx\removelastskip\undefined + + \def\removelastskip + {\ifvmode \ifdim\lastskip=\zeropoint \else + \vskip-\lastskip + \fi \fi} + +\fi + +\ifx\smallbreak\undefined + +\def\smallbreak + {\par + \ifdim\lastskip<\smallskipamount + \removelastskip + \penalty-50 + \smallskip + \fi} + +\def\medbreak + {\par + \ifdim\lastskip<\medskipamount + \removelastskip + \penalty-100 + \medskip + \fi} + +\def\bigbreak + {\par + \ifdim\lastskip<\bigskipamount + \removelastskip + \penalty-200 + \bigskip + \fi} + +\fi + +\newskip\ctxparskip \ctxparskip\zeropoint + +\newconditional \flexiblewhitespace \settrue\flexiblewhitespace + +\def\currentwhitespace {\zeropoint} + +\definecomplexorsimple\setupwhitespace + +\def\simplesetupwhitespace + {\doifnot\currentwhitespace\v!none\dosetupwhitespace} + +\def\complexsetupwhitespace[#1]% + {\edef\nextcurrentwhitespace{#1}% + \ifx\nextcurrentwhitespace\empty + \simplesetupwhitespace + \else + \let\currentwhitespace\nextcurrentwhitespace + \dosetupwhitespace + \fi} + +\def\dosetupwhitespace % quick test for no list + {\ifcsname\??ws\??ws\currentwhitespace\endcsname + \csname\??ws\??ws\currentwhitespace\endcsname + \else + \expandafter\processcommalist\expandafter[\currentwhitespace]\dowhitespacemethod % can be raw + \fi\relax + \ifgridsnapping + \setfalse\flexiblewhitespace + \ifdim\ctxparskip>\zeropoint + \ctxparskip + \ifcase\baselinegridmode + \baselineskip % normal ! ! ! ! !! + \or + \ifdim\scratchdimen=\baselineskip % maybe range + \baselineskip % normal ! ! ! ! !! + \else + \numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax + \fi + \else + \baselineskip % normal ! ! ! ! !! + \fi + \fi + \else + \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi + \fi + \parskip\ctxparskip} + +\chardef\baselinegridmode=0 % option in layout / 1=permit_half_lines + +\def\dodosetupwhitespace + {\ifgridsnapping + \setfalse\flexiblewhitespace + \ctxparskip1\ctxparskip + \ifdim\ctxparskip>\zeropoint + \ifcase\baselinegridmode + \ctxparskip\baselineskip % normal ! ! ! ! !! + \or + \ifdim\scratchdimen=\baselineskip % maybe range + \ctxparskip\baselineskip % normal ! ! ! ! !! + \else + \ctxparskip\numexpr\ctxparskip/\dimexpr.5\lineheight\relax\relax\dimexpr.5\lineheight\relax + \fi + \else + \ctxparskip\baselineskip % normal ! ! ! ! !! + \fi + \fi + \else + \ifconditional\flexiblewhitespace \else \ctxparskip1\ctxparskip \fi + \fi + \parskip\ctxparskip} + +\definesystemvariable {ws} % whitespace + +\def\definewhitespacemethod[#1]#2{\setvalue{\??ws\??ws#1}{#2}} + +\definewhitespacemethod [\v!fix] {} +\definewhitespacemethod [\v!fixed] {\setfalse\flexiblewhitespace} +\definewhitespacemethod [\v!flexible] {\settrue\flexiblewhitespace} +\definewhitespacemethod [\v!line] {\ctxparskip \baselineskip} +\definewhitespacemethod [\v!halfline] {\ctxparskip.5\baselineskip} +\definewhitespacemethod [\v!none] {\ctxparskip \zeropoint} +\definewhitespacemethod [\v!big] {\ctxparskip \bigskipamount} +\definewhitespacemethod [\v!medium] {\ctxparskip \medskipamount} +\definewhitespacemethod [\v!small] {\ctxparskip \smallskipamount} + +\definewhitespacemethod [\s!default] {\simplesetupwhitespace} % {\stelwitruimteopnieuwin} + +% \def\dowhitespacemethod#1% +% {\executeifdefined{\??ws\??ws#1}{\ctxparskip#1}\relax} + +\def\dowhitespacemethod#1% + {\ifcsname\??ws\??ws#1\endcsname\csname\??ws\??ws#1\endcsname\else\ctxparskip#1\fi\relax} + +% \def\nowhitespace +% {\ifdim\parskip>\zeropoint\relax +% \ifdim\lastskip=-\parskip +% \else +% \vskip-\parskip +% \fi +% \fi} + +\def\nowhitespace + {} + +\def\nowhitespaceunlessskip + {\ifdim\lastskip>\zeropoint \else + \nowhitespace + \fi} + +\def\redowhitespace + {\ifdim\lastskip>-\parskip \else + \vskip\parskip + \fi} + +\def\savecurrentwhitespace {\edef\savedcurrentwhitespace{\currentwhitespace}} +\def\restorecurrentwhitespace{\edef\currentwhitespace{\savedcurrentwhitespace}} + +\def\savedcurrentwhitespace{\currentwhitespace} + +% deze variant is nodig binnen \startopelkaar +% steeds testen: +% +% \hoofdstuk{..} +% \plaatslijst[..] +% \hoofdstuk{..} +% \input tufte +% +% met/zonder witruimte + +% \def\whitespace +% {\par +% \ifdim\parskip>\zeropoint\relax +% %\ifdim\lastskip>\parskip \else +% % \removelastskip interferes with blanko blokkeer en klein +% \vskip\parskip +% %\fi +% \fi} + +\def\whitespace + {\vspacing[\v!white]} + +% De onderstaande macro handelt ook de situatie dat er geen +% tekst tussen \start ... \stop is geplaatst. Daartoe wordt de +% laatste skip over de lege tekst heen gehaald. Dit komt goed +% van pas bij het plaatsen van (mogelijk lege) lijsten. + +\newif\ifopelkaar + +\newsignal \noparskipsignal % \def\noparskipsignal {0.00001pt} +\def\lastdoneparskip {0pt} + +\def\startpacked + {\dosingleempty\dostartpacked} + +\def\dostartpacked[#1]% nesting afvangen + {\par + \ifvmode + \bgroup + \blank[\v!disable] + \setupwhitespace[\v!none] + \fi} + +\def\stoppacked + {\par + \ifvmode + \egroup + \fi} + +\def\startunpacked + {\blank + \bgroup} + +\def\stopunpacked + {\egroup + \blank} + +% De onderstaande macro's moeten nog eens nader worden uitgewerkt. +% Ze spelen een rol bij de spatiering rond omkaderde teksten +% en/of boxen zonder diepte. + +% \prevdepth crosses pageboundaries! +% +% todo: a version that works ok inside a box + +\let\doaroundlinecorrection\relax + +\def\startlinecorrection + {\dodoubleempty\dostartlinecorrection} + +\def\dostartlinecorrection[#1][#2]% #2 gobbles spaces + {\bgroup + \processaction + [#1] + [ \v!blank=>\let\doaroundlinecorrection\blank, + \s!default=>\let\doaroundlinecorrection\relax, + \s!unknown=>{\def\doaroundlinecorrection{\blank[#1]}}]% + \doaroundlinecorrection + \startbaselinecorrection + \offbaselinecorrection + \ignorespaces} + +\def\stoplinecorrection + {\stopbaselinecorrection + \doaroundlinecorrection + \egroup} + +\def\correctwhitespace + {\dowithnextbox + {\startbaselinecorrection + \flushnextbox + \stopbaselinecorrection}% + \vbox} + +\def\verticalstrut {\normalvbox{\hsize\zeropoint\forgetall\strut}} +\def\horizontalstrut{\normalhbox {\strut}} + +% Hieronder volgen enkele instellingen en macro's ten behoeve +% van de interlinie en \strut. De waarden 2.8, 0.07, 0.72 en +% 0.28 zijn ooit eens ontleend aan INRS-TEX en moeten wellicht +% nog eens instelbaar worden. +% +% \lineheight : de hoogte van een regel +% \spacing{getal} : instellen interlinie +% \normalbaselines : instellen regelafstend +% +% \setstrut : instellen \strut +% \setnostrut : resetten \strut, \endstrut, \begstrut +% +% \setteststrut : instellen zichtbare struts +% \resetteststrut : instellen onzichtbare struts +% +% \setfontparameters : instellen na fontset +% +% De hoogte van een regel (\lineheight) is gelijk aan de +% som van de hoogte (\ht) en diepte (\dp) van \strutbox. +% +% \strut : denkbeeldig blokje met hoogte en diepte +% +% Een \hbox kan als deze aan het begin van een regel staat +% een breedte \hsize krijgen. Dit is soms te voorkomen met het +% commando \leavevmode. Binnen een \vbox geeft dit echter +% niet altijd het gewenste resultaat, vandaar het commando +% +% \leaveoutervmode + +% Pas op: niet zomaar \topskip en \baselineskip aanpassen +% en zeker niet \widowpenalty. Dit kan ernstige gevolgen +% hebben voor kolommen. +% +% Enige glue kan op zich geen kwaad, echter als blanko=vast, +% dan moet ook de rek 0 zijn. Binnen kolommen is rek ook +% niet bepaald mooi. Een hele kleine waarde (0.025) voldoet, +% omdat een positieve glue eindeloos rekbaar is. + +\newdimen\strutdimen +\newdimen\lineheight +\newdimen\openlineheight +\newdimen\openstrutheight +\newdimen\openstrutdepth +\newdimen\topskipgap +\newdimen\struttotal + +\def\strutheightfactor {.72} +\def\strutdepthfactor {.28} + +\def\baselinefactor {2.8} +\def\baselinegluefactor {0} + +\def\minimumstrutheight {0pt} +\def\minimumstrutdepth {0pt} + +\def\normallineheight {\baselinefactor ex} +\def\minimumlinedistance {\lineskip} + +\def\strutheight {0pt} +\def\strutdepth {0pt} +\def\strutwidth {0pt} + +\let\spacingfactor \plusone + +\def\topskipfactor {1.0} +\def\maxdepthfactor {0.5} + +\def\systemtopskipfactor {\topskipfactor} +\def\systemmaxdepthfactor {\maxdepthfactor} + +% De onderstaande definitie wordt in de font-module overruled + +\ifdefined\globalbodyfontsize\else + \newdimen\globalbodyfontsize + \globalbodyfontsize=12pt +\fi + +\ifx\normalizedbodyfontsize\undefined + \def\normalizedbodyfontsize{12pt} +\fi + +% door een \dimen. Dit is geen probleem omdat (1) de default +% korpsgrootte 12pt is en (2) de fonts nog niet geladen zijn +% en de instellingen bij het laden nogmaals plaatsvinden. + +\def\topskipcorrection + {\simpletopskipcorrection + \vskip-\struttotal + \verticalstrut} + +\def\simpletopskipcorrection + {\ifdim\topskip>\openstrutheight + % == \vskip\topskipgap + \vskip\topskip + \vskip-\openstrutheight + \fi} + +\def\settopskip % the extra test is needed for the lbr family + {\topskip\systemtopskipfactor\globalbodyfontsize + \ifgridsnapping \else + \ifr@ggedbottom\!!plus5\globalbodyfontsize\fi + \fi + \relax % the skip + \topskipgap\topskip + \advance\topskipgap -\openstrutheight\relax +\ifdim\minimumstrutheight>\zeropoint + \ifdim\topskip<\minimumstrutheight + \topskip\minimumstrutheight\relax + \fi +\else + \ifdim\topskip<\strutheightfactor\openlineheight + \topskip\strutheightfactor\openlineheight\relax + \fi +\fi} + +\def\setmaxdepth + {\maxdepth\systemmaxdepthfactor\globalbodyfontsize} + +\def\normalbaselines + {\baselineskip \normalbaselineskip + \lineskip \normallineskip + \lineskiplimit\normallineskiplimit} + +\def\setnormalbaselines + {\ifdim\normallineheight>\zeropoint + \lineheight\normallineheight + \fi + \openlineheight\spacingfactor\lineheight + \openstrutheight \ifdim\minimumstrutheight>\zeropoint + \minimumstrutheight % new + \else + \strutheightfactor\openlineheight + \fi + \openstrutdepth \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth % new + \else + \strutdepthfactor \openlineheight + \fi + \ifdim\dimexpr\minimumstrutdepth+\minimumstrutheight\relax>\zeropoint + \openlineheight\dimexpr\openstrutheight+\openstrutdepth\relax % new + \fi + \normalbaselineskip\openlineheight + \ifgridsnapping\else + \!!plus \baselinegluefactor\openlineheight + \!!minus\baselinegluefactor\openlineheight + \fi + \normallineskip\minimumlinedistance\relax % \onepoint\relax + \normallineskiplimit\zeropoint\relax + \normalbaselines + \dosetupgridsnapping} + +\def\spacing#1% + {\ifgridsnapping + %\ifdim#1\points=\onepoint\else\showmessage\m!layouts{11}{\withoutpt\the\dimexpr#1\points\relax}\fi + \let\spacingfactor\plusone + \else + \edef\spacingfactor{#1}% + \fi + \edef\systemtopskipfactor {\withoutpt\the\dimexpr#1\dimexpr\topskipfactor \points}% + \edef\systemmaxdepthfactor{\withoutpt\the\dimexpr#1\dimexpr\maxdepthfactor\points}% + \setnormalbaselines + \setstrut} + +%D Sometimes one needs to freeze the interlinespacing +%D +%D \starttyping +%D \rm \saveinterlinespace .... {\ss \restoreinterlinespace .... \endgraf} +%D \stoptyping + +\let\restoreinterlinespace\relax + +\def\saveinterlinespace + {\edef\restoreinterlinespace + {\lineheight \the\lineheight + \openstrutheight \the\openstrutheight + \openstrutdepth \the\openstrutdepth + \openlineheight \the\openlineheight + \normalbaselineskip \the\normalbaselineskip + \normallineskip \the\normallineskip + \normallineskiplimit\the\normallineskiplimit + \noexpand\def\noexpand\normallineheight{\the\dimexpr\normallineheight}% + \noexpand\normalbaselines}} + +% plain definition: +% +% \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} +% +% could be: +% +% \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} + +\ifx\strutbox\undefined + + \newbox\strutbox + + \setbox\strutbox\normalhbox{\vrule height8.5pt depth3.5pt width\zeropoint} + + \def\strut{\relax\ifmmode\copy\else\unhcopy\fi\strutbox} + +\fi + +\let\normalstrut\strut + +% The double \hbox construction enables us to \backtrack +% boxes. + +\let\strutht\undefined \newdimen\strutht +\let\strutdp\undefined \newdimen\strutdp + +\unexpanded\def\setstrut + {\ifgridsnapping + \setstrutgridyes + \else + \setstrutgridnop + \fi} + +\unexpanded\def\setstrutgridyes + {\strutht\spacingfactor\dimexpr + \ifdim\minimumstrutheight>\zeropoint + \minimumstrutheight + \else + \strutheightfactor\dimexpr\normallineheight + \fi + \strutdp\dimexpr + \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth + \else + \normallineheight-\strutht + \fi + \dosetstrut} + +\unexpanded\def\setstrutgridnop + {\strutht\spacingfactor\dimexpr + \ifdim\minimumstrutheight>\zeropoint + \minimumstrutheight + \else + \strutheightfactor\dimexpr\normallineheight + \fi + \strutdp\spacingfactor\dimexpr + \ifdim\minimumstrutdepth>\zeropoint + \minimumstrutdepth + \else + \strutdepthfactor\dimexpr\normallineheight + \fi + \dosetstrut} + +\unexpanded\def\setcharstrut#1% + {\setbox\strutbox\normalhbox{#1}% + \strutht\ht\strutbox + \strutdp\dp\strutbox + \dosetstrut} + +\unexpanded\def\setfontstrut + {\setcharstrut{(gplQT}} + +\unexpanded\def\setcapstrut% could be M, but Q has descender + {\setcharstrut{Q}} + +%D Handy for math (used in mathml): + +\def\charhtstrut + {\begingroup + \setcharstrut{GJY}% + \vrule\!!width\zeropoint\!!depth\zeropoint\!!height\strutht + \endgroup} + +\def\chardpstrut + {\begingroup + \setcharstrut{gjy}% + \vrule\!!width\zeropoint\!!depth\strutdp\!!height\zeropoint + \endgroup} + +% because of all the callbacks in mkiv, we avoid unnecessary boxes ... +% maybe use an attribute so that we can tag boxes that don't need a +% treatment; tests with using an attribute so far have shown that +% it's slower because testing the attribute takes time too + +\def\dosetstrut + {\let\strut\normalstrut + \edef\strutheight{\the\strutht}% + \edef\strutdepth {\the\strutdp}% + \ifdim\strutwidth=\zeropoint + \dosetstruthide + \else + \dosetstrutvide + \fi + \struttotal\dimexpr\strutht+\strutdp\relax} + +\def\dosetstruthide + {\setbox\strutbox\normalhbox + {\vrule + \!!width \zeropoint + \!!height\strutht + \!!depth \strutdp}} + +\def\dosetstrutvide + {\setbox\strutbox\normalhbox + {\normalhbox to \zeropoint + {% \hss % new, will be option + \vrule + \!!width \strutwidth + \!!height\strutht + \!!depth \strutdp + \hss}}} + +%D The dimen \type {\struttotal} holds the exact size of the +%D strut; occasionally a one scaled point difference can show +%D up with the lineheight. + +% experiment + +\newbox\emptystrutbox \setbox\emptystrutbox\hbox{} + +\def\dosetstruthide + {\setbox\strutbox\copy\emptystrutbox + \ht\strutbox\strutht + \dp\strutbox\strutdp} + +\def\strut{\relax\dontleavehmode\copy\strutbox} % still callbacks for \hbox{\strut} + + +\let\normalstrut\strut + +%D Sometimes a capstrut comes in handy +%D +%D \starttabulate[|Tl|l|l|] +%D \NC yes \NC normal strut \NC {\showstruts\setupstrut[yes]\strut} \NC \NR +%D \NC no \NC no strut \NC {\showstruts\setupstrut[no]\strut} \NC \NR +%D \NC kap \NC a capital strut (i.e. Q) \NC {\showstruts\setupstrut[cap]\strut} \NC \NR +%D \NC A B \unknown \NC a character strut (e.g. A) \NC {\showstruts\setupstrut[A]\strut} \NC \NR +%D \NC \NC a normal strut \NC {\showstruts\setupstrut\strut} \NC \NR +%D \stoptabulate + +\def\setupstrut + {\dosingleempty\dosetupstrut} + +\def\dosetupstrut[#1]% yet undocumented, todo: fontstrut + {\processaction + [#1] + [ \v!yes=>\setstrut, + \v!auto=>\setautostrut, + \v!no=>\setnostrut, + \v!cap=>\setcapstrut, + \v!fit=>\setfontstrut, + \v!line=>\setstrut, + \s!default=>\setstrut, + \s!unknown=>\setcharstrut\commalistelement]} + +\def\showstruts + {\setteststrut + \settestcrlf} + +\def\setteststrut + {\def\strutwidth{.8pt}% + \setstrut} + +\def\autostrutfactor{1.1} + +\def\setautostrut + {\begingroup + \setbox\scratchbox\copy\strutbox + \setstrut + \ifdim\strutht>\autostrutfactor\ht\scratchbox + \endgroup \setstrut + \else\ifdim\strutdp>\autostrutfactor\dp\scratchbox + \endgroup \setstrut + \else + \endgroup + \fi\fi} + +% when enabled, sigstruts will remove themselves if nothing +% goes inbetween + +\newsignal\strutsignal \setfalse\sigstruts + +\def\begstrut + {\relax\ifcase\strutht\else + \ifconditional\sigstruts + \noindent\horizontalstrut + \normalpenalty\plustenthousand + \normalhskip-\strutsignal + \normalhskip\strutsignal + \else + \strut + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \fi + \expandafter \ignorespaces + \fi} + +\def\endstrut + {\relax\ifhmode\ifcase\strutht\else + \ifconditional\sigstruts + \ifdim\lastskip=\strutsignal + \unskip\unskip\unpenalty\setbox\scratchbox\lastbox + \else + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \strut + \fi + \else + \removeunwantedspaces + \normalpenalty\plustenthousand + \normalhskip\zeropoint + \strut + \fi + \fi\fi} + +\newbox\nostrutbox \setbox\nostrutbox\normalhbox{} % {\normalhbox{}} + +\def\setnostrut + {\setbox\strutbox\copy\nostrutbox + \let\strut\empty + \let\endstrut\empty + \let\begstrut\empty + \let\crlfplaceholder\empty} + +% unsave: +% +% \def\pseudostrut +% {\bgroup +% \setnostrut +% \normalstrut +% \egroup} +% +% try: +% +% \startchemie +% \chemie[ONE,Z0,SB15,MOV1,SB15,Z0][C,C] +% \stopchemie +% +% so: + +\def\pseudostrut + {\noindent} % better: \dontleavehmode + +\let\pseudobegstrut\pseudostrut + +\let\pseudoendstrut\removeunwantedspaces + +\def\resetteststrut + {\let\strutwidth\zeropoint + \setstrut} + +\ifx\setfontparameters\undefined + % problems ! ! ! ! + \def\setfontparameters{\the\everybodyfont} +\fi + +%D Handy: + +\def\baselinedistance{\the\lineheight} + +%D We need \type{\normaloffinterlineskip} because the new +%D definition contains an assignment, and |<|don't ask me +%D why|>| this assignment gives troubles in for instance the +%D visual debugger. + +%D The plain ones: + +\def\offinterlineskip + {\baselineskip-\thousandpoint + \lineskip\zeropoint + \lineskiplimit\maxdimen} + +\def\nointerlineskip + {\prevdepth-\thousandpoint} + +\let\normaloffinterlineskip=\offinterlineskip % knuth's original + +%D My own one: + +\def\dopushinterlineskip + {\edef\oninterlineskip + {\baselineskip\the\baselineskip + \lineskip\the\lineskip + \lineskiplimit\the\lineskiplimit + \let\noexpand\offinterlineskip\noexpand\normaloffinterlineskip}} + +\def\nopushinterlineskip + {\let\oninterlineskip\setnormalbaselines} + +\def\offinterlineskip + {\ifdim\baselineskip>\zeropoint + \dopushinterlineskip + \else + \nopushinterlineskip + \fi + \normaloffinterlineskip} + +\let\oninterlineskip=\relax + +\def\leaveoutervmode + {\ifvmode\ifinner\else + \leavevmode + \fi\fi} + +% We stellen enkele penalties anders in dan Plain TEX: + +% oud +% +% \widowpenalty=\defaultwidowpenalty\relax +% \clubpenalty =\defaultclubpenalty \relax + +\def\resetpenalties#1% + {\ifx#1\undefined\else + #1\minusone + \fi} + +\def\setpenalties#1#2#3% + {\ifx#1\undefined\else % space before #3 prevents lookahead problems, needed when #3=text + #1\numexpr#2+\plusone\relax\space\doexpandedrecurse{\the\numexpr#2\relax}{ #3}\zerocount\relax + \fi} + +\def\doexpandedrecurse#1#2% + {\ifnum#1>\zerocount#2\@EA\doexpandedrecurse\@EA{\the\numexpr#1-1\relax}{#2}\fi} + +%D \macros +%D {keeplinestogether} +%D +%D Dirty hack, needed in margin content that can run of a page. + +% just before margintexts ... will eventually be done differently in mkiv using +% attributes + +\newcount\nofkeeplinestogether +\let\restoreinterlinepenalty\relax + +\def\dorestoreinterlinepenalty + {\global\let\restoreinterlinepenalty\relax + \global\resetpenalties\interlinepenalties + \global\nofkeeplinestogether\zerocount} + +\def\keeplinestogether#1% + {\ifnum#1>\nofkeeplinestogether + \global\nofkeeplinestogether#1% + \global\setpenalties\interlinepenalties\nofkeeplinestogether\plustenthousand + \global\let\restoreinterlinepenalty\dorestoreinterlinepenalty + \fi} + +\newif\ifgridsnapping % to be sure + +\def\defaultwidowpenalty {2000} % was: 1000 +\def\defaultclubpenalty {2000} % was: 800 +\def\defaultdisplaywidowpenalty {50} +\def\defaultbrokenpenalty {100} + +\def\defaultgridwidowpenalty {0} +\def\defaultgridclubpenalty {0} +\def\defaultgriddisplaywidowpenalty {0} +\def\defaultgridbrokenpenalty {0} + +\def\nopenalties + {\widowpenalty \zerocount + \clubpenalty \zerocount + \brokenpenalty \zerocount + \doublehyphendemerits\zerocount + \finalhyphendemerits \zerocount + \adjdemerits \zerocount} + +\def\setdefaultpenalties + {\directsetup{\systemsetupsprefix\s!default}} + +\startsetups [\systemsetupsprefix\s!reset] + \resetpenalties\widowpenalties + \resetpenalties\clubpenalties + \resetpenalties\interlinepenalties +\stopsetups + +% we use \directsetup because it's faster and we know there is no csl + +\startsetups [\systemsetupsprefix\s!default] + + \directsetup{\systemsetupsprefix\s!reset} + + \widowpenalty \defaultwidowpenalty + \clubpenalty \defaultclubpenalty + \displaywidowpenalty\defaultdisplaywidowpenalty + \brokenpenalty \defaultbrokenpenalty + +\stopsetups + +\startsetups [\v!grid] [\systemsetupsprefix\s!default] + + \directsetup{\systemsetupsprefix\s!reset} + + \widowpenalty \defaultgridwidowpenalty + \clubpenalty \defaultgridclubpenalty + \displaywidowpenalty\defaultgriddisplaywidowpenalty + \brokenpenalty \defaultgridbrokenpenalty + +\stopsetups + +% as an illustration: + +\startsetups [\systemsetupsprefix\v!strict] + + \directsetup{\systemsetupsprefix\s!reset} + + \setpenalties\widowpenalties2\maxdimen + \setpenalties\clubpenalties 2\maxdimen + \brokenpenalty \maxdimen + +\stopsetups + +\setdefaultpenalties % will happen later in \setuplayout + +%D To be checked: + +\ifx\savedstrutbox\undefined \newbox\savedstrutbox \fi + +\def\savestrut {\setbox\savedstrutbox\copy\strutbox} +\def\savedstrut{\copy \savedstrutbox} + +%D Page spacing + +\chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline + +\def\bottomalignlimit{3\lineheight} + +\newif\ifn@rmalbottom +\newif\ifr@ggedbottom +\newif\ifb@selinebottom + +\def\normalbottom + {% \topskip 10pt + \r@ggedbottomfalse} + +\def\raggedbottom + {\chardef\bottomraggedness\zerocount + \n@rmalbottomfalse + \r@ggedbottomtrue + \b@selinebottomfalse + \settopskip} + +\def\alignbottom + {\chardef\bottomraggedness\plusone + \n@rmalbottomtrue + \r@ggedbottomfalse + \b@selinebottomfalse + \settopskip} + +\def\baselinebottom + {\chardef\bottomraggedness\plustwo + \n@rmalbottomfalse + \r@ggedbottomfalse + \b@selinebottomtrue + \settopskip} + +\let\normalbottom=\alignbottom % downward compatible + +% so, the new one will be +% +% \chardef\bottomraggedness=0 % 0=ragged 1=normal/align 2=baseline +% +% \def\bottomalignlimit{3\lineheight} % will be settable +% +% \def\raggedbottom {\chardef\bottomraggedness=0 \settopskip} +% \def\alignbottom {\chardef\bottomraggedness=1 \settopskip} +% \def\baselinebottom{\chardef\bottomraggedness=2 \settopskip} +% +% \let\normalbottom =\alignbottom + +%D Good old blank: + +\definesystemattribute[kern-chars] +\definesystemattribute[skip-category] \chardef\skipcategoryattribute \dogetattributeid{skip-category} +\definesystemattribute[skip-penalty] \chardef\skippenaltyattribute \dogetattributeid{skip-penalty} +\definesystemattribute[skip-order] \chardef\skiporderattribute \dogetattributeid{skip-order} +\definesystemattribute[snap-category] +\definesystemattribute[display-math] + +% \start \dosetstretch{.25em} \setuptolerance[tolerant,stretch] \input tufte \endgraf \stop +% \start \dosetstretch{.5em} effe flink doorfietsen \stop + +\def\dosetupgridsnapping % calls too often, only needed in gridsnapping + {\ctxlua{nodes.setsnapvalue(1,\number\openstrutheight,\number\openstrutdepth)}} + +\def\doenablegridsnapping + {\dosetattribute{snap-category}{1}% + \topskip\strutht + \offinterlineskip} + +\def\dodisablegridsnapping + {\doresetattribute{snap-category}% + % reset topskip + \oninterlineskip} + +% experimental code, not yet interfaced: + +% category: +% 0 == discard discard +% 1 == only if larger largest +% 2 == force even if smaller force +% 3 == only take penalty component penalty +% 4 == add to existing skip add +% 5 == disable (ignore following) disable +% 6 == kill whitespace nowhite +% 7 == discard previous back +% +% penalty: larger wins +% order: larger wins +% category:2,order:5,penalty:10000,skip:value|kw +% +% always -- obsolete +% none -- obsolete +% outer -- obsolete +% reset -- obsolete +% \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} + +% todo, in grid mode: vspacing.fixed = false + +\let\saveouterspacing \relax % for old times sake +\let\restoreouterspacing\relax % for old times sake + +\newtoks\everybeforeblankhandling +\newtoks\everyafterblankhandling + +\appendtoks + \blankskip\zeropoint + \attribute\skipcategoryattribute\plusone + \attribute\skippenaltyattribute \attributeunsetvalue + \attribute\skiporderattribute \attributeunsetvalue + \ifgridsnapping % \ifblankflexible + \setfalse\blankisfixed + \else + \settrue\blankisfixed + \fi +\to \everybeforeblankhandling + +\appendtoks + \ifconditional\blankisfixed + \blankskip1\blankskip + \else + \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip + \fi +\to \everyafterblankhandling + +\def\setblankcategory#1{\attribute\skipcategoryattribute#1\relax} +\def\setblankorder #1{\attribute\skiporderattribute #1\relax} +\def\setblankpenalty #1{\attribute\skippenaltyattribute #1\relax} +\def\addblankskip#1#2#3{\advance\blankskip#1\dimexpr\ifgridsnapping#3\else#2\fi\relax\relax} +\def\fixedblankskip {\settrue \blankisfixed} % \blankskip1\blankskip} +\def\flexibleblankskip {\setfalse\blankisfixed} % \blankskip1\blankskip\!!plus\skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip} + +\def\startblankhandling + {\begingroup + \the\everybeforeblankhandling} + +\def\stopblankhandling + {\the\everyafterblankhandling + \vskip\blankskip + \endgroup} + +\def\flushblankhandling + {\the\everyafterblankhandling + \vskip\blankskip + \the\everybeforeblankhandling} + +% % % % + +\def\definevspacingamount + {\dotripleempty\dodefinevspacingamount} + +\def\dodefinevspacingamount[#1][#2][#3]% + {\ctxlua{vspacing.setskip("#1",\!!bs\detokenize{#2}\!!es,\!!bs\detokenize{#3}\!!es)}} + +\def\definevspacing + {\dodoubleempty\dodefinevspacing} + +\def\dodefinevspacing[#1][#2]% + {\ctxlua{vspacing.setmap("#1","#2")}} + +\unexpanded\def\vspacing + {\dosingleempty\dovspacing} + +\def\dovspacing[#1]% + {\ctxlua{vspacing.analyse("\iffirstargument#1\else\s!default\fi")}} + +% todo: checm them and make them faster: + +\definecomplexorsimple\setupvspacing + +\let\currentvspacing\empty + +\def\complexsetupvspacing[#1]% + {\edef\currentvspacing{#1}} + +\def\simplesetupvspacing + {\ifx\empty\currentvspacing\else + \let\currentvspacing\s!default + \fi + \simplesetupwhitespace} + +\def\restorestandardblank + {\let\currentvspacing\v!standard} + +% used both + +\def\doinhibitblank{\vspacing[\v!disable]} % can be made faster +\def\inhibitblank {\vspacing[\v!disable]} % can be made faster + +\let\setupblank \setupvspacing +\let\simplesetupblank\simplesetupvspacing +\let\blank \vspacing + +% category:4 is default + +\definevspacingamount[\v!big] [\bigskipamount] [\openlineheight] +\definevspacingamount[\v!medium] [\medskipamount] [0.50\openlineheight] +\definevspacingamount[\v!small] [\smallskipamount] [0.25\openlineheight] +\definevspacingamount[\v!line] [\openlineheight] [\openlineheight] +\definevspacingamount[\v!halfline][0.50\openlineheight][0.50\openlineheight] +\definevspacingamount[\v!formula] [\medskipamount] [0.50\openlineheight] +\definevspacingamount[\v!white] [\parskip] [\openlineheight] +\definevspacingamount[\v!height] [\strutheight] [\strutheight] +\definevspacingamount[\v!depth] [\strutdepth] [\strutdepth] + +\definevspacing[\v!samepage][penalty:10000] +\definevspacing[\v!max] [category:1] +\definevspacing[\v!force] [category:2] +\definevspacing[\v!disable] [category:5] +\definevspacing[\v!nowhite] [category:6] +\definevspacing[\v!back] [category:7] +\definevspacing[\v!always] [category:0] +\definevspacing[\v!weak] [order:0] +\definevspacing[\v!strong] [order:100] + +\definevspacing[\s!default] [\v!white] % was big for a while + +\setfalse\vspacingenabled + +\newtoks\everyenablevspacing +\newtoks\everydisablevspacing + +\def\enablevspacing {\the\everyenablevspacing} +\def\disablevspacing{\the\everydisablevspacing} + +\appendtoks + \writestatus\m!systems{! ! enabling vspacing ! !}% + \settrue\vspacingenabled + \ctxlua{vspacing.enable()}% +\to \everyenablevspacing + +\appendtoks + \writestatus\m!systems{! ! disabling vspacing ! !}% + \setfalse\vspacingenabled + \ctxlua{vspacing.disable()}% +\to \everydisablevspacing + +\global\let\blank \vspacing +\global\let\defineblank\definevspacing + +% moved from page-lin + +%D When spacing is active we need to handle commands in +%D a special way: +%D +%D \starttyping +%D \setuplines[space=on] +%D +%D \startlines +%D Let's talk about this{\ttsl\gobbleoneargument or}that. +%D \stoplines +%D +%D \startlines +%D Let's talk about this{\getvalue{ttsl}or}that. +%D \stoplines +%D \stoptyping +%D +%D One can indent in several ways: +%D +%D \starttyping +%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even +%D +%D \startlines +%D first +%D second +%D third +%D fourth +%D \stoplines +%D \stoptyping + +\def\setuplines + {\dodoubleargument\getparameters[\??rg]} + +\def\startlines + {\@@rgbefore + \pushmacro\checkindentation + \whitespace + %\page[\v!preference]} gaat mis na koppen, nieuw: later \nobreak + \begingroup + \setupindenting[\@@rgindenting]% + \typesettinglinestrue + \setupwhitespace[\v!none]% + \obeylines + \ignorespaces + \gdef\afterfirstobeyedline % tzt two pass, net als opsomming + {\gdef\afterfirstobeyedline + {\nobreak + \doifnot\@@rgoption\v!packed{\global\let\afterfirstobeyedline\relax}}}% + \def\obeyedline + {\par + \futurelet\next\dobetweenthelines}% + \activatespacehandler\@@rgspace + \GotoPar} + +\def\stoplines + {\endgroup + \popmacro\checkindentation + \@@rgafter} + +\def\dobetweenthelines + {\doifmeaningelse\next\obeyedline + {\@@rginbetween} + {\afterfirstobeyedline}} + +\setuplines + [\c!option=, + \c!before=\blank, + \c!after=\blank, + \c!inbetween=\blank, + \c!indenting=\v!no, + \c!space=\v!default] + +\def\emptylines + {\dosingleempty\doemptylines} + +\def\doemptylines[#1]% + {\endgraf\dorecurse{\iffirstargument#1\else3\fi}\crlf} + +\protect \endinput + +\dorecurse{2}{ + $2^{2^{2^{2}}}$ $2_{2_{2_{2}}}^{2^{2^{2^{2^{2^{2^{2^{2^{2}}}}}}}}}$ + \input tufte \inframed {tufte} + \par +} + +\dorecurse{100} { + + \kern \recurselevel pt + + \vbox { + \endgraf \strut first \endgraf + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{2}\vskip10pt} + \endgraf \strut second \endgraf + } + + \endgraf \strut first \endgraf + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + \endgraf \strut second \endgraf + + {\dosetattribute{skip-category}{0}\vskip10pt} % remove + {\dosetattribute{skip-category}{1}\vskip10pt} % take largest + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\dosetattribute{skip-order}{10}\vskip20pt} + {\dosetattribute{skip-category}{4}\dosetattribute{skip-order}{10}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip60pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{0}\vskip10pt} + + third (no break after this) + + {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip10pt} + {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + + fourth + \vskip10pt + fifth +} diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv index cb48d435a..b41a25e5b 100644 --- a/tex/context/base/strc-flt.mkiv +++ b/tex/context/base/strc-flt.mkiv @@ -110,10 +110,10 @@ \c!textcolor=, \c!align=, \c!number=\v!yes, -\c!prefix=\v!no, -\c!prefixconnector=., -\c!way=\v!by\v!chapter, -\c!prefixsegments=2:2, +% \c!prefix=\v!no, +% \c!prefixconnector=., +% \c!way=\v!by\v!chapter, +% \c!prefixsegments=2:2, % \c!way=\@@nrway, % \c!blockway=\@@nrblockway, % \c!sectionnumber=\@@nrsectionnumber, @@ -221,8 +221,11 @@ {\def\docommand##1{\getparameters[\??kj##1][#2]\def\currentfloat{##1}\the\everysetupcaption}% \processcommalist[#1]\docommand} +\presetstructurecountersetup\setupcaptions\sharedstructurecounterparameter + \appendtoks \dostructurecountersetup\currentfloat\floatcaptionparameter + \docheckstructurecountersetup\currentfloat \to \everysetupcaption %D Definitions: @@ -297,11 +300,18 @@ \installstructurelistprocessor{float}{\usestructurelistprocessor{number+title}} +% \def\thecurrentfloatnumber +% {\ifnofloatcaption \else \ifnofloatnumber \else +% % \labeltexts\currentfloat{\convertedstructurecounter[\currentfloat]}% ! ! todo: use a lua call instead +% \ifx\currentfloatnumber\relax\else +% \labeltexts\currentfloat{\ctxlua{structure.lists.savednumber("\currentfloat",\currentfloatnumber)}}% +% \fi +% \fi \fi} + \def\thecurrentfloatnumber {\ifnofloatcaption \else \ifnofloatnumber \else - % \labeltexts\currentfloat{\convertedstructurecounter[\currentfloat]}% ! ! todo: use a lua call instead \ifx\currentfloatnumber\relax\else - \labeltexts\currentfloat{\ctxlua{structure.lists.savednumber("\currentfloat",\currentfloatnumber)}}% + \labeltexts\currentfloat{\ctxlua{structure.lists.savedprefixednumber("\currentfloat",\currentfloatnumber)}}% \fi \fi \fi} diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index 4b3f09e21..315fb8236 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -141,24 +141,53 @@ \def\@@itemcounter{\s!itemcount\currentitemgroup} -\def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else\dosomebreak#1\fi\fi} +% \def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else\dosomebreak#1\fi\fi} +% +% \def\allowitembreak {\doitembreak\allowbreak} +% \def\noitembreak {\doitembreak\nobreak} +% \def\itembreakspecial {\doitembreak\itembreak} +% \def\noitembreakspecial{\doitembreak\itemnobreak} +% +% \def\itembreak {\flushnotes\penalty-5\relax} % -10 +% \def\itemnobreak{\flushnotes\penalty+5\ifinsidecolumns\else00\fi\relax} % +5 + +\definevspacing[\v!item @0] [penalty:0] % allow +\definevspacing[\v!item @10000] [penalty:10000] % no +\definevspacing[\v!item @-5] [penalty:-5] +\definevspacing[\v!item @5] [penalty:5] +\definevspacing[\v!item @500] [penalty:500] -\def\allowitembreak {\doitembreak\allowbreak} -\def\noitembreak {\doitembreak\nobreak} +\def\doitembreak#1{\ifconditional\optimizelistitem\ifconditional\textlistitem\else#1\fi\fi} + +\def\allowitembreak {\doitembreak\itembreakallow} +\def\noitembreak {\doitembreak\itembreakno} \def\itembreakspecial {\doitembreak\itembreak} \def\noitembreakspecial{\doitembreak\itemnobreak} -\def\itembreak {\flushnotes\penalty-5\relax} % -10 -\def\itemnobreak{\flushnotes\penalty+5\ifinsidecolumns\else00\fi\relax} % +5 +\def\itembreakallow{\vspacing[\v!item @0]} +\def\itembreakno {\vspacing[\v!item @10000]} +\def\itembreak {\flushnotes\vspacing[\v!item @-5]} +\def\itemnobreak {\flushnotes\ifinsidecolumns\vspacing[\v!item @5]\else\vspacing[\v!item @500]\fi} + +% cool but wrong: +% +% \def\initializeitemgrouplevel#1% +% {\ifcsname\??op\currentitemgroup#1\s!parent\endcsname +% % ok +% \else\ifnum#1>\plusone +% \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup\the\numexpr#1-1\relax}% +% \else +% \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup}% +% \fi\fi} +% +% so we have: \def\initializeitemgrouplevel#1% {\ifcsname\??op\currentitemgroup#1\s!parent\endcsname % ok - \else\ifnum#1>\plusone - \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup\the\numexpr#1-1\relax}% \else \setevalue{\??op\currentitemgroup#1\s!parent}{\??op\currentitemgroup}% - \fi\fi} + \fi} \def\defineitemgroup {\dotripleempty\dodefineitemgroup} @@ -199,8 +228,12 @@ \def\dodosetupitemgroupconstant#1% {\edef\itemgroupconstantvalue{#1}% \ifx\itemgroupconstantvalue\empty\else - \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond - \ifcsname\??op:::\itemgroupfirst\endcsname\csname\??op:::\itemgroupfirst\endcsname\fi + \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond + \ifx\itemgroupsecond\empty + \ifcsname\??op:::\itemgroupfirst\endcsname\csname\??op:::\itemgroupfirst\endcsname\fi + \else + \ifcsname\??op:::\itemgroupsecond\endcsname\csname\??op:::\itemgroupsecond\endcsname\fi + \fi \fi} \newconditional\inlinelistitem \setfalse\inlinelistitem @@ -208,8 +241,8 @@ \setvalue{\??op:::\v!packed }{\packitems} \setvalue{\??op:::\v!intro }{\settrue\introlistitem} % here? not set to false \setvalue{\??op:::\v!autointro}{\settrue\autointrolistitem} -\setvalue{\??op:::\v!broad }{\ifx\itemgroupsecond\empty\def\itemgroupsecond{1}\fi - \letitemparameter\currentitemlevel\c!factor\itemgroupsecond} +\setvalue{\??op:::\v!broad }{\ifx\itemgroupfirst\empty\def\itemgroupfirst{1}\fi + \letitemparameter\currentitemlevel\c!factor\itemgroupfirst} \setvalue{\??op:::\v!text }{\settrue\textlistitem \settrue\inlinelistitem \settrue\joinedlistitem @@ -225,12 +258,12 @@ \setvalue{\??op:::\v!loose }{\setfalse\optimizelistitem} \setvalue{\??op:::\v!fit }{\settrue\fittinglistitems} \setvalue{\??op:::\v!nofit }{\setfalse\fittinglistitems} -\setvalue{\??op:v:\v!paragraph}{\settrue\paragraphlistitem +\setvalue{\??op:::\v!paragraph}{\settrue\paragraphlistitem \packitems} \setvalue{\??op:::\v!joinedup }{\settrue\joinedlistitem \packitems} -\setvalue{\??op:::\v!serried }{\edef\itemgroupsecond{-\ifx\itemgroupsecond\empty1\else\itemgroupsecond\fi}% - \letitemparameter\currentitemlevel\c!factor\itemgroupsecond} +\setvalue{\??op:::\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}% + \letitemparameter\currentitemlevel\c!factor\itemgroupfirst} \setvalue{\??op:::\v!stopper }{\letitemparameter\currentitemlevel\c!placestopper\v!yes} % keep {} \setvalue{\??op:::\v!unpacked }{\setfalse\packlistitem} \setvalue{\??op:::\v!repeat }{\settrue\repeatlistitem} @@ -240,7 +273,7 @@ \def\dosetupstandarditemgroup#1% {\getparameters [\??op\currentitemgroup#1] - [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=, + [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=,\c!factor=0, \c!beforehead=,\c!afterhead=\blank,\c!before=\blank,\c!inbetween=\blank,\c!after=\blank]} % \def\packeditemspacing{\empty} diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv index bff243207..451ea60b4 100644 --- a/tex/context/base/strc-mat.mkiv +++ b/tex/context/base/strc-mat.mkiv @@ -50,6 +50,13 @@ [\v!formula] [\c!numberconversionset=\v!formula] +\presetstructurecountersetup\setupformulas\sharedstructurecounterparameter + +\appendtoks + \dostructurecountersetup\currentformula\formulaparameter + \docheckstructurecountersetup\currentformula +\to \everysetupformulas + \def\storecurrentformulanumber#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float) {\dostructurecountercomponent {formula}% @@ -67,10 +74,17 @@ \globallet#3\laststructurecountersynchronize \globallet#4\laststructurecounterattribute} +\newif\ifnoformulanumber + +% \def\thecurrentformulanumber +% {%\ifnoformulacaption \else \ifnoformulanumber \else +% \labeltexts\currentformula{\convertedstructurecounter[formula]}% ! ! todo: use a lua call instead +% }%\fi \fi} + \def\thecurrentformulanumber - {%\ifnoformulacaption \else \ifnoformulanumber \else - \labeltexts\currentformula{\convertedstructurecounter[formula]}% ! ! todo: use a lua call instead - }%\fi \fi} + {\ifx\currentformulanumber\relax\else \ifnoformulanumber \else + \labeltexts\currentformula{\ctxlua{structure.lists.savedprefixednumber("\currentformula",\currentformulanumber)}}% + \fi \fi} \def\placecurrentformulanumber {\currentformulassynchronize \currentformulasattribute % todo @@ -90,6 +104,8 @@ \let\currentsubformulasynchronize\relax \let\currentsubformulaattribute\relax \let\currentformulassynchronize \relax \let\currentformulasattribute \relax +\def\inhibitformulanumberflag{-} + \def\dododoformulanumber#1#2#3#4% (#1,#2)=outer(ref,sub) (#3,#4)=inner(ref,sub) {\hbox\bgroup \ifconditional\handleformulanumber @@ -107,11 +123,13 @@ \setsubstructurecounterown[\v!formula][2]{#2}% \detokenize? \fi \edef\currentformulareference{#1}% - \ifx\currentformulareference\empty + \ifx\currentformulareference\inhibitformulanumberflag \glet\currentformulasynchronize\relax \glet\currentformulaattribute \relax + \noformulanumbertrue \else \storecurrentformulanumber\currentformulareference\empty\currentformulasynchronize\currentformulaattribute1% + \noformulanumberfalse \fi % subcounter \setbox0\hbox{\ignorespaces#4\unskip}% @@ -561,7 +579,7 @@ \checknextindentation[\formulaparameter\c!indentnext]% \dorechecknextindentation} % here ? -%D Named subformulas +%D Named subformulas (to be redone) \def\startnamedsubformulas {\dosingleempty\dostartnamedsubformulas} diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 7c2b082fa..48c48caa0 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -156,7 +156,6 @@ \setupnotes [\c!location=\v!page, \c!way=\v!by\v!part, - \c!sectionnumber=\v!no, %\c!conversion=, \c!rule=\v!on, \c!before=\blank, @@ -194,18 +193,6 @@ \def\@@defaultnotedefloc{\v!inleft} \def\@@defaultnotedefdis{\!!zeropoint} -% also s!root -% -% \definedescription -% [\??vn\??vn] -% [\c!location=\@@defaultnotedefloc, -% \c!distance=\@@defaultnotedefdis, -% \c!width=\v!fit, -% \c!headstyle=\noteparameter\c!style, -% \c!headcolor=\noteparameter\c!color, -% \c!before=, -% \c!after=] - \def\startnotedef{\resetdescriptions\csname\e!start\??vn\??vn\currentnote\endcsname} \def\stopnotedef {\csname\e!stop \??vn\??vn\currentnote\endcsname} @@ -229,7 +216,7 @@ \c!width=\v!fit, \c!headstyle=\noteparameter\c!style, \c!headcolor=\noteparameter\c!color, -\s!handler=\v!note, + \s!handler=\v!note, \c!text=, \c!before=, \c!after=]% diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv index 3ea666290..45f71827f 100644 --- a/tex/context/base/strc-num.mkiv +++ b/tex/context/base/strc-num.mkiv @@ -39,21 +39,25 @@ % todo: better inheritane system -\definesystemvariable {nn} - \def\setupstructurecountering{\dodoubleempty\getparameters[\??nn]} \setupstructurecountering [\c!way=\v!by\v!chapter, -% \c!blockway=, -% \c!prefixstopper=, -\c!prefixconnector=., -\c!prefixsegments=\thenamedstructurecounterlevel\currentstructurecounter, -\c!start=0, -\c!state=\v!start, +% \c!blockway=, +% \c!prefixstopper=, + \c!prefixconnector=., + \c!prefixsegments=\thenamedstructurecounterlevel\currentstructurecounter, + \c!start=0, + \c!state=\v!start, \c!prefix=\v!yes, \c!state=\v!start] +\setupstructurecountering + [\c!prefixsegments=\autostructureprefixsegments\sharedstructurecounterparameter] + +\def\autostructureprefixsegments#1% todo: \c!prefixsegments=\v!auto + {2:\thenamedstructureheadlevel{\ctxlua{structure.sections.way("#1\c!way","\v!by")}}} + % \letvalue{\??nn\s!empty}\empty \def\structurecounterparameter#1#2% @@ -76,6 +80,17 @@ #1% \fi} +\def\sharedstructurecounterparameter#1% + {\csname + \ifcsname\??nn#1\endcsname + \??nn#1% + \else + \s!empty + \fi + \endcsname} + +\let\numberingparameter\sharedstructurecounterparameter + % \def\structurecounterparameter #1#2{\csname\dostructurecounterparameter{\??nn#1}#2\endcsname} % \def\dostructurecounterparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dostructurecounterparentparameter\csname#1\s!number\endcsname#2\fi} % \def\dostructurecounterparentparameter#1#2{\ifx#1\relax\s!empty\else\dostructurecounterparameter#1#2\fi} @@ -314,17 +329,6 @@ \c!blockway=, \c!state=\v!start] -\def\numberingparameter#1{\csname\??nr#1\endcsname} - -% \c!prefixconnector=., -% \c!stopper=, - -% \c!prefix=\v!no, -% \c!prefixconnector=., -% \c!way=bychapter, -% \c!prefixsegments=2:2, - - %D Helpers: % call: @@ -353,6 +357,11 @@ \edef\hasstructurecounternumber {#3\s!hasnumber}% \edef\hasstructurecounterlevel {#3\s!haslevel}% % +\edef\askedprefixsegments{#3\c!prefixsegments}% +\ifx\askedprefixsegments\v!auto + \edef\askedprefixsegments{\autostructureprefixsegments#3}% +\fi + % \edef\currentname{#3\c!name}% \ifx\currentname\empty \edef\currentname{#1}% @@ -422,7 +431,8 @@ conversion = \!!bs#3\c!prefixconversion\!!es, conversionset = "#3\c!prefixconversionset", set = "#3\c!prefixset", - segments = "#3\c!prefixsegments", +% segments = "#3\c!prefixsegments", +segments = "\askedprefixsegments", connector = \!!bs#3\c!prefixconnector\!!es, }, numberdata = { @@ -473,4 +483,21 @@ \c!numberstopper=#2\c!numberstopper, \c!numbersegments=#2\c!numbersegments]} +\def\presetstructurecountersetup#1#2% \setupcommand \someparameter + {#1% + [\c!way =#2\c!way, + \c!prefix =#2\c!prefix, + \c!prefixseparatorset =#2\c!prefixseparatorset, + \c!prefixconversion =#2\c!prefixconversion, + \c!prefixconversionset=#2\c!prefixconversionset, + \c!prefixstopper =#2\c!prefixstopper, + \c!prefixsegments =#2\c!prefixsegments, + \c!prefixset =#2\c!prefixset, + \c!prefixconnector =#2\c!prefixconnector, + \c!numberseparatorset =#2\c!numberseparatorset, + \c!numberconversion =#2\c!numberconversion, + \c!numberconversionset=#2\c!numberconversionset, + \c!numberstopper =#2\c!numberstopper, + \c!numbersegments =#2\c!numbersegments]} + \protect \endinput diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 675adcc15..16f5b6c41 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -948,15 +948,11 @@ filters.section.default = filters.section.number filters.formula = {} -filters.formula.default = filters.section.number +filters.formula.default = filters.generic.number filters.float = { } -filters.float.default = filters.section.number - ---~ filters.float.title = filters.generic.title ---~ filters.float.number = filters.generic.number ---~ filters.float.page = filters.generic.page +filters.float.default = filters.generic.number structure.references = structure.references or { } structure.helpers = structure.helpers or { } diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv index 5416c17f1..5b61b48a8 100644 --- a/tex/context/base/strc-ref.mkiv +++ b/tex/context/base/strc-ref.mkiv @@ -1226,13 +1226,15 @@ \hyphenatedurl{\ctxlua{jobreferences.urls.get("#1","\@@uralternative","\@@urspace")}}% \endgroup} +% # fails + %D This macro is hooked into a support macro, and thereby %D \URL's break ok, according to the setting of a switch, %D %D \startbuffer %D \useURL %D [test] -%D [sentence_sentence%sentence#sentence~sentence/sentence//sentence:sentence.sentence] +%D [sentence_sentence~sentence//sentence:sentence.sentence] %D \stopbuffer %D %D \typebuffer diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index 200ff56f2..b7e18746d 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -608,7 +608,8 @@ % the next one was: \somebreakmethod -\chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing +% \chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing +\chardef\somestructureheadbreakmethod\plusthree \def\dopreventbreakafterstructureheadauto % used after \c!before {\ifcase\somestructureheadbreakmethod diff --git a/tex/context/base/x-mathml.mkiv b/tex/context/base/x-mathml.mkiv index 649798c9f..82db51168 100644 --- a/tex/context/base/x-mathml.mkiv +++ b/tex/context/base/x-mathml.mkiv @@ -99,7 +99,7 @@ %D Remark: from now on this is a module and no longer an xtag %D filter. There is an intermediate cleaner module but it has -%D some namespace limitations. Here we do it the \MKV\ way. +%D some namespace limitations. Here we do it the \MKIV\ way. \def\widevec#1% {\vbox{\mathsurround\zeropoint\ialign{##\crcr diff --git a/tex/context/base/x-set-11.tex b/tex/context/base/x-set-11.tex index 6fcc7f934..6d4cab5ca 100644 --- a/tex/context/base/x-set-11.tex +++ b/tex/context/base/x-set-11.tex @@ -408,8 +408,9 @@ % \setup{setupinterlinespace} % \setup{setupinterlinespace:1} % \setup{setupinterlinespace:2} - +% todo: make this proper mkiv xml + \defineXMLenvironment [cd:command] [name=,type=,generated=,interactive=,variant=] {} {\showSETUPrecord} diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 6166237f7..b58c25a92 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 09/15/09 12:29:59 +-- merge date : 09/16/09 20:09:33 do -- begin closure to overcome local limits and interference -- cgit v1.2.3