* Test for displaying a header @ 2021-08-26 14:07 Fabrice Couvreur via ntg-context 2021-08-26 14:34 ` Taco Hoekwater via ntg-context 0 siblings, 1 reply; 7+ messages in thread From: Fabrice Couvreur via ntg-context @ 2021-08-26 14:07 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Fabrice Couvreur [-- Attachment #1.1: Type: text/plain, Size: 310 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 1942 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Test for displaying a header 2021-08-26 14:07 Test for displaying a header Fabrice Couvreur via ntg-context @ 2021-08-26 14:34 ` Taco Hoekwater via ntg-context 2021-08-26 15:56 ` Wolfgang Schuster via ntg-context 0 siblings, 1 reply; 7+ messages in thread From: Taco Hoekwater via ntg-context @ 2021-08-26 14:34 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Taco Hoekwater 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}} > 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: taco@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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Test for displaying a header 2021-08-26 14:34 ` Taco Hoekwater via ntg-context @ 2021-08-26 15:56 ` Wolfgang Schuster via ntg-context 2021-08-26 17:06 ` Fabrice Couvreur via ntg-context 0 siblings, 1 reply; 7+ messages in thread From: Wolfgang Schuster via ntg-context @ 2021-08-26 15:56 UTC (permalink / raw) To: mailing list for ConTeXt users, Taco Hoekwater via ntg-context Cc: Wolfgang Schuster, Taco Hoekwater 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Test for displaying a header 2021-08-26 15:56 ` Wolfgang Schuster via ntg-context @ 2021-08-26 17:06 ` Fabrice Couvreur via ntg-context 2021-08-26 17:56 ` Wolfgang Schuster via ntg-context 0 siblings, 1 reply; 7+ messages in thread From: Fabrice Couvreur via ntg-context @ 2021-08-26 17:06 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Fabrice Couvreur [-- Attachment #1.1: Type: text/plain, Size: 2279 bytes --] 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 > > ___________________________________________________________________________________ > [-- Attachment #1.2: Type: text/html, Size: 8439 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Test for displaying a header 2021-08-26 17:06 ` Fabrice Couvreur via ntg-context @ 2021-08-26 17:56 ` Wolfgang Schuster via ntg-context [not found] ` <CACyK-eryA8rxnsbOXbU7aOW0=PHFKsLSchU-J5vn7CsjOpJT2A@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: Wolfgang Schuster via ntg-context @ 2021-08-26 17:56 UTC (permalink / raw) To: mailing list for ConTeXt users, Fabrice Couvreur via ntg-context Cc: Wolfgang Schuster [-- Attachment #1.1: Type: text/plain, Size: 514 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 3185 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CACyK-eryA8rxnsbOXbU7aOW0=PHFKsLSchU-J5vn7CsjOpJT2A@mail.gmail.com>]
* Re: Test for displaying a header [not found] ` <CACyK-eryA8rxnsbOXbU7aOW0=PHFKsLSchU-J5vn7CsjOpJT2A@mail.gmail.com> @ 2021-08-27 16:05 ` Wolfgang Schuster via ntg-context [not found] ` <CACyK-eqnhx1dAAVBe3HK_OVR+e+HZ6han1enQkx_GukTd9cG-Q@mail.gmail.com> 0 siblings, 1 reply; 7+ messages in thread From: Wolfgang Schuster via ntg-context @ 2021-08-27 16:05 UTC (permalink / raw) To: Fabrice Couvreur; +Cc: Wolfgang Schuster, mailing list for ConTeXt users [-- Attachment #1.1: Type: text/plain, Size: 1332 bytes --] 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 [-- Attachment #1.2: Type: text/html, Size: 3030 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <CACyK-eqnhx1dAAVBe3HK_OVR+e+HZ6han1enQkx_GukTd9cG-Q@mail.gmail.com>]
[parent not found: <38a9bada-8507-ef96-c09a-7c48c865049b@gmail.com>]
[parent not found: <CACyK-eoL6uhusTErcq+P0HQ8_O9EN+ZV-MXtEOKo-iby4BHBVA@mail.gmail.com>]
[parent not found: <CACyK-epiR+X+r_TRJOH+0rz8v_FKAFH7ooR3xqkp1hPdNNm4dg@mail.gmail.com>]
* Re: Test for displaying a header [not found] ` <CACyK-epiR+X+r_TRJOH+0rz8v_FKAFH7ooR3xqkp1hPdNNm4dg@mail.gmail.com> @ 2021-08-28 12:24 ` Wolfgang Schuster via ntg-context 0 siblings, 0 replies; 7+ messages in thread From: Wolfgang Schuster via ntg-context @ 2021-08-28 12:24 UTC (permalink / raw) To: Fabrice Couvreur; +Cc: Wolfgang Schuster, mailing list for ConTeXt users 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-08-28 12:24 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-26 14:07 Test for displaying a header Fabrice Couvreur via ntg-context 2021-08-26 14:34 ` Taco Hoekwater via ntg-context 2021-08-26 15:56 ` Wolfgang Schuster via ntg-context 2021-08-26 17:06 ` Fabrice Couvreur via ntg-context 2021-08-26 17:56 ` Wolfgang Schuster via ntg-context [not found] ` <CACyK-eryA8rxnsbOXbU7aOW0=PHFKsLSchU-J5vn7CsjOpJT2A@mail.gmail.com> 2021-08-27 16:05 ` Wolfgang Schuster via ntg-context [not found] ` <CACyK-eqnhx1dAAVBe3HK_OVR+e+HZ6han1enQkx_GukTd9cG-Q@mail.gmail.com> [not found] ` <38a9bada-8507-ef96-c09a-7c48c865049b@gmail.com> [not found] ` <CACyK-eoL6uhusTErcq+P0HQ8_O9EN+ZV-MXtEOKo-iby4BHBVA@mail.gmail.com> [not found] ` <CACyK-epiR+X+r_TRJOH+0rz8v_FKAFH7ooR3xqkp1hPdNNm4dg@mail.gmail.com> 2021-08-28 12:24 ` Wolfgang Schuster via ntg-context
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).