diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-07-31 11:03:33 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-07-31 11:03:33 +0200 |
commit | cbaeded86ee193677fe0cae364b564616557449d (patch) | |
tree | 1b3286f018db07027ab715f3352b61838af6e59f /tex | |
parent | 4619c6e66ef47e8e4953142a5c65467a6b0a2c01 (diff) | |
download | context-cbaeded86ee193677fe0cae364b564616557449d.tar.gz |
2020-07-31 10:01:00
Diffstat (limited to 'tex')
25 files changed, 2277 insertions, 148 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 46d2af40e..34fcff4b5 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2020.07.30 16:49} +\newcontextversion{2020.07.31 09:58} %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/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 41ff80aea..48864f02c 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2020.07.30 16:49} +\edef\contextversion{2020.07.31 09:58} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 784ee18f0..dbb1d93fe 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -211,6 +211,7 @@ \setinterfacevariable{flushouter}{flushouter} \setinterfacevariable{flushright}{flushright} \setinterfacevariable{followingpage}{followingpage} +\setinterfacevariable{font}{font} \setinterfacevariable{footer}{piedipagina} \setinterfacevariable{footnote}{notapdp} \setinterfacevariable{force}{forza} @@ -633,6 +634,7 @@ \setinterfaceconstant{afterkey}{dopotasto} \setinterfaceconstant{aftersection}{aftersection} \setinterfaceconstant{align}{allinea} +\setinterfaceconstant{alignbottom}{alignbottom} \setinterfaceconstant{aligncharacter}{allineacarattere} \setinterfaceconstant{alignmentcharacter}{carattereallineamento} \setinterfaceconstant{alignmentleftsample}{alignmentleftsample} @@ -832,6 +834,7 @@ \setinterfaceconstant{focusin}{focusin} \setinterfaceconstant{focusoffset}{focusoffset} \setinterfaceconstant{focusout}{focusout} +\setinterfaceconstant{font}{font} \setinterfaceconstant{footer}{piedipagina} \setinterfaceconstant{footerdistance}{distanzapdp} \setinterfaceconstant{footerstate}{statopdp} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 045927f4a..1dd3b73e7 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.07.30 16:49} +\newcontextversion{2020.07.31 09:58} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 027d8fd7b..ae9929e59 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.07.30 16:49} +\edef\contextversion{2020.07.31 09:58} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index df3fe5133..bc442c527 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.07.30 16:49} +\edef\contextversion{2020.07.31 09:58} %D Kind of special: @@ -238,7 +238,7 @@ \loadmkvifile{pack-mis} \loadmkxlfile{pack-ori} % LMTX \loadmkxlfile{pack-rul} % LMTX -\loadmarkfile{pack-mrl} +\loadmkxlfile{pack-mrl} % LMTX \loadmkvifile{pack-bck} \loadmarkfile{pack-fen} @@ -266,7 +266,7 @@ %loadmarkfile{strc-reg} \loadmkvifile{strc-lev} % experiment -\loadmarkfile{spac-hor} +\loadmkxlfile{spac-hor} \loadmkxlfile{spac-ali} \loadmarkfile{spac-flr} \loadmkxlfile{spac-ver} % LMTX beware, hooks into strc-sec diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv index 1b630de49..693e55d2f 100644 --- a/tex/context/base/mkiv/grph-inc.mkiv +++ b/tex/context/base/mkiv/grph-inc.mkiv @@ -687,7 +687,6 @@ % \vss \vkern\ht\foundexternalfigure % - % \parfillskip\zeropoint \ht\foundexternalfigure\zeropoint \dp\foundexternalfigure\zeropoint \hpack to \wd\foundexternalfigure\bgroup diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 3e1f7bb8c..b15bf8033 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -7338,6 +7338,10 @@ return { ["pe"]="تنظیم", ["ro"]="aliniere", }, + ["alignbottom"]={ + ["en"]="alignbottom", + ["fr"]="alignerbas", + }, ["aligncharacter"]={ ["cs"]="aligncharacter", ["de"]="aligncharacter", diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index cbfd009a8..340e96446 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -74,7 +74,7 @@ return { "frozenwidowpenaltycode", "frozenclubpenaltycode", "frozenbrokenpenaltycode", "frozenadjdemeritscode", "frozendoublehyphendemeritscode", "frozenfinalhyphendemeritscode", "frozenparshapecode", "frozeninterlinepenaltiescode", "frozenwidowpenaltiescode", "frozenclubpenaltiescode", - "paragraphupdatecodes", "paragraphpenaltycodes", "paragraphdemeritcodes", + "paragraphupdatecodes", "paragraphpenaltycodes", "paragraphdemeritcodes", "paragraphshapecodes", -- "activemathcharcode", -- @@ -462,7 +462,7 @@ return { "carryoverpar", "freezeparagraphproperties", "defrostparagraphproperties", "setparagraphfreezing", "forgetparagraphfreezing", - "updateparagraphproperties", "updateparagraphpenalties", "updateparagraphdemerits", + "updateparagraphproperties", "updateparagraphpenalties", "updateparagraphdemerits", "updateparagraphshapes", -- "lastlinewidth", -- diff --git a/tex/context/base/mkiv/pack-mrl.mkiv b/tex/context/base/mkiv/pack-mrl.mkiv index 921d38964..1b7d4eb30 100644 --- a/tex/context/base/mkiv/pack-mrl.mkiv +++ b/tex/context/base/mkiv/pack-mrl.mkiv @@ -810,9 +810,9 @@ %D a piece of text, like %D %D \startbuffer -%D -%D \stopbuffer\fillinline \input reich \par +%D \fillinline \input reich \par %D \fillinline[margin=0cm] \input reich \par +%D \stopbuffer %D %D \startexample %D \getbuffer diff --git a/tex/context/base/mkiv/pack-mrl.mkxl b/tex/context/base/mkiv/pack-mrl.mkxl new file mode 100644 index 000000000..bd459dc46 --- /dev/null +++ b/tex/context/base/mkiv/pack-mrl.mkxl @@ -0,0 +1,876 @@ +%D \module +%D [ file=pack-mrl, % was pack-rul/core-rul, +%D version=1998.10.16, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=More Rules, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%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 Packaging Macros / More Rules} + +%D The (re)implementation of margin rules has been moved elsewhere. + +\unprotect + +%D \macros +%D {setupblackrules,blackrule} +%D +%D The graphic capabilities of \TEX\ do not go beyond simple filled rules, except of +%D course when using specials or, in \MKIV, manipulate node lists. Let's start with +%D a warning: using this commands is far more slower than using the \TEX\ primitives +%D \type {\hrule} and \type {\vrule}, but they save us some tokens. The +%D characteristics of these rule drawing command can be set by: +%D +%D \showsetup{setupblackrules} +%D +%D The simple command draws only one rule. Its optional argument can be used to +%D specify the dimensions. By setting the width, height or depth to \type {max}, one +%D gets the natural dimensions. +%D +%D \showsetup{blackrule} + +\installcorenamespace{blackrules} + +\installsimplecommandhandler \??blackrules {blackrules} \??blackrules + +\unexpanded\def\blackrule + {\hpack\bgroup + \doifelsenextoptionalcs\pack_black_rule_pickup\pack_black_rule_indeed} + +\def\pack_black_rule_pickup[#1]% + {\setupcurrentblackrules[#1]% + \pack_black_rule_indeed} + +\def\pack_black_rule_indeed + {\edef\p_width {\directblackrulesparameter\c!width }% + \edef\p_height{\directblackrulesparameter\c!height}% + \edef\p_depth {\directblackrulesparameter\c!depth }% + \ifx\p_height\v!max + \setstrut + \else\ifx\p_depth\v!max + \setstrut + \fi\fi + \useblackrulesstyleandcolor\c!style\c!color + \ifcsname\??blackruletype\directblackrulesparameter\c!type\endcsname + \lastnamedcs + \else + \vrule + \fi + \ifx\p_width \v!max\s!width \emwidth\else\ifx\p_width \empty\else\s!width \p_width \fi\fi + \ifx\p_height\v!max\s!height\strutht\else\ifx\p_height\empty\else\s!height\p_height\fi\fi + \ifx\p_depth \v!max\s!depth \strutdp\else\ifx\p_depth \empty\else\s!depth \p_depth \fi\fi + \egroup} + +\setupblackrules + [\c!width=\emwidth, + \c!height=\exheight, + \c!depth=\zeropoint, + \c!color=] + +%D \macros +%D {blackrules} +%D +%D One can call for a sequence of black rules, if needed equally spaced over the +%D given width. +%D +%D \showsetup{blackrules} +%D +%D The two alternative calls are therefore: +%D +%D \startbuffer +%D Tell me, is this according to the \blackrules[n=6]? +%D These \blackrules[alternativevariant=b,n=10,distance=.2em,width=4cm] are quite clear. +%D \stopbuffer +%D +%D \typebuffer +%D +%D or: +%D +%D \startlines +%D \getbuffer +%D \stoplines +%D +%D We could of course have implemented this macro using \type {\leaders}, but this +%D would probably have taken more tokens. + +\unexpanded\def\blackrules % probably never used + {\hpack\bgroup + \doifelsenextoptionalcs\pack_black_rules_pickup\pack_black_rules_indeed} + +\def\pack_black_rules_pickup[#1]% + {\setupcurrentblackrules[#1]% + \pack_black_rules_indeed} + +\def\pack_black_rules_indeed % no max handling here + {\scratchwidth \directblackrulesparameter\c!width + \scratchheight \directblackrulesparameter\c!height + \scratchdepth \directblackrulesparameter\c!depth + \scratchdistance\directblackrulesparameter\c!distance + \scratchcounter \directblackrulesparameter\c!n + \edef\p_alternative{\blackrulesparameter\c!alternative}% + \ifx\p_alternative\c!b % why not just check distance + \ifnum\scratchcounter=\plusone + \scratchdistance\zeropoint + \else + \scratchwidth\dimexpr(\scratchwidth-\scratchcounter\scratchdistance+\scratchdistance)/\scratchcounter\relax + \fi + \fi + \useblackrulesstyleandcolor\c!style\c!color + % a typical case of where we can use a simple loop or even a leaders + \dorecurse\scratchcounter\pack_black_rules_step + \unskip + \egroup} + +\def\pack_black_rules_step + {\ifcsname\??blackruletype\directblackrulesparameter\c!type\endcsname + \lastnamedcs + \else + \vrule + \fi + \s!width \scratchwidth + \s!height\scratchheight + \s!depth \scratchdepth + \relax + \ifzeropt\scratchdistance\else + \hskip\scratchdistance + \fi} + +\installcorenamespace{blackruletype} + +\setvalue{\??blackruletype mp}% + {\frule + type {mp}% + data {\includeMPgraphic{\directblackrulesparameter\c!mp}} + line \dimexpr\directblackrulesparameter\c!rulethickness\relax + } + +\letvalue{\??blackruletype\s!no }\novrule +%letvalue{\??blackruletype\s!yes}\vrule + +\setupblackrules + [\c!n=3, + \c!rulethickness=\linewidth, + \c!alternative=\c!a, + \c!distance=.25\emwidth, + \c!color=] + +%D \macros +%D {vl, hl} +%D +%D The command \type {\vl} draws a vertical rule \vl\ with strut dimensions, +%D multiplied with the factor specified in the optional argument. The height and +%D depth are clipped \vl [3] to the baselinedistance. Its horizontal counterpart +%D \type {\hl} draws a horizontal rule \hl\ with a width of 1em, multiplied with the +%D optional factor. The horizontal rule is drawn on top of the baseline. +%D +%D \showsetup{vl} +%D \showsetup{hl} + +\unexpanded\def\pack_rule_vl_indeed#1#2#3% + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox + {\vrule + \s!width #1\linewidth + \s!height#2\strutht + \s!depth #3\strutdp}% + \dp\scratchbox\strutdp + \ht\scratchbox\strutht + \box\scratchbox + \endgroup} + +\def\pack_rule_vl[#1]% + {\pack_rule_vl_indeed{#1}{#1}{#1}} + +\def\pack_rule_hl[#1]% + {\dontleavehmode + \hbox + {\vrule + \s!width #1\emwidth + \s!height\linewidth + \s!depth \zeropoint}} + +\unexpanded\def\vl{\dosingleempty\pack_rule_vl} +\unexpanded\def\hl{\dosingleempty\pack_rule_hl} + +\let\dovlwdhtdp\pack_rule_vl_indeed % used elsewhere + +%D \macros +%D {hairline, thinrule, thinrules, setupthinrules} +%D +%D Drawing thin lines can of course easily be accomplished by the \TEX\ +%D primitives \type{\hrule} and \type{\vrule}. The next few macros however +%D free us from some specifications. +%D +%D \startbuffer +%D some text +%D +%D \hairline +%D +%D some more text +%D +%D \thinrule +%D +%D more and more text +%D +%D hi \thinrule\ there +%D +%D and then the final text +%D \stopbuffer +%D +%D \typebuffer +%D +%D becomes +%D +%D \startexample +%D \getbuffer +%D \stopexample +%D +%D So we've got +%D +%D \showsetup{hairline} +%D \showsetup{thinrule} +%D +%D Both can be set up with: +%D +%D \showsetup{setupthinrules} +%D +%D We also have +%D +%D \showsetup{thinrules} +%D +%D which looks like: \thinrules[n=2] + +\installcorenamespace{thinrules} +\installcorenamespace{thinrulealternatives} + +\installdirectcommandhandler \??thinrules {thinrules} + +\setupthinrules + [\c!interlinespace=\v!small, + \c!n=3, + \c!before=, + \c!inbetween={\blank[\v!white]}, + \c!after=, + \c!color=, + \c!height=.5\linewidth, + \c!depth=.5\linewidth, + \c!frame=\v!on, % compatible with textbackgrounds + \c!alternative=\v!b, + \c!backgroundcolor=, + \c!background=, + \c!rulethickness=\linewidth] + +\letvalue{\??thinrulealternatives\v!a }\zerocount +\letvalue{\??thinrulealternatives\v!b }\plusone +\letvalue{\??thinrulealternatives\v!c }\plustwo +\letvalue{\??thinrulealternatives\v!none}\zerocount + +\newconstant\c_pack_thinrules_type + +\unexpanded\def\thinrule + {\strut + \bgroup + \edef\p_height {\directthinrulesparameter\c!height}% + \edef\p_depth {\directthinrulesparameter\c!depth}% + \edef\p_background{\directthinrulesparameter\c!background}% + \edef\p_frame {\directthinrulesparameter\c!frame}% + \linewidth\dimexpr\directthinrulesparameter\c!rulethickness/\plustwo\relax + \ifzeropt\linewidth + \c_pack_thinrules_type\zerocount + \else\ifx\p_frame\v!on + \c_pack_thinrules_type\expandnamespaceparameter\??thinrulealternatives\directthinrulesparameter\c!alternative\v!b\relax + \else + \c_pack_thinrules_type\zerocount + \fi\fi + \ifnum\c_pack_thinrules_type=\plusone + \ifx\p_height\v!max + \scratchheight\strutht + \else + \setdimensionwithunit\scratchheight\p_height\strutht + \fi + \ifx\p_depth\v!max + \scratchdepth\strutdp + \else + \setdimensionwithunit\scratchdepth\p_depth\strutdp + \fi + \else + \scratchheight\strutht + \scratchdepth \strutdp + \fi + \ifx\p_background\v!color + \startcolor[\directthinrulesparameter\c!backgroundcolor]% + \ifnum\c_pack_thinrules_type=\plustwo % prevent overshoot due to rounding + \leaders + \hrule + \s!height\dimexpr\scratchheight-\linewidth\relax + \s!depth \dimexpr\scratchdepth -\linewidth\relax + \hfill + \else + \leaders + \hrule + \s!height\scratchheight + \s!depth \scratchdepth + \hfill + \fi + \stopcolor + \ifcase\c_pack_thinrules_type + % no rule + \or + \startcolor[\directthinrulesparameter\c!color]% + \hfillneg + \leaders + \hrule + \s!height\linewidth + \s!depth \linewidth + \hfill + \stopcolor + \or + \startcolor[\directthinrulesparameter\c!color]% + \hfillneg + \leaders + \hrule + \s!height\dimexpr-\scratchdepth+\linewidth\relax + \s!depth \scratchdepth + \hfill + \hfillneg + \leaders + \hrule + \s!height\scratchheight + \s!depth \dimexpr-\scratchheight+\linewidth\relax + \hfill + \stopcolor + \fi + \else + \ifcase\c_pack_thinrules_type + % no rule + \else + \startcolor[\directthinrulesparameter\c!color]% + \leaders + \hrule + \s!height\scratchheight + \s!depth \scratchdepth + \hfill + \stopcolor + \fi + \fi + \strut + \carryoverpar\egroup} + +\unexpanded\def\hairline + {\endgraf + \thinrule + \endgraf} + +\unexpanded\def\thinrules + {\dosingleempty\pack_thinrules} + +\def\pack_thinrules[#1]% + {\bgroup + \setupcurrentthinrules[#1]% + \scratchcounter\directthinrulesparameter\c!n\relax + \ifcase\scratchcounter + % nothing, not even before/after + \let\p_after\relax + \else + \assignvalue{\directthinrulesparameter\c!interlinespace}\m_pack_thinrules_interlinespace{1.0}{1.5}{2.0}% + \spacing\m_pack_thinrules_interlinespace + \edef\p_after {\directthinrulesparameter\c!after}% + \edef\p_inbetween{\directthinrulesparameter\c!inbetween}% + \directthinrulesparameter\c!before + \ifcase\scratchcounter\or + \thinrule + \else + \dorecurse\scratchcounter + {\ifnum\recurselevel=\scratchcounter \directvspacing\v!samepage \else % \penalty500 + \ifnum\recurselevel=\plustwo \directvspacing\v!samepage \fi\fi % \penalty500 + \thinrule + \ifnum\recurselevel<\scratchcounter\relax + % test needed, else messed up whitespace + \ifx\p_inbetween\empty + \softbreak % \ifhmode \hskip \parfillskip \break \fi + \else + \endgraf + \nowhitespace + \p_inbetween + \fi + \fi}% + \fi + \fi + \ifx\p_after\empty + \carryoverpar\egroup + \else + \p_after\egroup + \fi{}} + +%D A couple of examples are given below. +%D +%D \startbuffer +%D \setupthinrules[n=3,inbetween=,color=gray] +%D +%D test test \thinrules\ test test \par +%D test test \thinrules [color=green] test test \par +%D test test \thinrules [height=max, depth=max] test test \par +%D +%D \setupthinrules[height=.9,depth=.9] +%D +%D test test \thinrules\ test test \par +%D test test \thinrules [alternativevariant=b] test test \par +%D test test \thinrules [alternativevariant=c] test test \par +%D test test \thinrules [alternativevariant=c,inbetween=\vskip2ex] test test \par +%D \stopbuffer +%D +%D \typebuffer {\getbuffer} +%D +%D There are a couple of alternative ways to visualize rules using backgrounds. At +%D first sight these may look strange, but they make sense in educational settings. +%D The alternatives are more or less compatible with the more advanced \METAPOST\ +%D based implementation. +%D +%D \startbuffer[a] +%D \setupthinrules +%D [n=2, +%D backgroundcolor=gray , +%D rulethickness=1pt, +%D colorkleur=donkerblauw, +%D after=\blank, +%D before=\blank] +%D \stopbuffer +%D +%D \typebuffer[a] +%D +%D \startbuffer[b] +%D \thinrules[alternativevariant=a] +%D \thinrules[alternativevariant=b] +%D \thinrules[alternativevariant=c] +%D \stopbuffer +%D +%D \typebuffer[b] \getbuffer[a,b] +%D +%D \startbuffer[b] +%D \thinrules[alternativevariant=a,background=color] +%D \thinrules[alternativevariant=b,background=color] +%D \thinrules[alternativevariant=c,background=color] +%D \stopbuffer +%D +%D \typebuffer[b] \getbuffer[a,b] +%D +%D \startbuffer[b] +%D \thinrules[alternativevariant=a,height=.8,depth=.8,background=color] +%D \thinrules[alternativevariant=b,height=.8,depth=.8,background=color] +%D \thinrules[alternativevariant=c,height=.8,depth=.8,background=color] +%D \stopbuffer +%D +%D \typebuffer[b] \getbuffer[a,b] + +%D \macros +%D {textrule, starttextrule, setuptextrules} +%D +%D Putting rules before and after a paragraph is very space sensitive, but the +%D next command handles that quite well. It comes in two disguises: +%D +%D \startbuffer +%D \textrule[top]{fragments} +%D \input reich +%D \textrule +%D \stopbuffer +%D +%D \start \typebuffer \getbuffer \stop +%D +%D \startbuffer +%D \setuptextrules +%D [width=90pt,distance=12pt,rulecolor=blue, +%D bodyfont=small,style=\sc,color=red] +%D +%D \starttextrule{Ship Building Tools} +%D \nl \setuptolerance[tolerant] \input materie +%D \stoptextrule +%D \stopbuffer +%D +%D \bgroup \typebuffer \getbuffer \egroup +%D +%D \startbuffer +%D \setuptextrules +%D [location=inmargin, +%D bodyfont=small,style=slantedbold] +%D +%D \starttextrule{wonderful} +%D \input tufte +%D \stoptextrule +%D \stopbuffer +%D +%D \bgroup \typebuffer \getbuffer \egroup +%D +%D The formal definition of these commands is: +%D +%D \showsetup{textrule} +%D \showsetup{starttextrule} +%D \showsetup{setuptextrules} +%D +%D The implementation looks a bit complicated due to the optional arguments. + +\installcorenamespace{textrules} +\installcorenamespace{textrulealternatives} + +\installdirectcommandhandler \??textrules {textrules} + +\setuptextrules + [\c!location=\v!left, + \c!before=\blank, + \c!after=\blank, + \c!inbetween=, + \c!width=2\emwidth, + \c!style=\v!bold, + \c!color=, + \c!rulecolor=, + \c!bodyfont=, + \c!depthcorrection=\v!on, + \c!rulethickness=\linewidth, + \c!distance=.5\emwidth] + +\unexpanded\def\textrule + {\dosingleempty\pack_textrule} + +\def\pack_textrule + {\iffirstargument + \expandafter\pack_textrule_yes + \else + \expandafter\pack_textrule_nop + \fi} + +\def\pack_textrule_yes[#1]% + {\expandnamespacevalue\??textrulealternatives{#1}\v!bottom} + +\def\pack_textrule_nop[#1]% + {\dosinglegroupempty\pack_textrule_nop_indeed} + +\def\pack_textrule_nop_indeed + {\iffirstargument + \expandafter\pack_textrule_nop_indeed_yes + \else + \expandafter\pack_textrule_nop_indeed_nop + \fi} + +\def\pack_textrule_nop_indeed_yes + {\csname\??textrulealternatives\v!top\endcsname} + +\def\pack_textrule_nop_indeed_nop + {\csname\??textrulealternatives\v!bottom\endcsname\empty} + +%D\startbuffer +%D\showstruts +%D +%D\setupwhitespace[none] +%D +%D\textrule[top]{test} xxxxx\smash{\strut} \textrule[bottom]{test} +%D\textrule[top]{test} xxxxx\strut \textrule[bottom]{test} +%D +%D\setupwhitespace[big] +%D +%D\textrule[top]{test} xxxxx\smash{\strut} \textrule[bottom]{test} +%D\textrule[top]{test} xxxxx\strut \textrule[bottom]{test} +%D\stoptyping +%D +%D \typebuffer \start \getbuffer \stop + +\setvalue{\??textrulealternatives\v!top}#1% + {\page[\v!preference] % interferes + \directtextrulesparameter\c!before\relax + \blank[\v!samepage,\v!nowhite]% + \pack_textrule_with_text_yes{#1}% + \blank[\v!samepage,\v!nowhite]% + \directtextrulesparameter\c!inbetween\relax + \endgraf} + +\setvalue{\??textrulealternatives\v!bottom}#1% + {\blank[\v!samepage,\v!nowhite]% + \pack_textrule_following{#1}% + \blank[\v!samepage,\v!nowhite]% + \directtextrulesparameter\c!after\relax + \page[\v!preference]} + +\setvalue{\??textrulealternatives\v!middle}#1% + {\blank[\v!samepage,\v!nowhite]% + \directtextrulesparameter\c!inbetween\relax + \pack_textrule_following{#1}% + \blank[\v!samepage,\v!nowhite]% + \directtextrulesparameter\c!inbetween\relax + \page[\v!preference]} + +\def\pack_textrule_with_text_yes#1% + {\noindent % this will force side floats to be calculated + \bgroup + \setbox\scratchbox\hpack to \availablehsize + {\scratchwidth \directtextrulesparameter\c!rulethickness\relax + \scratchheight\dimexpr .5\exheight+.5\scratchwidth\relax + \scratchdepth \dimexpr-.5\exheight+.5\scratchwidth\relax + \doifsomething{#1} + {\doifelse{\directtextrulesparameter\c!location}\v!inmargin + {\llap + {\usetextrulesstyleandcolor\c!style\c!color + #1% + \hskip\leftmargindistance}} + {\color[\directtextrulesparameter\c!rulecolor] + {\vrule + \s!height\scratchheight + \s!depth \scratchdepth + \s!width \directtextrulesparameter\c!width}% + \hbox spread 2\dimexpr\directtextrulesparameter\c!distance\relax + {\hss + \usetextrulesstyleandcolor\c!style\c!color + \strut#1% + \hss}}}% + \color[\directtextrulesparameter\c!rulecolor] + {\leaders\hrule + \s!height\scratchheight + \s!depth \scratchdepth + \hfill}}% + \ht\scratchbox\strutht + \dp\scratchbox\strutdp + \box\scratchbox + %\carryoverpar + \egroup} + +\def\pack_textrule_with_text_nop#1% + {\ifhmode + \endgraf + \fi + \doifelse{\directtextrulesparameter\c!depthcorrection}\v!on + \pack_textrule_correct_depth_yes + \pack_textrule_correct_depth_nop + \nointerlineskip + \noindent\naturalvpack % was \dontleavehmode + {\color[\directtextrulesparameter\c!rulecolor] + {\hrule + \s!depth \directtextrulesparameter\c!rulethickness + \s!height\zeropoint + \s!width \availablehsize}}} + +\def\pack_textrule_correct_depth_yes + {\vskip\dimexpr + \strutdp +.5\exheight + \ifdim\prevdepth>\strutdp\else + \ifdim\prevdepth>\zeropoint + -\prevdepth + \fi + \fi + \relax + \relax} + +\def\pack_textrule_correct_depth_nop + {\vskip\dimexpr + \strutdp +.5\exheight + \relax + \relax} + +\def\pack_textrule_following#1% + {\doifelsenothing{#1} + \pack_textrule_with_text_nop + \pack_textrule_with_text_yes + {#1}% + \ifvmode + \prevdepth\zeropoint + \fi} + +%D The grouped commands also supports bodyfont switching: + +\unexpanded\def\starttextrule#1% + {\bgroup + \def\pack_textrule_nop_indeed{\csname\??textrulealternatives\v!middle\endcsname}% + \csname\??textrulealternatives\v!top\endcsname{#1}% + \bgroup + \usebodyfontparameter\directtextrulesparameter} + +\unexpanded\def\stoptextrule + {\par + \egroup + \csname\??textrulealternatives\v!bottom\endcsname\empty + \egroup} + +%D \macros +%D {fillinrules, setupfillinrules} +%D +%D The next few commands do not really deserve a place in a core module, because +%D they deal with specific typography. Nevertheless I decided to make them part of +%D the core, because they permit us to make questionaires. Let's start with some +%D examples. +%D +%D \fillinrules[n=2,width=fit]{first} +%D \fillinrules[n=2,width=broad]{first} +%D \fillinrules[n=2,width=3cm]{first} +%D \fillinrules[n=2,width=3cm,distance=.5em,separator=:]{first} +%D \fillinrules[n=2]{first}{last} +%D \fillintext{first}{last} \input reich \par +%D +%D The main command is \type{\fillinrules}. This command takes one and an optional +%D second argument and sets a paragraph with empty visualized lines. +%D +%D \showsetup{fillinrules} +%D \showsetup{setupfillinrules} + + +\installcorenamespace{fillinrules} + +\installdirectcommandhandler \??fillinrules {fillinrules} + +\setupfillinrules + [\c!width=\v!broad, + \c!distance=\emwidth, + \c!before=\blank, + \c!after=\blank, + \c!n=\plusone, + \c!interlinespace=\v!small, + \c!separator=, + \c!style=, + \c!color=] + +\unexpanded\def\fillinrules + {\dosingleempty\pack_fillinrules} + +\def\pack_fillinrules[#1]% + {\endgraf + \begingroup + \setupcurrentfillinrules[#1]% + \let\pack_fillinrules_rule\thinrules + \dodoublegroupempty\pack_fillinrules_indeed} + +\def\pack_fillinrules_indeed#1#2% + {\directfillinrulesparameter\c!before + \setupcurrentthinrules + [\c!n=\directfillinrulesparameter\c!n, + \c!interlinespace=\directfillinrulesparameter\c!interlinespace, + \c!before=, + \c!after=]% + \scratchdistance\directfillinrulesparameter\c!distance\relax + \edef\m_fillinrules_one{#1}% + \edef\m_fillinrules_two{#2}% + \noindent + \ifx\m_fillinrules_one\empty \else + \edef\p_width{\directfillinrulesparameter\c!width}% + \ifx\p_width\v!fit + \scratchdistance\zeropoint + \hbox + \else\ifx\p_width\v!broad + \hbox + \else + \hbox to \directfillinrulesparameter\c!width + \fi\fi + \bgroup + \usefillinrulesstyleandcolor\c!style\c!color + \strut + \m_fillinrules_one + \hfill\directfillinrulesparameter\c!separator + \hskip\scratchdistance + \egroup + \fi + \setupwhitespace[\v!big]% + \ignorespaces + \pack_fillinrules_rule + \ifx\m_fillinrules_two\empty \else + \kern\scratchdistance + \usefillinrulesstyleandcolor\c!style\c!color + \m_fillinrules_two + \strut + \fi + \endgraf + \directfillinrulesparameter\c!after + \endgroup} + +%D \macros +%D {fillintext} +%D +%D To provide compatible layouts when texts and lines are mixed, one can typeset +%D a paragraph by using the command \type {\fillintext}. +%D +%D \showsetup{fillintext} + +\unexpanded\def\fillintext + {\dosingleempty\pack_fillintext} + +\def\pack_fillintext[#1]% ugly + {\endgraf + \begingroup + \setupcurrentfillinrules[#1]% + \dodoublegroupempty\pack_fillintext_indeed} + +\def\pack_fillintext_indeed#1#2% + {\def\pack_fillinrules_rule{\unhbox\nextbox\unskip}% + \dowithnextbox{\pack_fillinrules_indeed{#1}{\hfill#2}}% + \hbox\bgroup\let\par\egroup\ignorespaces} + +%D \macros +%D {fillinline, setupfillinlines} +%D +%D Another member of the family takes care of putting a (often small) rule after +%D a piece of text, like +%D +%D \startbuffer +%D \fillinline \input reich \par +%D \fillinline[margin=0cm] \input reich \par +%D \stopbuffer +%D +%D \startexample +%D \getbuffer +%D \stopexample +%D +%D which was typeset by saying: +%D +%D \typebuffer +%D +%D The two commands that take care of this are: +%D +%D \showsetup{fillinline} +%D \showsetup{setupfillinlines} +%D +%D Contrary to older implementations we now use the wrapper. + +\installcorenamespace{fillinlines} + +\installdirectcommandhandler \??fillinlines {fillinlines} + +\setupfillinlines + [\c!width=8\emwidth, % was 3cm + \c!margin=\directfillinlinesparameter\c!width, + \c!rulethickness=\linewidth, + \c!color=, + \c!distance=\emwidth, + \c!before=\blank, + \c!after=\blank] + +\unexpanded\def\fillinline + {\dosingleempty\pack_fillinline} + +\def\pack_fillinline[#1]% + {\begingroup + \setupcurrentfillinlines[#1]% + \directfillinlinesparameter\c!before + \advance\rightskip \directfillinlinesparameter\c!margin\relax + \parfillskip\zeropoint\relax + \dontleavehmode + \endgroup + \wrapuppar + {\begingroup + \setupcurrentfillinlines[#1]% + \ifhmode\unskip\hfill\fi + \scratchdistance\directfillinlinesparameter\c!distance + \scratchheight\dimexpr\directfillinlinesparameter\c!rulethickness/\plustwo\relax + \scratchwidth \dimexpr\directfillinlinesparameter\c!width-\scratchdistance\relax + \ifdim\scratchwidth>\directfillinlinesparameter\c!margin\else + \expandafter\rlap + \fi + {\kern\scratchdistance + \blackrule + [\c!color=\directfillinlinesparameter\c!color, + \c!width=\scratchwidth, + \c!height=\scratchheight, + \c!depth=\scratchheight]}% + \endgraf + \directfillinlinesparameter\c!after + \endgroup}} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-box.mkvi b/tex/context/base/mkiv/page-box.mkvi index 4804e8370..02c190e65 100644 --- a/tex/context/base/mkiv/page-box.mkvi +++ b/tex/context/base/mkiv/page-box.mkvi @@ -252,7 +252,6 @@ {\setbox#1\vpack to \paperheight {\hsize\paperwidth \vkern\topspace -% \parfillskip\zeropoint \hkern\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}% \box#1}% \dp#1\zeropoint} diff --git a/tex/context/base/mkiv/spac-hor.mkxl b/tex/context/base/mkiv/spac-hor.mkxl new file mode 100644 index 000000000..38e495e3c --- /dev/null +++ b/tex/context/base/mkiv/spac-hor.mkxl @@ -0,0 +1,1287 @@ +%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 ADE \& \CONTEXT\ Development Team}] +%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 + +\registerctxluafile{spac-hor}{} + +\let \parfillrightskip \parfillskip +\newskip \parfillleftskip +\newconstant\parfillleftmode + +\let\v_spac_indentation_current\empty % amount/keyword + +\newdimen \d_spac_indentation_par +\parindent\d_spac_indentation_par % for the show + +\newconditional\c_spac_indentation_indent_first \settrue\c_spac_indentation_indent_first +\newconstant \c_spac_indentation_toggle_state + +%D After a blank or comparable situation (left side floats) we +%D need to check if the next paragraph has to be indented. + +\unexpanded\def\presetindentation + {\doifoutervmode{\ifconditional\c_spac_indentation_indent_first\else\spac_indentation_variant_no\fi}} + +\unexpanded\def\setupindenting + {\doifelsenextoptionalcs\spac_indentation_setup_options\spac_indentation_setup_size} + +% \unexpanded\def\spac_indentation_setup_size +% {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}} + +\unexpanded\def\spac_indentation_setup_size + {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}% + \ifzeropt\parindent\else + \parindent\d_spac_indentation_par\relax % new per 2019-04-12 : just in case it has been set beforehand + \fi} + +\let\synchronizeindenting\spac_indentation_setup_size + +\let\m_spac_indentation_options\empty + +\def\spac_indentation_setup_options[#1]% + {\edef\m_spac_indentation_options{#1}% comma separated list + \ifx\m_spac_indentation_options\empty \else + \spac_indentation_setup_indeed + \fi} + +\def\spac_indentation_setup_indeed + {% not here: \settrue\c_spac_indentation_indent_first + % not here: \parindent\d_spac_indentation_par + % not here: \c_spac_indentation_toggle_state\zerocount + \processcommacommand[\m_spac_indentation_options]\spac_indentation_apply_step_one % catch small, medium, etc + \processcommacommand[\m_spac_indentation_options]\spac_indentation_apply_step_two % catch rest + \ifzeropt\parindent\else + \doifemptytoks\everypar\spac_indentation_set_everypar + \fi + \ifconditional\c_spac_indentation_indent_first + \spac_indentation_variant_yes % better than: \let\checkindentation\relax + \else + \spac_indentation_variant_no + \fi + \spac_indentation_check_toggle} + +\def\spac_indentation_set_everypar + {\everypar{\checkindentation}} + +\unexpanded\def\useindentingparameter#1% faster local variant + {\edef\m_spac_indentation_options{#1\c!indenting}% + \ifx\m_spac_indentation_options\empty \else + \spac_indentation_setup_indeed + \fi} + +% \def\spac_indentation_apply_step_one#1% +% {\ifcsname\??indentingmethod#1\endcsname +% % case two +% \else +% \edef\v_spac_indentation_current{#1}% single entry in list +% \let\normalindentation\v_spac_indentation_current +% \spac_indentation_setup_size +% \fi} +% +% \def\spac_indentation_apply_step_two#1% +% {\ifcsname\??indentingmethod#1\endcsname +% \csname\??indentingmethod#1\endcsname +% \else +% % case one +% \fi} + +% \defineindenting[whatever][yes,2cm] +% %defineindenting[whatever][yes,-2cm] +% +% \setupindenting[yes,-2em] \input ward \par +% \setupindenting[yes,2em] \input ward \par +% \setupindenting[whatever] \input ward \par + +\installcorenamespace {indentingpreset} + +\unexpanded\def\defineindenting + {\dodoubleargument\spac_indenting_define} + +\def\spac_indenting_define[#1][#2]% todo: mixes + {\setevalue{\??indentingpreset#1}{#2}} + +% \def\spac_indentation_apply_step_one_nested#1% +% {\expandafter\processcommacommand\expandafter[\csname\??indentingpreset#1\endcsname]\spac_indentation_apply_step_one} +% +% \def\spac_indentation_apply_step_two_nested#1% +% {\expandafter\processcommacommand\expandafter[\csname\??indentingpreset#1\endcsname]\spac_indentation_apply_step_two} +% +% \def\spac_indentation_apply_step_one#1% +% {\ifcsname\??indentingpreset#1\endcsname +% \spac_indentation_apply_step_one_nested{#1}% +% \else\ifcsname\??indentingmethod#1\endcsname +% % case two +% \else +% \edef\v_spac_indentation_current{#1}% single entry in list +% \let\normalindentation\v_spac_indentation_current +% \spac_indentation_setup_size +% \fi\fi} +% +% \def\spac_indentation_apply_step_two#1% +% {\ifcsname\??indentingpreset#1\endcsname +% \spac_indentation_apply_step_two_nested{#1}% +% \else\ifcsname\??indentingmethod#1\endcsname +% \lastnamedcs +% \else +% % case one +% \fi\fi} + +\def\spac_indentation_apply_step_one_nested + {\expandafter\processcommacommand\expandafter[\lastnamedcs]\spac_indentation_apply_step_one} + +\def\spac_indentation_apply_step_two_nested + {\expandafter\processcommacommand\expandafter[\lastnamedcs]\spac_indentation_apply_step_two} + +\def\spac_indentation_apply_step_one#1% + {\ifcsname\??indentingpreset#1\endcsname + \spac_indentation_apply_step_one_nested + \else\ifcsname\??indentingmethod#1\endcsname + % case two + \else + \edef\v_spac_indentation_current{#1}% single entry in list + \let\normalindentation\v_spac_indentation_current + \spac_indentation_setup_size + \fi\fi} + +\def\spac_indentation_apply_step_two#1% + {\ifcsname\??indentingpreset#1\endcsname + \spac_indentation_apply_step_two_nested + \else\ifcsname\??indentingmethod#1\endcsname + \lastnamedcs + \else + % case one + \fi\fi} + +\unexpanded\def\indenting % kind of obsolete + {\doifelsenextoptionalcs\spac_indentation_setup_options\relax} + +% use \noindentation to suppress next indentation + +\installcorenamespace{indentingmethod} + +\unexpanded\def\installindentingmethod#1#2% + {\setvalue{\??indentingmethod#1}{#2}} + +\installindentingmethod \v!no {\parindent\zeropoint} +\installindentingmethod \v!not {\parindent\zeropoint} + +\installindentingmethod \v!first {\settrue\c_spac_indentation_indent_first} +\installindentingmethod \v!next {\setfalse\c_spac_indentation_indent_first} + +\installindentingmethod \v!yes {\parindent\d_spac_indentation_par\relax} % not \indent ! +\installindentingmethod \v!always{\parindent\d_spac_indentation_par\relax} % not \indent ! + +\installindentingmethod \v!never {\parindent\zeropoint\relax % no \indent ! + \c_spac_indentation_toggle_state\zerocount} + +\installindentingmethod \v!odd {\c_spac_indentation_toggle_state\plusone} +\installindentingmethod \v!even {\c_spac_indentation_toggle_state\plustwo} + +\installindentingmethod \v!normal{\ifx\normalindentation\empty\else + \let\v_spac_indentation_current\normalindentation + \spac_indentation_setup_size + \fi} + +\installindentingmethod \v!reset {\settrue\c_spac_indentation_indent_first + \parindent\zeropoint + \c_spac_indentation_toggle_state\zerocount} + +\installindentingmethod \v!toggle{\parindent\ifzeropt\parindent + \d_spac_indentation_par + \else + \zeropoint + \fi\relax} + +\unexpanded\def\noindenting{\indenting[\v!no, \v!next ]} +\unexpanded\def\doindenting{\indenting[\v!yes,\v!first]} + +%D Here come the handlers (still rather messy ... we need states). + +%newif\ifindentation \indentationtrue % will become a mode + +\let\checkindentation\relax + +\installmacrostack\checkindentation +%installmacrostack\ifindentation + +\def\spac_indentation_remove + {\ifzeropt\parindent \else + \begingroup + \setbox\scratchbox\lastbox + \endgroup + \fi} + +\def\spac_indentation_kill_indeed + {%\global\indentationfalse + \spac_indentation_remove} + +\def\spac_indentation_do_toggle_indeed + {%\global\indentationfalse + \glet\checkindentation\spac_indentation_no_toggle_indeed + \spac_indentation_remove} + +\def\spac_indentation_no_toggle_indeed + {%\global\indentationtrue + \glet\checkindentation\spac_indentation_do_toggle_indeed} + +\def\spac_indentation_do_indeed + {}%\global\indentationtrue} + +\def\spac_indentation_do_toggle + {\glet\checkindentation\spac_indentation_do_toggle_indeed} + +\def\spac_indentation_no_toggle + {\glet\checkindentation\spac_indentation_no_toggle_indeed} + +\def\spac_indentation_check_toggle + {\ifcase\c_spac_indentation_toggle_state + % nothing + \or + \spac_indentation_no_toggle + \or + \spac_indentation_do_toggle + \fi} + +\def\spac_indentation_variant_yes + {\glet\checkindentation\spac_indentation_do_indeed} + +\def\spac_indentation_no_next_check + {\spac_indentation_remove + \glet\checkindentation\spac_indentation_do_indeed} + +\def\spac_indentation_variant_no % made global + {\ifinpagebody \else + %\global\indentationfalse + \glet\checkindentation\spac_indentation_no_next_check + \fi} + +\def\nonoindentation % bv bij floats + {\ifinpagebody \else + %\global\indentationtrue + \glet\checkindentation\spac_indentation_do_indeed + \fi} + +\def\spac_indentation_variant_force + {\ifvmode \ifzeropt\parindent \else + % was : \hskip\parindent + % can be: \indent + % but we test: + \noindent\hskip\parindent + \fi \fi} + +\appendtoks + \push_macro_checkindentation + \push_macro_ifindentation +\to \everypushsomestate + +\appendtoks + \pop_macro_ifindentation + \pop_macro_checkindentation +\to \everypopsomestate + +% public: + +\let\indentation \spac_indentation_variant_force +\let\noindentation\spac_indentation_variant_no % public +\let\doindentation\spac_indentation_variant_yes % public + +\def\dontrechecknextindentation % public (in macros) + {\glet\dorechecknextindentation\relax} + +\let\dorechecknextindentation\relax % public (in macros) + +\unexpanded\def\spac_indentation_check_next_indentation + {\glet\dorechecknextindentation\relax + \doifelsenextchar\par\donothing\spac_indentation_variant_no} % messy check as next is seldom \par + +\def\spac_indentation_variant_auto + {\glet\dorechecknextindentation\spac_indentation_check_next_indentation} + +%D This one sets up the local indentation behaviour (i.e. either or not +%D a next paragraph will be indented). + +\installcorenamespace{indentnext} + +\unexpanded\def\checknextindentation[#1]% + {\begincsname\??indentnext#1\endcsname} + +\unexpanded\def\useindentnextparameter#1% new, the more efficient variant + {\edef\p_indentnext{#1\c!indentnext}% + \ifx\p_indentnext\empty\else + \begincsname\??indentnext\p_indentnext\endcsname + \fi} + +\letvalue{\??indentnext }\donothing +\letvalue{\??indentnext\v!yes }\spac_indentation_variant_yes +\letvalue{\??indentnext\v!no }\spac_indentation_variant_no +\letvalue{\??indentnext\v!auto}\spac_indentation_variant_auto + +%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 + +% maybe an everyforgetparindent + +\unexpanded\def\forgetparindent + {\settrue\c_spac_indentation_indent_first % recently added + \d_spac_indentation_par\zeropoint + \parindent\zeropoint + \let\v_spac_indentation_current\v!none} + +\appendtoks + \forgetparindent +\to \everyforgetall + +\unexpanded\def\forgethorizontalstretch + {\emergencystretch\zeropoint} + +\appendtoks + \forgethorizontalstretch +\to \everyforgetall % needed in pagebody + +%D Helper: + +\unexpanded\def\softbreak + {\relax\ifhmode\hskip\parfillskip\break\fi} + +%D \macros +%D {frenchspacing,nonfrenchspacing} +%D +%D Somehow \type{\frenchspacing} can lead to hyphenation between dashes so we now +%D have \type {\newfrenchspacing} (moved from \type {syst-chr}). Maybe it's not +%D needed any more. + +%D Hm ... todo: + +\installcorenamespace{spacecodemethod} + +\sfcode`\)=\zerocount +\sfcode`\'=\zerocount +\sfcode`\]=\zerocount + +\def\spac_spacecodes_set_fixed#1% + {\sfcode`\.#1\relax \sfcode`\,#1\relax + \sfcode`\?#1\relax \sfcode`\!#1\relax + \sfcode`\:#1\relax \sfcode`\;#1\relax} + +\def\spac_spacecodes_set_stretch + {\sfcode`\.3000 \sfcode`\,1250 + \sfcode`\?3000 \sfcode`\!3000 + \sfcode`\:2000 \sfcode`\;1500 } + +\unexpanded\def\frenchspacing {\spac_spacecodes_set_fixed\plusthousand} +\unexpanded\def\newfrenchspacing{\spac_spacecodes_set_fixed{1050}} +\unexpanded\def\nonfrenchspacing{\spac_spacecodes_set_stretch} + +\unexpanded\def\installspacingmethod#1#2{\setvalue{\??spacecodemethod#1}{#2}} + +\installspacingmethod \empty {} % keep values +\installspacingmethod \v!fixed {\frenchspacing } % equal spaces everywhere +\installspacingmethod \v!packed {\newfrenchspacing} % slighly more after punctuation +\installspacingmethod \v!broad {\nonfrenchspacing} % more depending on what punctuation + +\unexpanded\def\setupspacing + {\doifelsenextoptionalcs\spac_spacecodes_setup_yes\spac_spacecodes_setup_nop} + +\def\spac_spacecodes_setup_yes[#1]% + {\begincsname\??spacecodemethod#1\endcsname + \updateraggedskips} + +\def\spac_spacecodes_setup_nop + {\updateraggedskips} + +%D Here's a tweak .. if needed one can configure it in the configuration +%D so that initialization happens more efficient. +%D +%D \starttyping +%D \startoverlay +%D { +%D \green +%D \enabledirectives[characters.spaceafteruppercase=normal]% +%D \vbox{\hsize 5em x. X\par x.\ X\par X. X\par X.\ X\par} +%D } { +%D \blue +%D \enabledirectives[characters.spaceafteruppercase=traditional]% +%D \vbox{\hsize 5em x. X\par x.\ X\par X. X\par X.\ X\par} +%D } +%D \stopoverlay +%D \stoptyping + +% This is not needed, as \updateraggedskips is taking care of it: + +\let\synchronizespacecodes\spac_spacecodes_setup_nop % \relax + +% \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 \<endlinechar> and +% since we have by default \def\^^M{\ } we get into a loop. + +\let\normalspaceprimitive=\ % space-comment is really needed + +%D As the \type{\ } is convenient in: +%D +%D \starttyping +%D \TEX\space x\crlf +%D \TEX\ x\crlf +%D \TEX{} x\crlf +%D \stoptyping +%D +%D from now on we treat it as a normal space and not as a space with \type +%D {sfcode} 1000. + +\unexpanded\def\specialspaceprimitive + {\begingroup + % so, no fancy extra spacing after: foo i.e.\ bar + \nonfrenchspacing\normalspaceprimitive + \endgroup} + +\unexpanded\def\normalnotobeyedspace + {\mathortext\normalspaceprimitive\specialspaceprimitive} % no \dontleavehmode\space (else no frenchspacing) + +\let\ =\normalnotobeyedspace + +% Because I strip spaces at the end of lines (in the editor) we need a bit of +% a trick to define slash+newline, so \space and \<newline> are the same + +% We need to be careful with \ and \space and the definition of ~ which uses \ as +% we need to associate unicode spacing with it. There is some messy aspect that +% I forgot to note down so I will revision the \ once I ran into it again. + +% \ruledhbox spread 10pt {\frenchspacing xx xx\ X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx xx\ X} +% \ruledhbox spread 10pt {\frenchspacing xx xx X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx xx X} +% \ruledhbox spread 10pt {\frenchspacing xx xx~X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx xx~X} + +% \ruledhbox spread 10pt {\frenchspacing xx dr.\ X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx dr.\ X} +% \ruledhbox spread 10pt {\frenchspacing xx dr. X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx dr. X} +% \ruledhbox spread 10pt {\frenchspacing xx dr.~X} +% \ruledhbox spread 10pt {\nonfrenchspacing xx dr.~X} + +\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\normalspaceprimitive} % no space in math + +\letcatcodecommand \ctxcatcodes \tildeasciicode \nonbreakablespace % overloaded later + + \def\space { } +\unexpanded\def\removelastspace{\ifhmode\unskip\fi} +\unexpanded\def\nospace {\removelastspace\ignorespaces} + +\ifdefined\nospaces + \unexpanded\def\nospacing{\normalnospaces\plusone} + \unexpanded\def\dospacing{\normalnospaces\zerocount} +\else + \unexpanded\def\nospacing{\spaceskip\scaledpoint \xspaceskip\zeropoint} + \unexpanded\def\dospacing{\spaceskip\currentspaceskip\xspaceskip\zeropoint} % what +\fi + +\ifdefined\softhyphen \else + \let\softhyphen\explicitdiscretionary +\fi + +\cldcontext{"\string\\unexpanded\string\\def\string\\\string\n{\string\\space}"} +%cldcontext{"\string\\let\string\\\string\n=\string\\space"} + +% in tables we need: +% +% \def\fixedspace {\hskip.5em\relax} +% +% but, since not all fonts have .5em digits: + +\unexpanded\def\fixedspace + {\setbox\scratchbox\hpack{\mathortext{0}{0}}% was \hbox + \hskip\wd\scratchbox\relax} + +\unexpanded\def\fixedspaces + {\letcatcodecommand \ctxcatcodes \tildeasciicode\fixedspace + \let~\fixedspace} % we need to renew it + +\appendtoks + \let~\space + \let\ \space +\to \everysimplifycommands + +\newsignal\s_spac_keep_unwanted_space + +\unexpanded\def\keepunwantedspaces + {\ifhmode + \ifdim\lastskip=\s_spac_keep_unwanted_space\else + \hskip\s_spac_keep_unwanted_space\relax + \fi + \fi} + +\unexpanded\def\removeunwantedspaces + {\ifhmode + \expandafter \spac_helpers_remove_unwantedspace + \fi} + +\def\spac_helpers_remove_unwantedspace + {\ifnum\lastnodetype=\gluenodecode + \ifdim\lastskip=\s_spac_keep_unwanted_space\relax + \unskip + \else + \unskip + \doubleexpandafter\spac_helpers_remove_unwantedspace + \fi + \fi} + +\unexpanded\def\onlynonbreakablespace + {\ifdim\lastskip=\interwordspace + \unskip + \nonbreakablespace + \fi + \ignorespaces} + +% \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: + +\ifdefined\thinspace \else + + \unexpanded\def\thinspace {\kern .16667\emwidth} + \unexpanded\def\negthinspace{\kern-.16667\emwidth} + \unexpanded\def\enspace {\kern .5\emwidth} + +\fi + +\ifdefined\quad \else + + \unexpanded\def\enskip{\hskip.5\emwidth\relax} + \unexpanded\def\quad {\hskip \emwidth\relax} + \unexpanded\def\qquad {\hskip 2\emwidth\relax} + +\fi + +\unexpanded\def\negenspace{\kern-.5\emwidth} +\unexpanded\def\negemspace{\kern- \emwidth} + +\let\emspace\quad + +\unexpanded\def\charspace{ } % the unexpandable \space (as space can also be delimiter for numbers) + +\unexpanded\def\quads + {\dosingleempty\spac_quads} + +\def\spac_quads[#1]% + {\zwj\dorecurse{\iffirstargument#1\else\plusthree\fi}{\hskip\emwidth\zwj}} + +% 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: + +\unexpanded\def\hfilll {\hskip\zeropoint\s!plus1\s!filll\relax} +\unexpanded\def\vfilll {\vskip\zeropoint\s!plus1\s!filll\relax} + +%unexpanded\def\hfilneg {\hskip\zeropoint\s!plus-1\s!fil\relax} +\unexpanded\def\hfillneg {\hskip\zeropoint\s!plus-1\s!fill\relax} +\unexpanded\def\hfilllneg{\hskip\zeropoint\s!plus-1\s!filll\relax} +%unexpanded\def\vfilneg {\vskip\zeropoint\s!plus-1\s!fil\relax} +\unexpanded\def\vfillneg {\vskip\zeropoint\s!plus-1\s!fill\relax} +\unexpanded\def\vfilllneg{\vskip\zeropoint\s!plus-1\s!filll\relax} + +\unexpanded\def\tfskip {\begingroup\tf\hskip\emwidth\endgroup} +\unexpanded\def\dotfskip#1{\begingroup\tf\hskip #1\endgroup} % used elsewhere + +% maybe we should hash the analysis + +\installcorenamespace{narrower} +\installcorenamespace{narrowermethod} + +\newskip\s_spac_narrower_left +\newskip\s_spac_narrower_right +\newskip\s_spac_narrower_middle + +\installcommandhandler \??narrower {narrower} \??narrower + +\setupnarrower + [\c!before=\endgraf, + \c!after=\endgraf, + \c!left=1.5\emwidth, + \c!right=1.5\emwidth, + \c!middle=1.5\emwidth, + \c!default=\v!middle] + +\appendtoks + \setuevalue{\e!start\currentnarrower}{\spac_narrower_start{\currentnarrower}}% + \setuevalue{\e!stop \currentnarrower}{\spac_narrower_stop}% +\to \everydefinenarrower + +\unexpanded\def\installnarrowermethod#1#2% + {\setvalue{\??narrowermethod#1}{#2}} + +\unexpanded\def\spac_narrower_method_analyze#1% + {\ifcsname\??narrowermethod#1\endcsname + \lastnamedcs + \else + \global\advance\s_spac_narrower_middle#1\relax + \fi} + +\def\spac_narrower_initialize[#1]% hm, can be dorepeat directly + {\dorepeatwithcommand[#1]\spac_narrower_method_analyze} + +\installnarrowermethod \v!left {\global\advance\s_spac_narrower_left \narrowerparameter\c!left \relax} +\installnarrowermethod \v!middle {\global\advance\s_spac_narrower_middle \narrowerparameter\c!middle\relax} +\installnarrowermethod \v!right {\global\advance\s_spac_narrower_right \narrowerparameter\c!right \relax} +\installnarrowermethod{-\v!left }{\global\advance\s_spac_narrower_left -\narrowerparameter\c!left \relax} +\installnarrowermethod{-\v!middle}{\global\advance\s_spac_narrower_middle-\narrowerparameter\c!middle\relax} +\installnarrowermethod{-\v!right }{\global\advance\s_spac_narrower_right -\narrowerparameter\c!right \relax} +\installnarrowermethod \v!reset {\global \s_spac_narrower_left \zeropoint + \global \s_spac_narrower_middle \zeropoint + \global \s_spac_narrower_right \zeropoint\relax} +\installnarrowermethod \v!none {} +\installnarrowermethod \v!reverse {} % never seen + +\unexpanded\def\spac_narrower_start#1% + {\begingroup + \edef\currentnarrower{#1}% + \dosingleempty\spac_narrower_start_indeed} + +\unexpanded\def\spac_narrower_start_indeed[#1]% + {\iffirstargument + \spac_narrower_start_apply{#1}% + \else + \spac_narrower_start_apply{\narrowerparameter\v!default}% + \fi} + +\newskip\s_spac_narrower_left_last +\newskip\s_spac_narrower_right_last +\newconditional\s_spac_narrower_last_swap + +\def\spac_narrower_start_apply#1% + {\narrowerparameter\c!before + \global\s_spac_narrower_left \zeropoint + \global\s_spac_narrower_right \zeropoint + \global\s_spac_narrower_middle\zeropoint + \edef\askednarrower{#1}% + \ifx\askednarrower\v!reverse + \ifconditional\s_spac_narrower_last_swap + \frozen\leftskip \s_spac_narrower_right_last + \frozen\rightskip\s_spac_narrower_left_last + \setfalse\s_spac_narrower_last_swap + \else + \frozen\leftskip \s_spac_narrower_left_last + \frozen\rightskip\s_spac_narrower_right_last + \settrue\s_spac_narrower_last_swap + \fi + \else + \normalexpanded{\processcommalistwithparameters[\askednarrower]}\spac_narrower_initialize + \frozen\advance\leftskip \dimexpr\s_spac_narrower_left +\s_spac_narrower_middle\relax + \frozen\advance\rightskip\dimexpr\s_spac_narrower_right+\s_spac_narrower_middle\relax + \fi + \seteffectivehsize} + +\unexpanded\def\spac_narrower_stop + {\narrowerparameter\c!after + \normalexpanded{% + \endgroup + \s_spac_narrower_left_last \the\leftskip \relax + \s_spac_narrower_right_last\the\rightskip\relax + \ifconditional\s_spac_narrower_last_swap + \setfalse\s_spac_narrower_last_swap + \else + \settrue\s_spac_narrower_last_swap + \fi + }} + +\unexpanded\def\startnarrower + {\dosingleempty\spac_narrower_start_basic} + +\unexpanded\def\spac_narrower_start_basic[#1]% + {\begingroup + \let\currentnarrower\empty + \iffirstargument + \spac_narrower_start_apply{#1}% + \else + \spac_narrower_start_apply{\narrowerparameter\v!default}% + \fi} + +\let\stopnarrower\spac_narrower_stop + +\unexpanded\def\startnarrow % current how + {\begingroup + \dodoubleempty\spac_narrower_start_named} + +% \def\spac_narrower_start_named[#1][#2]% +% {\edef\currentnarrower{#1}% +% \ifsecondargument +% \spac_narrower_start_apply{#2}% +% \else +% \spac_narrower_start_apply{\narrowerparameter\v!default}% +% \fi} + +\def\spac_narrower_start_named + {\ifsecondargument + \expandafter\spac_narrower_start_named_two + \else + \expandafter\spac_narrower_start_named_one + \fi} + +\def\spac_narrower_start_named_one[#1]% + {\doifelseassignment{#1}\spac_narrower_start_named_one_yes\spac_narrower_start_named_one_nop[#1]} + +\def\spac_narrower_start_named_one_yes[#1][#2]% [settings] [] + {\setupcurrentnarrower[#1]% + \spac_narrower_start_apply{\narrowerparameter\v!default}} + +\def\spac_narrower_start_named_one_nop[#1][#2]% [tag] [] + {\edef\currentnarrower{#1}% + \spac_narrower_start_apply{\narrowerparameter\v!default}} + +\def\spac_narrower_start_named_two[#1]% + {\doifelseassignment{#1}\spac_narrower_start_named_settings_how\spac_narrower_start_named_tag_unknown[#1]} + +\def\spac_narrower_start_named_settings_how[#1][#2]% [settings] [how] + {\setupcurrentnarrower[#1]% + \spac_narrower_start_apply{#2}} + +\def\spac_narrower_start_named_tag_unknown[#1][#2]% [tag] [...] + {\doifelseassignment{#2}\spac_narrower_start_named_tag_settings\spac_narrower_start_named_tag_how[#1][#2]} + +\def\spac_narrower_start_named_tag_settings[#1][#2]% [tag] [settings] + {\edef\currentnarrower{#1}% + \setupcurrentnarrower[#2]% + \spac_narrower_start_apply{\narrowerparameter\v!default}} + +\def\spac_narrower_start_named_tag_how[#1][#2]% [tag] [how] + {\edef\currentnarrower{#1}% + \spac_narrower_start_apply{#2}} + +\let\stopnarrow\spac_narrower_stop + +\newdimen\d_spac_effective_hsize \def\effectivehsize {\hsize} +\newdimen\d_spac_effective_leftskip \def\effectiveleftskip {\dimexpr\leftskip \relax} +\newdimen\d_spac_effective_rightskip \def\effectiverightskip{\dimexpr\rightskip\relax} + +\unexpanded\def\seteffectivehsize + {\setlocalhsize + \d_spac_effective_hsize \localhsize + \d_spac_effective_leftskip 1\leftskip + \d_spac_effective_rightskip1\rightskip + \let\effectivehsize \d_spac_effective_hsize + \let\effectiveleftskip \d_spac_effective_leftskip + \let\effectiverightskip\d_spac_effective_rightskip} + +\installcorenamespace{skipadaptionleft} +\installcorenamespace{skipadaptionright} + +\newskip\leftskipadaption +\newskip\rightskipadaption + +\setvalue{\??skipadaptionleft \v!yes }{\ifzeropt\d_spac_indentation_par\narrowerparameter\c!left\else\d_spac_indentation_par\fi} +\letvalue{\??skipadaptionleft \v!no }\zeropoint +\letvalue{\??skipadaptionleft \empty }\zeropoint +\setvalue{\??skipadaptionright\v!yes }{\narrowerparameter\c!right} +\letvalue{\??skipadaptionright\v!no }\zeropoint +\letvalue{\??skipadaptionright\empty }\zeropoint + +% \setvalue{\??skipadaptionleft \v!standard}{\ifzeropt\d_spac_indentation_par\narrowerparameter\c!left\else\d_spac_indentation_par\fi} +% \setvalue{\??skipadaptionright\v!standard}{\narrowerparameter\c!right} + +\letcsnamecsname\csname\??skipadaptionleft \v!standard\endcsname\csname\??skipadaptionleft \v!yes\endcsname +\letcsnamecsname\csname\??skipadaptionright\v!standard\endcsname\csname\??skipadaptionright\v!yes\endcsname + +% \unexpanded\def\dosetleftskipadaption #1{\leftskipadaption \ifcsname\??skipadaptionleft #1\endcsname\csname\??skipadaptionleft #1\endcsname\else#1\fi\relax} +% \unexpanded\def\dosetrightskipadaption#1{\rightskipadaption\ifcsname\??skipadaptionright#1\endcsname\csname\??skipadaptionright#1\endcsname\else#1\fi\relax} + +\unexpanded\def\dosetleftskipadaption #1{\leftskipadaption \ifcsname\??skipadaptionleft #1\endcsname\lastnamedcs\else#1\fi\relax} +\unexpanded\def\dosetrightskipadaption#1{\rightskipadaption\ifcsname\??skipadaptionright#1\endcsname\lastnamedcs\else#1\fi\relax} + +\unexpanded\def\doadaptleftskip #1{\normalexpanded{\dosetleftskipadaption {#1}}\frozen\advance\leftskip \leftskipadaption } +\unexpanded\def\doadaptrightskip#1{\normalexpanded{\dosetrightskipadaption{#1}}\frozen\advance\rightskip\rightskipadaption} + +\unexpanded\def\forgetbothskips + {\leftskip\zeropoint + \rightskip\zeropoint + \relax} + +\appendtoks + \forgetbothskips +\to \everyforgetall + +% in spac-ver.mkiv +% +% \unexpanded\def\forgetparskip +% {\s_spac_whitespace_parskip\zeropoint +% \parskip\zeropoint +% \let\v_spac_whitespace_current\v!none} +% +% \appendtoks +% \forgetparskip +% \to \everyforgetall + +%D Tolerance (can also be set with align): + +\installcorenamespace{tolerancemethods} + +\unexpanded\def\installtolerancemethod#1#2#3% + {\setvalue{\??tolerancemethods#1:#2}{#3}} + +\installtolerancemethod \v!vertical \v!verystrict {\let\bottomtolerance\empty} +\installtolerancemethod \v!vertical \v!strict {\def\bottomtolerance{.050}} +\installtolerancemethod \v!vertical \v!tolerant {\def\bottomtolerance{.075}} +\installtolerancemethod \v!vertical \v!verytolerant {\def\bottomtolerance{.100}} + +\installtolerancemethod \v!horizontal \v!stretch {\emergencystretch\bodyfontsize} +\installtolerancemethod \v!horizontal \v!space {\spaceskip.5em\s!plus.25em\s!minus.25em\relax} +\installtolerancemethod \v!horizontal \v!verystrict {\tolerance\plustwohundred} +\installtolerancemethod \v!horizontal \v!strict {\tolerance1500 } +\installtolerancemethod \v!horizontal \v!tolerant {\tolerance3000 } +\installtolerancemethod \v!horizontal \v!verytolerant {\tolerance4500 } + +\appendetoks + \pretolerance\plushundred + \tolerance \plustwohundred +\to\everyforgetall + +\def\spac_tolerances_step_vertical #1{\csname\??tolerancemethods\v!vertical :#1\endcsname} +\def\spac_tolerances_step_horizontal#1{\csname\??tolerancemethods\v!horizontal:#1\endcsname} + +\unexpanded\def\setuptolerance + {\dosingleargument\spac_tolerances_setup} + +\def\spac_tolerances_setup[#1]% + {\doifelseinset\v!vertical{#1}% + {\processcommacommand[#1]\spac_tolerances_step_vertical } + {\processcommacommand[#1]\spac_tolerances_step_horizontal}} + +%D \macros +%D {pushindentation,popindentation} +%D +%D The pushing and popping is done by: + +\newbox\b_spac_indentations_a +\newbox\b_spac_indentations_b + +\unexpanded\def\pushindentation + {\begingroup + \ifhmode + \unskip + \setbox\b_spac_indentations_a\lastbox % get \strut if present + \unskip + \setbox\b_spac_indentations_b\lastbox % get \indent generated box + \unskip + \else + \dontleavehmode % was \hskip\zeropoint % switch to horizontal mode + \unskip + \setbox\b_spac_indentations_a\lastbox % get \indent generated box + \setbox\b_spac_indentations_b\emptybox + \fi} + +\unexpanded\def\popindentation + {\box\b_spac_indentations_b + \box\b_spac_indentations_a + \endgroup} + +%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=\hbox{\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}. + +%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 + +\unexpanded\def\justonespace{\removeunwantedspaces\space} +%unexpanded\def\justaperiod {\removeunwantedspaces.} +%unexpanded\def\justacomma {\removeunwantedspaces,} + +\installcorenamespace{hspace} + +\unexpanded\def\ignorecrlf + {\let\crlf\justonespace\let\\\crlf} + +\unexpanded\def\definehspace + {\dotripleempty\spac_hspaces_define} + +\def\spac_hspaces_define[#1][#2][#3]% #1 = optional namespace + {\ifthirdargument + \setvalue{\??hspace#1:#2}{#3}% + \else + \setvalue{\??hspace:#1}{#2}% + \fi} + +\unexpanded\def\hspace + {\dodoubleempty\spac_hspaces_insert} + +\def\spac_hspaces_insert[#1][#2]% + {\ifhmode + \removeunwantedspaces + \hskip % always a skip even when 0pt + \ifsecondargument + \hspaceamount{#1}{#2}% + \else\iffirstargument + \hspaceamount\empty{#1}% + \else + \hspaceamount\empty\s!default + \fi\fi + \expandafter\ignorespaces + \fi} + +\def\hspaceamount#1#2% + {\dimexpr\ifcsname\??hspace#1:#2\endcsname\lastnamedcs\else\zeropoint\fi\relax} + +\def\directhspaceamount#1% + {\dimexpr\ifcsname\??hspace :#1\endcsname\lastnamedcs\else\zeropoint\fi\relax} + +% no installhspace here (this is already an old command) + +\definehspace [\v!small] [.25\emspaceamount] +\definehspace [\v!medium] [.5\emspaceamount] +\definehspace [\v!big] [1\emspaceamount] +\definehspace [\v!normal] [1\spaceamount] +\definehspace [\v!default] [\spaceamount] +\definehspace [\v!none] [\zeropoint] + +%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\textormathspacecommand #1#2#3{\ifmmode\mskip#1#2\else#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} % 4/18 em +\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} + +\unexpanded\edef\medspace {\textormathspacecommand+\medmuskip{\Uchar"205F}} + +% needed for unicode: + +%unexpanded\def\breakablethinspace {\breakabletextormathspace+\thinmuskip1} +%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\kern\interwordspace} +%unexpanded\def\narrownobreakspace {\penalty\plustenthousand\thinspace} +%unexpanded\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} +%unexpanded\def\zerowidthspace {\hskip\zeropoint} + +\definehspace[.5][.1250\emwidth] % hair +\definehspace[1] [.1667\emwidth] % thin +\definehspace[2] [.2222\emwidth] % med +\definehspace[3] [.2777\emwidth] % thick + +\let \, \thinspace +\let \: \medspace +\let \; \thickspace +\let \! \negthinspace + +% plain ... +% +% \ifdefined\> \else \unexpanded\def\>{\mskip \medmuskip } \fi +% \ifdefined\* \else \unexpanded\def\*{\discretionary{\thinspace\the\textfont2\char2}{}{}} \fi + +\def\flexiblespaceamount#1#2#3% + {#1\interwordspace + \s!plus#2\interwordstretch + \s!minus#3\interwordshrink} + +\def\fixedspaceamount#1% + {#1\interwordspace} + +% moved from page-lin +% +% the following code is used in startlines\stoplines +% +% do we need \normalspaceprimitive here? + +\installcorenamespace{spacemethods} + +\unexpanded\def\installspacemethod#1#2% needs to set \obeyedspace + {\setvalue{\??spacemethods#1}{#2}} + +\def\activatespacehandler#1% + {\csname\??spacemethods\ifcsname\??spacemethods#1\endcsname#1\else\v!off\fi\endcsname} + +\unexpanded\def\spac_spaces_checked_control{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}% +\unexpanded\def\spac_spaces_checked_normal {\mathortext\normalspace{\dontleavehmode\normalspace}}% +\unexpanded\def\spac_spaces_checked_fixed {\mathortext\normalspace{\dontleavehmode\fixedspace}}% + +% hm, order matters when we \let in \obeyspaces + +\installspacemethod \v!on + {\obeyspaces + \let\obeyedspace\spac_spaces_checked_control + \let\ =\obeyedspace} + +\installspacemethod \v!yes + {\obeyspaces + \let\obeyedspace\spac_spaces_checked_normal + \let\ =\obeyedspace} + +\installspacemethod \v!off % == default + {\normalspaces + \let\obeyedspace\normalspace + \let\ =\normalspaceprimitive} % was \normalspace + +\installspacemethod \v!fixed + {\obeyspaces + \let\obeyedspace\spac_spaces_checked_fixed + \let\ =\obeyedspace} + +\appendtoks + \normalspaces % to be sure +\to \everybeforeoutput + +%D A more robust variant of the \MKII\ one: +%D +%D \startbuffer +%D bla \TEX\autoinsertnextspace bla +%D bla \TEX\autoinsertnextspace (bla) +%D bla (\TEX\autoinsertnextspace) bla +%D bla \TEX\autoinsertnextspace\ bla +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\unexpanded\def\autoinsertnextspace + {\futurelet\nexttoken\spac_spaces_auto_insert_next} + +\def\spac_spaces_auto_insert_next + {\clf_autonextspace{\normalmeaning\nexttoken}} % todo, just consult nexttoken at the lua end + +%D Moved from bib module: + +\unexpanded\def\outdented#1% + {\hskip-\hangindent#1\relax} + +%D Beware: due to char-def this becomes an active character but that +%D might change sometime when we will replace all these specials to +%D node insertions. We might even expand it to utf then as it then +%D can be used in string comparison (not that much needed anyway). + +% \chardef\zwnj="200C +% \chardef\zwj ="200D + +% TODO (but used in languages): + +\unexpanded\def\spac_glues_text_or_math#1#2% + {\begingroup + \ifmmode + \mskip#1% + \else + \scratchdimen#1\hspaceamount\empty{#2}% + \scratchskip\scratchdimen\s!plus.5\scratchdimen\s!minus.3\scratchdimen + \hskip\scratchskip + \fi + \endgroup} + +\unexpanded\def\thinglue {\spac_glues_text_or_math\thinmuskip \v!small} +\unexpanded\def\medglue {\spac_glues_text_or_math\medmuskip \v!medium} +\unexpanded\def\thickglue{\spac_glues_text_or_math\thickmuskip\v!big} + +%D A rather unknown one: + +\unexpanded\def\widened % moved from cont-new + {\doifelsenextoptionalcs\spac_widened_yes\spac_widened_nop} + +\def\spac_widened_yes[#1]#2{\hbox \s!spread #1{\hss#2\hss}} +\def\spac_widened_nop #1{\hbox \s!spread \emwidth{\hss#1\hss}} + +\definecomplexorsimple\widened + +%D For the moment here (used in page-txt): + +\unexpanded\def\ignoredlinebreak{\unskip\space\ignorespaces} + +%D \macros +%D {startignorespaces} +%D +%D I'll probably forget that this one exists: +%D +%D \starttyping +%D \ruledhbox +%D {\startignorespaces +%D \def\oeps{a} +%D \startignorespaces +%D \def\oeps{a} +%D \stopignorespaces +%D \def\oeps{a} +%D \stopignorespaces +%D \oeps} +%D \stoptyping + +\newsignal\s_spac_ignore_spaces +\newcount \c_spac_ignore_spaces + +\unexpanded\def\startignorespaces + {\advance\c_spac_ignore_spaces\plusone + \ifcase\c_spac_ignore_spaces\or \ifhmode + \hskip\s_spac_ignore_spaces + \fi \fi + \ignorespaces} + +\unexpanded\def\stopignorespaces + {\ifcase\c_spac_ignore_spaces \or + \ifhmode + \doloop\spac_ignore_spaces_body + \fi + \fi + \advance\c_spac_ignore_spaces\minusone} + +\def\spac_ignore_spaces_body + {\ifzeropt\lastskip + \exitloop + \else\ifdim\lastskip=\s_spac_ignore_spaces + \unskip + \exitloop + \else + \unskip + \fi\fi} + +%D \macros +%D {obeyfollowingtoken} + +\def\obeyfollowingtoken{{}} % end \cs scanning + +%D Something new: + +\unexpanded\def\interwordspacebefore{\wordboundary\zwnj\hskip\interwordspace\relax} +\unexpanded\def\interwordspaceafter {\hskip\interwordspace\relax\zwnj\wordboundary} + +\unexpanded\def\interwordspacesbefore#1{\dofastloopcs{#1}\interwordspacebefore} +\unexpanded\def\interwordspacesafter #1{\dofastloopcs{#1}\interwordspaceafter} +\unexpanded\def\interwordspaces #1{\wordboundary\zwnj\dofastloopcs{\numexpr#1+\minusone}\interwordspaceafter} + +\protect \endinput diff --git a/tex/context/base/mkiv/spac-par.mkiv b/tex/context/base/mkiv/spac-par.mkiv index aeb7a6da3..ee2d9c9cd 100644 --- a/tex/context/base/mkiv/spac-par.mkiv +++ b/tex/context/base/mkiv/spac-par.mkiv @@ -55,10 +55,15 @@ \let\defrostparagraphproperties\relax \let\setparagraphfreezing \relax \let\forgetparagraphfreezing \relax +\let\updateparagraphproperties \relax +\let\updateparagraphpenalties \relax +\let\updateparagraphdemerits \relax +\let\updateparagraphshapes \relax \let\updateparwrapper \relax -\let\registerparwrapper\gobbletwoarguments \let\forgetparwrapper \relax +\let\registerparwrapper\gobblethreearguments +\let\directparwrapper \gobbletwoarguments \let\spac_paragraph_wrap \relax \let\spac_paragraph_freeze\relax diff --git a/tex/context/base/mkiv/spac-par.mkxl b/tex/context/base/mkiv/spac-par.mkxl index 031e2e725..51b210d45 100644 --- a/tex/context/base/mkiv/spac-par.mkxl +++ b/tex/context/base/mkiv/spac-par.mkxl @@ -80,12 +80,24 @@ + \frozenfinalhyphendemeritscode \relax +% + \frozenparskipcode + +\setnewconstant\paragraphshapecodes\numexpr + \frozenhangindentcode + + \frozenhangaftercode + + \frozenleftskipcode + + \frozenrightskipcode + + \frozenparfillskipcode + + \frozenparshapecode +\relax + \protected\def\freezeparagraphproperties {\snapshotpar\maxcount} \protected\def\defrostparagraphproperties{\snapshotpar\zerocount} -\protected\def\updateparagraphproperties {\ifhmode\snapshotpar\paragraphupdatecodes\fi} +\protected\def\updateparagraphproperties {\ifhmode\snapshotpar\paragraphupdatecodes \fi} \protected\def\updateparagraphpenalties {\ifhmode\snapshotpar\paragraphpenaltycodes\fi} \protected\def\updateparagraphdemerits {\ifhmode\snapshotpar\paragraphdemeritcodes\fi} +\protected\def\updateparagraphshapes {\ifhmode\snapshotpar\paragraphshapecodes \fi} % so far @@ -107,7 +119,9 @@ {\c_spac_paragraph_group_level\currentgrouplevel\relax \ifcsname\??bparwrap\the\c_spac_paragraph_group_level\endcsname \the\lastnamedcs - \wrapuppar{\the\csname\??eparwrap\the\c_spac_paragraph_group_level\endcsname}% + \relax + \dontleavehmode % just in case + \wrapuppar{\the\csname\??eparwrap\the\c_spac_paragraph_group_level\endcsname\relax}% \fi} \protected\def\registerparwrapper {\spac_register_par_wrapper\toksapp\tokspre} @@ -123,7 +137,7 @@ #1\csname\??bparwrap\the\currentgrouplevel\endcsname\expandafter{\expandafter\the\csname\??parwrapbefore#3\endcsname}% #2\csname\??eparwrap\the\currentgrouplevel\endcsname\expandafter{\expandafter\the\csname\??parwrapafter #3\endcsname}} -\protected\def\spac_register_par_wrapper#1#2#3#4#5% +\def\spac_register_par_wrapper_yes#1#2#3#4#5% {\ifcsname\??bparwrap\the\currentgrouplevel\endcsname \else \spac_paragraph_install \fi @@ -135,6 +149,16 @@ \clf_newparwrapper{#3}% \let\spac_paragraph_wrap\spac_paragraph_update} +\def\spac_register_par_wrapper_nop#1#2#3#4#5% + {#4\wrapuppar{#5}} + +\protected\def\spac_register_par_wrapper + {\ifhmode + \expandafter\spac_register_par_wrapper_nop + \else + \expandafter\spac_register_par_wrapper_yes + \fi} + \protected\def\forgetparwrapper {\csname\??bparwrap\the\currentgrouplevel\endcsname\emptytoks \csname\??eparwrap\the\currentgrouplevel\endcsname\emptytoks} @@ -143,6 +167,9 @@ {\csname\??parwrapbefore#1\endcsname\emptytoks \csname\??parwrapafter #1\endcsname\emptytoks} +\def\directparwrapper#1#2% + {#1\wrapuppar{#2}} + % \getparwrapper % defined in lua % \lastparwrapper % defined in lua @@ -161,15 +188,6 @@ \appendtoks\let\spac_paragraph_wrap\relax\to\everyforgetall -% \installtexexperiment -% {paragraphs.freeze} -% {\setparagraphfreezing -% \appendtoksonce\spac_paragraph_wrap \to \everypar -% \appendtoksonce\spac_paragraph_freeze\to \everypar} -% {\forgetparagraphfreezing -% \removetoks \spac_paragraph_wrap \from\everypar -% \removetoks \spac_paragraph_freeze\from\everypar} - %D In due time, the code below will be upgraded using the above mechanisms. %D The dreadful sequence \type {\bgroup} \unknown\ \type {\carryoverpar} \unknown\ @@ -178,14 +196,6 @@ %D indentation as set (by the output routine) inside the group are forgotten %D afterwards. (I must not forget its existence). -% Todo (maybe): -% -% \parshape \getparshape\relax -% \interlinepenalties \getinterlinepenalties\relax -% \clubpenalties \getclubpenalties\relax -% \widowpenalties \getwidowpenalties\relax -% \displaywidowpenalties\getdisplaywidowpenalties\relax - \def\carryoverpar#1% #1 can be \endgroup or \egroup or ... expandable ! {\normalexpanded {\noexpand#1% diff --git a/tex/context/base/mkiv/spac-ver.mkxl b/tex/context/base/mkiv/spac-ver.mkxl index 9c3f361c0..7406ae143 100644 --- a/tex/context/base/mkiv/spac-ver.mkxl +++ b/tex/context/base/mkiv/spac-ver.mkxl @@ -2422,20 +2422,20 @@ \fi \scratchcounter\directhangingparameter\c!n\relax \ifnum\scratchcounter>\zerocount - \hangafter-\scratchcounter + \frozen\hangafter-\scratchcounter \else \getboxheight\scratchdimen\of\box\nextbox \getnoflines\scratchdimen - \hangafter-\noflines + \frozen\hangafter-\noflines \fi \ht\nextbox\strutht \dp\nextbox\strutdp \scratchwidth\dimexpr\wd\nextbox+\scratchdistance\relax \ifx\m_spac_hanging_location\v!right - \hangindent\ifconditional\displaylefttoright-\fi\scratchwidth + \frozen\hangindent\ifconditional\displaylefttoright-\fi\scratchwidth \rlap{\hskip\dimexpr\hsize-\leftskip-\wd\nextbox\relax\box\nextbox}% \leftskip is new \else - \hangindent\ifconditional\displaylefttoright\else-\fi\scratchwidth + \frozen\hangindent\ifconditional\displaylefttoright\else-\fi\scratchwidth \llap{\box\nextbox\hskip\scratchdistance}% \fi \ignorespaces} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 0371e81bc..96dadd675 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 2274357c5..b64e6fb23 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-con.mkvi b/tex/context/base/mkiv/strc-con.mkvi index 1f5a1629f..66ff3097b 100644 --- a/tex/context/base/mkiv/strc-con.mkvi +++ b/tex/context/base/mkiv/strc-con.mkvi @@ -418,6 +418,8 @@ % \dostoptagged % tag \dostarttagged\t!constructioncontent\empty + %\freezeparagraphproperties + \updateparagraphshapes \ignorespaces} % args not needed \unexpanded\setvalue{\??constructionstophandler\v!construction}% @@ -433,7 +435,7 @@ \dorechecknextindentation} \unexpanded\def\boxedconstructionhead#1% - {\vtop + {\doifelse{\constructionalternativeparameter\c!alignbottom}{\v!yes}\vbox\vtop {\hsize\constructionsheadwidth \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% \ifx\p_strc_constructions_headalign\empty \else @@ -919,6 +921,43 @@ \endgroup \stopsetups +\ifcase\contextlmtxmode \else + % just an empty check so that we can grep for contextlmtxmode in mkiv files +\fi + +% \definedescription[whatever][alternative=right:bottom] +% +% \startwhatever{just a small\\example} +% \input ward +% \stopwhatever + +\defineconstructionalternative + [\v!right:\v!bottom] + [%\c!width=7em, + %\c!distance=1em, + \c!alignbottom=\v!yes, + \c!renderingsetup=\??constructionrenderings:\v!right:\v!bottom] + +\startsetups[\??constructionrenderings:\v!right:\v!bottom] + \let\\=\crlf + \noindent + \leftskip\leftconstructionskip + \rightskip\dimexpr\rightconstructionskip+\constructionsheadwidth+\constructionsheaddistance\relax + \parfillskip\zeropoint + \strc_constructions_set_pure_box\v!flushright + \directparwrapper \relax {% + \hfilll + \rlap + {\kern\constructionsheaddistance + \copy\constructionheadbox}% + }% + \useconstructionstyleandcolor\c!style\c!color + \ignorespaces +\stopsetups + +%D This next feature will get an lmtx implementation (probably by using a new generic +%D close mechanism). + % you can use \placeclosesymbol or \qed to place a symbol at the end of a % construction diff --git a/tex/context/base/mkiv/strc-itm.mklx b/tex/context/base/mkiv/strc-itm.mklx index 3d1861d12..46fb90c9e 100644 --- a/tex/context/base/mkiv/strc-itm.mklx +++ b/tex/context/base/mkiv/strc-itm.mklx @@ -929,7 +929,7 @@ \strc_itemgroups_calculate_list_width\c_strc_itemgroups_nesting \ifdim\d_strc_itemgroups_list_width>\zeropoint\relax \ifconditional\c_strc_itemgroups_inline\else - \advance\leftskip\d_strc_itemgroups_list_width\relax + \frozen\advance\leftskip\d_strc_itemgroups_list_width\relax \fi \fi \ifempty\m_strc_itemgroups_repeat_start diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl index 027b89e23..273a20ef1 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkiv/supp-box.mkxl @@ -1157,111 +1157,9 @@ \ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi \ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi -% \protected\def\limitatetext -% {\bgroup % evt \setstrut -% \forgetall % otherwise indentation and so -% \let\limitatetext\firstofthreearguments -% \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! -% \dowithnextboxcs\syst_boxes_limitate_text\hbox} -% -% \def\syst_boxes_limitate_text#1% #2 -% {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}} % {#2} -% -% \def\syst_boxes_limitate_text_nop#1#2% -% {\unhbox\nextbox -% \egroup} -% -% \def\syst_boxes_limitate_text_yes#1#2% -% {\nopenalties -% \scratchdimen#1\relax -% \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line -% \donefalse -% \scratchdimen-\scratchdimen -% \else -% \donetrue -% \fi -% \ifdim\wd\nextbox>\scratchdimen -% \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}% -% \advance\scratchdimen -\wd\scratchbox -% \setbox\scratchboxone\box\nextbox -% \setbox\nextbox\vbox -% {\hsize\scratchdimen -% \hfuzz\maxdimen -% \veryraggedright -% \strut -% \ifdone \else -% \parfillskip\zeropoint -% \rightskip\zeropoint -% \hskip\zeropoint \s!plus 1\s!fill % \hsize -% \fi -% \unhcopy\scratchboxone}% -% \ifdim\ht\nextbox>\strutht -% \setbox\nextbox\vbox % if omitted: missing brace reported -% {\splittopskip\openstrutheight -% \ifdone -% \setbox\nextbox\vsplit\nextbox to \strutht -% \else -% \doloop -% {\setbox\scratchboxone\vsplit\nextbox to \strutht -% \ifdim\ht\nextbox>\strutht \else \exitloop \fi}% -% \fi -% \unvbox\nextbox -% \setbox\nextbox\lastbox -% \global\setbox1\hpack -% {\ifdone -% \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox -% \else -% \box\scratchbox\unhbox\nextbox -% \fi -% \unskip}}% -% \unhbox1 -% \else -% \unhbox0% -% \fi -% \else -% \unhbox\nextbox -% \fi -% \egroup} -% -% %D We can also limit a text with more control: -% %D -% %D \startbuffer -% %D \limitatetext {\input tufte } {2cm,5mm} {\unknown} -% %D \limitatetext {ton en hans} {2cm,5mm} {\unknown} -% %D \limitatetext {ton en hans zijn eikels} {2cm,5mm} {\unknown} -% %D \limitatetext {ton} {2cm,5mm} {\unknown} -% %D \stopbuffer -% %D -% %D \typebuffer \getbuffer -% %D -% %D We build this feature on top of the previous macro. -% -% % we could move the text argument to the end -% -% \let\normallimitatetext\limitatetext -% -% \def\speciallimitatetext#1#2#3#4% text left right placeholder -% {%\dontleavehmode -% \bgroup -% \let\speciallimitatetext\firstoffourarguments -% \setbox\scratchboxone\hbox -% {\nohyphens -% \normallimitatetext{#1}{+#2}{}#4% -% \normallimitatetext{#1}{-#3}{}}% -% \setbox\scratchboxtwo\hbox -% {#1}% -% \ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi -% \egroup} -% -% \protected\def\limitatetext#1#2#3% \expanded added 2003/01/16 -% {\splitatcomma{#2}\leftlimit\rightlimit -% \ifempty\rightlimit -% \normallimitatetext {#1}\leftlimit {#3}% -% \else -% \speciallimitatetext{#1}\leftlimit\rightlimit{#3}% -% \fi} - -\protected\def\limitatetext#1#2#3% \expanded added 2003/01/16 +%D See \MKIV\ file for the older implementation. + +\protected\def\limitatetext#1#2#3% {\splitatcomma{#2}\leftlimit\rightlimit \limitated left \leftlimit diff --git a/tex/context/base/mkiv/syst-aux.mkiv b/tex/context/base/mkiv/syst-aux.mkiv index fb65abce8..2d1ae17be 100644 --- a/tex/context/base/mkiv/syst-aux.mkiv +++ b/tex/context/base/mkiv/syst-aux.mkiv @@ -6166,21 +6166,24 @@ \def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax} %D \macros -%D {swapdimens,swapcounts,swapmacros, +%D {swapdimens,swapskips,swapcounts,swapmacros, %D globalswapdimens,globalswapcounts,globalswapmacros} %D %D Simple but effective are the next two macros. There name exactly states their %D purpose. \newdimen\d_syst_helpers_swapped +\newskip \s_syst_helpers_swapped \newcount\c_syst_helpers_swapped \let \m_syst_helpers_swapped\relax \protected\def\swapdimens#1#2{\d_syst_helpers_swapped #1\relax#1#2\relax#2\d_syst_helpers_swapped} +\protected\def\swapskips #1#2{\s_syst_helpers_swapped #1\relax#1#2\relax#2\s_syst_helpers_swapped} \protected\def\swapcounts#1#2{\c_syst_helpers_swapped #1\relax#1#2\relax#2\c_syst_helpers_swapped} \protected\def\swapmacros#1#2{\let\m_syst_helpers_swapped#1\let #1#2\let #2\m_syst_helpers_swapped} \protected\def\globalswapdimens#1#2{\d_syst_helpers_swapped #1\global#1#2\global#2\d_syst_helpers_swapped} +\protected\def\globalswapskips #1#2{\s_syst_helpers_swapped #1\global#1#2\global#2\s_syst_helpers_swapped} \protected\def\globalswapcounts#1#2{\c_syst_helpers_swapped #1\global#1#2\global#2\c_syst_helpers_swapped} \protected\def\globalswapmacros#1#2{\let\m_syst_helpers_swapped#1\glet #1#2\glet #2\m_syst_helpers_swapped} diff --git a/tex/context/base/mkiv/syst-aux.mkxl b/tex/context/base/mkiv/syst-aux.mkxl index f4135d123..1951e166f 100644 --- a/tex/context/base/mkiv/syst-aux.mkxl +++ b/tex/context/base/mkiv/syst-aux.mkxl @@ -4754,21 +4754,24 @@ \def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax} %D \macros -%D {swapdimens,swapcounts,swapmacros, +%D {swapdimens,swapskips,swapcounts,swapmacros, %D globalswapdimens,globalswapcounts,globalswapmacros} %D %D Simple but effective are the next two macros. There name exactly states their %D purpose. \newdimen\d_syst_helpers_swapped +\newskip \s_syst_helpers_swapped \newcount\c_syst_helpers_swapped \let \m_syst_helpers_swapped\relax \protected\def\swapdimens#1#2{\d_syst_helpers_swapped#1#1#2#2\d_syst_helpers_swapped} +\protected\def\swapskips #1#2{\s_syst_helpers_swapped#1#1#2#2\s_syst_helpers_swapped} \protected\def\swapcounts#1#2{\c_syst_helpers_swapped#1#1#2#2\c_syst_helpers_swapped} \protected\def\swapmacros#1#2{\let\m_syst_helpers_swapped#1\let#1#2\let#2\m_syst_helpers_swapped} \protected\def\globalswapdimens#1#2{\d_syst_helpers_swapped#1\global#1#2\global#2\d_syst_helpers_swapped} +\protected\def\globalswapskips #1#2{\s_syst_helpers_swapped#1\global#1#2\global#2\s_syst_helpers_swapped} \protected\def\globalswapcounts#1#2{\c_syst_helpers_swapped#1\global#1#2\global#2\c_syst_helpers_swapped} \protected\def\globalswapmacros#1#2{\let\m_syst_helpers_swapped#1\glet#1#2\glet#2\m_syst_helpers_swapped} diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 51484ed05..9394f9ffc 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -214,6 +214,7 @@ <cd:variable name='flushouter' value='flushouter'/> <cd:variable name='flushright' value='flushright'/> <cd:variable name='followingpage' value='followingpage'/> + <cd:variable name='font' value='font'/> <cd:variable name='footer' value='piedipagina'/> <cd:variable name='footnote' value='notapdp'/> <cd:variable name='force' value='forza'/> @@ -639,6 +640,7 @@ <cd:constant name='afterkey' value='dopotasto'/> <cd:constant name='aftersection' value='aftersection'/> <cd:constant name='align' value='allinea'/> + <cd:constant name='alignbottom' value='alignbottom'/> <cd:constant name='aligncharacter' value='allineacarattere'/> <cd:constant name='alignmentcharacter' value='carattereallineamento'/> <cd:constant name='alignmentleftsample' value='alignmentleftsample'/> @@ -838,6 +840,7 @@ <cd:constant name='focusin' value='focusin'/> <cd:constant name='focusoffset' value='focusoffset'/> <cd:constant name='focusout' value='focusout'/> + <cd:constant name='font' value='font'/> <cd:constant name='footer' value='piedipagina'/> <cd:constant name='footerdistance' value='distanzapdp'/> <cd:constant name='footerstate' value='statopdp'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 4377bfcde..366a59957 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2020-07-30 16:49 +-- merge date : 2020-07-31 09:58 do -- begin closure to overcome local limits and interference |