latex處理表格 [轉]


論文寫作中,有時候會遇到某一個表格水平跨度太長,但是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處理多列表格,水平太長無法顯示 - A rey - 風繼續吹

 

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處理多列表格,水平太長無法顯示 - A rey - 風繼續吹

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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處理多列表格,水平太長無法顯示 - A rey - 風繼續吹



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處理多列表格,水平太長無法顯示 - A rey - 風繼續吹

 

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處理多列表格,水平太長無法顯示 - A rey - 風繼續吹

例子二:

\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 設定寬度,換行

1.jpg

 

如表格第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}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM