多语言展示
当前在线:1494今日阅读:197今日分享:19

如何使用latex生成表格

在使用latex对论文进行排版时,有时要插入表格,然而表格的插入有专门的宏包和命令,本例分享如何使用latex插入表格。
工具/原料

latex

方法/步骤
1

先使用word或手工将表格草稿画出。

2

再开始使用latex语法将自己所需要的效果画出来。

4

学习表格的相关语法,例如,multirow 宏包提供了 \multirow 命令可以在表格中排版横跨两行以上的文本。命令的格式如下:\multirow{nrows}[bigstructs]{width}[fixup]{text}nrows   设定所占用的行数。bigstructs  此为可选项,主要是在你使用了 bigstruct 宏包时使用。width  设定该栏文本的宽度。如果想让 LaTeX 自行决定文本的宽度,则用 * 即可。fixup   此为可选项,主要用来调整文本的垂直位置。text     所要排版的文本。可用 \\ 来强迫换行

5

根据latex的语法,得出第一幅表格的代码为:%\% Please add the following required packages to your document preamble:% \usepackage{multirow}\documentclass{article}\usepackage{multirow} \begin{tabular}{|l|l|l|l|}        \hline        \multirow{4}{*}{This is a demo table}                & C2a &        \multirow{4}{*}{This is another one} & C4a\\                & C2b &  & C4b\\                & C2c &  & C4c\\                & C2d & & C4d\\        \hline        \end{tabular} \end{document}

6

第二个表格的latex代码为:\hline \multirow{2}{*}{Multi-Row} & \multicolumn{2}{c|}{Multi-Column} & \multicolumn{2}{c|}{\multirow{2}{*}{Multi-Row and Col}} \\ \cline{2-3}   & column-1 & column-2 & \multicolumn{2}{c|}{} \\ \hline label-1 & label-2 & label-3 & label-4 & label-5 \\ \hline \end{tabular}

推荐信息