LaTeX制表命令使用教程(简要例子+清晰代码)(论文排版)

1.基本格式


   
   
  1. \documentclass {article}
  2. \begin {document}
  3. \begin {tabular} {cc} %一个c表示有一列,格式为居中显示(center)
  4. ( 1, 1)&( 1, 2)\\ %第一行第一列和第二列 中间用&连接
  5. ( 2, 1)&( 2, 2)\\ %第二行第一列和第二列 中间用&连接
  6. \ end {tabular}
  7. \ end {document}

效果如下: 

2.添加竖线和横线


   
   
  1. \documentclass {article}
  2. \begin {document}
  3. \begin {tabular} {|c|c|} % 通过添加 | 来表示是否需要绘制竖线
  4. \hline % 在表格最上方绘制横线
  5. ( 1, 1)&( 1, 2)\\
  6. \hline %在第一行和第二行之间绘制横线
  7. ( 2, 1)&( 2, 2)\\
  8. \hline % 在表格最下方绘制横线
  9. \ end {tabular}
  10. \ end {document}

效果如下: 

3.设置每一列的单元格格式


   
   
  1. \documentclass {article }
  2. \begin {document }
  3. \begin {tabular } {|l|c|r| } %l(left)居左显示 r(right)居右显示 c居中显示
  4. \hline
  5. Name &Steve &Bill \\
  6. \hline
  7. Matlab &Mathmatica &Maple \\
  8. \hline
  9. \end {tabular }
  10. \end {document }

效果如下: 

4.常见的三线表


   
   
  1. \documentclass [UTF8 ] {ctexart }
  2. \begin {document }
  3. \begin {tabular } {ccc }
  4. \hline
  5. 姓名 & 学号 & 性别 \\
  6. \hline
  7. Steve Jobs & 001 & Male \\
  8. Bill Gates & 002 & Female \\
  9. \hline
  10. \end {tabular }
  11. \end {document }

效果如下: 

通常来说,我们会希望表格的第一根线和最后一根线比表格中的横线更粗一些。

booktabs 宏包为我们提供了这个功能,加载 booktabs 宏包之后可以使用 \toprule 和 \bottomrule 命令分别画出表格头和表格底的粗横线,而用 \midrule 画出表格中的横线。


   
   
  1. \documentclass [UTF8] {ctexart}
  2. \usepackage {booktabs} %需要加载宏包{booktabs}
  3. \begin {document}
  4. \begin {tabular} {ccc}
  5. \toprule %添加表格头部粗线
  6. 姓名& 学号& 性别\\
  7. \midrule %添加表格中横线
  8. Steve Jobs& 001& Male\\
  9. Bill Gates& 002& Female\\
  10. \bottomrule %添加表格底部粗线
  11. \ end {tabular}
  12. \ end {document}

效果如下: 


5.table环境


   
   
  1. \documentclass [UTF8 ] {ctexart }
  2. \usepackage {booktabs }
  3. \begin {document }
  4. \begin {table } [!htbp ]
  5. \centering
  6. \caption {这是一张三线表 } \label {tab:aStrangeTable } %添加标题 设置标签
  7. \begin {tabular } {ccc }
  8. \toprule
  9. 姓名 & 学号 & 性别 \\
  10. \midrule
  11. Steve Jobs & 001 & Male \\
  12. Bill Gates & 002 & Female \\
  13. \bottomrule
  14. \end {tabular }
  15. %\caption{这是一张三线表}\label{tab:aStrangeTable} 标题放在这里也是可以的
  16. \end {table }
  17. \end {document }

{table}有若干可选参数 [!htbp] 
h代表here,将表格排在当前文字位置 
t 表示将表格放在下一页的 top (页首) 
b 表示将表格放在当前页的 bottom (底部) 
!表示忽略美观因素,尽可能按照参数指定的方式来处理表格浮动位置。 
表格将会按照所给参数,依次尝试按照每个参数进行排版,当无法排版时,将会按照下一个参数

6.单元格合并


   
   
  1. \documentclass [UTF8 ] {ctexart }
  2. \begin {document }
  3. \begin {table } [!htbp ]
  4. \centering
  5. \begin {tabular } {|c|c|c| }
  6. \hline
  7. \multicolumn {3 } {|c| } {学生信息 } \\ % 用\multicolumn{3}表示横向合并三列
  8. % |c|表示居中并且单元格两侧添加竖线 最后是文本
  9. \hline
  10. 姓名 &学号 &性别 \\
  11. \hline
  12. Jack & 001 & Male \\
  13. \hline
  14. Angela & 002 & Female \\
  15. \hline
  16. \end {tabular }
  17. \caption {这是一张三线表 }
  18. \end {table }
  19. \end {document }

效果如下: 


   
   
  1. \documentclass [UTF8] {ctexart}
  2. \usepackage {multirow}
  3. \begin {document}
  4. \begin {table} [!htbp]
  5. \centering
  6. \begin {tabular} {|c|c|c|c|c|c|c|} %表格7列 全部居中显示
  7. \hline
  8. \multicolumn {7} {|c|} {事件}\\ %横向合并7列单元格 两侧添加竖线
  9. \hline
  10. \multirow {4}* {策略}& 50& 0& 100& 200& 300& 300\\ %纵向合并4行单元格
  11. \cline {2-7} %为第二列到第七列添加横线
  12. & 100& 100& 0& 100& 200& 200\\
  13. \cline {2-7}
  14. & 150& 200& 100& 0& 100& 200\\
  15. \cline {2-7}
  16. & 200& 300& 200& 100& 0& 300\\
  17. \hline
  18. \ end {tabular}
  19. \ end {table}
  20. \ end {document}


横向合并和纵向合并可以嵌套,代码如下:


   
   
  1. \documentclass [UTF8] {ctexart}
  2. \usepackage {multirow}
  3. \begin {document}
  4. \begin {table} [!htbp]
  5. \centering
  6. \begin {tabular} {|c|c|c|c|c|c|c|}
  7. \hline
  8. \multicolumn {2} {|c|} { \multirow{2}* {$S_i$} }& \multicolumn {4} {c|} {事件} &\multirow {2}* {max}\\
  9. \cline {3-6}
  10. \multicolumn {2} {|c|} {}& 50& 100& 150& 200&\\
  11. \hline
  12. \multirow {4}* {策略}& 50& 0& 100& 200& 300& 300\\
  13. \cline {2-7}
  14. & 100& 100& 0& 100& 200& 200\\
  15. \cline {2-7}
  16. & 150& 200& 100& 0& 100& 200\\
  17. \cline {2-7}
  18. & 200& 300& 200& 100& 0& 300\\
  19. \hline
  20. \ end {tabular}
  21. \ end {table}
  22. \ end {document}

效果如下: 

7.斜线表头

需要使用{diagbox}宏包


   
   
  1. \documentclass {UTF8 } {ctexart }
  2. \usepackage {diagbox } % 加载宏包
  3. \begin {document }
  4. \begin {table } [!htbp ]
  5. \centering
  6. \begin {tabular } {|c|c|c|c| }
  7. \hline
  8. \diagbox {} { $\alpha_{i,j}$ } {} & $\beta_1$ & $\beta_2$ & $\beta_3$ \\ %添加斜线表头
  9. \hline
  10. $\alpha_1$ &-4 &0 &-8 \\
  11. \hline
  12. $\alpha_2$ &3 &2 &4 \\
  13. \hline
  14. $\alpha_3$ &16 &1 &-9 \\
  15. \hline
  16. $\alpha_4$ &-1 &1 &7 \\
  17. \hline
  18. \end {tabular }
  19. \end {table }
  20. \end {document }

效果如下: 


##### 转载请注明出处 https://blog.csdn.net/gentleman_qin/article/details/79970563 #####

  •                     <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count">3</span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/Gentleman_Qin">
                    <img src="https://profile.csdnimg.cn/B/5/8/3_gentleman_qin" class="avatar_pic" username="Gentleman_Qin">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/4.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/Gentleman_Qin" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">秦皓楠Howard_XDU</a></span>
                                            </div>
                    <div class="text"><span>发布了53 篇原创文章</span> · <span>获赞 227</span> · <span>访问量 26万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=Gentleman_Qin" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm attented bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">已关注</a>
                                    </div>
                            </div>
                    </div>
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值