From Wiki
Jump to navigation Jump to search



The command \useblocks is used to typeset blocks


criteriumtext section


Typesets all the requested blocks defined in the document, in the order in which they were defined. An optional second argument can be used to print only blocks with certain tags.


Example 1


% We don't want to display blocks when we define them.

First question, defined at the start

First answer

\subsection{My questions and answers, original interleaving}

\subsection{Only the first answer}

Second block, defined at the end

Second answer, also defined at the end

\subsection{You can't select by tag only}
\useblocks[first]   % produces nothing
\useblocks[][first] % produces nothing


This gives:

Test if a block is empty or not

In some cases, one may want use the collected blocks, e. g., at the end of a chapter, preceded (of course) with a section header. However, some chapters may not have had blocks, so that an empty section would appear. In this case, \doifelseblocksempty it comes in handy to test if a block is empty or not (will work from some upload in Aug 2021 onwards):



Test B was a great!

\doifelseblocksempty {testa}{}{} {\section{Test A}} {Nothing to show here} % {name}{tag}{criterium}
\doifelseblocksempty {testb}{}{} {\section{Test B}} {Nothing to show here} % {name}{tag}{criterium}



See also

Help from ConTeXt-Mailinglist/Forum

All issues with: