我正在使用 ConTeXt,并尝试将文档的子部分标题设置为以彩色规则开头。但是,无论我如何尝试,结果都是规则位于标题文本上方一行。
说明该问题的最简单的文档如下:
\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
渲染为
有谁知道当规则是节标题的一部分时什么原因导致换行,以及如何防止这种情况发生?
答案1
您需要\leavevmode
在规则之前明确说明:
\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