Changes

Jump to navigation Jump to search
68 bytes added ,  19:11, 27 August 2012
m
Reorganized content
== Checking for multiple modes (`or`/`and` statements for modes) ==
<code>\startmode</code> and <code>\startnotmode</code> can check for multiple modes,
by giving a list of modes as their arguments. <code>\startmode</code>
\doifnotallmodeselse{modes} {content} {alt}
</texcode>
 
== Checking multiple modes in sequence (`case` statement for modes) ==
 
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.
== Checking modes in Lua ==
</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]]

Navigation menu