3

Consider the following MWE:

\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

This produces the following image:

itemizes

Question: Is there a way to remove the blank line in the itemize example (to raise the itemize to the same height as the marginal text appears)?

Some notes:

  • I already played around with keys like nowhite etc. They do not seem to have any effect.
  • As there are some other environments then itemize it would be nice if it could be environment-agnostic. Maybe one could apply some Lua magic (in LaTeX one could do easily with callbacks).
5

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

enter image description here

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
}
  • That looks good. Is there an automated way to insert this whenever there is an itemization at the beginning of an example? – TeXnician Jul 11 at 9:43
  • @TeXnician This solution is only to treat one-off situations. – Henri Menke Jul 11 at 9:48
  • I will accept this for now and ask a follow-up question concerning automatization. – TeXnician Jul 12 at 8:13
  • @TeXnician I have added and idea to automate the insertion, but please, don't use it... – Henri Menke Jul 12 at 8:24
  • Thanks. It does work. But as it seems to register for all enumerations and you noted "don't use it", I tried to generalize the question and asked it as tex.stackexchange.com/q/499602/124577. – TeXnician Jul 12 at 8:33
3

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

enter image description here

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:

enter image description here

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

enter image description here

  • Many thanks for the explanation. Only one question: What does scope=local do? – TeXnician Jul 12 at 20:58
  • I don't use margin notes so I don't know on the top of my head. A quick look at the code does not provide much insight. I haven't check the documentation yet. – Aditya Jul 13 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.