LaTeX 表格的处理.docx
- 文档编号:19345400
- 上传时间:2023-04-24
- 格式:DOCX
- 页数:21
- 大小:21.42KB
LaTeX 表格的处理.docx
《LaTeX 表格的处理.docx》由会员分享,可在线阅读,更多相关《LaTeX 表格的处理.docx(21页珍藏版)》请在冰豆网上搜索。
LaTeX表格的处理
LaTeX表格的处理
LaTeX表格处理概述
一般三线表的处理
带表格注释的三线表
固定列宽和自动伸缩列宽
固定列宽与对齐方式
自动伸缩列宽
跨页表格
表格旋转和后置
表格旋转
表格后置
辅助转换工具
LaTeX表格处理概述
与word不同,LaTeX通过一定的语法规则将表格写成纯文本形式。
基本规则包括:
表格从上到下,每一行从左到右,单元格内容使用&分隔,用\\换行。
最基本的表格环境是tabular环境。
下面是一个简单的表格代码和实际效果:
\begin{tabular}[t]{l|c}
\hline
姓名&年龄\\
\hline
张三&32\\
李四&12\\
王五&24\\
\hline
\end{tabular}
一般三线表的处理
学术论文普遍使用三线表。
三线表的特点主要是:
整个表格通常只有三条横线,首尾两条横线较粗,中间一条较细,一般不使用竖线。
LaTeX处理三线表相当简单方便。
用到的宏包主要是booktabs。
下面是普通三线表的代码和效果:
\begin{table}[htbp]
\caption{\label{tab:
test}示例表格}
\begin{tabular}{lcl}
\toprule
姓名&年龄&地址\\
\midrule
张三&32&中华人民共和国\\
李四&12&中华人民共和国\\
王五&24&中华人民共和国\\
\bottomrule
\end{tabular}
\end{table}
带表格注释的三线表
三线表有时候还需要加上注释以便给出表格的资料来源等信息。
解决这一问题可以使用下面三个办法之一:
∙使用ctable宏包。
该宏包用法简单,下面是典型代码和效果:
\ctable[%
caption=TheSkewingAngles,
label=tab:
nowidth,
]{lcc}
{\tnote{fortheabstractionreaction,
$Mu+HX\rightarrowMuH+X$.}
\tnote[b]{1degree${}=\pi/180$radians.}
\tnote[c]{thisisaparticularlylongnote,showingthatfootnotes
aresetinraggedrightmodeaswedon'tlikehyphenation
intablefootnotes.}
}
{\FL&$H(Mu)+F_2$&$H(Mu)+Cl_2$\ML
$\beta$(H)&$80.9$\tmark[b]&$83.2$\NN
$\beta$(Mu)&$86.7$&$87.7$\LL
}
∙使用threeparttable宏包。
下面是典型代码和效果:
\begin{table}[htbp]
\centering\small
\begin{threeparttable}
\caption{\label{tab:
results}EffectofTradeOpennesson
Environment(AirPollution)}
\begin{tabular}{lccc}
\toprule
&NO$_2$&SO$_2$&PM\\
\midrule
$\ln(y/pop)$&408.74*&287.25*&566.65\\
&(121.79)&(118.81)&(336.19)\\
$\ln(y/pop)^2$&$-$22.85*&$-$16.58*&$-$35.57**\\
&(6.90)&(6.78)&(19.06)\\
$(X+M)/Y$&$-$.29**&$-$.31*&$-$.37\\
&(.17)&(.08)&(.34)\\
$Polity$&$-$3.20*&$-$6.58*&$-$6.70**\\
&(1.47)&(2.05)&(3.42)\\
$\ln(LandArea/pop)$&$-$5.94&$-$2.92*&$-$13.02*\\
&(5.93)&(1.39)&(6.29)\\
Obs.&36&41&38\\
$R^2$&0.16&0.68&0.62\\
\bottomrule
\end{tabular}
\small
Note:
Robuststandarderrorsinparentheses.Intercept
includedbutnotreported.
\begin{tablenotes}
\item[*]significantat5\%level
\item[**]significantat10\%level
\end{tablenotes}
\end{threeparttable}
\end{table}
固定列宽和自动伸缩列宽
有时三线表需要固定某列的列宽,或者指定整个表格的总宽度,指定某几列自动伸缩。
固定列宽与对齐方式
固定列宽可以使用array宏包的p{2cm}系列命令,如果需要指定水平对齐方式,可以使用下面的形式>{\centering}p{2cm}实现,但如果使用这种方式,缺省情况下不能使用\\换行,需要使用\tabularnewline代替。
为了仍然使用\\换行,需要在导言区加上下面的代码:
\usepackage{array}
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\newcolumntype{C}[1]{>{\PreserveBackslash\centering}p{#1}}
\newcolumntype{R}[1]{>{\PreserveBackslash\raggedleft}p{#1}}
\newcolumntype{L}[1]{>{\PreserveBackslash\raggedright}p{#1}}
使用C{3cm}命令即可指定该列宽度为3cm,并且文字居中对齐,左对齐和右对齐命令分别是L{2cm}和R{2cm}。
下面是一个的例子:
\begin{table}[htbp]
\centering\caption{\label{tab:
test}2000和~2004年中国制造业产品的出口份额}
\begin{tabular}{l*{2}{R{2cm}}}
\toprule
&2000&2004\\
\midrule
钢铁&3.1&5.2\\
化学制品&2.1&2.7\\
办公设备及电信设备&4.5&15.2\\
汽车产品&0.3&0.7\\
纺织品&10.4&17.2\\
服装&18.3&24\\
\bottomrule
\end{tabular}
\end{table}
自动伸缩列宽
使用tabularx宏包可以实现自动伸缩列宽。
下面是一个简单的例子。
与普通的tabular环境不同之处在于:
(1)需要指定整个表格的总宽度;
(2)需要用X指定至少一列为自动伸缩列。
\begin{table}[htbp]
\centering\caption{\label{tab:
test}2000和~2004年中国制造业产品的出口份额}
\begin{tabularx}{10cm}{Xrr}
\toprule
&2000&2004\\
\midrule
钢铁&3.1&5.2\\
化学制品&2.1&2.7\\
办公设备及电信设备&4.5&15.2\\
汽车产品&0.3&0.7\\
纺织品&10.4&17.2\\
服装&18.3&24\\
\bottomrule
\end{tabularx}
\end{table}
跨页表格
普通的表格不能跨页。
如果需要跨页表格,需要使用longtable或supertabular等宏包。
此处以longtable为主介绍。
下面是一个例子。
\begin{longtable}{p{1.2cm}p{8cm}p{5cm}}
\caption{\label{tab:
test}WTO英语缩写}\\
\toprule
缩写&原\hspace{1em}文&解\hspace{1em}释\\
\midrule
\endfirsthead
{\bf续表~\ref{tab:
test}}\\
\toprule
缩写&原\hspace{1em}文&解\hspace{1em}释\\
\midrule
\endhead
\endfoot
\bottomrule
\endlastfoot
WTO&WorldTradeOrganization&世界贸易组织\\
TRIMs&Trade-RelatedInvestmentMeasures&与贸易有关的投资措施\\
TPR&TradePolicyReview&贸易政策审议\\
....
\end{longtable}
表格旋转和后置
表格旋转
如果表格过宽,可以将表格旋转90度横放。
使用rotating宏包即可实现此功能。
与普通表格的不同之处是:
需要将table环境替换成sidewaystable环境。
表格后置
使用endfloat宏包可以将文章中的所有图表置于文章末尾,以满足某些杂志的排版要求。
辅助转换工具
∙calc2latex或excel2latex可以将电子表格文件数据转换为latex表格。
∙dat2latex.pl这是perl脚本,可将gnuplot的文本数据文件转换为latex表格。
点击此处下载。
11月13日
latex中的距离
固定长度
cm 厘米
mm 毫米
in 英寸(1in=2.54cm)
pt 点(1in=72.27pt)
bp 大点(1in=72bp)
pc pica(1pc=12pt) 十二点活字
dd didot(1157dd=1238pt) 迪多点制
cc cicero(1cc=12dd) 西塞罗
em 字体相关尺寸,相当于大写字母M的宽度
ex 字体相关尺寸,相当于字母x的高度
要想给长度赋值,用命令\setlength{长度命令}{已定义的长度}
E.G. \setlength{\textwidth}{12.5cm}
橡皮长度
有些命令的参数是橡皮长度,一个橡皮长度的基本命令是:
正常值plus 伸展值minus收缩值 e.g.\setlength{\parskip}{1explus0.5exminus0.2ex}
\fill:
正常长度为零,但可以伸展到任意长度。
有用的距离
\mathindent:
公式缩进
\columnsep:
两列之间的间距
\columnseprule:
两列间竖线的宽度
\parskip:
两个段落之间的距离。
以ex为单位,橡皮长度
\parindent:
段落第一行的缩进
\baselinestretch:
度量两条基线之间的正常间距的数值。
初始化值为1,
用\renewcommand{\baselinestretch}{因子}修改
\baselineskip:
行间距,字体尺寸*\baselinestretch
页面样式的距离:
\headheight:
页眉高度
\headsep:
页眉基线到正文顶部的距离
\topskip:
正文顶部到正文第一行的距离
\textwidth:
文本行宽度
\textheight:
文本高度
\footskip:
正文底部到页脚底部的距离
\paperwidth,\paperheight
广义列表中的距离
\topsep
\partopsep
\parsep
\itemsep
表格中的距离
\tabcolsep tabular和tabular*中两列间距的一半
\arraycolsep array中列间距的一半
\arrayrulewidth 表格中水平线和竖直线的粗细
\doublerulesep 双直线时两线之间的距离
\arraystretch 表格中的行间距
图形中距离
\unitlength 单位长度
任意的间距
\hspace{}\hfill
\vspace{}\vfill
\quad\qquad:
当前字体的尺寸
\dotfill&\hrulefill
\\[距离]
长度命令
\setlength{\长度命令}{长度指定}
\addtolength{\长度命令}{长度指定}
\settowidth{\长度命令}{文本}
\settoheight{\长度命令}{文本}
\settodepth{\长度命令}{文本}
\newlength{\新长度命令}
最近在网上找到不错的latex技巧。
LaTeX的一些代码样式2007年01月12日星期五17:
36把自己总结的用了很久的一些LaTeX的代码样式发上来,这些样式平时用得很多。
对我来说非常珍贵呀。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%一些最基本的环境
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%居中环境
\begin{center}
\end{center}
%左对齐环境
\begin{flushleft}
\end{flushleft}
%右对齐环境
\begin{flushright}
\end{flushright}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%小页环境(可嵌入上面那三种环境中形成组合)
\begin{minipage}{**cm}
\end{minipage}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%列举样式
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%itemize列举样式1:
· · · ·
\begin{itemize}
\vspace{-2.8mm}\item
\vspace{-2.8mm}\item
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%itemize列举样式2:
* * * *
\begin{itemize}
\vspace{-2.8mm}\item[*]
\vspace{-2.8mm}\item[**]
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%itemize列举样式3:
任意符号
\begin{itemize}
\renewcommand\labelitemi{}%这里面写符号
\vspace{-2.8mm}\item
\vspace{-2.8mm}\item
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%itemize列举样式4:
彩色符号
\begin{itemize}
\setlength\baselineskip{12pt}%用这个命令来调整间距应该比较具有通用性
\item[\textcolor{black}{$\spadesuit$}] 文字。
。
。
\item[\textcolor{red}{$\heartsuit$}] 文字。
。
。
\item[\textcolor{black}{$\clubsuit$}] 文字。
。
。
\item[\textcolor{red}{$\diamondsuit$}]文字。
。
。
\end{itemize}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%enumerate列举样式1:
1.2.3.4.
\begin{enumerate}
\vspace{-2.8mm}\item
\vspace{-2.8mm}\item
\end{enumerate}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%enumerate列举样式2:
(1)
(2)(3)(4)
\begin{enumerate}
\renewcommand\labelenumi{ \theenumi }%就在前面那个括号的空格处加符号
%\setlength\itemindent{}%这个会使列举的左移或右移指定的距离
\vspace{-2.8mm}\item
\vspace{-2.8mm}\item
\end{enumerate}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形插入样式
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形排版样式1:
定点
%图形排版时名称一般都在下方
\begin{center}
\includegraphics[width=10cm,height=6cm]{*.eps}%就在前面括号中写图片名
\renewcommand{\figurename}{图}
\caption{}
\label{}
\end{center}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形排版样式2:
浮动
%图形排版时名称一般都在下方
\begin{figure}
\begin{center}
\includegraphics[width=10cm,height=6cm]{*.eps}%就在前面括号中写图片名
\renewcommand{\figurename}{图}
\caption{}
\label{}
\end{center}
\end{figure}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形排版样式3:
两个图片并列,统一取名
%图形排版时名称一般都在下方
\begin{figure}
\begin{center}
\begin{minipage}[c]{0.5\textwidth}
\centering\includegraphics[width=5cm,height=3cm]{*.eps}%就在前面括号中写图片名
\end{minipage}%
\begin{minipage}[c]{0.5\textwidth}
\centering\includegraphics[width=5cm,height=3cm]{*.eps}%就在前面括号中写图片名
\end{minipage}
\renewcommand{\figurename}{图}
\caption{}
\label{}
\end{center}
\end{figure}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形排版样式4:
两个图片并列,分别取名
%图形排版时名称一般都在下方
\begin{figure}
\begin{center}
\begin{minipage}[c]{0.5\textwidth}
\centering\includegraphics[width=5cm,height=3cm]{}%就在前面括号中写图片名
\renewcommand{\figurename}{图}
\caption{}
\label{}
\end{minipage}%
\begin{minipage}[c]{0.5\textwidth}
\centering\includegraphics[width=5cm,height=3cm]{}%就在前面括号中写图片名
\renewcommand{\figurename}{图}
\caption{}
\label{}
\end{minipage}
\end{center}
\end{figure}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%图形排版样式5:
两个图片作为子图并列,分别取名。
四个可形成图形阵列。
在下方有一个总名称
\begin{figure}
\centering
\subfigure[子标题]{\includegraphics[width=0.45\textwidth]{*.eps}}
%\mbox{\hspace{0.5cm}}
\subfigure[子标题]{\includegraphics[width=0.45\textwidth]{*.eps}}
\\
\subfigure[子标题]{\in
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- LaTeX 表格的处理 表格 处理
![提示](https://static.bdocx.com/images/bang_tan.gif)