关于LaTeX表格的高阶技巧 您所在的位置:网站首页 如何将Excel表格转成横线 关于LaTeX表格的高阶技巧

关于LaTeX表格的高阶技巧

2024-07-14 15:00| 来源: 网络整理| 查看: 265

本文的主要内容是:

用工具快速生成表格 三线表的画法 合并单元格 添加斜线表头(Slash header) 给表格添加脚注 快速生成LaTeX表格

手动输入LaTeX的表格实在是太累了!大家一定也曾想尽办法让自己已经写好的Microsoft Word或者Microsoft Excel内的表格变成LaTeX的表格环境。在这里我介绍两种办法让大家方便地将word和excel表格变为LaTeX命令。

在线工具

在线工具的优点在于不需要下载任何文件,打开浏览器就可以用。在这里我推荐Tables Generator这个网站。将我们已经制作好的表格黏贴进去后,立即就可以得到LaTeX命令。同时访问这个网站不需要科学上网。最令人意外的是,这个网站不仅仅支持将表格转换成LaTeX命令,也可以将表格转换成HTML表格、纯文本表格、markdown表格和MediaWiki表格。

classes of lipids polar portion nonpolar portion triacyglycerol glycerol fatty acid glycerophospholipid phosphorate group and alcohol fatty acid sphingolipid phosphorate group and Choline Sphingosine and fatty acid ganglioside oilgosaccharide Sphingosine and fatty acid cholesterol the hydroxyl group at C-3 the steroid nucleus and the hydrocarbon side chain at C-17

我们将上面的表格输入这个网站,就可以得到以下的结果:

LaTeX表格 1234567891011\begin{table}[]\begin{tabular}{|l|l|l|}\hline\begin{tabular}[c]{@{}l@{}}classes of\\ lipids\end{tabular} & polar portion & nonpolar portion \\ \hlinetriacyglycerol & glycerol & fatty acid \\ \hlineglycerophospholipid & phosphorate group and alcohol & fatty acid \\ \hlinesphingolipid & phosphorate group and Choline & Sphingosine and fatty acid \\ \hlineganglioside & oilgosaccharide & Sphingosine and fatty acid \\ \hlinecholesterol & the hydroxyl group at C-3 & the steroid nucleus and the hydrocarbon side chain at C-17 \\ \hline\end{tabular}\end{table} HTML表格 1234567891011121314151617181920212223242526272829303132333435363738.tg {border-collapse:collapse;border-spacing:0;}.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top} classes of;;lipids polar portion nonpolar portion triacyglycerol glycerol fatty acid glycerophospholipid phosphorate group and alcohol fatty acid sphingolipid phosphorate group and Choline Sphingosine and fatty acid ganglioside oilgosaccharide Sphingosine and fatty acid cholesterol the hydroxyl group at C-3 the steroid nucleus and the hydrocarbon side chain at C-17 纯文本表格 1234567891011121314+---------------------+-------------------------------+------------------------------------------------------------+| classes of | polar portion | nonpolar portion || lipids | | |+---------------------+-------------------------------+------------------------------------------------------------+| triacyglycerol | glycerol | fatty acid |+---------------------+-------------------------------+------------------------------------------------------------+| glycerophospholipid | phosphorate group and alcohol | fatty acid |+---------------------+-------------------------------+------------------------------------------------------------+| sphingolipid | phosphorate group and Choline | Sphingosine and fatty acid |+---------------------+-------------------------------+------------------------------------------------------------+| ganglioside | oilgosaccharide | Sphingosine and fatty acid |+---------------------+-------------------------------+------------------------------------------------------------+| cholesterol | the hydroxyl group at C-3 | the steroid nucleus and the hydrocarbon side chain at C-17 |+---------------------+-------------------------------+------------------------------------------------------------+ Markdown表格 1234567| classes of lipids | polar portion | nonpolar portion ||---------------------|-------------------------------|------------------------------------------------------------|| triacyglycerol | glycerol | fatty acid || glycerophospholipid | phosphorate group and alcohol | fatty acid || sphingolipid | phosphorate group and Choline | Sphingosine and fatty acid || ganglioside | oilgosaccharide | Sphingosine and fatty acid || cholesterol | the hydroxyl group at C-3 | the steroid nucleus and the hydrocarbon side chain at C-17 | 本地插件

有很多朋友不喜欢在线工具,因为它们更新速度快,消失的速度也快,同时完全离不开网络。我们也有着可以下载到本地的插件,能够将excel表格转化成LaTeX代码。我要介绍的插件是Excel2LaTeX,这个插件是一个可以应用于Windows平台下的Microsoft Excel 2000-2019的excel插件,是一个标准的.xla文件。

它能支持的Excel表格特性有:

粗体、斜体 精确到每一单元格的左右对齐 每一个单元格的边框样式 字体颜色(使用xcolor宏包) 单元格背景色(使用colorbl宏包) 内容旋转(使用rotating宏包) 合并单元格 能将单元格中的特殊符号转换为LaTeX命令 支持booktabs宏包

其实它还有更多优良的特性,在此不再赘述。

画三线表

三线表是学术论文写作中的必备。三线表通常只有三条线,即顶线、底线和栏目线,这三条线都是横线,表格中没有任何竖线。其中顶线和底线为粗线,栏目线为细线。要制作三线表,我们必须使用booktabs宏包。进入tabular环境后,在对应的位置加入相应的横线:顶线是\toprule,栏目线是\midrule,底线是\bottomrule。

首先在你的导言区加上:

1\usepackage{booktabs} 1234567891011121314151617\begin{tabular}{ccccc} \toprule Year & NME & New BLA & Total& Rate/\% \\ \midrule 2008 & 21 & 3 & 95 & 25.3 \\ 2009 & 20 & 6 & 98 & 26.5 \\ 2010 & 15 & 6 & 93 & 22.6 \\ 2011 & 24 & 6 & 100 & 30 \\ 2012 & 33 & 6 & 101 & 38.6 \\ 2013 & 25 & 4 & 102 & 28.4 \\ 2014 & 30 & 11 & 119 & 34.4 \\ 2015 & 33 & 12 & 127 & 35.4 \\ 2016 & 15 & 7 & 102 & 21.6 \\ 2017 & 34 & 12 & 150 & 30.7 \\ 2018 & 42 & 17 & 151 & 39.1 \\ \bottomrule\end{tabular}

m2jVw8.png

合并单元格

合并单元格在LaTeX中看起来是个非常非常困难的事情。从完成这件事上所用的宏包的数量也可以看出着并不简单。为了达到这个目的,我们需要使用两个宏包array和multirow。

1234567891011121314151617181920212223\documentclass{article}\usepackage{array}\usepackage{multirow}\usepackage{booktabs}\usepackage{metalogo}\renewcommand{\arraystretch}{1.6}\begin{document} \begin{tabular}{@{}p{1.5cm}p{1.6cm}>{\raggedleft}p{1cm} >{\raggedright}p{1.6cm}r@{}} Compiler & \multicolumn{2}{c}{Input} & \multicolumn{2}{c@{}}{Output} \\ \cmidrule(r){1-1}\cmidrule(lr){2-3}\cmidrule(l){4-5} & Encoding & Images & Fonts & Format \\ \cmidrule(lr){2-2}\cmidrule(lr){3-3} \cmidrule(lr){4-4}\cmidrule(l){5-5} \LaTeX & utf8, ascii, applemac, latin1, \ldots & EPS & Type 1, Type 3 & DVI \\ pdf\LaTeX & utf8, ascii, applemac, latin1, \ldots & PDF PNG JPG & Type 1, Type 3 & PDF \\ \XeLaTeX, \LuaLaTeX & utf8 & PDF PNG JPG & Type 1, Type 3, OpenType, Graphite, TrueType & PDF \\ \end{tabular}\end{document}

m2jEef.png

让我们来看看tabular环境的参数的意义:

@{code}: 这将插入给定代码而不是列分隔空间。代码可以是诸如符号或空间宏之类的命令。在这里,我们将其设置为空,从而实现与线的左对齐。 p{width}: 这指定了包含文本的特定宽度的单元格。字母p代表段落。 >{code}: 这会在列的单元格之前插入代码,而


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有