一般情况下,我们不会用到很粗的表格线,而标准的三线格可以用booktabs来生成三个不同粗细的表格线。有时,我们想自己随意设置不同粗细的表格线该怎么办?

【解决方案】
方案一:我们可以定义自己的表格线,可以任意指定其宽度如:
\makeatletter
\def\hlinew#1{%
\noalign{\ifnum0=`}\fi\hrule \@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


本文引用地址:http://blog.sciencenet.cn/blog-47522-458393.html 此文来自科学网吴新星博客,转载请注明出处。

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()