[NTG-context] layout parameter testing

Wolfgang Schuster schuster.wolfgang at googlemail.com
Sun Nov 16 15:42:41 CET 2008


Am 16.11.2008 um 15:15 schrieb Alan STONE:

> Hi,
>
> It doesn't work with the width=fit and width=middle options...
>
> %\definelayout[mylayout][backspace=4cm,width=11cm]
> %\definelayout[mylayout][backspace=4cm,width=9cm]
> \definelayout[mylayout][backspace=5cm,cutspace=7cm,width=fit]
> %\definelayout[mylayout][backspace=3cm,width=middle]
>
> \setuplayout[mylayout]
>
> \starttext
> \doifdimensionelse{\namedlayoutparameter{mylayout}{width}}
>  {\ifdim\namedlayoutparameter{mylayout}{width}>10cm
>   width > 10cm
>  \else
>   width < 10cm
>  \fi}
>  {\processaction
>    [\namedlayoutparameter{mylayout}{width}]
>    [fit=>fit,
>   middle=>middle,
>   unknown=>unknown width]}
> \stoptext
>

I hadn't tested the above code and wrote it from mind but here
are two working solutions:

This version checks first if width is 'middle' or 'fit' if
the value is none of them it is treated as dimension.

\doifinsetelse{\namedlayoutparameter{mylayout}{width}}{middle,fit}
   {\processaction
      [\namedlayoutparameter{mylayout}{width}]
      [    fit=>fit,
        middle=>middle,
       unknown=>unknown width]}
   {\ifdim\namedlayoutparameter{mylayout}{width}>10cm
      width > 10cm
    \else
      width < 10cm
    \fi}

This version checks first if the value is a number and is this
is wrong looks for a keyword.

\doifnumberelse{\namedlayoutparameter{mylayout}{width}}
   {\ifdim\namedlayoutparameter{mylayout}{width}>10cm
      width > 10cm
    \else
      width < 10cm
    \fi}
   {\processaction
      [\namedlayoutparameter{mylayout}{width}]
      [    fit=>fit,
        middle=>middle,
       unknown=>unknown width]}

Regards,
Wolfgang



More information about the ntg-context mailing list