* Blocks inside a conditional mode.
@ 2021-11-28 18:39 Fabrice L via ntg-context
2021-11-28 20:42 ` Henning Hraban Ramm via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Fabrice L via ntg-context @ 2021-11-28 18:39 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Fabrice L
[-- Attachment #1.1: Type: text/plain, Size: 3369 bytes --]
Dear list,
I have an error when I try to insert a block inside a conditional mode (but there is two nested conditional mode.. is this the problem ?).
In my courses notes, I insert some blocks (named « Complement » in the minimal exemple below) when in « Professor » mode. This works fine, as shown in the first « \beginComplement … \endComplement » of my example below.
But now I have to use another condition for some blocks, depending of the number of the current course. So I insert my block with a condition, here « CourseOne » :
\enablemode[CourseOne]
\doifmode{CourseOne}{
\beginComplement
Another complementary slide.
\endComplement
}
But this does not work :
% ————
tex error > tex error on line 1 in file /Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv: ! TeX capacity exceeded, sorry [input stack size=50000]
% ————
The problem can be summarized in this minimal non working example :
% — MWE —————————————————————
\setuppapersize[S5][S5]
\enablemode[Professor]
\defineblock[Complement]
\setupblock[Complement][
before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]
\doifallmodes{Professor} {
\keepblocks[Complement]
}
\starttext
page 1
\beginComplement
A complementary slide.
\endComplement
page 2
\enablemode[CourseOne]
\doifmode{CourseOne}{
\beginComplement
Another complementary slide but only for course number 1.
\endComplement
}
\disablemode[CourseOne]
page 3
\enablemode[CourseTwo]
\doifmode{CourseTwo}{
\beginComplement
Another complementary slide but only for course number 2.
\endComplement
}
\disablemode[CourseTwo]
\stoptext
\stoptext
% — MWE —————————————————————
Blocks and modes usually works fine for me, but here, I do not understand my error.
Thanks for any help !
Fabrice.
Note : in case this way of doing things seems a bit silly, here are more explanations. I do use mode « CourseOne » here because in the real life, the content in the condition « \doifmode{CourseOne}{ …} » is read in an external file, containing material for « CourseOne », « CourseTwo », etc. The setup is then, in the main file :
% Main file : begin ----------------
Bla bla bla ...
\enablemode[CourseOne]
\input ComplementMaterial.tex
\disablemode[CourseOne]
Bla bla bla ...
\enablemode[CourseOne]
\input ComplementMaterial.tex
\disablemode[CourseOne]
% Main file : end ----------------
And in the « ComplementMaterial.tex » there is :
% ComplementMaterial.tex —————————
\doifmode{CourseOne}{
\beginComplement
A complementary slide but only for course number 1.
\endComplement
\beginComplement
Another complementary slide but only for course number 1.
\endComplement
}
\doifmode{CourseTwo}{
\beginComplement
A complementary slide but only for course number 2.
\endComplement
\beginComplement
Another complementary slide but only for course number 2.
\endComplement
}
% ComplementMaterial.tex —————————
[-- Attachment #1.2: Type: text/html, Size: 9560 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] 5+ messages in thread
* Re: Blocks inside a conditional mode.
2021-11-28 18:39 Blocks inside a conditional mode Fabrice L via ntg-context
@ 2021-11-28 20:42 ` Henning Hraban Ramm via ntg-context
2021-11-29 1:54 ` Fabrice L via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2021-11-28 20:42 UTC (permalink / raw)
To: ntg-context; +Cc: Henning Hraban Ramm
Am 28.11.21 um 19:39 schrieb Fabrice L via ntg-context:
> I have an error when I try to insert a block inside a conditional mode
> (but there is two nested conditional mode.. is this the problem ?).
You can’t nest modes in \startmode ... \stopmode.
I don’t know what are the limitations of \doifmode.
Maybe it helps to use additional grouping with {}, \bgroup .. \egroup or
\start .. \stop.
> In my courses notes, I insert some blocks (named « Complement » in the
> minimal exemple below) when in « Professor » mode. This works fine, as
> shown in the first « \beginComplement … \endComplement » of my example
> below.
Maybe you can work with buffers or (ConTeXt) blocks (the latter were
recently discussed here, it’s a quite unknown mechanism).
Hraban
___________________________________________________________________________________
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] 5+ messages in thread
* Re: Blocks inside a conditional mode.
2021-11-28 20:42 ` Henning Hraban Ramm via ntg-context
@ 2021-11-29 1:54 ` Fabrice L via ntg-context
2021-11-29 8:54 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Fabrice L via ntg-context @ 2021-11-29 1:54 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Fabrice L
[-- Attachment #1.1: Type: text/plain, Size: 4108 bytes --]
Thanks Hraban for your answer,
> Le 28 nov. 2021 à 15:42, Henning Hraban Ramm via ntg-context <ntg-context@ntg.nl> a écrit :
>
> Am 28.11.21 um 19:39 schrieb Fabrice L via ntg-context:
>> I have an error when I try to insert a block inside a conditional mode (but there is two nested conditional mode.. is this the problem ?).
>
> You can’t nest modes in \startmode ... \stopmode.
> I don’t know what are the limitations of \doifmode.
According to the wiki, we cannot nest several \startmode …\stopmode, but there is no limitation with \doifmode.
>
> Maybe it helps to use additional grouping with {}, \bgroup .. \egroup or \start .. \stop.
Following your advice, I tried with several {}, but no luck.
>
>> In my courses notes, I insert some blocks (named « Complement » in the minimal exemple below) when in « Professor » mode. This works fine, as shown in the first « \beginComplement … \endComplement » of my example below.
>
> Maybe you can work with buffers or (ConTeXt) blocks (the latter were recently discussed here, it’s a quite unknown mechanism).
I already use blocks, but following your message, I tried to think differently. One solution would be to define a block for each course. Something like this (a working minimal example, redone in order this would be more easier to understand (I hope!) what I’m trying to do):
% —————————————
\setuppapersize[S5][S5]
\enablemode[Professor]
\defineblock[ComplementTwo]
\defineblock[ComplementThree]
\setupblock[ComplementTwo,ComplementThree][
before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]
\starttext
% Let's process the summaries ;
\beginComplementTwo
Last course, we have seen A.
\endComplementTwo
\beginComplementThree
Last course, we have seen B….
\endComplementThree
\beginComplementThree
Last course, we have seen C….
\endComplementThree
% ----
Let's begin course 1.
This is course 1 : a lot of pages here about A!
\page[yes]
Let's begin course 2.
\doifmode{Professor} {
\useblocks[ComplementTwo]
}
This is course 2 : a lot of pages here about B and C!
\page[yes]
Let's begin course 3.
\doifmode{Professor} {
\useblocks[ComplementThree]
}
This is course 3 : a lot of pages here about D... !
\stoptext
%—————————
The only inconvenient of this solution if that I have to define 15 blocks (one for each week of the term): ComplementOne, ComplementTwo, .., ComplementFithteen… Another drawback of this is difficult to move one block form one week to another if I change something. Each block here correspond in fact to a summary of the previous course. So I have typically around 10 pages of summary for each course. The challenge is that the content of each course is not exactly the same form one term to another, so I have to move a page to the summary from one course to the other one, like in a given term, if teach about subject C in course 3 :
\beginComplementThree
Last course, we have seen C….
\endComplementThree
, but next term in course 4:
\beginComplementFour
Last course, we have seen C….
\\beginComplementFour
I have to manually change \beginComplementThree … \endComplementThree to \beginComplementFour … \beginComplementFour.
But I will do this if I do not find another solution.
Thanks again Hraban.
Fabrice.
>
>
> Hraban
> ___________________________________________________________________________________
> 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: 10198 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] 5+ messages in thread
* Re: Blocks inside a conditional mode.
2021-11-29 1:54 ` Fabrice L via ntg-context
@ 2021-11-29 8:54 ` Hans Hagen via ntg-context
2021-11-29 13:54 ` Fabrice L via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2021-11-29 8:54 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hans Hagen
On 11/29/2021 2:54 AM, Fabrice L via ntg-context wrote:
> The only inconvenient of this solution if that I have to define 15
> blocks (one for each week of the term): ComplementOne, ComplementTwo,
\defineblock[example]
\starttext
\beginexample[Two]
Last course, we have seen A.
\endexample
\beginexample[Three]
Last course, we have seen B….
\endexample
\beginexample[Three]
Last course, we have seen C….
\endexample
\useblocks[example][Two]
% \useblocks[example][Three]
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 5+ messages in thread
* Re: Blocks inside a conditional mode.
2021-11-29 8:54 ` Hans Hagen via ntg-context
@ 2021-11-29 13:54 ` Fabrice L via ntg-context
0 siblings, 0 replies; 5+ messages in thread
From: Fabrice L via ntg-context @ 2021-11-29 13:54 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Fabrice L
Dear Hans,
> Le 29 nov. 2021 à 03:54, Hans Hagen <j.hagen@xs4all.nl> a écrit :
>
> On 11/29/2021 2:54 AM, Fabrice L via ntg-context wrote:
>
>> The only inconvenient of this solution if that I have to define 15 blocks (one for each week of the term): ComplementOne, ComplementTwo,
> \defineblock[example]
>
> \starttext
>
> \beginexample[Two]
> Last course, we have seen A.
> \endexample
>
> \beginexample[Three]
> Last course, we have seen B….
> \endexample
>
> \beginexample[Three]
> Last course, we have seen C….
> \endexample
>
> \useblocks[example][Two]
> % \useblocks[example][Three]
>
> \stoptext
>
> %————————————————————————————————
Thanks (again). ConTeXt is always full of ressource ! I did not know we could do this, even if I realized now that there is a similar example in the wiki.
For the list, in case in the future this would be useful for another user, below is the complete minimal example using this approach.
% ----- Minimal working example :
\setuppapersize[S5][S5]
\enablemode[Professor]
\defineblock[Complement]
\setupblock[Complement][
before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]
\starttext
% Let's process the summaries ------------;
\beginComplement[Two]
Last course, we have seen A.
\endComplement
\beginComplement[Three]
Last course, we have seen B….
\endComplement
\beginComplement[Three]
Last course, we have seen C….
\endComplementThree
\beginComplement[Four]
Last course, we have seen D….
\endComplementFour
\beginComplement
and E !
\endComplementFour
% ---- summaries: end ------------;
Let's begin course 1.
This is course 1 : a lot of pages here about A!
\page[yes]
Let's begin course 2.
\doifmode{Professor} {
\useblocks[Complement][Two]
}
This is course 2 : a lot of pages here about B and C!
\page[yes]
Let's begin course 3.
\doifmode{Professor} {
\useblocks[Complement][Three]
}
This is course 3 : a lot of pages here about D... !
\doifmode{Professor} {
\useblocks[Complement][Four]
}
The course 4 !
\stoptext
% ----- Minimal working example : end --------
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-29 13:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-28 18:39 Blocks inside a conditional mode Fabrice L via ntg-context
2021-11-28 20:42 ` Henning Hraban Ramm via ntg-context
2021-11-29 1:54 ` Fabrice L via ntg-context
2021-11-29 8:54 ` Hans Hagen via ntg-context
2021-11-29 13:54 ` Fabrice L 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).