ConTeXt: Automatically insert a command under certain conditions

by TeXnician   Last Updated July 12, 2019 09:23 AM - source

This is a follow-up to https://tex.stackexchange.com/a/499481/124577. That answer works great (manually as well as automated), but the author noted in terms of automatization "don't use it".

So, consider the example from there:

\setuplayout[backspace=5cm]
\defineenumeration[example][text=Example,alternative=inmargin]

\starttext
\startexample
  One line before
  \startitemize
    \item Test
  \stopitemize
\stopexample
\startexample
  \startitemize
    \item direct itemize
  \stopitemize
\stopexample
\stoptext

To motivate this: I want to automatically eliminate all whitespace at the beginning of the enumeration.

As this depends on what follows the \startexample in this case (e.g. \startitemize, \startformula create white space, normal text does not), I am interested in setting some constraints. In LuaLaTeX I would register a callback and preprocess the input buffer, but this is disabled in ConTeXt.

Question: Is there an automatic way to insert some code dependent on conditions (which can be determinded by pattern-matching input) after a specific command?



Related Questions


what is meaning of "\hbox to \hsize" in ConTeXt?

Updated July 04, 2015 13:10 PM



Line numbering in two-column layout with ConTeXt

Updated October 14, 2016 08:09 AM