Allen's blog Allen's blog
首页
面经
算法 (opens new window)
分类

Allen

前端CV工程师
首页
面经
算法 (opens new window)
分类
  • 随笔前言
  • Latex笔记
    • 创建表格
      • 创建固定宽度的表格
      • 使整个表格居中
      • 分割线
      • 取消表格浮动
  • 随笔
Allen
2023-04-02
目录

Latex笔记

# 创建表格

# 创建固定宽度的表格

您可以使用tabular* 环境来创建一个固定宽度的表格。例如,\begin{tabular*}{0.8\textwidth}{@{\extracolsep{\fill}}|c|c|} 表示创建一个宽度为0.8\textwidth的表格,表格有两列,每一列都居中对齐。

# 使整个表格居中

使用\centering

\begin{center}
\begin{tabular}{|c|c|}
\hline
A & B \\
\hline
C & D \\
\hline
\end{tabular}
\end{center}
1
2
3
4
5
6
7
8
9

或者\begin{center}

\centering
\begin{tabular}{|c|c|}
\hline
A & B \\
\hline
C & D \\
\hline
\end{tabular}
1
2
3
4
5
6
7
8

# 分割线

语法 含义
\toprule 顶部分割线
\midrule 中部分割线
\bottomrule 底部分割线

示例:

\documentclass{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{cc}
\toprule
A & B \\
\midrule
C & D \\
\bottomrule
\end{tabular}
\end{document}
1
2
3
4
5
6
7
8
9
10
11
12

# 取消表格浮动

表格table默认是浮动的,要取消浮动,可以使用宏包\usepackage{float},然后设置:

\documentclass{article}
\usepackage{float}

\begin{document}
Some text before the table.

\begin{table}[H]
\centering
\begin{tabular}{|c|c|}
\hline
A & B \\
\hline
C & D \\
\hline
\end{tabular}
\caption{This is a table.}
\label{tab:mytable}
\end{table}

Some text after the table.
\end{document}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
上次更新: 2023/12/16, 09:22:46
随笔前言

← 随笔前言

最近更新
01
rollup使用配置文件rollup.config.ts打包
12-08
02
package.json导出类型
12-08
03
关键问题方案
11-17
更多文章>
Theme by Vdoing | Copyright © 2023-2023 Allen | Github
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式