Changes

Jump to navigation Jump to search
51 bytes added ,  19:28, 27 August 2012
m
Improved explanation of modesets
</texcode>
== Checking multiple modes in sequence parallel (<code>case</code> statement for modes) ==
Sometimes In addition to the above <em>"or"</em> and <em>"and"</em> environment which check modes is sequence, you have to choose between a couple of can also check multiple modesin parallel. One way to do this The syntax for such a <em>"case"</em> environment is the followingas follows:
<texcode>
\doifmodeelse {one} { startmodeset [mode1, mode2, ... } ] { \doifmodeelse {twoProcessed if either mode is enabled} { [mode3, mode4, ... } { ] \doifmodeelse { threeProcessed if either mode is enabled} { ... etc ... [default] {Processed if none of the above modes match} } } \stopmodeset
</texcode>
A more readable but also more efficient way is to The same mode can be referenced multiple times, and '''all''' matching brances are executed. The <cmd>startmodeset</cmd> ... <cmd>stopmodeset</cmd> environments can be nested. So, you can use a modeset:
<texcode>
\startmodeset
[one] {1} [two] {2} [two] {2} [three] {3} [default] {?}\stopmodeset \startmodeset [one] {1} [three] {3} [default] {?}\stopmodeset \startmodeset [onemode1, mode2] { \input tufteProcessed when either mode1 or mode2 is enabled
}
[twomode3] {
\startmodeset
[onemode1] {AProcessed when mode1 and mode3 are enabled} [twomode2] {BProcessed when mode2 and mode3 are enabled} [two] {B} [threedefault] {C} [default] {!Processed when mode3 is enabled and mode1 and mode2 are disabled}
\stopmodeset
}
[three,four] {
\input zapf
}
[default] {
\input wardProcessed when mode1, mode2, and mode3 are disabled.:
}
\stopmodeset
</texcode>
 
The syntax is somewhat special but suits the purpose. It's a sort of
case statement. There can be multiple references to the same mode and
each match is honored. Of course the default only is used when no match
has taken place.
== Checking modes in Lua ==

Navigation menu