[dev-context] Leaders

Wolfgang Schuster wolfgang.schuster at gmail.com
Sun Jan 13 19:06:17 CET 2013


Hi Hans,

what’s your opinion to redefine the leaders command to take a optional name which loads a predefined setup?

<code>
% use \doifsymbolelse for the symbol key?

\unprotect

\installcorenamespace{leaders}
\installcorenamespace{leadersalternative}

\installdefinehandler    \??leaders {leaders} \??leaders
\installparameterhandler \??leaders {leaders}
\installsetuphandler     \??leaders {leaders}

\def\leaders
  {\doifnextoptionalelse\leaders_indeed\normalleaders}

\def\leaders_indeed[#1]%
  {\def\currentleaders{#1}%
   \expandcheckedcsname\??leadersalternative{\leadersparameter\c!alternative}\s!default}

\setvalue{\??leadersalternative\s!default}%
  {\leadersparameter\c!left
   \normalleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill
   \leadersparameter\c!right}

\setvalue{\??leadersalternative\s!default}%
  {\leadersparameter\c!left
   \normalleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill
   \leadersparameter\c!right}

\setvalue{\??leadersalternative\v!global}%
  {\leadersparameter\c!left
   \normalgleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill
   \leadersparameter\c!right}

\setupleaders
  [\c!width=1em,
   \c!symbol=.,
   \c!alternative=\s!default]

\protect

\defineleaders[test]%[symbol=x]

\starttext

text\leaders\hbox to 1em{\hss .\hss}\hfill text

text\leaders[test]text

\stoptext
</code>

This method would be cleaner for user defined list layouts where one want to change the filler between the text and the page number because a setup like this isn’t something for a normal user.

<code source="strc-lst.mkvi">
\definelistalternative
  [c]
  [\c!distance=5em,
   \c!width=0pt,
   \c!stretch=10em,
   \c!filler=\hskip.5em\gleaders\hbox to .5em{\hss.\hss}\hfill\hskip.5em\relax,
   \c!renderingsetup=\??listrenderings:abc]
</code>

Wolfgang


More information about the dev-context mailing list