常见的使用Latxe生成两种效果的表格,其实现区别在于生成横线的方式不同:
第一种是直接使用\hline生成横线
第二种是使用\toprule顶部线,\midrule中间线,\bottomrule底部线
第一种生成的表格比较紧凑,代码如下,效果如下图所示:
\begin{table}[hp] %%参数: h:放在此处 t:放在顶端 b:放在底端 p:在本页
\renewcommand\arraystretch{1.2}
%\setlength{\abovecaptionskip}{0.cm}
%\setlength{\belowcaptionskip}{-0.cm}
\centering % 显示位置为中间
\textbf{Table 2}~~Parameters description.\\ %%表的标题
\begin{tabular}{p{45pt}l|ll|l} %第一列设置宽度为45pt 全为左对齐 没有分割线
%\setlength{\tabcolsep}{20mm}
\hline % 表格的横线
%\toprule % 顶部线
Parameters & & Definitions & Value & Source \\%[3pt]只改一行 %%表格第一行标题 % 表格中的内容,用&分开,\\表示下一行
\hline % 表格的横线
%\midrule % 中部线
$\beta_{1}$ & & xxxxabcdxxx & 1 & Estimation \\ %%表格内容
%\midrule
\multirow{2}[2]{*}{$\alpha_{3}$} & & aaa1 & \multirow{2}[2]{*}{1} & \multirow{2}[2]{*}{Estimation} \\
& & bbb2 & & \\
$d_{1}$ & & xxxxabcdxxx & 1 & Estimation \\
\multirow{3}[2]{*}{$1/\theta(t)$}& $\theta_{0}$ & 1aaa & 1 & Estimation \\
& $\theta_{1}$ & 2bbb & 1 & Estimation \\
& $\theta_{2}$ & 3ccc & 1 & Estimation \\
%\bottomrule % 底部线
\hline % 表格的横线
\end{tabular}
\end{table}
效果如下:
想要生成双线,只需要在相应位置使用两次\hline即可,效果如下:
第二种生成的表格比较宽松,四周有空隙,代码如下,效果如下图图所示:
\begin{table}[hp] %%参数: h:放在此处 t:放在顶端 b:放在底端 p:在本页
\renewcommand\arraystretch{1.2}
%\setlength{\abovecaptionskip}{0.cm}
%\setlength{\belowcaptionskip}{-0.cm}
\centering % 显示位置为中间
\textbf{Table 2}~~Parameters description.\\ %%表的标题
\begin{tabular}{p{45pt}l|ll|l} %第一列设置宽度为45pt 全为左对齐 没有分割线
%\setlength{\tabcolsep}{20mm}
%\hline % 表格的横线
\toprule % 顶部线
Parameters & & Definitions & Value & Source \\%[3pt]只改一行 %%表格第一行标题 % 表格中的内容,用&分开,\\表示下一行
%\hline % 表格的横线
\midrule % 中部线
$\beta_{1}$ & & xxxxabcdxxx & 1 & Estimation \\ %%表格内容
%\midrule
\multirow{2}[2]{*}{$\alpha_{3}$} & & aaa1 & \multirow{2}[2]{*}{1} & \multirow{2}[2]{*}{Estimation} \\
& & bbb2 & & \\
$d_{1}$ & & xxxxabcdxxx & 1 & Estimation \\
\multirow{3}[2]{*}{$1/\theta(t)$}& $\theta_{0}$ & 1aaa & 1 & Estimation \\
& $\theta_{1}$ & 2bbb & 1 & Estimation \\
& $\theta_{2}$ & 3ccc & 1 & Estimation \\
\bottomrule % 底部线
%\hline % 表格的横线
%\hline
\end{tabular}
\end{table}
导入该宏包\usepackage{booktabs},效果如下:
如果中间需要多个横线,可以多次使用\midrule。
修改表格线粗细
需要先导入\usepackage{booktabs}%修改表格线段的粗细包,可以自定义修改线段粗细。
\toprule[2pt]%表格最上端线条设置
\midrule[1pt]%中间线条设置
\bottomrule[2pt]%末端线条设置
\begin{table}
\caption{硬件设备配置与实验环境}
\vspace{-3mm}
\begin{center}
%\renewcommand\arraystretch{1}
\begin{tabular}{c c}
\toprule[2pt]
\small{设备名称 } & \small{型号}
\\
\midrule[1pt]
\small{笔记本GPU} & \small{NVIDIA GeForce 940MX(4G)}
\vspace{1mm}
\\
\small{笔记本CPU} & \small{Inter(R) Core(TM) i5-7200 CPU $@$ 2.50GHz(4核8G)}
\vspace{1mm}
\\
\small{云服务器GPU} & \small {NVIDIA RTX 2080Ti(11G)}
\vspace{1mm}
\\
\small{云服务器CPU}& \small{Inter(R) Core(TM) i3-10100F CPU $@$ 3.60GHz(8核31G)}
\vspace{1mm}
\\
\small{Pytorch}& \small{1.7.0}
\vspace{1mm}
\\
\small{Python}& \small{3.7.9}
\vspace{1mm}
\\
\small{Anaconda}& \small{4.8.3}
\vspace{1mm}
\\
\small{Jupyter Notebook}& \small{6.1.4}
\vspace{1mm}
\\
\small{Pycharm}& \small{2020.2.3}
\vspace{1mm}
\\
\bottomrule[2pt]
\end{tabular}
\end{center}
\label{tab1}
\end{table}