Re: [NTG-context] Test for displaying a header

2021-08-28 Thread Wolfgang Schuster via ntg-context

Fabrice,

there is difference between putting something on the first page 
regardless of the number of pages in your document or do something when 
your document contains only a single or more pages.



When you have a header or title which is always placed on the first page 
(but not on the following pages) you have to options.


    1. Check the current page when to header is placed which can be 
done with \doif{\pagenumber}{1}{...}


    2. Disable the header on the first page (\setupheader[state=high]) 
and place your own title as a regular element in the running text.



A case where you have to number the number of total pages is when you 
try to show the page counter in the form "Page x of y" for 2 or more 
pages. In this case you have to check against the value for the total 
number of pages which can be done with 
\doifnot{\totalnumberofpages}{1}{...}.



Below are two examples which show how the header/title placement works.

 start example 1
\startsetups [header]
    \startframed [width=max,height=max]
    First page header
    \stopframed
\stopsetups

\startsetups [footer]
    Page \userpagenumber\ of \lastuserpagenumber
\stopsetups

\setupheadertexts
  [\doif{\pagenumber}{1}{\directsetup{header}}]

\setupfootertexts
  [\doifnot{\totalnumberofpages}{1}{\directsetup{footer}}]

\starttext
\dorecurse{12}{\samplefile{lorem}\par}
\stoptext
 stop example 1

 start example 2
\startsetups [header]
    \setupheader[state=high]
    \startframed [width=max,height=3cm]
    First page header
    \stopframed
    \blank
\stopsetups

\startsetups [footer]
    Page \userpagenumber\ of \lastuserpagenumber
\stopsetups

\setuppagenumbering
  [location=none]

\setupfootertexts
  [\doifnot{\totalnumberofpages}{1}{\directsetup{footer}}]

\starttext

\setup[header]

\dorecurse{12}{\samplefile{lorem}\par}

\stoptext
 stop example 2

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Test for displaying a header

2021-08-27 Thread Wolfgang Schuster via ntg-context



Fabrice Couvreur schrieb am 27.08.2021 um 10:04:

Hi Wolfgang,
This may not be nicest but seems to work
Fabrice

%%

\definelayout
[1]
  [header=10mm]

\setuplayout
  [header=0pt,
 height=middle]

\setuppagenumbering
[alternative=doublesided,location=]

\setupbackgrounds
[header]
  [text]
  [frame=off,bottomframe=on,
 framecolor=lightgray,rulethickness=1pt]

\startsetups[header]
\doifelse{\totalnumberofpages}{1}
    {\setuplayout[1]}
{\setuplayout[reset]}
\stopsetups


\starttext
\input knuth
%\dorecurse{10}{\input knuth\par}
\stoptext


I have no idea what you try to achieve but the check for the number of 
pages in your document is never used. The layout on the first page is 
different from the following pages but this is just how \definelayout 
work when you use a number as first argument.



What you have to understand is that a setups-environment is just a macro 
definition where you provide the names as argument to the start command. 
This means


    \startsetups [header]
    ...
    \stopsetups

works the same way as

    \def\internalname_header
      {...}

but you have to use

    \setups [header]

rather than

    \internalname_header

to get the content of the environment.


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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Test for displaying a header

2021-08-26 Thread Wolfgang Schuster via ntg-context

Fabrice Couvreur via ntg-context schrieb am 26.08.2021 um 19:06:

Hi,

Using this (almost what I'm trying to do) without success

[...]

\startsetups[header]
\doifelse{\totalnumberofpages}{1}
{\setupheadertexts[\setups{header}]}
    {}
\stopsetups


This stores the page check in the setups environment  but you never call 
it. The call from within the environment itself can't work because the 
content is never evaluated and even if it would be called you create an 
endless loop.


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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Test for displaying a header

2021-08-26 Thread Fabrice Couvreur via ntg-context
Hi,
Using this (but it's not exactly what I want) it works

test-1.tex %%

\setuppagenumbering
  [alternative=doublesided,location=]

\definelayout
  [1]
  [header=10mm]

\setuplayout
  [header=0pt,
   height=middle]

\setupbackgrounds
   [header]
   [text]
   [frame=off,bottomframe=on,
 framecolor=lightgray,rulethickness=1pt]


\starttext
\dorecurse{5}{\samplefile{lorem}}
%\dorecurse{1}{\samplefile{lorem}}
\stoptext

%%ù

Using this (almost what I'm trying to do) without success

test-2.tex %
\setuppagenumbering
  [alternative=doublesided,location=]

\setupbackgrounds
  [header]
  [text]
  [frame=off,bottomframe=on,
   framecolor=lightgray,rulethickness=1pt]

\startsetups[header]
  \doifelse{\totalnumberofpages}{1}
{\setupheadertexts[\setups{header}]}
{}
\stopsetups


\starttext
\dorecurse{5}{\samplefile{lorem}}
%\dorecurse{1}{\samplefile[lorem]r}
\stoptext

%%%

Fabrice


Le jeu. 26 août 2021 à 17:56, Wolfgang Schuster via ntg-context <
ntg-context@ntg.nl> a écrit :

> Taco Hoekwater via ntg-context schrieb am 26.08.2021 um 16:34:
> >
> > Hi,
> >
> >> On 26 Aug 2021, at 16:07, Fabrice Couvreur via ntg-context <
> ntg-context@ntg.nl> wrote:
> >>
> >> Hi,
> >> I know I asked the question a few years ago, but I don't remember !
> >> The idea is to test whether the document contains only one page or not.
> >
> > Perhaps not the nicest solution, but this works:
> >
> > \doifvalueelse
> >{\lastpage}
> >{1}
> >{\message{true}}
> >{\message{false}}
>
>
> Same solution but better counter name:
>
> \doifelse{\totalnumberofpages}{1}{...}{...}
>
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
>
> ___
>
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Test for displaying a header

2021-08-26 Thread Wolfgang Schuster via ntg-context

Taco Hoekwater via ntg-context schrieb am 26.08.2021 um 16:34:


Hi,


On 26 Aug 2021, at 16:07, Fabrice Couvreur via ntg-context  
wrote:

Hi,
I know I asked the question a few years ago, but I don't remember !
The idea is to test whether the document contains only one page or not.


Perhaps not the nicest solution, but this works:

\doifvalueelse
   {\lastpage}
   {1}
   {\message{true}}
   {\message{false}}



Same solution but better counter name:

\doifelse{\totalnumberofpages}{1}{...}{...}

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Test for displaying a header

2021-08-26 Thread Taco Hoekwater via ntg-context

Hi,

> On 26 Aug 2021, at 16:07, Fabrice Couvreur via ntg-context 
>  wrote:
> 
> Hi, 
> I know I asked the question a few years ago, but I don't remember ! 
> The idea is to test whether the document contains only one page or not. 

Perhaps not the nicest solution, but this works:

\doifvalueelse
  {\lastpage}
  {1}
  {\message{true}}
  {\message{false}}

> If it contains only one page, the header is enabled. 
> If it contains several pages, the header is enabled only on the first page 
> but not on the others. 
> Thanks
> Fabrice
> ___
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)



___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Test for displaying a header

2021-08-26 Thread Fabrice Couvreur via ntg-context
Hi,
I know I asked the question a few years ago, but I don't remember !
The idea is to test whether the document contains only one page or not.
If it contains only one page, the header is enabled.
If it contains several pages, the header is enabled only on the first page
but not on the others.
Thanks
Fabrice
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___