Am 13.01.2013 um 20:43 schrieb Hans Hagen <[email protected]>:
> On 1/13/2013 7:06 PM, Wolfgang Schuster wrote:
>
>> what’s your opinion to redefine the leaders command to take a optional name
>> which loads a predefined setup?
>
> We should avoid redefining a primitive (esp one that is used in math).
No problem.
>> […]
>
> before we add this kind of code, how about a more extensive mechanism so that
> we can say filler=periods
>
> for this we need to generalize the above even more i.e. we could have:
>
> alternative=rule (height width depth)
> alternative=box (the leaders)
> alternative=stretch (hfill
>
> and then methods, for leaders, so now we get:
>
> \unprotect
>
> \installcorenamespace{fillers}
> \installcorenamespace{fillersalternative}
> \installcorenamespace{fillersleadermethod}
>
> \installcommandhandler \??fillers {fillers} \??fillers
>
> \unexpanded\def\fillers
> {\dosingleempty\spac_fillers_indeed}
>
> \def\spac_fillers_indeed[#1]%
> {\begingroup
> \edef\currentfillers{#1}%
> \scratchdimen\fillersparameter\c!leftmargin\relax
> \ifdim\scratchdimen=\zeropoint\else
> \hskip\scratchdimen
> \fi
> \fillersparameter\c!left\relax
> \getvalue{\??fillersalternative\fillersparameter\c!alternative}\relax
> \fillersparameter\c!right\relax
> \scratchdimen\fillersparameter\c!rightmargin\relax
> \ifdim\scratchdimen=\zeropoint\else
> \hskip\scratchdimen
> \fi
> \endgroup}
>
> \setvalue{\??fillersalternative\s!box}%
> {\expandcheckedcsname\??fillersleadermethod{\fillersparameter\c!method}\v!local
> \simplealignedbox
> {\fillersparameter\c!width}%
> {\fillersparameter\c!align}%
> {\fillersparameter\c!symbol}%
> \hfill}
>
> \setvalue{\??fillersalternative\c!stretch}%
> {\hfill}
>
> \setvalue{\??fillersalternative\c!rule}%
> {\expandcheckedcsname\??fillersleadermethod{\fillersparameter\c!method}\v!local
> \hrule
> \!!height\fillersparameter\c!height
> \!!depth \fillersparameter\c!depth
> \hfill}
>
> \letvalue{\??fillersleadermethod\s!local }\normalleaders % overflow ends up
> inbetween (current box)
> \letvalue{\??fillersleadermethod\v!global}\normalgleaders % overflow ends up
> inbetween (outermost box)
> \letvalue{\??fillersleadermethod\v!middle}\normalcleaders % overflow ends up
> before, after (current box)
> \letvalue{\??fillersleadermethod\v!broad }\normalxleaders % overflow ends up
> before, inbetween, after (current box)
>
> \setupfillers
> [\c!width=\emwidth,
> \c!symbol=.,
> \c!align=\v!middle,
> \c!height=.1\exheight,
> \c!depth=\zeropoint,
> \c!leftmargin=\zeropoint,
> \c!rightmargin=\zeropoint,
> \c!alternative=\s!box,
> \c!method=\s!local]
>
> % maybe box -> symbol
>
> \protect
>
> \definefillers[test-a][alternative=stretch]
> \definefillers[test-b][alternative=box,symbol=!]
> \definefillers[test-c][alternative=rule,height=.1ex,leftmargin=.5em,rightmargin=.25em]
>
> \starttext
>
> text\leaders\hbox to 1em{\hss .\hss}\hfill text
>
> text\fillers[test-a]text
>
> text\fillers[test-b]text
>
> text\fillers[test-c]text
>
> \stoptext
>
> maybe box should be symbol (no \v!symbol yet)
>
> maybe some more tricks can be added
That version is even better, maybe remove spaces before/after the command to
avoid unwanted spaces.
Even though the \fillers command is slower than direct use of leaders it’s in
my opinion more user friendly.
Wolfgang
_______________________________________________
dev-context mailing list
[email protected]
http://www.ntg.nl/mailman/listinfo/dev-context