我不确定如何在typing
环境中将行号与背景结合起来。
这是我正在尝试的一个最小示例:
\starttext
\startbackground[frame=on,background=off]
\startlinenumbering
\starttyping
Phasellus neque orci, porta a, aliquet quis, semper a, massa.
Etiam laoreet quam sed arcu.
In id erat non orci commodo lobortis.
\stoptyping
\stoplinenumbering
\stopbackground
\stoptext
当我编译这个时,我在背景中输入内容,但没有行号:
但是,如果我background
从块中删除行号,则行号将按预期显示。
我基本上可以通过环境获得我想要的东西framedtext
,但是我无法跨页面:
\starttext
\startframedtext[frame=on,background=off,width={\hsize},frameoffset=2em]
\startlinenumbering
\starttyping
Phasellus neque orci, porta a, aliquet quis, semper a, massa.
Etiam laoreet quam sed arcu.
In id erat non orci commodo lobortis.
\stoptyping
\stoplinenumbering
\stopframedtext
\stoptext
如果我将文本换行,我也可以让行号显示出来textbackground
,但是我无法让背景延伸到行号周围:
\starttext
\definetextbackground
[MyBackground]
[framecolor=black,
location=always,
background=off]
\starttextbackground[MyBackground]
\startlinenumbering
\starttyping
Phasellus neque orci, porta a, aliquet quis, semper a, massa.
Etiam laoreet quam sed arcu.
In id erat non orci commodo lobortis.
\stoptyping
\stoplinenumbering
\stoptextbackground
\stoptext
有什么方法可以实现第一幅图的效果,使得打字可以跨页面中断?
答案1
答案2
我进一步研究了手册和示例,并找到了使用 MetaPost 的解决方案。这提供了很大的灵活性,但代价是更难理解。
\startuseMPgraphic{MyMPBackground}
begingroup; save lftbdry, rtbdry, parframe;
for i=1 upto nofmultipars :
path lftbdry, rtbdry, parframe;
rtbdry := rightboundary multipars[i];
lftbdry := (leftboundary multipars[i])
shifted (-36pt, 0);
parframe := point 0 of lftbdry
--point 1 of lftbdry
--point 0 of rtbdry
--point 1 of rtbdry
--cycle;
draw parframe;
endfor;
endgroup;
\stopuseMPgraphic
\starttext
\definetextbackground
[MyBackground]
[location=paragraph,
mp=MyMPBackground,
frame=off]
\startlinenumbering
\starttextbackground[MyBackground]
\typefile[option=context]{\jobname.mkiv}
\stoptextbackground
\stoplinenumbering
\stoptext