![背景](https://linux22.com/image/467761/%E8%83%8C%E6%99%AF.png)
背景
我正在寻找一种类似 HTML 字段集的环境风格,以允许连续的“并发”部分出现在文档中。
使用版本2023.07.18 22:07。
输出
示例输出:
代码
以下是我目前所掌握的信息:
\startuseMPgraphic{GraphicConcurrent}
begingroup;
string legend;
picture title;
picture border;
picture bg;
numeric tw;
numeric th;
legend := \MPstring{1};
title := nullpicture;
border := nullpicture;
bg := textext( "\strut " & legend );
tw := xpart lrcorner bg - xpart llcorner bg;
th := ypart ulcorner bg - ypart llcorner bg;
addto title also image(
fill unitsquare
xysized (tw + 8, th)
shifted ulcorner multipars[1]
shifted 28 right
shifted 8 down
withcolor white;
draw
textext.drt( legend )
shifted ulcorner multipars[1]
shifted 32 right
shifted 3 down;
);
addto border also image(
for i = 1 upto nofmultipars:
draw
llcorner multipars[i] --
ulcorner multipars[i] shifted 8 down ..
ulcorner multipars[i] shifted 8 right --
urcorner multipars[i]
withpen pencircle scaled 0.75 withcolor black;
endfor;
);
draw image(
draw border;
draw title;
);
endgroup;
\stopuseMPgraphic
\definetextbackground[TextConcurrentFrame][
mp=GraphicConcurrent,
frame=off,
topoffset=1em,
leftoffset=1em,
location=paragraph,
]
\definestartstop[concurrent][
before={%
\blank[big]%
\setMPtext{1}{Terminal Berth 5}
\startTextConcurrentFrame%
},
after={\stopTextConcurrentFrame\blank[big]},
]
\starttext
\startconcurrent
\dorecurse{7}{\input knuth}
\stopconcurrent
\input ward
\startconcurrent
\dorecurse{7}{\input knuth}
\stopconcurrent
\stoptext
这会在文本周围产生简单的边框,并根据需要跨越页面:
问题
使用cornered
绕过角落似乎需要一个循环,但这并不总是需要的。
问题
你会怎样绕过拐角?
答案1
对于圆角部分,你可以更有创意地使用以下if
语句:
begingroup;
for i = 1 upto nofmultipars:
draw llcorner multipars[i] --
if multikind[i] = "first":
ulcorner multipars[i] shifted 8 down ..
ulcorner multipars[i] shifted 8 right --
urcorner multipars[i]
else:
ulcorner multipars[i]
fi
withpen pencircle scaled 0.75 withcolor black;
endfor;
endgroup;
(未测试)