返回表格的位置在有些情况下,表格放在页面的哪个区域有着规范要求。可以用\placetable来指定表格的位置。
第 1 组参数强调表的位置,第 2 组用于被引用时的 ID 名称,第 3 组用于表题,第 4 组用来放表格内容。我们使用 visual 库来随机产生一些单词块,并把 table 存放在 buffer 中便于重复使用。然后使用不同的第 1 组参数来观察表格位置的变化。
\usemodule[visual]
\startbuffer[fruits]
\starttabulate[format=|ck2|ck2|ck2|]
\HL
\NC 年份 \NC 产品 \NC 销量 \NC\NR
\HL
\NC 2021 \NC 柚子 \NC 4500 \NC\NR
\NC 2022 \NC 水蜜桃 \NC 480 \NC\NR
\NC 2023 \NC 柠檬 \NC 50 \NC\NR
\NC 2024 \NC 蓝莓 \NC 930 \NC\NR
\HL
\stoptabulate
\stopbuffer
here:把表格放在命令行执行时的位置
\fakenwords{60}{2}
\placetable[here]{产品销量汇总表}{\getbuffer[fruits]}
\fakenwords{60}{2}
top:把表格放在页面顶部
\fakenwords{60}{2}
\placetable[top]{产品销量汇总表}{\getbuffer[fruits]}
\fakenwords{60}{2}
left:把表格放在页面左边,文字环绕右侧
\fakenwords{60}{2}
\placetable[left]{产品销量汇总表}{\getbuffer[fruits]}
\fakenwords{60}{2}
90:把表格 90 度旋转,同时在新的一页放置
\fakenwords{20}{2}
\placetable[90]{产品销量汇总表}{\getbuffer[fruits]}
page:把表格在新的一页放置
\fakenwords{20}{2}
\placetable[page]{产品销量汇总表}{\getbuffer[fruits]}
Split: 允许长表格被拆分跨页
\placetable[split]{产品销量汇总表}{
\starttabulate[format=|ck2|ck2|ck2|]
……
\stoptabulate
}
一行多表
表格默认一行放置一张表,当有小表格,并且想要一行放置多个表格时,可以使用 combination 来布局。
1. 最外层使用 placetable 语句,并且设置 location = none 来禁止表格序号 + 1 并且不显示表题序号。使用 floatcombination 开始 combination 环境,设置 nx=2,ny=1. 1 行 2 列的布局。通过 placetable 包围小表格的内容(这里为了表格重复使用,同样用的 buffer)
\startplacetable [location={none}] % 设置最外层不显示表题
\startfloatcombination [nx=2,ny=1]
\startplacetable[title=fruit A]
{
\getbuffer[fruita]
}
\stopplacetable
\startplacetable[title=fruit B]
{
\getbuffer[fruitb]
}
\stopplacetable
\stopfloatcombination
\stopplacetable
2. 上面的方法中,每个小表均显示了标题。还有一种效果是我们只显示总表表题和公用的序号,而不显示小表序号。同样使用 combination 开启环境,但是小表格使用 content 包围,小表表题使用 caption 包围。
\fakewords{60}{80}
\startplacetable[title=共享表序表题]
\startcombination [nx=2,ny=1]
\startcontent
\getbuffer[fruita]
\stopcontent
\startcaption
fruit A
\stopcaption
\startcontent
\getbuffer[fruitb]
\stopcontent
\startcaption
fruit B
\stopcaption
\stopcombination
\stopplacetable
\fakewords{60}{80}