* Placing a section ending depending on odd/even sectionnumber
@ 2020-08-04 16:56 Willi Egger
2020-08-04 17:46 ` Wolfgang Schuster
0 siblings, 1 reply; 3+ messages in thread
From: Willi Egger @ 2020-08-04 16:56 UTC (permalink / raw)
To: NTG-Context ConTeXt users
Hi,
now I have another hurdle to be taken :-) — Depending on the odd or even number of the section I have to place an ornament at the end of the section.
I have sofar the following setup:
\define\stopmysection
{\setups{endsection}}
\startsetups endsection
\doifelse
{\currentheadnumber} %{\headnumber[section][current]}{odd}
{even}
{\vfil
{\bf End of even numbered section}
\stopsection%
}
{\vfil
{\bf End of odd numbered section}
\stopsection%
}
\stopsetups
\starttext
\startsection[title=Ward]
\setuppagenumbering[conversion=romannumerals]
\input ward
\stopmysection
\startsection[title=Knuth]
\setuppagenumbering[conversion=numbers]
\input knuth
\stopmysection
\stoptext
However the the evaluation of the sectionnumber results always in “false”, having therefore always odd as a sectionending.
What to change in order to get the desired result?
Kind regards
Willi
___________________________________________________________________________________
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] 3+ messages in thread
* Re: Placing a section ending depending on odd/even sectionnumber
2020-08-04 16:56 Placing a section ending depending on odd/even sectionnumber Willi Egger
@ 2020-08-04 17:46 ` Wolfgang Schuster
2020-08-05 11:39 ` Willi Egger
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2020-08-04 17:46 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Willi Egger
Willi Egger schrieb am 04.08.2020 um 18:56:
> Hi,
>
> now I have another hurdle to be taken :-) — Depending on the odd or even number of the section I have to place an ornament at the end of the section.
>
> I have sofar the following setup:
>
> [...]
>
> However the the evaluation of the sectionnumber results always in “false”, having therefore always odd as a sectionending.
You have two problem:
1. To get the current value for \currentheadnumber you have use
\determineheadnumber[section] before you use it but the example below
shows a better method.
2. What you do with \doifelse{...}{even} is to compare the numeric value
of the section with the string "even" which is always false. To check
whether the value is odd or even you have to use the \ifodd command.
> What to change in order to get the desired result?
%%%% begin example
\startsetups [section:odd]
\vfill
\bold {End of odd numbered section}
\stopsetups
\startsetups [section:even]
\vfill
\bold {End of even numbered section}
\stopsetups
\startsetups [section:end]
\ifodd\namedheadnumber{section}
\directsetup{section:odd}
\else
\directsetup{section:even}
\fi
\stopsetups
\setuphead
[section]
[aftersection=\directsetup{section:end}]
\starttext
\startsection[title=Ward]
\input ward
\stopsection
\page
\startsection[title=Knuth]
\input knuth
\stopsection
\stoptext
%%%% end example
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] 3+ messages in thread
* Re: Placing a section ending depending on odd/even sectionnumber
2020-08-04 17:46 ` Wolfgang Schuster
@ 2020-08-05 11:39 ` Willi Egger
0 siblings, 0 replies; 3+ messages in thread
From: Willi Egger @ 2020-08-05 11:39 UTC (permalink / raw)
To: NTG-Context ConTeXt users
Wolfgang, thank you so much for your help!
Hm, when reading your explanation I start to understand my short cut in thinking about solving the problem.
I will build it into my project…
Thanks and kind regards
Willi
> On 4 Aug 2020, at 19:46, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
>
> Willi Egger schrieb am 04.08.2020 um 18:56:
>> Hi,
>> now I have another hurdle to be taken :-) — Depending on the odd or even number of the section I have to place an ornament at the end of the section.
>> I have sofar the following setup:
>> [...]
>> However the the evaluation of the sectionnumber results always in “false”, having therefore always odd as a sectionending.
>
> You have two problem:
>
> 1. To get the current value for \currentheadnumber you have use \determineheadnumber[section] before you use it but the example below shows a better method.
>
> 2. What you do with \doifelse{...}{even} is to compare the numeric value of the section with the string "even" which is always false. To check whether the value is odd or even you have to use the \ifodd command.
>
>> What to change in order to get the desired result?
>
> %%%% begin example
> \startsetups [section:odd]
> \vfill
> \bold {End of odd numbered section}
> \stopsetups
>
> \startsetups [section:even]
> \vfill
> \bold {End of even numbered section}
> \stopsetups
>
> \startsetups [section:end]
> \ifodd\namedheadnumber{section}
> \directsetup{section:odd}
> \else
> \directsetup{section:even}
> \fi
> \stopsetups
>
> \setuphead
> [section]
> [aftersection=\directsetup{section:end}]
>
> \starttext
>
> \startsection[title=Ward]
> \input ward
> \stopsection
>
> \page
>
> \startsection[title=Knuth]
> \input knuth
> \stopsection
>
> \stoptext
> %%%% end example
>
> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-05 11:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 16:56 Placing a section ending depending on odd/even sectionnumber Willi Egger
2020-08-04 17:46 ` Wolfgang Schuster
2020-08-05 11:39 ` Willi Egger
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).