ConTeXt: empty line in enumeration
You can use the ad-hoc solution which almost always works in such situations and cancel the whitespace manually using \blank[back,overlay]
.
\setuplayout[backspace=5cm]
\defineenumeration[example][text=Example,alternative=inmargin]
\starttext
\startexample
One line before
\startitemize
\item Test
\stopitemize
\stopexample
\startexample
\blank[back,overlay]
\startitemize
\item direct itemize
\stopitemize
\stopexample
\stoptext
To automate this solution, i.e. to insert \blank[back,overlay]
whenever \startENUMERATION
is directly followed by \startitemize
you can use this. Please don't use this...
\appendvalue{\csname ??constructionstarthandler\endcsname enumeration}{\futurelet\next\checkitemize}
\unexpanded\def\checkitemize{%
\ifx\next\startitemize
\blank[back,overlay]%
\fi
}
First let's try to understand why the extra space is occuring. Roughly speaking, using alternative=inmargin
is equivalent to
\noindent\inmargin{ .. title .. }
... content ...
The following example shows the behavior.
\starttext
\noindent
\inmargin{Example 1}
\startitemize
\item This is how enumeration works.
\stopitemize
\inmargin{Example 2}
\startitemize
\item This works correctly
\stopitemize
\stoptext
An easy fix it to replace \noindent
by \noindentation
in strc-con.mkvi
or locally:
\unprotect
\startsetups[\??constructionrenderings:\v!margin]
\let\\=\crlf
\noindentation
\inmargin[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
\ignorespaces
\stopsetups
\protect
This fixes the extra new line, but produces a misaglined title:
This can be "fixed" by removing the scope=local
:
\unprotect
\startsetups[\??constructionrenderings:\v!margin]
\let\\=\crlf
\noindentation
\inmargin[\c!scope=\v!local]{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
\ignorespaces
\stopsetups
\protect
Here is a complete MWE:
\showboxes
\unprotect
\startsetups[\??constructionrenderings:\v!margin]
\let\\=\crlf
\noindentation
\inmargin{\flushconstructionheadbox}%
\useconstructionstyleandcolor\c!style\c!color
\ignorespaces
\stopsetups
\protect
\setuplayout[backspace=5cm]
\defineenumeration[example][text=Example,alternative=inmargin,
titlealign=flushleft]
\starttext
\startexample
\startitemize
\item Test
\stopitemize
\stopexample
\startexample
Line 1
\startitemize
\item Test
\stopitemize
\stopexample
\stoptext
which gives