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

1.基本格式

\documentclass{article}

\begin{document}

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

\end{document}

效果如下: 

2.添加竖线和横线

\documentclass{article}

\begin{document}

\begin{tabular}{|c|c|}% 通过添加 | 来表示是否需要绘制竖线
\hline  % 在表格最上方绘制横线
(1,1)&(1,2)\\
\hline  %在第一行和第二行之间绘制横线
(2,1)&(2,2)\\
\hline % 在表格最下方绘制横线
\end{tabular}

\end{document}

效果如下: 

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

\documentclass{article}

\begin{document}

\begin{tabular}{|l|c|r|} %l(left)居左显示 r(right)居右显示 c居中显示
\hline 
Name&Steve&Bill\\
\hline  
Matlab&Mathmatica&Maple\\
\hline 
\end{tabular}

\end{document}

效果如下: 

4.常见的三线表

\documentclass[UTF8]{ctexart}
\begin{document}

\begin{tabular}{ccc}
\hline
姓名& 学号& 性别\\
\hline
Steve Jobs& 001& Male\\
Bill Gates& 002& Female\\
\hline
\end{tabular}

\end{document}

效果如下: 

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

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

\documentclass[UTF8]{ctexart}
\usepackage{booktabs} %需要加载宏包{booktabs}
\begin{document}

\begin{tabular}{ccc}
\toprule  %添加表格头部粗线
姓名& 学号& 性别\\
\midrule  %添加表格中横线
Steve Jobs& 001& Male\\
Bill Gates& 002& Female\\
\bottomrule %添加表格底部粗线
\end{tabular}

\end{document}

效果如下: 


5.table环境

\documentclass[UTF8]{ctexart}
\usepackage{booktabs}
\begin{document}

\begin{table}[!htbp]
\centering
\caption{这是一张三线表}\label{tab:aStrangeTable}%添加标题 设置标签
\begin{tabular}{ccc}
\toprule
姓名& 学号& 性别\\
\midrule
Steve Jobs& 001& Male\\
Bill Gates& 002& Female\\
\bottomrule
\end{tabular}
%\caption{这是一张三线表}\label{tab:aStrangeTable}  标题放在这里也是可以的
\end{table}

\end{document}

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

6.单元格合并

\documentclass[UTF8]{ctexart}
\begin{document}

\begin{table}[!htbp]
\centering
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{3}{|c|}{学生信息}\\ % 用\multicolumn{3}表示横向合并三列 
                        % |c|表示居中并且单元格两侧添加竖线 最后是文本
\hline
姓名&学号&性别\\
\hline
Jack& 001& Male\\
\hline
Angela& 002& Female\\
\hline
\end{tabular}
\caption{这是一张三线表}
\end{table}

\end{document}

效果如下: 

\documentclass[UTF8]{ctexart}
\usepackage{multirow}
\begin{document}

\begin{table}[!htbp]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|} %表格7列 全部居中显示
\hline
\multicolumn{7}{|c|}{事件}\\  %横向合并7列单元格  两侧添加竖线
\hline
\multirow{4}*{策略}&50&0&100&200&300&300\\  %纵向合并4行单元格 
\cline{2-7}  %为第二列到第七列添加横线
&100&100&0&100&200&200\\
\cline{2-7}
&150&200&100&0&100&200\\
\cline{2-7}
&200&300&200&100&0&300\\
\hline
\end{tabular}
\end{table}

\end{document}


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

\documentclass[UTF8]{ctexart}
\usepackage{multirow}
\begin{document}

\begin{table}[!htbp]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline

\multicolumn{2}{|c|}{ \multirow{2}*{$S_i$} }& \multicolumn{4}{c|}{事件} &\multirow{2}*{max}\\
\cline{3-6}
\multicolumn{2}{|c|}{}&50&100&150&200&\\
\hline
\multirow{4}*{策略}&50&0&100&200&300&300\\
\cline{2-7}
&100&100&0&100&200&200\\
\cline{2-7}
&150&200&100&0&100&200\\
\cline{2-7}
&200&300&200&100&0&300\\
\hline
\end{tabular}
\end{table}

\end{document}

效果如下: 

7.斜线表头

需要使用{diagbox}宏包

\documentclass{UTF8}{ctexart}
\usepackage{diagbox} % 加载宏包
\begin{document}

\begin{table}[!htbp]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\diagbox{}{$\alpha_{i,j}$}{}&$\beta_1$&$\beta_2$&$\beta_3$\\ %添加斜线表头
\hline
$\alpha_1$&-4&0&-8\\
\hline
$\alpha_2$&3&2&4\\
\hline
$\alpha_3$&16&1&-9\\
\hline
$\alpha_4$&-1&1&7\\
\hline
\end{tabular}
\end{table}

\end{document}

效果如下: 


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

  • 17
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LaTeX是一种排版系统,用于专业且高质量的文档制作。下面是一些常用的LaTeX命令和技巧,供初学者参考: 1. 使用LaTeX平台:LaTeX可以在多个平台上使用,比如OverleafTeX Live等。选择合适的平台是个人习惯问题,但是LaTeX的语法是通用的。 2. LaTeX命令LaTeX命令用于控制文档的格式和样式。例如,使用\documentclass命令定义文档类,\section命令用于创建章节,\subsection命令用于创建小节等等。 3. 标题和目录:LaTeX可以使用自动编号的章节命令,比如\section{标题}。如果不需要自动编号,可以使用\section*{标题}命令。生成目录的方法很简单,只需在适当的位置插入\tableofcontents命令即可。 4. 数学公式:LaTeX排版数学公式方面非常强大。使用\begin{equation}和\end{equation}命令可以创建带有自动编号的数学公式。使用$符号可以创建行内公式。 5. 图片和表格LaTeX可以插入图片和创建表格。使用\includegraphics命令插入图片,使用\begin{table}和\end{table}命令创建表格。 6. 引用和参考文献:LaTeX可以轻松管理引用和参考文献。使用\cite命令可以引用文献,并使用bibliography命令指定参考文献列表。 以上是关于LaTeX使用教程的一些基本排版方法和命令。希望对初学者有所帮助。任何问题都可以在评论区留言,同时也可以参考本文末尾的小实例来进一步学习和实践。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [LaTeX基本命令使用教程清晰实例)(Overleaf平台)(论文排版)](https://blog.csdn.net/Gentleman_Qin/article/details/79963396)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [LaTeX教程(三)——文档格式排版](https://blog.csdn.net/ifhuke/article/details/128212990)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值