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?

  • 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/… – Philipp Gesang Jul 5 '14 at 11:47
  • 2
    @phg would you be so kind and write an answer? – doed Jul 13 '14 at 13:19
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

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.