Latex中的表格用法总结(三)
2018-02-09 18:06
771 查看
Latex中的表格用法总结(三)
标签: latex2016-08-01 02:01 19716人阅读 评论(0) 收藏 举报分类:【Latex】(12)
版权声明:本文为博主原创文章,未经博主允许不得转载。 http://blog.csdn.net/chichoxian/article/details/52081125我们可以使用makecell命令对表格单元格中的数据进行一些变换的控制。我们可以使用 \ 命令进行换行,也可以使用p{(宽度)}选项控制列表的宽度使用\makecell 命令我们需要在导言区添加\usepackage{makecell}才能正常编译通过。\makecell命令的内容是默认居中对齐的,也可以选用选项t,b,l,r,c等分别控制表格单元格中的格式。举个例子:
代码如下:
\documentclass[UTF8]{ctexart} \usepackage{makecell} \begin{document} \begin{tabular}{|r|r|} \hline \makecell{处理前\\ 数据} & \makecell{处理后 \\ 数据} \\ \hline 1234 & 5678 \\ \hline \end{tabular} \end{document}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
makecell 宏包这种表项分行常用在表头中。在Latex中还单独定义了类似的\thead命令,它产生的字体较小,上下间距较大的单元更适合文字较多的多行表头使用。先贴代码
\begin{tabular}{|r|r|} \hline \thead{处理前 \\ 数据} & \thead{处理后 \\ 数据} \\ \hline 1234 & 5678 \\ \hline \end{tabular}1
2
3
4
5
6
7
\documentclass[UTF8]{ctexart}1
\usepackage{makecell}
\begin{tabular}{|r|r|} \hline \thead{处理前 \\ 数据} & \thead{处理后 \\ 数据} \\ \hline 1234 & 5678 \\ \hline \end{tabular}
\end{document}
2
3
4
5
6
7
8
9
10
11
12
13
我们可以对比一下使用makecell 和使用\thead之前表格的区别:
直观的感受就是字体变小了。在makecell的\rothead 命令则相当于旋转了90° 的\thead命令,这个命令还依赖rotating宏包,在我们使用\rothead时需要给旋转表头的宽度\rotheadsize赋值,否则就会就没有我们想要的效果表头的字体由\theadfont 命令控制例如:
\documentclass[UTF8]{ctexart} \usepackage{makecell,rotating} \begin{document} \settowidth\rotheadsize{\theadfont 数学课} \begin{tabular}{|c|c|} \hline \thead{姓名} & \rothead{数学课\\成绩} \\ \hline Hebe & 100 \\ \hline \end{tabular} \end{document}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
可以得到的效果如下所示:
如果我们想要画下面的表格:
代码如下:
\documentclass[UTF8]{ctexart} \usepackage{makecell,rotating,multirow,diagbox} \begin{document} \begin{tabular}{|c|*{4}{c}|} \hline \diagbox{序号1}{序号2} & 我 & 爱 & hebe & 哈哈 \\ \hline 数字 & 1 & 2 & 3 & 4 \\ \hline 数字 & 2 & 4 & 6 & 8 \\ \hline \end{tabular} \end{document}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
都学了这么多,下面是我们的DIY时间,我们总结一下我写论文时候用到的一些表格,下次大家用到的时候直接拿去用吧。
\documentclass[UTF8]{ctexart} \usepackage{makecell,multirow,diagbox} \begin{document} \begin{tabular}{|c|c|c|c|c|c|} \hline \multirow{2}*{} & system & \multicolumn{2}{c|}{4.0} & \multicolumn{2}{c|}{6.0} \\ \cline{2-6} & Device & D1 & D2 & D3 & D4 \\ \hline \multirow{2}*{Runtime} & 600 byte & 12/23/34 & 23/2/1 & 12/1/2 & 1/2/3 \\ \cline{2-6} & 1000 byte & 12 & 21 & 12 & 12 \\ \hline \multirow{2}*{System} & 600 byte & 12 & 23 & 12 & 1 \\ \cline{2-6} & 1000 byte & 12 & 21 & 12 & 12 \\ \hline \end{tabular} \end{document}
相关文章推荐
- Latex中的一些表格用法总结(二)
- Latex中的一些表格用法总结(二)
- Latex中的表格用法总结(三)
- Latex:基本用法、表格、公式、算法(持续更新)
- jQuery表格插件datatables用法总结
- Spreadsheet电子表格控件安装及用法总结
- easyui-layout和easyui-combobox和jQuery表格控件flexigrid用法总结
- jQuery表格插件datatables用法总结(中)
- Latex中的表格总结
- Excel 转Latex 及tex表格的处理 总结
- LaTex表格用法
- Latex中的表格总结
- jQuery表格插件datatables用法总结(上)
- Spreadsheet电子表格控件安装及用法总结
- jQuery表格插件datatables用法总结
- jQuery表格插件datatables用法总结(下)
- markdown、latex用法总结
- Spreadsheet电子表格控件安装及用法总结
- 关于typedef的用法总结
- [C/C++]static关键字用法总结