Head sections automatically marked for conditional text
![](https://secure.gravatar.com/avatar/cb57b6ff7728dddec1b41e8935a5ad47.jpg?s=120&d=mm&r=g)
The short version: I'd like to set up a context document with multiple user-defined heads, such that they can be conditionally compiled and/or altered. It seems that modes are what I want, but I'm having trouble figuring out how to automatically set up a particular section to be wrapped in a particular mode (if that makes any sense at all). Is this possible? The long version: What I think I want is something like: --- begin foo.tex --- \startenvironment foo \definemode[showexamples][keep] % Can I add some magic here in the following setup to automagically % wrap these sections with commands to start and stop a particular mode? \definehead[example][subject][style=\bfc] --- end foo.tex --- --- begin bar.tex --- \environment foo \enablemode[showexamples] \starttext \startexample[title={I'd like to be able to use modes to enable or disable this section}] I'd like to have a mode to conditionally show all of the {\tt example} sections (without affecting other content, etc.). \stopexample \stoptext --- end bar.tex --- The added difficulty here is that I need three kinds of modes (A, B, And C) with the need to support changing the layout, etc. based on what modes are enabled. I've gotten this to work by including \startmode[example] and \stopmode commands in the document, but I'd love to find a way to have this happen automatically by some clever setups for user defined heads, as above. (I tried playing around with before= and after=, with disastrous results...) I've worked through the discussion about using blocks against enumerations, found here: http://www.mail-archive.com/ntg-context@ntg.nl/msg83818.html ...but I'm hoping that there's a simpler solution (without the external file, etc.) Is there a way to do this within the current framework, or should I be wrapping all of this in new commands? Or something else entirely? Thanks! -Paul
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Tue, 29 Aug 2017, Paul Mazaitis wrote:
The short version:
I'd like to set up a context document with multiple user-defined heads, such that they can be conditionally compiled and/or altered. It seems that modes are what I want, but I'm having trouble figuring out how to automatically set up a particular section to be wrapped in a particular mode (if that makes any sense at all).
Is this possible?
Here is how I usually do this: \definemode[showexamples][keep] \doifmodeelse{showexamples} {\definehead[example][subject][style=\bfc]} {\definebuffer[example]} \starttext \input ward \startexample[title={I'd like to be able to use modes to enable or disable this section}] I'd like to have a mode to conditionally show all of the {\tt example} sections (without affecting other content, etc.). \stopexample \stoptext Aditya
participants (2)
-
Aditya Mahajan
-
Paul Mazaitis