ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* layout parameter testing
@ 2008-11-13 19:52 Alan STONE
  2008-11-13 20:48 ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Alan STONE @ 2008-11-13 19:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 286 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 336 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-13 19:52 layout parameter testing Alan STONE
@ 2008-11-13 20:48 ` Wolfgang Schuster
  2008-11-14  9:40   ` Alan STONE
  2008-11-14 14:06   ` Alan STONE
  0 siblings, 2 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2008-11-13 20:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-13 20:48 ` Wolfgang Schuster
@ 2008-11-14  9:40   ` Alan STONE
  2008-11-14 14:06   ` Alan STONE
  1 sibling, 0 replies; 7+ messages in thread
From: Alan STONE @ 2008-11-14  9:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 959 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1538 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-13 20:48 ` Wolfgang Schuster
  2008-11-14  9:40   ` Alan STONE
@ 2008-11-14 14:06   ` Alan STONE
  2008-11-14 14:33     ` Wolfgang Schuster
  1 sibling, 1 reply; 7+ messages in thread
From: Alan STONE @ 2008-11-14 14:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 793 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1706 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-14 14:06   ` Alan STONE
@ 2008-11-14 14:33     ` Wolfgang Schuster
  2008-11-16 14:15       ` Alan STONE
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2008-11-14 14:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 14.11.2008 um 15:06 schrieb Alan STONE:

> 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
>
> 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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-14 14:33     ` Wolfgang Schuster
@ 2008-11-16 14:15       ` Alan STONE
  2008-11-16 14:42         ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Alan STONE @ 2008-11-16 14:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1403 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 2661 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: layout parameter testing
  2008-11-16 14:15       ` Alan STONE
@ 2008-11-16 14:42         ` Wolfgang Schuster
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2008-11-16 14:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-11-16 14:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-13 19:52 layout parameter testing Alan STONE
2008-11-13 20:48 ` Wolfgang Schuster
2008-11-14  9:40   ` Alan STONE
2008-11-14 14:06   ` Alan STONE
2008-11-14 14:33     ` Wolfgang Schuster
2008-11-16 14:15       ` Alan STONE
2008-11-16 14:42         ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).