-
Notifications
You must be signed in to change notification settings - Fork 241
Selective Processing
Text can be marked up for selective processing. OLP uses a list of tags for this. They can be set to on or off using \toggletrue{taglist}
and \togglefalse{taglist}
, where taglist is a comma-separated list of tags. For each tag, automatically a matching not_tag_ is initialized with the opposite truth vale.
All environments take a taglist as a special optional argument, e.g.,
\begin<math>{ex} ... \end{ex}
can be used to include an example which will print iff the tag "math" is active. [Note: this does not work for environments that are deferred, e.g., problems. SUrround the environment in an \iftag
command instead; see below.]
To include a (short) piece of text depending on whether at least one of a list of tags is active or not, use
\iftag{taglist}{text to print}{alternative text}
Tags are implemented as etoolbox "toggles." Thus, you can use etoolbox's \ifboolexpr
if more complicated tests are required. E.g.,
\ifboolexpr{not togl {math} and not togl {phil}}{some text}{}
Note, however, that since each tag comes with a negated tag, many combinations can be implemented with just \iftag
, e.g., to print some text iff both tags math and phil are active, use
\iftag{notmath,notphil}{}{some text}
The \tagitem{taglist}{text if active}{text if not}
will set text if active or text if not as an \item
in an enumerate
or itemize
environment. If the text is empty, no \item
will be produced. Use this to supress or include items in itemized lists.
Selective processing of itemized lists may result in lists with a single item. To avoid this, use the tagenumerate
environment. It takes a taglist as argument and produces an itemized list if more than one tag is active; if only one tag is active, any \tagitem
in the environment will simply typeset its argument without an \item
. For instance:
\begin{tagenumerate}{a,b,c}
\tagitem{a}{Item A}{}
\tagitem{b}{Item B}{}
\tagitem{c}{Item C}{}
\end{tagenumerate}
A comma-separated list of tagged items may also cause problems (extra commas or spaces). It is typeset this way:
Here's a list of things:
\startycommalist
\iftag{a}{\ycomma item A}{}%
\iftag{b}{\ycomma item B}{}%
\iftag{c}{\ycomma item C}{}.