ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Tagged blocks
@ 2019-06-18 18:17 Jan Willem Flamma
  2019-06-19 15:24 ` Wolfgang Schuster
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Willem Flamma @ 2019-06-18 18:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Dear list members,

I would like to add a tag to a block so I can easily select a few blocks and print them in another chapter.

In the below MWE I would like to print the normal (non-tagged) block in the first chapter. The second block with the tag [exam] should not be processed in the first chapter and only appear in the second chapter.

According to the wiki and reference manual it should be possible using either \useblocks or \selectblocks but I can't get it to work.

Who can help me out?

Best regards,
Jan Willem Flamma


\defineenumeration[question][location=margin,text=Question,way=bychapter]
\defineenumeration[answer]  [location=margin,text=Answer]

\defineblock[question]
\defineblock[answer]

\hideblocks[question]
\hideblocks[answer]

\starttext

\startchapter[title=Chapter for regular questions]

\beginquestion
\startquestion 
Normal question
\stopquestion
\endquestion
\beginanswer
\startanswer 
Normal answer
\stopanswer
\endanswer

\beginquestion[exam]
\startquestion 
Exam question
\stopquestion
\endquestion
\beginanswer[exam]
\startanswer 
Exam answer
\stopanswer
\endanswer

\startsection[title=Questions]
\useblocks[question][criterium=chapter]
\stopsection

\startsection[title=Answers]
\useblocks[answer][criterium=chapter]
\stopsection

\stopchapter

\startchapter[title=Chapter for exam questions]

\startsection[title=Exam Questions]
%\useblocks[question][exam]   %<--- does not work
\stopsection

\startsection[title=Exam Answers]
%\useblocks[answer][exam]     %<--- does not work
\stopsection

\stopchapter

\stoptext

[-- Attachment #1.2: Type: text/html, Size: 9943 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] 2+ messages in thread

* Re: Tagged blocks
  2019-06-18 18:17 Tagged blocks Jan Willem Flamma
@ 2019-06-19 15:24 ` Wolfgang Schuster
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2019-06-19 15:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jan Willem Flamma


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

Jan Willem Flamma schrieb am 18.06.2019 um 20:17:
> Dear list members,
>
> I would like to add a tag to a block so I can easily select a few 
> blocks and print them in another chapter.
>
> In the below MWE I would like to print the normal (non-tagged) block 
> in the first chapter. The second block with the tag [exam] should not 
> be processed in the first chapter and only appear in the second chapter.
>
> According to the wiki and reference manual it should be possible using 
> either \useblocks or \selectblocks but I can't get it to work.
At this point you can hide tagged blocks.
> \beginquestion
> \startquestion
> Normal question
> \stopquestion
> \endquestion
> \beginanswer
> \startanswer
> Normal answer
> \stopanswer
> \endanswer
>
> \beginquestion[exam]
> \startquestion
> Exam question
> \stopquestion
> \endquestion
> \beginanswer[exam]
> \startanswer
> Exam answer
> \stopanswer
> \endanswer
This flushes all saved blocks and you can't exclude tagged blocks but 
it's possible to extend the mechanism an apply a default tag to each 
block which will allow selective output.
> \startsection[title=Questions]
> \useblocks[question][criterium=chapter]
> \stopsection
>
> \startsection[title=Answers]
> \useblocks[answer][criterium=chapter]
> \stopsection
>
> \stopchapter
>
> \startchapter[title=Chapter for exam questions]
This was a bug (do you get a error message in your document?) and should 
be fixed in the next beta.
> \startsection[title=Exam Questions]
> %\useblocks[question][exam]   %<--- does not work
> \stopsection
>
> \startsection[title=Exam Answers]
> %\useblocks[answer][exam]     %<--- does not work
> \stopsection
Wolfgang


[-- Attachment #1.2: Type: text/html, Size: 7789 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] 2+ messages in thread

end of thread, other threads:[~2019-06-19 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 18:17 Tagged blocks Jan Willem Flamma
2019-06-19 15:24 ` 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).