原文链接: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}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/92207.html