出于布局原因,我想将数据嵌入到表格中。现在,如果某一行太大,页面就会溢出,这会带来问题。
如果发生这种情况,我该如何允许分页?
梅威瑟:
\starttext
\startxtable[option={stretch,width},split=yes]
\startxrow[foregroundcolor=white,background=color,backgroundcolor=black]
\startxcell[nx=2] \bf Table NAME\stopxcell
\stopxrow
\startxrow
\startxcell[width=0.5cm,background=color,backgroundcolor=black]\stopxcell
\startxcell[background=color, backgroundcolor=gray] \bf Description: \stopxcell
\stopxrow
\startxrow
\startxcell[width=0.5cm,background=color,backgroundcolor=black]\stopxcell
\startxcell
\startitemize
\dorecurse{60}{\item Item \recurselevel}
\stopitemize
\stopxcell
\stopxrow
\stopxtable
\stoptext
答案1
极端表 (Extreme Tables) 的一个 hack 变体是将每个项目放在其自己的行中。
\starttext
\startxtable[option={stretch,width},split=yes]
\startxrow[foregroundcolor=white,background=color,backgroundcolor=black]
\startxcell[nx=2] \bf Table NAME\stopxcell
\stopxrow
\startxrow
\startxcell[width=0.5cm,background=color,backgroundcolor=black]\stopxcell
\startxcell[background=color, backgroundcolor=gray] \bf Description: \stopxcell
\stopxrow
\dorecurse{60}{%
\startxrow[topframe=off,bottomframe={\ifnum\recurselevel=60 on\else off\fi}]
\startxcell[width=0.5cm,background=color,backgroundcolor=black]\stopxcell
\startxcell
\startitemize
\item Item \recurselevel
\stopitemize
\stopxcell
\stopxrow
}
\stopxtable
\stoptext
您可能还想使用简短的语法和一些设置来压缩您的代码。
\setupxtable
[whiteonblack]
[foregroundcolor=white,
foregroundstyle=bold,
background=color,
backgroundcolor=black]
\setupxtable
[blackongray]
[foregroundcolor=black,
foregroundstyle=bold,
background=color,
backgroundcolor=gray]
\starttext
\startxtable[option={stretch,width},split=yes]
\NC[whiteonblack][nx=2] Table NAME \NR
\NC[whiteonblack][width=0.5cm] \NC[blackongray] Description: \NR
\dorecurse{60}{%
\NC[whiteonblack][width=0.5cm]
\NC[topframe=off,bottomframe={\ifnum\recurselevel=60 on\else off\fi}]
\startitemize
\item Item \recurselevel
\stopitemize
\NR
}
\stopxtable
\stoptext