Latex表格之一
\begin{table}
\begin{tabular}{ l {5}{D{.}{.}{4}} }
\toprule
\textbf{MVV} & \multicolumn{5}{c}{\textbf{QP}} \
\cmidrule(lr){2-6}
\textbf{Content} & \multicolumn{1}{c}{
20
20
20} & \multicolumn{1}{c}{
26
26
26} & \multicolumn{1}{c}{
32
32
32} & \multicolumn{1}{c}{
38
38
38} & \multicolumn{1}{c}{
44
44
44} \
\midrule
\texttt{BookArrival} &1.72% &4.65% &9.84% &19.17%
&36.15% \
\texttt{Newspaper} &3.00% &8.39% &18.31% &28.09% &41.61%\
\texttt{ChampagneTower} &4.13% &8.64% &14.51% &25.83%
&39.26%\
\texttt{Caf’{e}} &7.78% &18.28% &31.58% &47.49%
&64.43%\
\texttt{PoznanStreet} &2.21% &7.37% &15.55% &32.48%
&49.00%\
\texttt{PoznanCarPark} &2.22% &7.41% &16.01% &30.06%
&50.78%\
\bottomrule
\end{tabular}
\end{table}
\renewcommand{\arraystretch}{1.5} %控制行高
\begin{table}[tp]
\centering
\fontsize{6.5}{8}\selectfont
\begin{threeparttable}
\caption{Demographic Prediction performance comparison by three evaluation metrics.}
\label{tab:performance_comparison}
\begin{tabular}{ccccccc}
\toprule
\multirow{2}{}{Method}&
\multicolumn{3}{c}{ G}&\multicolumn{3}{c}{ G}\cr
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
&Precision&Recall&F1-Measure&Precision&Recall&F1-Measure\cr
\midrule
kNN&0.7324&0.7388&0.7301&0.6371&0.6462&0.6568\cr
F&0.7321&0.7385&0.7323&0.6363&0.6462&0.6559\cr
E&0.7321&0.7222&0.7311&0.6243&0.6227&0.6570\cr
D&0.7654&0.7716&0.7699&0.6695&0.6684&0.6642\cr
C&0.7435&0.7317&0.7343&0.6386&0.6488&0.6435\cr
B&0.7667&0.7644&0.7646&0.6609&0.6687&0.6574\cr
A&{\bf 0.8189}&{\bf 0.8139}&{\bf 0.8146}&{\bf 0.6971}&{\bf 0.6904}&{\bf 0.6935}\cr
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
——————-
\documentclass{article}
\usepackage{multirow}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}{lccccc}
\toprule
\textbf{MVV} & \multicolumn{5}{c}{\textbf{QP}} \
\cmidrule(lr){2-6}
\textbf{Content} & {
20
20
20} & {
26
26
26} & {
32
32
32} & {
38
38
38} & {
44
44
44} \
\midrule
\texttt{BookArrival} &1.72% &4.65% &9.84% &19.17%
&36.15% \
\texttt{Newspaper} &
3.00
%
3.00\%
3.00% &
8.39
%
8.39\%
8.39% &
18.31
%
18.31\%
18.31% &
28.09
%
28.09\%
28.09% &
41.61
%
41.61\%
41.61%\
\texttt{ChampagneTower} &
4.13
%
4.13\%
4.13% &
8.64
%
8.64\%
8.64% &
14.51
%
14.51\%
14.51% &
25.83
%
25.83\%
25.83%
&
39.26
%
39.26\%
39.26%\
\texttt{Caf’{e}} &
7.78
%
7.78\%
7.78% &
18.28
%
18.28\%
18.28% &
31.58
%
31.58\%
31.58% &
47.49
%
47.49\%
47.49%
&
64.43
%
64.43\%
64.43%\
\texttt{PoznanStreet} &
2.21
%
2.21\%
2.21% &
7.37
%
7.37\%
7.37% &
15.55
%
15.55\%
15.55% &
32.48
%
32.48\%
32.48%
&
49.00
%
49.00\%
49.00%\
\texttt{PoznanCarPark} &
2.22
%
2.22\%
2.22% &
7.41
%
7.41\%
7.41% &
16.01
%
16.01\%
16.01% &
30.06
%
30.06\%
30.06%
&
50.78
%
50.78\%
50.78%\
\bottomrule
\end{tabular}
\end{table}
\end{document}
——————————
\documentclass{article}
\usepackage{dcolumn}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}{ l {5}{D{.}{.}{4}} }
\toprule
\textbf{MVV} & \multicolumn{5}{c}{\textbf{QP}} \
\cmidrule(lr){2-6}
\textbf{Content} & \multicolumn{1}{c}{
20
20
20} & \multicolumn{1}{c}{
26
26
26} & \multicolumn{1}{c}{
32
32
32} & \multicolumn{1}{c}{
38
38
38} & \multicolumn{1}{c}{
44
44
44} \
\midrule
\texttt{BookArrival} &1.72% &4.65% &9.84% &19.17%
&36.15% \
\texttt{Newspaper} &3.00% &8.39% &18.31% &28.09% &41.61%\
\texttt{ChampagneTower} &4.13% &8.64% &14.51% &25.83%
&39.26%\
\texttt{Caf’{e}} &7.78% &18.28% &31.58% &47.49%
&64.43%\
\texttt{PoznanStreet} &2.21% &7.37% &15.55% &32.48%
&49.00%\
\texttt{PoznanCarPark} &2.22% &7.41% &16.01% &30.06%
&50.78%\
\bottomrule
\end{tabular}
\end{table}
\end{document}
————————————————————————————————————————————————————————————_————
彩色表格
\begin{table}
\centering
\caption{彩色的表格}
\begin{tabular}
{>{\columncolor{blue}}rccccc}
\toprule[1pt]
\rowcolor[gray]{0.9} &1 &2 &3 &4 &5\
\midrule
A &\multicolumn{1}{>{\columncolor{green}[0pt][0pt]}c}{318.3} &327.8 &152.0 &104.9 &135.8\
B &&\multicolumn{1}{>{\columncolor{red}[0pt][0pt]}r}{335.5} &137.7 &290.9 &198.6\
\bottomrule[1pt]
\end{tabular}
\end{table}
要记得引入包
\usepackage{xcolor}%定义了一些颜色
\usepackage{colortbl,booktabs}%第二个包定义了几个rule
效果:
设置表格总长
\begin{table}
\caption{设置表格总长}
\begin{tabular*}{12cm}{lll}
\hline
Start & End & Character Block Name \
\hline
3400 & 4DB5 & CJK Unified Ideographs Extension A \
4E00 & 9FFF & CJK Unified Ideographs \
\hline
\end{tabular*}
\end{table}
设置表格总长是12cm,前两行剩下的都是第三行的
效果图
表格内自动换行
\begin{table}
\Large
\caption{自动换行}
\begin{center}
\begin{tabular}{|l|l|l|l| p{5cm}|}
\hline
Item & Name & Gender & Habit & Self-introduction \ \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
\end{tabular}
\end{center}
\end{table}
\begin{tabular}{|l|l|l|l| p{5cm}|}设置最后一列最大是5cm,超出部分要换行。
效果:
设置表格宽度
\begin{table}
\caption{表格宽度X}
\begin{tabularx}{10cm}{llX} % 10cm 減去前兩個欄位寬度後,剩下的通通給
\hline % 第三欄位使用,文字超出的部份會自動折行
Start & End & Character Block Name \
\hline
3400 & 4DB5 & CJK Unified Ideographs Extension A \
4E00 & 9FFF & CJK Unified Ideographs \
\hline
\end{tabularx}
\end{table}
设置表格中间某列的宽度
\begin{table}
\caption{设置宽度}
\begin{tabularx}{12cm}{lXl}
\hline
Start & End & Character Block Name \
\hline
3400 & 4DB5 & CJK Unified Ideographs Extension A \
4E00 & 9FFF & CJK Unified Ideographs \
\hline
\end{tabularx}
\end{table}
记得引入包
\usepackage{tabularx}
改变任一列宽
\begin{table}[h] %开始一个表格environment,表格的位置是h,here。
\caption{改变表格任一列宽} %显示表格的标题
\begin{tabular}{p{3.5cm}|p{2cm}|p{5cm}} %设置了每一列的宽度,强制转换。
\hline
\hline
Format & Extension & Description \ %用&来分隔单元格的内容 \表示进入下一行
\hline %画一个横线,下面的就都是一样了,这里一共有4行内容
Bitmap & .bmp & Bitmap images are recommended because they offer the most control over the exact image and colors.\
\hline
Graphics Interchange Format (GIF) & .gif & Compressed image format used for Web pages. Animated GIFs are supported.\
\hline
Joint Photographic Experts Group (JPEG) & .jpeg, .jpg & Compressed image format used for Web pages.\
\hline
Portable Network Graphics (PNG) & .png & Compressed image format used for Web pages.\
\hline
\hline
\end{tabular}
\end{table}
效果:
tabu包用法
\begin{table}
\caption{tab包用法}
\begin{center}
\begin{tabu} to 0.8\textwidth{X[c]|X[3,b]|X[2,l]|X[c]|X[3,m]|X[1,c]}
%0.8\textwidth 为设置表格宽度
%X[c] 表示这一列居中,所占比例为1,相当于X[1,c]
%X[3,c] 表示这一列居中,所占比例为3,这列的宽度是X[c]列的3倍
\hline
i
i
i &
x
i
x_i
xi &
n
i
n_i
ni &
i
i
i &
x
i
x_i
xi &
n
i
n_i
ni\
\hline
1 &0.5$\simKaTeX parse error: Expected 'EOF', got '&' at position 12: 0.64 &̲1 &8 …\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.62 &̲53\\ 2 &0.64\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 0.78 &̲2 &9 …\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.76 &̲25\\ 3 &0.78\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 0.92 &̲9 &10…\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.90 &̲19\\ 4 &0.92\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.06 &̲26 &11…\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 2.04 &̲16\\ 5 &1.06\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.20 &̲37 &12…\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 2.18 &̲3\\ 6 &1.20\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 1.34 &̲53 &13…\simKaTeX parse error: Expected 'EOF', got '&' at position 11: 2.38 &̲1\\ 7 &1.34\sim$1.48 &56 & & & \
\hline
\end{tabu}
\end{center}
\end{table}
不要忘记引入包
\usepackage{tabu}
水平居中显示
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
\begin{table}[!t]
\centering
\scriptsize
\caption{NOTATIONS}
\label{tab:notations}
\begin{tabular}{ll}
\[-2mm]
\hline
\hline\[-2mm]
{\bf \small Symbol}&\qquad {\bf\small Meaning}\
\hline
\vspace{1mm}\[-3mm]
P
​
M
i
P\!M_i
PMi & \tabincell{l}{The
i
 
t
h
i\,th
ith physical machine or host server in the data \center, i = 1, 2, ?-}\
\vspace{1mm}
C
​
M
C\!M
CM & \tabincell{l}{ Vector of maximum disk size;
C
M
[
i
]
CM[i]
CM[i] stores the maximum\ disk size of
P
M
i
PM_i
PMi}\
\vspace{1mm}
B
​
M
B\!M
BM & \tabincell{l}{Vector of remaining disk size;
B
M
[
i
]
BM[i]
BM[i] stores the remaining\ disk size of
P
M
i
PM_i
PMi}\
\vspace{1mm}
S
​
P
(
P
​
M
i
)
S\!P(P\!M_i)
SP(PMi) & \tabincell{l}{Selection preference of
P
M
i
PM_i
PMi }\
\vspace{1mm}
N
​
o
d
e
m
N\!ode_m
Nodem & \tabincell{l}{The m,th node of the data center network. A node can be a \host server or a switch. m = 1, 2, ?-}\
\hline
\hline
\end{tabular}
\end{table}
\usepackage{multicol}
\usepackage{multirow}
\renewcommand{\arraystretch}{1.5} %¿ØÖƱí¸ñÐиߵÄËõ·Å±ÈÀý
\begin{table}[tp]
\centering
\fontsize{6.5}{8}\selectfont
\caption{Demographic Prediction performance comparison by three evaluation metrics.}
\label{tab:performance_comparison}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{Method}&
\multicolumn{3}{c|}{C}&\multicolumn{3}{c|}{ D}\cr\cline{2-7}
&Precision&Recall&F1-Measure&Precision&Recall&F1-Measure\cr
\hline
\hline
A&0.7324&0.7388&0.7301&0.6371&0.6462&0.6568\cr\hline
B&0.7321&0.7385&0.7323&0.6363&0.6462&0.6559\cr\hline
C&0.7321&0.7222&0.7311&0.6243&0.6227&0.6570\cr\hline
D&0.7654&0.7716&0.7699&0.6695&0.6684&0.6642\cr\hline
E&0.7435&0.7317&0.7343&0.6386&0.6488&0.6435\cr\hline
F&0.7667&0.7644&0.7646&0.6609&0.6687&0.6574\cr\hline
G&{\bf 0.8189}&{\bf 0.8139}&{\bf 0.8146}&{\bf 0.6971}&{\bf 0.6904}&{\bf 0.6935}\cr
\hline
\end{tabular}
\end{table}
三线表法
\usepackage{booktabs}
\usepackage{threeparttable}
\renewcommand{\arraystretch}{1.5} %控制行高
\begin{table}[tp]
\centering
\fontsize{6.5}{8}\selectfont
\begin{threeparttable}
\caption{Demographic Prediction performance comparison by three evaluation metrics.}
\label{tab:performance_comparison}
\begin{tabular}{ccccccc}
\toprule
\multirow{2}{*}{Method}&
\multicolumn{3}{c}{ G}&\multicolumn{3}{c}{ G}\cr
\cmidrule(lr){2-4} \cmidrule(lr){5-7}
&Precision&Recall&F1-Measure&Precision&Recall&F1-Measure\cr
\midrule
kNN&0.7324&0.7388&0.7301&0.6371&0.6462&0.6568\cr
F&0.7321&0.7385&0.7323&0.6363&0.6462&0.6559\cr
E&0.7321&0.7222&0.7311&0.6243&0.6227&0.6570\cr
D&0.7654&0.7716&0.7699&0.6695&0.6684&0.6642\cr
C&0.7435&0.7317&0.7343&0.6386&0.6488&0.6435\cr
B&0.7667&0.7644&0.7646&0.6609&0.6687&0.6574\cr
A&{\bf 0.8189}&{\bf 0.8139}&{\bf 0.8146}&{\bf 0.6971}&{\bf 0.6904}&{\bf 0.6935}\cr
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
画了两个表格,存放在一个图片中。
\renewcommand{\arraystretch}{1.2}
\begin{figure}[]
\centering
\centerline{\bf (a). CDR samples}
\vspace{1.5mm}
\begin{tabular}{|l|c|c|}
\hline
\cline{1-1}
\underline{\textbf{record-id}} & \textbf{caller-id} & \textbf{callee-id} \\hline
1 & #user-1 & #user-2 \\hline
2 & #user-1 & #user-4 \\hline
3 & #user-2 & #user-1 \\hline
4 & #user3 & #user-5\\hline
5 & #user1 & #user-2\\hline
\vdots & \vdots & \vdots\\hline
\end{tabular}
\vspace{3mm}
\centering
\centerline{\bf (b). DTR samples}
\vspace{1.5mm}
\begin{tabular}{|l|c|c|c|}
\hline
\cline{1-1}
\textbf{record-id} & \textbf{user-id} & \textbf{online-time} & \textbf{offline-time} \\hline
1 & #user-1 & #timestamp-1 & #timestamp-2 \\hline
2 & #user-2 & #timestamp-3 & #timestamp-4 \\hline
3 & #user-2 & #timestamp-5 & #timestamp-6 \\hline
4 & #user3 & #timestamp-7 & #timestamp-8 \\hline
\vdots & \vdots & \vdots &\vdots\\hline
\end{tabular}
\vspace{1.5mm}
\caption{CDR (Call Detail Records) and DTR (Data Traffic Records) samples.}
\end{figure}
作者:打工皇帝在此
来源:优快云
原文:https://blog.youkuaiyun.com/golden1314521/article/details/40891515
版权声明:本文为博主原创文章,转载请附上博文链接!