LaTeX技巧653:如何隔开LaTeX表格邻近\cline表格线?

原文链接:http://www.latexstudio.net/archives/700.html

LaTeX制作表格,若是需要做局部画线的表格,会用到如下的命令\cline,示例如下:

                              

代码如下:

\begin{tabular}{lrrrrrrr}
 \hline
 \multicolumn{2}{c}{level1} \multicolumn{2}{c}{level2} \multicolumn{2}{c}{level3} \\
  \cline{3-8}
 type & f1 & f2 & f3 & f4 & f5 & f6 & f7 \\ 
   \hline
 Section    & 2.3 & 2.288 & 0.009 &  1.779 & 0.008 & 0.338 & 2.1\\ 
   Period    & 2.8 & 3.309 & 0.002  &  4.060 & 0.000 & 0.866 & 2.3\\ 
   \hline
 \end{tabular}

若是我们需要的效果是:

                                  

用下面的代码:

\begin{tabular}{lrrrrrrr}
 \hline
  &  & \multicolumn{2}{c}{level1} & \multicolumn{2}{c}{level2} & 
 \multicolumn{2}{c}{level3} \\
  \cline{3-4}  \cline{5-6} \cline{7-8}
 type & f1 & f2 & f3 & f4 & f5 & f6 & f7 \\ 
   \hline
 Section    & 2.3 & 2.288 & 0.009 &  1.779 & 0.008 & 0.338 & 2.1\\ 
   Period    & 2.8 & 3.309 & 0.002  &  4.060 & 0.000 & 0.866 & 2.3\\ 
   \hline
 \end{tabular}

显示的效果仍旧是上面的表格效果。 【解决方案】 我们可以使用booktabs里所提供的命令\cmidrule 命令,上面的效果实现的代码如下:

 \begin{tabular}{lrrrrrrr}
 \hline
  &  & \multicolumn{2}{c}{level1} & \multicolumn{2}{c}{level2} & 
 \multicolumn{2}{c}{level3} \\
  \cmidrule(r){3-4}  \cmidrule(r){5-6} \cmidrule(r){7-8}
 \noalign{\smallskip} 
 type & f1 & f2 & f3 & f4 & f5 & f6 & f7 \\ 
   \hline
 Section    & 2.3 & 2.288 & 0.009 &  1.779 & 0.008 & 0.338 & 2.1\\ 
   Period    & 2.8 & 3.309 & 0.002  &  4.060 & 0.000 & 0.866 & 2.3\\ 
   \hline
 \end{tabular}
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值