我要制作一个特殊的页面布局。它包含文本块、图表和表格。我事先不知道文档中表格的长度。我有一个虚拟的两个表格示例来展示我想要做的事情。
执行该操作的代码如下:
\setupcolors[state=start]
\setuplayout[backspace=20mm,
topspace=20mm,
header=0mm,
footer=10mm,
leftedge=0.5in,
rightedge=0.5in,
width=fit,
rightmargin=0mm]
\starttext
\startuseMPgraphic{FunnyFrame}
picture p ; numeric o ; path a, b ; pair c ;
p := textext.rt(\MPstring{FunnyFrame}) ;
o := BodyFontSize ;
a := unitsquare xyscaled(OverlayWidth,OverlayHeight) ;
pickup pencircle scaled OverlayLineWidth ;
b := a ;
fill b withcolor .5[white, blue] ;
draw b withcolor .5[white, blue] ;
setbounds currentpicture to a ;
\stopuseMPgraphic
\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}]
\defineblank[aroundFrame][1pt]
\defineframedtext[FunnyText][frame=off,background=FunnyFrame,align={middle,hilo}, color=white,backgroundoffset=0pt,offset=3pt,width=\hsize,margin=no,before={\blank[aroundFrame]},after={\blank[aroundFrame]}]
\def\StartFrame{\startFunnyText}
\def\StopFrame {\stopFunnyText }
\setMPtext{FunnyFrame}{} % initialize the text variable
\defineparagraphs[DetailTablesColumns][n=2, distance=0pt, tolerance=very tolerant]
\setupparagraphs[DetailTablesColumns][1][width=2.5cm]
\setupTABLE[row][each][framecolor=white,rulethickness=2pt,frame=on]
\setupTABLE[row][even]
[background=color,backgroundcolor=white,frame=off]
\setupTABLE[row][odd]
[background=color,backgroundcolor=gray,frame=off]
\setupTABLE[header][each]
[background=color,backgroundcolor=darkblue,foregroundcolor=white,style=bold]
\setupTABLE[column][each][width=.25\hsize]
\startDetailTablesColumns
\StartFrame[width=\hsize]
Some funny title
With subtitle
\StopFrame
\DetailTablesColumns
\bTABLE[align=right,option=stretch,split=repeat]
\bTABLEhead
\bTR
\bTH A1 \eTH \bTH B1 \eTH \bTH C1 \eTH \bTH D1 \eTH
\eTR
\eTABLEhead
\bTABLEbody
\dorecurse{3}
{
\bTR
\bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD
\eTR
}
\eTABLEbody
\eTABLE
\stopDetailTablesColumns
\startDetailTablesColumns
\StartFrame[width=\hsize]
Another funny title
Still with subtitle
\StopFrame
\DetailTablesColumns
\bTABLE[align=right,option=stretch,split=repeat]
\bTABLEhead
\bTR
\bTH A \eTH \bTH B \eTH \bTH C \eTH \bTH D \eTH
\eTR
\eTABLEhead
\bTABLEbody
\dorecurse{26}
{
\bTR
\bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD
\eTR
}
\eTABLEbody
\eTABLE
\stopDetailTablesColumns
\startDetailTablesColumns
\StartFrame[width=\hsize]
Another funny title
Still with subtitle
\StopFrame
\DetailTablesColumns
\bTABLE[align=right,option=stretch]
\bTABLEhead
\bTR
\bTH A \eTH \bTH B \eTH \bTH C \eTH \bTH D \eTH
\eTR
\eTABLEhead
\bTABLEbody
\dorecurse{24}
{
\bTR
\bTD 1 \eTD \bTD 2 \eTD \bTD 3 \eTD \bTD 4 \eTD
\eTR
}
\eTABLEbody
\eTABLE
\stopDetailTablesColumns
\stoptext
我希望能够仅定义一次我的表,因为这是动态生成的。有什么想法吗?
我使用段落是因为它似乎有效,但如果需要的话我愿意尝试其他方法。