我有两段说明,我需要向读者指出他们可以选择其中一段。我使用此代码将数据放入不同的列中,并在两列之间划一条线:
\startcolumns[n=2, rule=on]
\startlines
This is some instructions.
\stoplines
\column
\startlines
This is some other instructions.
\stoplines
\stopcolumns
这样就可以制作出如下所示的文档,中间有一条漂亮的分隔线:
_______________________________
| |
| This is some : This is some |
| instructions. : other instru- |
| : ctions. |
| |
|_______________________________|
我想在两列之间添加文字“或”,以便更清楚地让读者做出选择。这会打破分界线,并恰好出现在中间,垂直居中,水平居中,例如:
_______________________________
| |
| This is some : This is some |
| instructions. or other instr- |
| : uctions. |
| |
|_______________________________|
如何在分隔两列的线上添加“或”文本?
答案1
没有任何内置命令可以向列规则添加文本。假设您只对两列文本感兴趣不要跨页,您可以使用低级 TeX 伪造两列文本,并使用 metapost 添加框架。
\defineframed
[fakecolumn]
[location=top,
width=0.45\textwidth,
align=normal,
frame=off]
\defineframed
[ORcolumn]
[location=top,
height=\ORcolumnht,
width=2.5em,
frame=off,
background=ORcolumn,
top=\vss,
bottom=\vss]
\defineoverlay[ORcolumn][\useMPgraphic{ORcolumn}]
\startuseMPgraphic{ORcolumn}
ht := 2*StrutHeight;
draw (OverlayWidth/2, OverlayHeight/2-ht/2) -- (OverlayWidth/2, 0);
draw (OverlayWidth/2, OverlayHeight/2+ht/2) -- (OverlayWidth/2, OverlayHeight);
setbounds currentpicture to boundingbox OverlayBox;
\stopuseMPgraphic
\newbox\leftcolumnbox \newbox\rightcolumnbox
\newdimen\ORcolumnht
\def\startORcolumns#1\column#2\stopORcolumn
{\blank
\setbox\leftcolumnbox \hbox{\fakecolumn{#1}}%
\setbox\rightcolumnbox\hbox{\fakecolumn{#2}}%
% location=top sets the ht of the box to structheight
% and depth to the remaining length
\ORcolumnht=\dimexpr\strutheight+
\dp\ifdim\dp\leftcolumnbox>\dp\rightcolumnbox\leftcolumnbox\else\rightcolumnbox \fi
\hbox to \textwidth
{\hss\copy\leftcolumnbox
\hss\ORcolumn{OR}\hss
\copy\rightcolumnbox\hss}%
\blank}
\starttext
\input zapf
\startORcolumns
\input knuth
\column
\input ward
\stopORcolumn
\input zapf
\stoptext