latex处理表格 [转]

时间:2021-04-21 06:40:25
论文写作中,有时候会遇到某一个表格水平跨度太长,但是latex不能根据页面的宽度自动断开单元格内的内容,会出现表格内容跨出文档水平长度无法显示。这里提供四种解决方案:
第一,最简单也是最初级的方法,就是缩小表格里面的内容显示字体。这种处理往往不能很好的满足一些期刊要求。
第二,使用表格中的p{width}来限定某一列的长度,比如p{5cm}。
第三,换一种表格生成环境,换成tabular*环境或者tabularx环境。
第四,如果制作的表格水平跨度确实非常长,而且表格也很大,这时最好的处理方式是将表格旋转为纵向放置,使用rotating宏包。

 

latex如何使得表格不同列的字体大小不一样

http://bbs.sciencenet.cn/home.php?mod=space&uid=111494&do=blog&id=436728

首先需要在preamble中使用\usepackage{array}宏包,然后在\begin{tabular}环境后定义不同列的字体。需要注意的是,此时需要在表格每个单元格内容对齐位置之前,使用>{decl}来定义每个单元格不同的字体大小。示例如下:
%%%%%%%%%%%how to change the font size of a table column?%%%%%

My living address in Canada is given in Table~\ref{address}.

\begin{table} [h]

\centering

\caption{This is my living address in Canada}

\label{address}

\begin{tabular}{|>{\small}c|>{\Huge}c|}

\hline

Barclay Street & Hamilton \\

\hline

Ontario & Canada \\

\hline

\end{tabular}

\end{table}

latex处理表格 [转]

 

latex中表格列宽控制命令p{width}使用举例

http://bbs.sciencenet.cn/home.php?mod=space&uid=111494&do=blog&id=434507

对于表格中水平方向的内容太长无法显示问题,在以前的博文提到可以使用p{width}来控制列宽予以解决,这里给出一个应用举例以及相应的做表代码。
 
%%%%%%%%%%%%%%%%%%%%%%%%%Without specifying width for last column%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{center}

\begin{tabular}{ | l | l | l | l | l |}

\hline

Item & Name & Gender & Habit & Self-introd tion \\ \hline

1 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\ \hline

2 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\ \hline

3 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\

\hline

\end{tabular}

\end{center}

latex处理表格 [转]

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%With width specified for the last column%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{center}

\begin{tabular}{ | l | l | l | l | p{5cm}|}

\hline

Item & Name & Gender & Habit & Self-introd tion \\ \hline

1 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\ \hline

2 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\ \hline

3 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,

and it's my great honour to give this example. My topic is about how to use p{width} command \\

\hline

\end{tabular}

\end{center}

latex处理表格 [转]



latex之表格水平位置转换垂直位置

http://bbs.sciencenet.cn/home.php?mod=space&uid=111494&do=blog&id=434772

将表格在页面布局位置旋转,需要在preamble部分加上\usepackage{rotating} 宏包,然后使用环境sidewaystable.
示例如下:
 
%%%方法四:将表格页面位置旋转为纵向排列%%%%%%%%

\begin{sidewaystable}

\centering

\begin{tabular}{lllll}

\hline

Item 1 & Item 2 &Item 3 &Item 4 &Item 5 \\

\hline

\multicolumn{5}{l}{\bf S item 1}\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

&&&&\\

\multicolumn{5}{l}{\bf S item 2}\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

a & b & c &d &e\\

\hline

\end{tabular}

\caption{This is an example of rotate table layout}\label{rotatetable}

\end{sidewaystable}

latex处理表格 [转]

 

latex制作复杂表格之multirow,multicolum和cline综合使用简介

http://bbs.sciencenet.cn/home.php?mod=space&uid=111494&do=blog&id=445494

在复杂表格制作中,有时候会遇到一列横跨多行,或者一行横跨多列的情况,那么这个时候就要分别用到\multirow,\multicolum的命令,标准语法如下:
\multicolumn{num_cols}{alignment}{contents}.  %%%%%%%%%%%%  num_cols is the number of s seqnt columns to merge;  alignment is, either l, c, r or to have text wrapping specifiy a width p{5.0cm} . And  contents is simply the act l data you want to be contained within that cell.%%%%%%%%%%%%%%%%
 
\multirow{num_rows}{width}{contents}. %%%%%%%%%%%%%%%%The arguments are pretty simple to ded e ( * for the  width means the content's natural width).%%%%%%%%%%%%%%
(需要注意的是:这个命令需要在preamble中添加宏包 \usepackage{multirow}
 
另外,在复杂表格中,需要从某个某列开始画线,那么需要使用\cline命令,标准语法为:
\cline{i-j}    %%%%%%%%%%% partial horizontal line beginning in column  i and ending in column  j %%%%%%%%%%%%%
 
关于\multicolum和 \multirow在做表时的一些细节问题表述,可以参考latex文档中的Table部分。
 
这里,本博文给出一个更加复杂的表格制作,那就是表格中同时存在横跨多行和多列的情况,这个时候会出现\multicolum和\multirow混合使用的情况。(需要注意的是:这种情况下需要使用\multicolumn{1}{|c|}{...}来画单元格的左右边界线)。
 
例子一:
\usepackage{multirow}
..................
 
\begin{tabular}{c|c|c|c}
\hline
\multicolumn{1}{c|}{\multirow {2}{*}{Canada}}&\multicolumn{1}{|c|}{\multirow {2}{*}{Ontario}}& \multicolumn{2}{|c}{Hamilton}\\\cline{3-4}
\multicolumn{1}{c|}{}&\multicolumn{1}{|c}{}&
\multicolumn{1}{|c|}{Barclay Street} & Emerson Street\\
\hline
\end{tabular}
 
latex处理表格 [转]

例子二:

\usepackage{multirow}
..................
 
\begin{tabular}{cc|c|c|c|c|l}
\cline{3-6}
& & \multicolumn{4}{|c|}{Jimmy} \\ \cline{3-6}
& & Canada & China & Ontario & Hamilton \\ \cline{1-6}
\multicolumn{1}{|c|}{\multirow{2}{*}{McMaster}} &
\multicolumn{1}{|c|}{MS} & Mon & T & Wed & Thu & DeGroote School of Business\\ \cline{2-6}
\multicolumn{1}{|c|}{}                          &
\multicolumn{1}{|c|}{IS} & Jan & Feb & Mar & Apr & DeGroote School of Business \\ \cline{1-6}
\end{tabular}
 
 
 
-------

multirow 设定宽度,换行

latex处理表格 [转]

 

如表格第4列, 首先合并三行,然后分4行写入内容,如何实现这个单元格内容的换行呢?

 \begin{tabular}{p{2em}c}
\hline%
a \newline b& \multirow{3}{8em}{soppurt ISO\\18000-6b\\Compactflash,\\SD slots}\\
b & \\
c& \\
\hline
\end{tabular}