新浪博客

[转载]LaTeX技巧423:LaTeX如何加粗表格横线

2010-12-04 20:14阅读:

一般情况下,我们不会用到很粗的表格线,而标准的三线格可以用booktabs来生成三个不同粗细的表格线。有时,我们想自己随意设置不同粗细的表格线该怎么办?
【解决方案】
方案一:我们可以定义自己的表格线,可以任意指定其宽度如:
makeatletter
defhlinew#1{%
noalign{ifnum0=`}fihrule @height #1 futurelet
reserved@a@xhline}
makeatother%在正文中的用法为 hlinewd{0.75pt} 等等
%不过上面的命令hlinewd不能与longtable正常工作
使用示例:
begin{tabular}{|l||*{4}{c|}}hlinew{1pt}
Room With a Long Name &&&&\hline
Auditorium &&&&\hline
Seminar Room &&&&\hline
end{tabular}
效果图:
[转载]LaTeX技巧423:LaTeX如何加粗表格横线
这是比较底层的方
法。我们已经有更为高级的方法来实现。
方案二:使用makecell宏包来定制表格线,这个包提供了Xcline Xhline来定制表格线如:
begin{tabular}{!{vrule width1.2pt}c
!{vrule width1.2pt}c|c
!{vrule width1.2pt}}
Xhline{1.2pt}
multirowthead{4}{First Column head}&
multicolumn{2}{c!{vrule width1.2pt}}{thead{Multicolumn head}}\
Xcline{2-3}{1.2pt}
& thead{Second \multlined \ column head} &
thead{Third \ column head}\
Xhline{1.2pt}
Cell text & A &multirowcell{4}{28--31}\
Xhline{1.2pt}
end{tabular}
示例为:
[转载]LaTeX技巧423:LaTeX如何加粗表格横线
另外,这个宏包还提供了一组命令,可使表格中列数据单独定位:居中、靠左或靠右,可将某一列标题旋转90度,可在单元格中划对角线,还可设定表格线段的粗细等。
参看:
http://www.ctan.org/tex-archive/macros/latex/contrib/makecell/makecell.pdf

我的更多文章

下载客户端阅读体验更佳

APP专享