Hi, With \definelayout[myLayout][...], how do you test whether one of its parameters has a certain value, is greater than 0, etc... ? -- Best, Alan * TeX engine = LuaTeX * ConTeXt minimals ver: 2008.56.06 19:11 MKIV fmt: 2008.11.10 int: english/english * Ubuntu 8.04 Hardy Heron
Am 13.11.2008 um 20:52 schrieb Alan STONE:
Hi,
With \definelayout[myLayout][...], how do you test whether one of its parameters has a certain value, is greater than 0, etc... ?
\definelayout [mylayout] [backspace=3cm, width=12cm] \starttext \doifdimensionelse{\namedlayoutparameter{mylayout}{width}} % width could be 'fit' {\ifdim\namedlayoutparameter{mylayout}{width}<10cm ... \else ... \fi} {\processaction [\namedlayoutparameter{mylayout}{width}] [fit=>..., unknown=>...]} \stoptext Wolfgang
On Thu, Nov 13, 2008 at 9:48 PM, Wolfgang Schuster < schuster.wolfgang@googlemail.com> wrote:
Am 13.11.2008 um 20:52 schrieb Alan STONE:
Hi,
With \definelayout[myLayout][...], how do you test whether one of its parameters has a certain value, is greater than 0, etc... ?
\definelayout [mylayout] [backspace=3cm, width=12cm]
\starttext
\doifdimensionelse{\namedlayoutparameter{mylayout}{width}} % width could be 'fit' {\ifdim\namedlayoutparameter{mylayout}{width}<10cm ... \else ... \fi} {\processaction [\namedlayoutparameter{mylayout}{width}] [fit=>..., unknown=>...]}
\stoptext
Wolfgang
Whoopie... way cool! Thanks Wolfgang. Seems there are "a few" system macros hiding in the source code. -- Best, Alan * TeX engine = LuaTeX * ConTeXt minimals ver: 2008.56.06 19:11 MKIV fmt: 2008.11.10 int: english/english * Ubuntu 8.04 Hardy Heron
On Thu, Nov 13, 2008 at 9:48 PM, Wolfgang Schuster < schuster.wolfgang@googlemail.com> wrote:
Am 13.11.2008 um 20:52 schrieb Alan STONE:
Hi,
With \definelayout[myLayout][...], how do you test whether one of its parameters has a certain value, is greater than 0, etc... ?
\definelayout [mylayout] [backspace=3cm, width=12cm]
\starttext
\doifdimensionelse{\namedlayoutparameter{mylayout}{width}} % width could be 'fit' {\ifdim\namedlayoutparameter{mylayout}{width}<10cm ... \else ... \fi}
{\processaction [\namedlayoutparameter{mylayout}{width}] [fit=>..., unknown=>...]}
Re: http://wiki.contextgarden.net/System_Macros/Action_Processing What is 'fit' ? \stoptext
Wolfgang
Alan
Am 14.11.2008 um 15:06 schrieb Alan STONE:
On Thu, Nov 13, 2008 at 9:48 PM, Wolfgang Schuster
wrote:
Am 13.11.2008 um 20:52 schrieb Alan STONE:
Hi,
With \definelayout[myLayout][...], how do you test whether one of its parameters has a certain value, is greater than 0, etc... ?
\definelayout [mylayout] [backspace=3cm, width=12cm]
\starttext
\doifdimensionelse{\namedlayoutparameter{mylayout}{width}} % width could be 'fit' {\ifdim\namedlayoutparameter{mylayout}{width}<10cm ... \else ... \fi} {\processaction [\namedlayoutparameter{mylayout}{width}] [fit=>..., unknown=>...]}
\stoptext
Re: http://wiki.contextgarden.net/System_Macros/Action_Processing
What is 'fit' ?
You could set the the width of the textarea in three different ways: 1) as absolute value, 2) as remaining space between backspace and cutspace (useful in presentations) and 3) as remaining space between equal margins. \definelayout[1][backspace=4cm,width=12cm] \definelayout[2][backspace=5cm,cutspace=7cm,width=fit] \definelayout[3][backspace=3cm,width=middle] \showframe \starttext \dorecurse{3} {\starttabulate \NC backspace \EQ \PtToCm\backspace \NC\NR \NC textwidth \EQ \PtToCm\textwidth \NC\NR \NC cutspace \EQ \PtToCm\cutspace \NC\NR \stoptabulate \page} \stoptext Regards, Wolfgang
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 ---------------------------------------------------------- width=fit -> ! Missing number, treated as zero. <to be read again> f \@@lymylayoutwidth ->f it \doifdimensionelse ...mensionelse \scratchdimen #1 pt\relax l.11 ...se{\namedlayoutparameter{mylayout}{width}} ---------------------------------------------------------- width=middle -> ! Missing number, treated as zero. <to be read again> m \@@lymylayoutwidth ->m iddle \doifdimensionelse ...mensionelse \scratchdimen #1 pt\relax l.11 ...se{\namedlayoutparameter{mylayout}{width}} ---------------------------------------------------------- Best, Alan
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
participants (2)
-
Alan STONE
-
Wolfgang Schuster