Changes

Jump to navigation Jump to search
1,159 bytes added ,  21:54, 20 January 2012
no edit summary
</texcode>
== Handling multiple modes in a row ==
Sometimes you have to choose between a couple of modes. One way to do this is
the following:
 
<texcode>
\doifmodeelse {one} {
...
} {
\doifmodeelse {two} {
...
} {
\doifmodeelse { three} {
... etc ...
}
}
}
</texcode>
 
A more readable but also more efficient way is to use a modeset:
 
<texcode>
\startmodeset
[one] {1}
[two] {2}
[two] {2}
[three] {3}
[default] {?}
\stopmodeset
 
\startmodeset
[one] {1}
[three] {3}
[default] {?}
\stopmodeset
 
\startmodeset
[one] {
\input tufte
}
[two] {
\startmodeset
[one] {A}
[two] {B}
[two] {B}
[three] {C}
[default] {!}
\stopmodeset
}
[three,four] {
\input zapf
}
[default] {
\input ward
}
\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.
[[Category:ConTeXt programming]]
30

edits

Navigation menu