推荐一个在线生成表格命令的工具:LaTeX Table Generator
常用选项[htbp]是浮动格式:
h当前位置。将图形放置在正文文本中给出该图形环境的地方。如果本页所剩的页面不够,这一参数将不起作用。
t顶部。将图形放置在页面的顶部。
b底部。将图形放置在页面的底部。
p浮动页。将图形放置在一只允许有浮动对象的页面上。
一般使用[htb]这样的组合,只用[h]是没有用的。这样组合的意思就是latex会尽量满足排在前面的浮动格式,就是[h-t-b]这个顺序,让排版的效果尽量好。
[!h] 只是试图放在当前位置。如果页面剩下的部分放不下,还是会跑到下一页的。一般页言,用 [!h] 选项经常会出现不能正确放置的问题,所以常用 [ht]、[htbp] 等。
如果你确实需要把图片放在当前位置,不容改变,可以用float宏包的[H]选项。不过如果这样做,出现放不下的问题时需要手工调整。使用格式如下:
1.标准的表格格式:
\begin{table}[htbp]\centering % 显示位置为中间\caption{standard table} % 表格标题\label{table1} % 用于索引表格的标签%字母的个数对应列数,|代表分割线% l代表左对齐,c代表居中,r代表右对齐\begin{tabular}{|c|c|c|c|} \hline % 表格的横线& & & \\[-6pt] %可以避免文字偏上来调整文字与上边界的距离1&2&3&4 \\ % 表格中的内容,用&分开,\\表示下一行\hline& & & \\[-6pt] %可以避免文字偏上 0.1&0.2&0.3&0.4 \\\hline\end{tabular}
\end{table}

2.表格宽度拓宽
\begin{tabular} {|l|r|}\hline1 & 2 \\ \hlineYes & No \\ \hline
\end{tabular}\renewcommand\arraystretch{2} % 宽度拓展为原来的2倍\begin{tabular} {|l|r|}\hline1 & 2 \\ \hlineYes & No \\ \hline
\end{tabular}\renewcommand\arraystretch{1} % 宽度恢复
\begin{tabular} {|l|r|}\hline1 & 2 \\ \hlineYes & No \\ \hline
\end{tabular}
3.三线表的制作
\usepackage{booktabs} % 引入三线表宏包\begin{table}[htbp]\centering\caption{three-line table}\begin{tabular}{cccc}\toprule % 顶部线1&2&3&4 \\ \midrule % 中部线0.1&0.2&0.3&0.4 \\\bottomrule % 底部线\end{tabular}
\end{table}
三线表伸缩:
\begin{table}[htbp]\centering\caption{three-line table}\begin{tabular}{cccc}\toprule % 顶部线1&2&3&4 \\ \cmidrule(r){2-4}0.1&0.2&0.3&0.4 \\\bottomrule % 底部线\end{tabular}
\end{table}

4.表格的合并
\usepackage{multirow} % 多行合并的宏包
\begin{tabular}{|c|r|r|}\hline% \multirow{2}{*}{Name},2为所占的行数,此语句可以使得内容垂直居中% \multicolumn{2}{c|}{Flag},2为所占的列数,格式由第二个{}控制% \cline{2-3}指本行的2,3列画横线\multirow{2}{*}{Name} & \multicolumn{2}{c|}{Flag} \\ \cline{2-3}& Yes & NO \\ \hlineIndex & 87 & 100 \\ \hline
\end{tabular}
5.表格的resize
\resizebox{1\linewidth}{!}{
\begin{tabular}{|c|r|r|}\hline% \multirow{2}{*}{Name},2为所占的行数,此语句可以使得内容垂直居中% \multicolumn{2}{c|}{Flag},2为所占的列数,格式由第二个{}控制% \cline{2-3}指本行的2,3列画横线\multirow{2}{*}{Name} & \multicolumn{2}{c|}{Flag} \\ \cline{2-3}& Yes & NO \\ \hlineIndex & 87 & 100 \\ \hline
\end{tabular}
}
6.两个表格并排:
\begin{table}[t]\begin{minipage}{0.49\linewidth}\centering\caption{\textbf{ImageNet classification} results of the WeightNet.}\label{table:snetv2}\resizebox{1\textwidth}{!}{\begin{tabular}{lccc}\hlineModel & \# Params & FLOPs & Top-1 err. \\ \hline ShuffleNetV2 (0.5$\times$) & 1.4M & 41M & 39.7 \\ + WeightNet (1$\times$) & 1.5M & 41M & \textbf{36.7} \\ \hline\end{tabular}}\end{minipage}\hfill\begin{minipage}{0.49\linewidth} \centering\caption{\textbf{ImageNet classification} results of the WeightNet on ShuffleNetV2.}\label{table:snetv2flops}\resizebox{1\textwidth}{!}{\begin{tabular}{lccc}\hlineModel & \# Params & FLOPs & Top-1 err. \\ \hline ShuffleNetV2 (0.5$\times$) & 1.4M & 41M & 39.7 \\ + WeightNet (8$\times$) & 2.7M & 42M & \textbf{34.0} \\ \hline\end{tabular}}\end{minipage}
\end{table}

7. 用表格来规划图片和表格
\begin{table}[t]\caption{SADASDASDASDASD }\begin{minipage}{0.6\linewidth}\centering\resizebox{1\textwidth}{!}{\begin{tabular}{c}\includegraphics[scale=0.8]{figs/1.JPEG}\end{tabular}}\end{minipage}\begin{minipage}{0.4\linewidth} \centering\resizebox{1\textwidth}{!}{\begin{tabular}{lc}\hlinexxxx &xxx \\ \hlinexxx & xxx\\xxx& YYYY \\xxxx & ZZZZ \\\hline\end{tabular}}\end{minipage}\label{overview_self_kd}
\end{table}

8.表格中加入虚线
\begin{table*}[!htb]\begin{tabular}{c:c:c}
\toprule
\multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Vlaue1} & Value2\\
\midrule
A & 11 & 100\\
B & 12 & 200\\
\hdashline[0.5pt/5pt]
C & 1 & 10\\
\hdashline
$\psi$ & 1.1 & 0.1\\
\cdashline{2-2}[1pt/1pt]
$\delta$ & 1.2 & 0.2\\
\bottomrule
\end{tabular}\end{table*}




















