答案1
可以通过放置方法轻松地将结构编号与页边对齐。这些是普通的宏,它们接受两个参数——一个用于编号,另一个用于标题文本——并确定它们在正文上下文中的排版方式。这样,结构呈现就只受您的想象力和 TEX 技能的限制。要实现这一点,设置键选择需要设置为command
和键命令到您的宏。此外,左边距必须配置为与所需的左对齐相匹配。(有关更多信息,请参阅结构渲染源,strc-ren.mkiv。
% macros=mkvi
\unprotect
%% 1. Create a placement alternative, i. e. a dyadic macro. % ······· %
\unexpanded\def\left_margin_placement#number#content{%
\vbox{%
\localheadsetup\begstrut\dontleavehmode
\ifconditional\headshownumber\inleftmargin{#number}\fi
{#content}%
}
}
%% 2. Setup the alignment within the margin. % ······················ %
\setupmargindata [left] [align=flushleft]
\setuplayout [leftmargin=1cm]
%% 3. Hook the new method into the structurals. % ··················· %
\setuphead [chapter,section] [
alternative=\v!command,
\c!command=\left_margin_placement,
]
\protect
%% 4. ... Profit?
\starttext % ························································ %
\chapter{foo}
\section{bar}
\input knuth
\stoptext % ························································· %