添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
成熟的荔枝  ·  花了100块大洋搞懂 ...·  4 月前    · 
喝醉的青椒  ·  C/C++ ...·  10 月前    · 
博学的山寨机  ·  antd ...·  1 年前    · 

跟Microsoft word一样,LaTex也是一套排版系统。二者的区别是前者排版属于富文本编辑,后者排版更像是写程序。LaTeX的使用者只要调用模板即可,完全不用去处理字体样大小、位置、目录生成和图片公式序号等诸多细节。这样,我们能够更专注地编辑内容。

表格,又称为表,既是一种可视化交流模式,又是一种组织整理数据的手段。人们在通讯交流、科学研究以及数据分析活动当中广泛采用着形形色色的表格。各种表格常常会出现在印刷介质、手写记录、计算机软件、建筑装饰、交通标志等许许多多地方。随着上下文的不同,用来确切描述表格的惯例和术语也会有所变化。此外,在种类、结构、灵活性、标注法、表达方法以及使用方面,不同的表格之间也炯然各异。在各种书籍和技术文章当中,表格通常放在带有编号和标题的浮动区域内,以此区别于文章的正文部分。

好了,废话不多说(主要是CSDN发文助手太不智能了,老是检测我文章质量不行)。直接上干货。论文中的表格排版是很重要的!每个科研人都希望弄出一个美观又使用的表格,这应该没有人反驳吧?

博客中 第一、二、三、四、五章节 适用于 Elsevier LaTeX模板 (“cas-dc-template.tex”这个文件)。

博客的 第六章节 适用于Elsevier和其他LaTeX论文模板,普适性更大。

一、使用两栏的LaTeX模板,表格占整页宽度

实现整页宽度的思路是\begin{tabular*}{\linewidth}{@{}LLLL@{}}中的“ \linewidth ”,另外\begin{table*}中的“ * ”表示这个表格在两栏模板中使用一栏。

LaTeX代码

\begin{table*}
\caption{This is a table with full width in single column.}
\label{tab_fwsc}
\begin{tabular*}{\linewidth}{@{}LLLL@{}}
\toprule
Col 1 & Col 2 & Col 3 & Col4\\
\midrule
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
\bottomrule
\end{tabular*}
\end{table*}

生成的PDF效果(可以看到是整页宽度)

二、使用两栏的LaTeX模板,表格宽度自定义

实现的思路:还是\begin{tabular*}{\linewidth}{@{}LLLL@{}}中的“ \linewidth ”,在“ \linewidth ”之前添加一个(0,1)的小数值可以自定义表格的宽度,例如,我在下面的代码中取了0.8。当然这个数值主要取决于你的表格内容,具体取多少、表格美观就可以。

LaTeX代码

\begin{table*}
\caption{This is a table with diy width in single column.}
\label{tab_dwsc}
\begin{tabular*}{0.8\linewidth}{@{}LLLL@{}}
\toprule
Col 1 & Col 2 & Col 3 & Col4\\
\midrule
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
\bottomrule
\end{tabular*}
\end{table*}

生成的PDF效果(可以看到比整页宽度要小20%)

三、使用两栏的LaTeX模板,表格宽度自适应

实现的思路:其实上面的自定义宽度基本够用了。但是,如果不想调“\linewidth”前面的小数值,可以试试自适应的宽度。这会儿主要用\begin{tabular*}{\tblwidth}{@{}LLLL@{}}中的“ \tblwidth ”来实现这个需求。

LaTeX代码

\begin{table*}
\caption{This is a table with adaptive width in single column.}
\label{tab_awsc}
\begin{tabular*}{\tblwidth}{@{}LLLL@{}}
\toprule
Col 1 & Col 2 & Col 3 & Col4\\
\midrule
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
\bottomrule
\end{tabular*}
\end{table*}

生成的PDF效果(自适应的宽度,好像不是很明显,跟上面自定义的差不多)

四、使用两栏的模板,表格占满一栏宽度

实现的思路:\begin{table}不带星号,然后在\begin{tabular*}{\linewidth}{@{}LLLL@{}}中使用“\linewidth”这个东西。

LaTeX代码

\begin{table}
\caption{This is a table with full width in double column.}
\label{tab_fwdc}
\begin{tabular*}{\linewidth}{@{}LLLL@{}}
\toprule
Col 1 & Col 2 & Col 3 & Col4\\
\midrule
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
\bottomrule
\end{tabular*}
\end{table}

生成的PDF效果(充满了一栏布局的宽度)

五、使用两栏的模板,表格占一栏宽度+自适应

实现的思路:很简单,\begin{table}不带星号+\begin{tabular*}{\tblwidth}{@{}LLLL@{}}中的“\tblwidth”。

LaTeX代码

\begin{table}
\caption{This is a table with adaptive width in double column.}
\label{tab_awdc}
\begin{tabular*}{\tblwidth}{@{}LLLL@{}}
\toprule
Col 1 & Col 2 & Col 3 & Col4\\
\midrule
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
12345 & 12345 & 123 & 12345 \\
\bottomrule
\end{tabular*}
\end{table}

生成的PDF效果(跟占满宽度没啥区别...我也不知道为什么)

六、(更新) 针对其他LaTeX模板表格满宽和自定义宽度的设置

很遗憾上述的方法仅适用于Elsevier的LaTeX模板,而对于其他模板,会出现下面的问题:右边空出空白,影响整个表格的美观性。

上面对应的源代码是

\documentclass[twocolumn]{article}
\usepackage{multirow}
\title{A demo to DIY set the table width in double column template}
\author{See Chen}
\date{March 2023}
\begin{document}
\maketitle
\section{Introduction}
This is an introduction with a specific table \ref{tab_demo}.
\begin{table*}
\caption{A Table Demo}
\label{tab_demo}
\begin{tabular*}{0.99\linewidth}{@{}ccccccccc@{}}
\hline
\multirow{2}{*}{Animal} & \multicolumn{2}{c}{Sample 1} & \multicolumn{2}{c}{Sample 2} & \multicolumn{2}{c}{Sample 3} & \multicolumn{2}{c}{Sample 4} \\
& Weight & Color & Weight & Color & Weight & Color & Weight & Color \\
\hline
Dog  & 20.1 & White  & 18.0 & Gray  & 30.5 & Black & 25.2 & White \\
Cat  & 10.2 & Yellow & 11.2 & Black & 11.5 & White & 12.5 & White \\
Fox  & 15.5 & Gold   & 15.6 & Gold  & 16.5 & Gold  & 17.0 & Gold \\
Duck & 2.4  & White  & 3.0  & White & 4.0  & White & 3.8  & White \\
\hline
\end{tabular*}
\end{table*}
\end{document}

        解决办法:使用“\tabcolsep=len”命令,其中len是表格宽度大小,可以设置为具体长度,也可以通过\linewidth设置。通过这个方法,实现的表格宽度设置效果如下:可以看出表格内容已经居中显示了。

        相应的代码如下:

\documentclass[twocolumn]{article}
\usepackage{multirow}
\title{A demo to DIY set the table width in double column template}
\author{See Chen}
\date{March 2023}
\begin{document}
\maketitle
\section{Introduction}
This is an introduction with a specific table \ref{tab_demo}.
\begin{table*}
\caption{A Table Demo}
\label{tab_demo}
\centering
%\tabcolsep=0.35cm
\tabcolsep=0.016\linewidth
\begin{tabular}{ccccccccc}
\hline
\multirow{2}{*}{Animal} & \multicolumn{2}{c}{Sample 1} & \multicolumn{2}{c}{Sample 2} & \multicolumn{2}{c}{Sample 3} & \multicolumn{2}{c}{Sample 4} \\
& Weight & Color & Weight & Color & Weight & Color & Weight & Color \\
\hline
Dog  & 20.1 & White  & 18.0 & Gray  & 30.5 & Black & 25.2 & White \\
Cat  & 10.2 & Yellow & 11.2 & Black & 11.5 & White & 12.5 & White \\
Fox  & 15.5 & Gold   & 15.6 & Gold  & 16.5 & Gold  & 17.0 & Gold \\
Duck & 2.4  & White  & 3.0  & White & 4.0  & White & 3.8  & White \\
\hline
\end{tabular}
\end{table*}
\end{document}

        如果表格宽度太大怎么办?例如(已经超出双栏宽度,快到页面边界了)

        解决办法:使用\resizebox{1.0\linewidth}{!}命令(需要配合\usepackage{graphicx}同时使用),该命令可以使表格宽度缩小至LaTeX论文单行宽度,大的文字会变小,小的文字会变大。一般用在大的文字缩小这种情况,后面的情况不需要使用、只需要扩大表格宽度变得好看就好。下面是使用了该命令的效果:

        上面的代码如下:

\documentclass[twocolumn]{article}
\usepackage{multirow}
\usepackage{graphicx}
\title{A demo to DIY set the table width in double column template}
\author{See Chen}
\date{March 2023}
\begin{document}
\maketitle
\section{Introduction}
This is an introduction with a specific table \ref{tab_demo}.
\begin{table*}
\caption{A Table Demo}
\label{tab_demo}
\resizebox{1.0\linewidth}{!}{
\begin{tabular}{ccccccccccccc}
\hline
Animal & Weight & Color & Weight & Color & Weight & Color & Weight & Color & Weight & Color & Weight & Color\\
\hline
Dog  & 20.1 & White  & 18.0 & Gray  & 30.5 & Black & 25.2 & White & 25.2 & White & 25.2 & White\\
Cat  & 10.2 & Yellow & 11.2 & Black & 11.5 & White & 12.5 & White & 12.5 & White & 12.5 & White\\
Fox  & 15.5 & Gold   & 15.6 & Gold  & 16.5 & Gold  & 17.0 & Gold  & 16.5 & Gold  & 17.0 & Gold\\
Duck & 2.4  & White  & 3.0  & White & 4.0  & White & 3.8  & White & 4.0  & White & 3.8  & White\\
\hline
\end{tabular}
\end{table*}

        其实,resizebox也可以和tabcolsep同时配合使用,如果你想的话。前者使表格宽度自适应到LaTeX单栏一行宽度,而后者使表格列宽被设为等同大小。配合起来的效果在一定程度下是叠加的。

七、结束语

        上面的记录都是非常简单的思路,如果有更加简单有效(最好不要导包)的方式,敬请各位大神留言。我感觉最强大的功能是tabcolsep命令和resizebox命令。另外如果想调整表格行间距的话,可以看看LaTeX表格行高、列宽设置这篇博客。

elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括单双栏,简单实用。 elsevier期刊三种类型的模板,包括
\begin{table} \label{tab:1} % Give a unique label \begin{tabular*}{\tblwidth}{@{} LLLL@{} } \toprule Col 1 & Col 2 & Col 3 & ...
在用latex时,经常会遇到表格或者图片需要跨栏情况,特别是有一些会议格式为双栏,单栏显示不好看,特别丑。非常简单,在figure后面或者tabel后面直接加*就完成了。当然有时候也会遇到表格太大,整体放不下的情况,这时候就需要改变表格大小了。 插入图片 普通单栏 \begin{figure}[htbp] \centering \includegraphics[scale=0.4]{img1.png} \caption{xxxxx} \label{fig1} \end{figure}
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录前言一、Latex三线表1、普通三线表2、跨页三线表二、简单表1、基本需求表2、更多需求设置【表名及位置、表、注解、字体】1. 表名及位置2. 表设置3. 表格注解4. 字体设置三、复杂表1、合并单元格2、斜线表头总结 提示:这里可以添加本文要记录的大概内容: Latex 表格代码汇总,包括三线表[跨页]、普通表[表格基本配置(表名、表、注解、字体)]、单元格合并、斜线表头、 提示:以下是本篇文章正文内容,下面案例.
转载自:http://blog.csdn.net/huilingwu/article/details/51649250 latex进行两栏排版时,有时会遇到一些度较大的图形或表格,没办法挤在一栏中,希望能够让其占据两栏,如下图,如何实现呢? 其实很简单,只需要多加一个星号就可以了。 表格横跨两栏代码 \begin{table*} .... \end{table*} 图形横跨两...
在上述示例中,我们使用了`multicol`宏包,并将文档类设置为`twocolumn`,以启用双栏布局。然后,在`table*`环境中创建了一个普通的表格,其中的`tabular`环境用于定义表格的结构和内容。注意,在表格环境外部使用了`\centering`命令将表格居中放置。 要创建双栏表格,请将`table*`环境替换为`table`环境。在双栏布局中,`table*`可以使表格跨越两列,而`table`只能在单个列中显示。 最后,使用`\caption`命令为表格添加标题,并使用`\label`命令为表格添加标签,以便在文中引用。示例中的`\lipsum[1-5]`用于生成示例文本,你可以替换为你自己的内容。 编译以上LaTeX代码,你将得到一个双栏布局表格