我有一张表格,表格标题(由于长度原因,顺时针旋转了 90 度)需要与底部对齐。该怎么做?
这是我的代码:
\starttext
\starttable[s1|cp(.05\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|]
\HL
\VL \VL \VL \VL \VL \TWO \mbox{Afzonderlijke} \\ \mbox{productieprijs} \VL \TWO \mbox{Algemene} \\ \mbox{productieprijs} \VL \VL \AR
\DC \DC \DC \DC \DL[4] \DC \DR
\VL \vtop{\phantom{x} \vfill \rotate[90]{~Bodemsoort}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~Kap. invest. in \$}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~Gemid. winst in \$}} \VL \vtop{\phantom{x} \vss \rotate[90]{~Product in 100 kg}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~v/h gehele product in \$}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~van 100 kg in \$}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~van 100 kg in \$}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~v/h gehele product in \$}} \VL \vtop{\phantom{x} \vfill \rotate[90]{~Differentiële rente I in \$}} \VL \AR
\HL
\VL I \VL 100 \VL 20 \VL 4 \VL 120 \VL 30 \VL 30 \VL 120 \VL 0 \VL \AR
\VL II \VL 100 \VL 20 \VL 5 \VL 120 \VL 24 \VL 30 \VL 150 \VL 30 \VL \AR
\VL III \VL 100 \VL 20 \VL 6 \VL 120 \VL 20 \VL 30 \VL 180 \VL 60 \VL \AR
\HL
\stoptable
\stoptext
下面是它现在的样子:
(注意:表格是灰色的,因为我在那里使用了背景)。
顺便说一句。上面两个框中的标题似乎也有点错位,“p”尾接触到水平线。有没有办法纠正这个问题(除了使用新的表格布局格式)?
答案1
您还可以使用天然桌对于这样的表格,因为它提供了内容和表示的更清晰的分离。
\startsetups table:formatting
\setupTABLE[each][each][width=0.1\textwidth, align={middle,lohi}]
\setupTABLE[each][each][frame=off, leftframe=on, rightframe=on]
\setupTABLE[row][1,2][frame=on]
\setupTABLE[row][2][align={middle,low}]
\setupTABLE[row][last][bottomframe=on]
\stopsetups
\define\tablerotate{\dontleavehmode\rotate[rotation=90, location=normal]}
\starttext
\startTABLE[setups={table:formatting}]
\NC \NC \NC \NC \NC[nc=2] Afzonderlijke \\ productieprijs \NC[nc=2] Algemene \\ productieprijs \NC \NC \NR
\NC \tablerotate{Bodemsoort} \NC \tablerotate{Kap. invest. in \$} \NC \tablerotate{Gemid. winst in \$} \NC \tablerotate{Product in 100 kg} \NC \tablerotate{v/h gehele product in \$} \NC \tablerotate{van 100 kg in \$} \NC \tablerotate{van 100 kg in \$} \NC \tablerotate{v/h gehele product in \$} \NC \tablerotate{Differentiële rente I in \$} \NC \NR
\NC I \NC 100 \NC 20 \NC 4 \NC 120 \NC 30 \NC 30 \NC 120 \NC 0 \NC \NR
\NC II \NC 100 \NC 20 \NC 5 \NC 120 \NC 24 \NC 30 \NC 150 \NC 30 \NC \NR
\NC III \NC 100 \NC 20 \NC 6 \NC 120 \NC 20 \NC 30 \NC 180 \NC 60 \NC \NR
\stopTABLE
\stoptext
这使
答案2
我现在知道我哪里犯了错误,我添加了\vtop{\phantom{x} \vfill .. }
标题元素,如果我删除该代码以及~
每个标题之前的不必要的代码,表格看起来就很好了。
\starttext
\starttable[s0|cp(.05\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|cp(.1\textwidth)|]
\HL
\VL \VL \VL \VL \VL \TWO \mbox{Afzonderlijke} \\ \mbox{productieprijs} \VL \TWO \mbox{Algemene} \\ \mbox{productieprijs} \VL \VL \AR
\DC \DC \DC \DC \DL[4] \DC \DR
\VL \rotate[90]{Bodemsoort} \VL \rotate[90]{Kap. invest. in \$} \VL \rotate[90]{Gemid. winst in \$} \VL \rotate[90]{Product in 100 kg} \VL \rotate[90]{v/h gehele product in \$} \VL \rotate[90]{van 100 kg in \$} \VL \rotate[90]{van 100 kg in \$} \VL \rotate[90]{v/h gehele product in \$} \VL \rotate[90]{Differentiële rente I in \$} \VL \AR
\HL
\VL I \VL 100 \VL 20 \VL 4 \VL 120 \VL 30 \VL 30 \VL 120 \VL 0 \VL \AR
\VL II \VL 100 \VL 20 \VL 5 \VL 120 \VL 24 \VL 30 \VL 150 \VL 30 \VL \AR
\VL III \VL 100 \VL 20 \VL 6 \VL 120 \VL 20 \VL 30 \VL 180 \VL 60 \VL \AR
\HL
\stoptable
\stoptext
它看起来是这样的:
答案3
感谢 Aditya,我找到了以下更令人满意的解决方案,使用新的表命令:
% setup for the table
\startsetups table:grondrente
\setupTABLE[each][each][width=0.11\textwidth, align={middle,lohi}]
\setupTABLE[each][each][frame=off, leftframe=on, rightframe=on]
\setupTABLE[row][1,2][background=color,backgroundcolor=gray]
\setupTABLE[row][1][topframe=on]
\setupTABLE[row][2][bottomframe=on,align={middle,low}]
\setupTABLE[row][last][bottomframe=on]
\stopsetups
% Table definition
\startTABLE[setups={table:grondrente}]
\NC \NC \NC \NC \NC[nc=2] Afzonderlijke \\ productieprijs \NC[nc=2] Algemene \\ productieprijs \NC \NC \NR
\NC \tablerotate{Bodemsoort} \NC \tablerotate{Kap. invest. in \$} \NC \tablerotate{Gemid. winst in \$} \NC \tablerotate{Product in 100 kg} \NC \tablerotate{v/h gehele product in \$} \NC \tablerotate{van 100 kg in \$} \NC \tablerotate{van 100 kg in \$} \NC \tablerotate{v/h gehele product in \$} \NC \tablerotate{Differentiële rente I in \$} \NC \NR
\NC I \NC 100 \NC 20 \NC 4 \NC 120 \NC 30 \NC 30 \NC 120 \NC ~0 \NC \NR
\NC II \NC 100 \NC 20 \NC 5 \NC 120 \NC 24 \NC 30 \NC 150 \NC 30 \NC \NR
\NC III \NC 100 \NC 20 \NC 6 \NC 120 \NC 20 \NC 30 \NC 180 \NC 60 \NC \NR
\stopTABLE
您可以看到以下结果:
我已更正第 1 行中不应显示的水平底线以及第 3 行(第 1 个数据行)最后一列中“0”的对齐方式。尽管该解决方案并不通用,并且只适用于此处,因为除这种情况外,列中数字的宽度在各处都相同。
如果不是这种情况,该怎么做呢?我的意思是,仍然在每个单元格中显示稍微中间对齐的数字(至少在数字的最后一位数字和每个单元格的右边框之间留出一些空间),而同一列的不同行之间的数字对齐是正确的(根据小数点的位置进行垂直对齐,即使省略了小数点)。将它们全部向右对齐(右对齐)可以解决没有小数点的数字问题,尽管人们希望在数字和单元格的右边框之间留出一些额外的空间。