Excel 转Latex 及tex表格的处理 总结

Excel 转LaTex表格 与TeX表格的处理 总结

 

工具使用:一个Latex表格输入神器——Excel2Tex插件的安装过程。

首先下载插件http://www.ctan.org/tex-archive/support/excel2latex/ 

CTAN的下载界面如下:

 

然后打开excel程序,“文件”--“选项”--“加载项”--“转到”--“浏览”,找到刚才下载的插件文件选择安装即可


 具体使用界面:

彩色表格

[plain] view plain copy
 
  1. egin{table}  
  2. centering  
  3. caption{彩色的表格}  
  4. egin{tabular}  
  5. {>{columncolor{blue}}rccccc}  
  6. oprule[1pt]  
  7. owcolor[gray]{0.9}    &1 &2   &3  &4  &5\  
  8. midrule  
  9. A   &multicolumn{1}{>{columncolor{green}[0pt][0pt]}c}{318.3}   &327.8  &152.0  &104.9  &135.8\  
  10. B   &&multicolumn{1}{>{columncolor{red}[0pt][0pt]}r}{335.5}    &137.7  &290.9  &198.6\  
  11. ottomrule[1pt]  
  12. end{tabular}  
  13. end{table}  
要记得引入包
[plain] view plain copy
 
  1. usepackage{xcolor}%定义了一些颜色  
  2. usepackage{colortbl,booktabs}%第二个包定义了几个*rule  
效果:

微笑设置表格总长

[plain] view plain copy
 
  1. egin{table}  
  2. caption{设置表格总长}  
  3. egin{tabular*}{12cm}{lll}  
  4. hline  
  5. Start & End  & Character Block Name \  
  6. hline  
  7. 3400  & 4DB5 & CJK Unified Ideographs Extension A \  
  8. 4E00  & 9FFF & CJK Unified Ideographs \  
  9. hline  
  10. end{tabular*}  
  11. end{table}  

设置表格总长是12cm,前两行剩下的都是第三行的
效果图

 

微笑表格内自动换行

[plain] view plain copy
 
  1. egin{table}  
  2. Large  
  3. caption{自动换行}  
  4. egin{center}  
  5. egin{tabular}{|l|l|l|l| p{5cm}|}  
  6. hline  
  7. Item & Name & Gender & Habit & Self-introduction \ hline  
  8. 1 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,  
  9. and it's my great honour to give this example. My topic is about how to use p{width} command \ hline  
  10. 2 & Jimmy & Male & Badminton & Hi, everyone,my name is Jimmy. I come from Hamilton,  
  11. and it's my great honour to give this example. My topic is about how to use p{width} command \  
  12. hline  
  13. end{tabular}  
  14. end{center}  
  15. end{table}  
egin{tabular}{|l|l|l|l| p{5cm}|}设置最后一列最大是5cm,超出部分要换行。
效果:

 

微笑设置表格宽度

[plain] view plain copy
 
  1. egin{table}  
  2. caption{表格宽度X}  
  3. egin{tabularx}{10cm}{llX}  % 10cm 減去前兩個欄位寬度後,剩下的通通給  
  4. hline                      % 第三欄位使用,文字超出的部份會自動折行  
  5. Start & End  & Character Block Name  \  
  6. hline  
  7. 3400  & 4DB5 & CJK Unified Ideographs Extension A \  
  8. 4E00  & 9FFF & CJK Unified Ideographs \  
  9. hline  
  10. end{tabularx}  
  11. end{table}  


 

微笑设置表格中间某列的宽度

[plain] view plain copy
 
  1. egin{table}  
  2. caption{设置宽度}  
  3. egin{tabularx}{12cm}{lXl}  
  4. hline  
  5. Start & End  & Character Block Name \  
  6. hline  
  7. 3400  & 4DB5 & CJK Unified Ideographs Extension A \  
  8. 4E00  & 9FFF & CJK Unified Ideographs \  
  9. hline  
  10. end{tabularx}  
  11. end{table}  

记得引入包
[plain] view plain copy
 
  1. usepackage{tabularx}  


微笑改变任一列宽

[plain] view plain copy
 
  1. egin{table}[h] %开始一个表格environment,表格的位置是h,here。  
  2. caption{改变表格任一列宽} %显示表格的标题  
  3. egin{tabular}{p{3.5cm}|p{2cm}|p{5cm}} %设置了每一列的宽度,强制转换。  
  4. hline  
  5. hline  
  6. Format & Extension & Description \ %用&来分隔单元格的内容 \表示进入下一行  
  7. hline %画一个横线,下面的就都是一样了,这里一共有4行内容  
  8. Bitmap & .bmp & Bitmap images are recommended because they offer the most control over the exact image and colors.\  
  9. hline  
  10. Graphics Interchange Format (GIF) & .gif & Compressed image format used for Web pages. Animated GIFs are supported.\  
  11. hline  
  12. Joint Photographic Experts Group (JPEG) & .jpeg, .jpg & Compressed image format used for Web pages.\  
  13. hline  
  14. Portable Network Graphics (PNG) & .png & Compressed image format used for Web pages.\  
  15. hline  
  16. hline  
  17. end{tabular}  
  18. end{table}  
效果:


微笑tabu包用法

[plain] view plain copy
 
  1. egin{table}  
  2. caption{tab包用法}  
  3. egin{center}  
  4. egin{tabu} to 0.8 extwidth{X[c]|X[3,b]|X[2,l]|X[c]|X[3,m]|X[1,c]}  
  5. %0.8 extwidth   为设置表格宽度  
  6. %X[c]      表示这一列居中,所占比例为1,相当于X[1,c]  
  7. %X[3,c]   表示这一列居中,所占比例为3,这列的宽度是X[c]列的3倍  
  8. hline  
  9. $i$  &$x_i$              &$n_i$      &$i$    &$x_i$               &$n_i$\  
  10. hline  
  11. 1    &0.5$sim$0.64       &1           &8    &1.48$sim$1.62      &53\  
  12. 2    &0.64$sim$0.78      &2           &9    &1.62$sim$1.76      &25\  
  13. 3    &0.78$sim$0.92      &9           &10   &1.76$sim$1.90      &19\  
  14. 4    &0.92$sim$1.06      &26          &11   &1.90$sim$2.04      &16\  
  15. 5    &1.06$sim$1.20      &37          &12   &2.04$sim$2.18      &3\  
  16. 6    &1.20$sim$1.34      &53          &13   &2.18$sim$2.38      &1\  
  17. 7    &1.34$sim$1.48      &56          &     &                    & \  
  18. hline  
  19. end{tabu}  
  20. end{center}  
  21. end{table}  
 
不要忘记引入包
[plain] view plain copy
 
  1. usepackage{tabu}  

 

微笑水平居中显示

[plain] view plain copy
 
  1. ewcommand{ abincell}[2]{
    egin{tabular}{@{}#1@{}}#2end{tabular}
    }  
  2. egin{table}[!t]  
  3.   centering  
  4.   scriptsize  
  5.   caption{NOTATIONS}  
  6.   label{tab:notations}  
  7.   egin{tabular}{ll}  
  8.     \[-2mm]  
  9.     hline  
  10.     hline\[-2mm]  
  11.     {f small Symbol}&qquad {fsmall Meaning}\  
  12.     hline  
  13.     vspace{1mm}\[-3mm]  
  14.     $P!M_i$      &    abincell{l}{The $i\,th$ physical machine or host server in the data \center, i = 1, 2, ?-}\  
  15.     vspace{1mm}  
  16.     $C!M$          &   abincell{l}{ Vector of maximum disk size; $CM[i]$ stores the maximum\ disk size of $PM_i$}\  
  17.      vspace{1mm}  
  18.     $B!M$          &   abincell{l}{Vector of remaining disk size; $BM[i]$ stores the remaining\ disk size of $PM_i$}\  
  19.      vspace{1mm}  
  20.     $S!P(P!M_i)$  &    abincell{l}{Selection preference of $PM_i$  }\  
  21.      vspace{1mm}  
  22.     $N!ode_m$    &  abincell{l}{The m\,th node of the data center network. A node can be a  \host server or a switch. m = 1, 2, ?-}\  
  23.     hline  
  24.     hline  
  25.   end{tabular}  
  26. end{table}  


微笑
 
[plain] view plain copy
 
  1. usepackage{multicol}  
  2. usepackage{multirow}  


 
[plain] view plain copy
 
  1. enewcommand{arraystretch}{1.5} %¿ØÖƱí¸ñÐиߵÄËõ·Å±ÈÀý  
  2. egin{table}[tp]  
  3.   
  4.   centering  
  5.   fontsize{6.5}{8}selectfont  
  6.   caption{Demographic Prediction performance comparison by three evaluation metrics.}  
  7.   label{tab:performance_comparison}  
  8.     egin{tabular}{|c|c|c|c|c|c|c|}  
  9.     hline  
  10.     multirow{2}{*}{Method}&  
  11.     multicolumn{3}{c|}{C}&multicolumn{3}{c|}{ D}crcline{2-7}  
  12.     &Precision&Recall&F1-Measure&Precision&Recall&F1-Measurecr  
  13.     hline  
  14.     hline  
  15.     A&0.7324&0.7388&0.7301&0.6371&0.6462&0.6568crhline  
  16.    B&0.7321&0.7385&0.7323&0.6363&0.6462&0.6559crhline  
  17.     C&0.7321&0.7222&0.7311&0.6243&0.6227&0.6570crhline  
  18.     D&0.7654&0.7716&0.7699&0.6695&0.6684&0.6642crhline  
  19.     E&0.7435&0.7317&0.7343&0.6386&0.6488&0.6435crhline  
  20.     F&0.7667&0.7644&0.7646&0.6609&0.6687&0.6574crhline  
  21.     G&{f 0.8189}&{f 0.8139}&{f 0.8146}&{f 0.6971}&{f 0.6904}&{f 0.6935}cr  
  22.     hline  
  23.     end{tabular}  
  24. end{table}  



微笑 三线表法

[plain] view plain copy
 
  1. usepackage{booktabs}  
  2. usepackage{threeparttable}  
  3.   
  4. enewcommand{arraystretch}{1.5} %控制行高  
  5. egin{table}[tp]  
  6.   
  7.   centering  
  8.   fontsize{6.5}{8}selectfont  
  9.   egin{threeparttable}  
  10.   caption{Demographic Prediction performance comparison by three evaluation metrics.}  
  11.   label{tab:performance_comparison}  
  12.     egin{tabular}{ccccccc}  
  13.      oprule  
  14.     multirow{2}{*}{Method}&  
  15.     multicolumn{3}{c}{ G}&multicolumn{3}{c}{ G}cr  
  16.     cmidrule(lr){2-4} cmidrule(lr){5-7}  
  17.     &Precision&Recall&F1-Measure&Precision&Recall&F1-Measurecr  
  18.     midrule  
  19.     kNN&0.7324&0.7388&0.7301&0.6371&0.6462&0.6568cr  
  20.     F&0.7321&0.7385&0.7323&0.6363&0.6462&0.6559cr  
  21.     E&0.7321&0.7222&0.7311&0.6243&0.6227&0.6570cr  
  22.     D&0.7654&0.7716&0.7699&0.6695&0.6684&0.6642cr  
  23.     C&0.7435&0.7317&0.7343&0.6386&0.6488&0.6435cr  
  24.     B&0.7667&0.7644&0.7646&0.6609&0.6687&0.6574cr  
  25.     A&{f 0.8189}&{f 0.8139}&{f 0.8146}&{f 0.6971}&{f 0.6904}&{f 0.6935}cr  
  26.     ottomrule  
  27.     end{tabular}  
  28.     end{threeparttable}  
  29. end{table}  



微笑画了两个表格,存放在一个图片中。

[plain] view plain copy
 
    1. enewcommand{arraystretch}{1.2}  
    2. egin{figure}[]  
    3. centering  
    4. centerline{f (a). CDR samples}  
    5. vspace{1.5mm}  
    6. egin{tabular}{|l|c|c|}  
    7. hline  
    8. cline{1-1}  
    9. underline{ extbf{record-id}} &  extbf{caller-id} &  extbf{callee-id} \hline   
    10. 1                                              & #user-1           & #user-2           \hline  
    11. 2                                              & #user-1           & #user-4           \hline  
    12. 3                                              & #user-2           & #user-1           \hline  
    13. 4                                              & #user3            & #user-5\hline  
    14. 5                                              & #user1            & #user-2\hline  
    15. vdots                                             & vdots           & vdots\hline  
    16. end{tabular}  
    17.   
    18. vspace{3mm}  
    19. centering  
    20. centerline{f (b). DTR samples}  
    21. vspace{1.5mm}  
    22. egin{tabular}{|l|c|c|c|}  
    23. hline  
    24. cline{1-1}  
    25. extbf{record-id} &  extbf{user-id} &  extbf{online-time} &  extbf{offline-time} \hline  
    26. 1    & #user-1           & #timestamp-1  & #timestamp-2           \hline  
    27. 2    & #user-2           & #timestamp-3  & #timestamp-4           \hline  
    28. 3    & #user-2           & #timestamp-5  & #timestamp-6           \hline  
    29. 4    & #user3            & #timestamp-7  & #timestamp-8           \hline  
    30. vdots & vdots           & vdots          &vdots\hline  
    31. end{tabular}  
    32. vspace{1.5mm}  
    33. caption{CDR (Call Detail Records) and DTR (Data Traffic Records) samples.}  
    34. end{figure}
原文地址:https://www.cnblogs.com/tsingke/p/6106733.html