\nobs and \Nobs
Alternating note and observe
The following code defines two commands,\nobs and
\Nobs, which alternatingly expands to
note
resp.
Note and observe resp.
Observe.
\ExplSyntaxOn
\bool_new:N \g_noteobserve
\NewDocumentCommand{\setnote}{}{
\bool_gset_true:N \g_noteobserve
}
\NewDocumentCommand{\setobserve}{}{
\bool_gset_false:N \g_noteobserve
}
\NewDocumentCommand{\nobs}{ o }{
\IfValueT{#1}{
\str_if_eq:noTF {note} {#1} {
\bool_gset_true:N \g_noteobserve
} {
\str_if_eq:noTF {Note} {#1} {
\bool_gset_true:N \g_noteobserve
} {
\bool_gset_false:N \g_noteobserve
}
}
}
\bool_if:nTF { \g_noteobserve } {
\bool_gset_false:N \g_noteobserve
note
} {
\bool_gset_true:N \g_noteobserve
observe
}
\IfValueF{#1}{~}
}
\NewDocumentCommand{\Nobs}{ o }{
\IfValueT{#1}{
\str_if_eq:noTF {note} {#1} {
\bool_gset_true:N \g_noteobserve
} {
\str_if_eq:noTF {Note} {#1} {
\bool_gset_true:N \g_noteobserve
} {
\bool_gset_false:N \g_noteobserve
}
}
}
\bool_if:nTF { \g_noteobserve } {
\bool_gset_false:N \g_noteobserve
Note
} {
\bool_gset_true:N \g_noteobserve
Observe
}
\IfValueF{#1}{~}
}
\ExplSyntaxOffnote,
Note,
observe, or
Observe, and forces the command to expand to the corresponding word. Here is an
example that illustrates how these commands work:
\Nobs that for all $i\in\N$ it holds that $x_i\geq 0$.
Furthermore, \nobs that for all $i\in\N$ it holds that $y_i\leq 0$.
In addition, \nobs[observe] that for all $i\in\N$ it holds that $z_i\geq 0$.