5

I'm using ConTeXt, and trying to setup my document's subsection headings to start with a colored rule. However, any way I've tried doing this results in a rule placed a line higher than the heading text.

The simplest document that illustrates the issue is the following:

\startmode[*mkii]
  \enableregime[utf-8]
  \setupcolors[state=start]
\stopmode

\setuphead[section]      [style=\tfb, before={beforetext}]
\setuphead[subsection]   [style=\tfb, before={\blackrule}]

\starttext

\section{Section}
This works as expected.

\subsection{Subsection}
Here, for some reason the rule doesn't come on the same line as the heading.
However, inlining does seem to work in the section text: \blackrule
\stoptext

which gets rendered as

rule rendering test

Does anyone know what causes the line break when the rule is part of the section heading, and how to prevent it?

2
  • 4
    Rules don’t cause TeX to enter horizontal mode as text does. Try \setuphead[subsection][style=\tfb, before=\leavevmode\blackrule] (or \dontleavehmode\blackrule). See also wiki.contextgarden.net/… Jul 5, 2014 at 11:47
  • 2
    @phg would you be so kind and write an answer?
    – doed
    Jul 13, 2014 at 13:19

1 Answer 1

2

You need to \leavevmode explicitly before of the rule:

\startmode[*mkii]
  \enableregime[utf-8]
  \setupcolors[state=start]
\stopmode

\setuphead[section]   [style=\tfb, before={beforetext}]
\setuphead[subsection][style=\tfb, before=\leavevmode\blackrule]

\starttext

\section{Section}
This works as expected.

\subsection{Subsection}
Here, for some reason the rule doesn't come on the same line as the heading.
However, inlining does seem to work in the section text: \blackrule
\stoptext

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .