• Latex生成两种效果的表格


    常见的使用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}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    效果如下:

    在这里插入图片描述
    想要生成双线,只需要在相应位置使用两次\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}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    导入该宏包\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(48G)}
    			\vspace{1mm}
    			\\
    			\small{云服务器GPU} &  \small {NVIDIA RTX 2080Ti(11G)}
    			\vspace{1mm}
    			\\
    			\small{云服务器CPU}& \small{Inter(R) Core(TM) i3-10100F CPU $@$ 3.60GHz(831G)}
    			\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}
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    在这里插入图片描述

  • 相关阅读:
    设计模式之迭代器模式
    工业CT 三维重建 及分割
    Vue常见指令补充(附加案例)
    Kafka之Controller(Broker的领导者)
    电脑屏幕模糊?这5个方法教你恢复清晰屏幕!
    在Winform程序中动态绘制系统名称,代替图片硬编码名称
    cisp-pts学习笔记-sql注入
    AtCoder ABC324 B~E赛后补题
    软件测试|Python自动化测试实现的思路
    千兆以太网传输层 UDP 协议原理与 FPGA 实现(UDP回环)
  • 原文地址:https://blog.csdn.net/qq_27353621/article/details/126413638