latex 论文表格

问题

latex 中想制作论文常见的表格,整理自己常用模板,与常用命令。

命令

调整行高

\renewcommand{\arraystretch}{1.3}

调整列宽

    \begin{tabular}{ m{3.1cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}}
高度方向
  • p{‘width’} paragraph column with text vertically aligned at the top
  • m{‘width’} paragraph column with text vertically aligned in the middle (requires array package)
  • b{‘width’} paragraph column with text vertically aligned at the bottom (requires array package)

写入的文字的顶端,中间,底端对齐到表格中央,是中央,

在这里插入图片描述

水平方向
  • l---------left-justified column
  • c--------centred column
  • r---------right-justified column

另一种方法

  • left, \raggedright
  • right, \raggedleft
  • center, \centering

绘制横线

\hline

\usepackage{booktabs}包中有,

  • \toprule
  • \midrule
  • \bottomrule

\toprule[1pt]
\midrule[3pt]
\bottomrule[5pt]

去掉两端多余横线

使用 @{}表格宽度设置的两端

\begin{tabular}{@{}lll@{}}

长度单位

Abbreviation Value
pt a point is approximately 1/72.27 inch, that means about 0.0138 inch or 0.3515 mm (exactly point is defined as 1/864 of American printer’s foot that is 249/250 of English foot)
mm a millimeter
cm a centimeter
in inch
ex roughly the height of an ‘x’ (lowercase) in the current font (it depends on the font used)
em roughly the width of an ‘M’ (uppercase) in the current font (it depends on the font used)
mu math unit equal to 1/18 em, where em is taken from the math symbols family
sp so-called “special points”, a low-level unit of measure where 65536sp=1pt

改变线宽

竖直线,\vrule width 1pt, 水平线, \noalign{\hrule height 1.2pt}


\begin{tabular}{
  |c!{\vrule width 1pt}
  c!{\vrule width 1.6pt}
  c!{\vrule width 2.2pt}
  c!{\vrule width 2.8pt}
  c!{\vrule width 3.4pt}
  c!{\vrule width 4pt}
  c!{\vrule width 4.6pt}
  }
\hline
& & & & & & \\
\noalign{\hrule height 1.2pt}
& & & & & & \\
\noalign{\hrule height 1.6pt}
& & & & & & \\
\noalign{\hrule height 2pt}
& & & & & & \\
\noalign{\hrule height 2.6pt}
& & & & & & \\
\noalign{\hrule height 3.4pt}
& & & & & & \\
\noalign{\hrule height 4pt}
& & & & & & \\
\noalign{\hrule height 4.6pt}
\end{tabular}

在这里插入图片描述

模板

模板一

  \begin{table}[htpb]
    \begin{center}
      \renewcommand{\arraystretch}{1.3}
      \caption{Table}
      \begin{tabular}{ @{}m{3.1cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}  m{0.8cm}<{\centering}@{}}
        \toprule
        Square    & Ellip.    & Circ.   & Surf.  & Rect. \\
        \midrule
        A         & Failed    & 19      & 98     & 62 \\ 
        B         & 14.4      & 72      & 68     & 4.7 \\  
        C         & -         & 17\%    & 17\%   & 8\% \\
        \bottomrule
      \end{tabular}
      \label{Table::M}
    \end{center}
    \end{table}

在这里插入图片描述

模板二

  \begin{table}[htpb]
    \begin{center}
      \renewcommand{\arraystretch}{1.3}
      \caption{Table}
      % \begin{tabular}{ c{3.1cm} | c{0.8cm} | c{0.8cm} | c{0.8cm} | c{0.8cm}}
      \begin{tabular}{ m{3.1cm} | m{0.8cm}| m{0.8cm} | m{0.8cm} | m{0.8cm}}
        \hline
        Square    & Ellip.    & Circ.   & Surf.  & Rect. \\
        \hline
        A         & Failed    & 19      & 98     & 62 \\ 
        B         & 14.4      & 72      & 68     & 4.7 \\  
        C         & -         & 17\%    & 17\%   & 8\% \\
        \hline
      \end{tabular}
      \label{Table::M}
    \end{center}
    \end{table}

在这里插入图片描述

模板三

  \begin{table}[htpb]
    \begin{center}
      \renewcommand{\arraystretch}{1.3}
      \caption{Table}
      \begin{tabular}{ m{3.1cm} | m{0.8cm}| m{0.8cm} | m{0.8cm} | m{0.8cm}}
        \hline \hline
        Square    & Ellip.    & Circ.   & Surf.  & Rect. \\
        \hline
        A         & Failed    & 19      & 98     & 62 \\ 
        B         & 14.4      & 72      & 68     & 4.7 \\  
        C         & -         & 17\%    & 17\%   & 8\% \\
        \hline \hline
      \end{tabular}
      \label{Table::M}
    \end{center}
    \end{table}

在这里插入图片描述

如果把 \hline 改成 \toprule 等会导致 数线不连续

在这里插入图片描述

参考

https://nasa.github.io/nasa-latex-docs/html/examples/table.html
https://www.overleaf.com/learn/latex/Tables

相关推荐

  1. Latex论文模板

    2024-02-16 21:08:02       49 阅读
  2. ACM论文LaTeX模板解析(五)| TODO

    2024-02-16 21:08:02       63 阅读
  3. Nougat - 学术文档PDF解析(LaTeX数学、表格

    2024-02-16 21:08:02       24 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-16 21:08:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-16 21:08:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-16 21:08:02       82 阅读
  4. Python语言-面向对象

    2024-02-16 21:08:02       91 阅读

热门阅读

  1. Keras的默认下载位置

    2024-02-16 21:08:02       56 阅读
  2. Promise学习笔记

    2024-02-16 21:08:02       49 阅读
  3. 实验5-4 使用函数计算两点间的距离

    2024-02-16 21:08:02       52 阅读
  4. 【C++】线段树(一)

    2024-02-16 21:08:02       59 阅读
  5. STM32入坑

    2024-02-16 21:08:02       50 阅读
  6. leetcode 152.乘积最大子数组

    2024-02-16 21:08:02       46 阅读
  7. Vue2源码梳理:render函数的实现

    2024-02-16 21:08:02       48 阅读
  8. CSS之BFC

    CSS之BFC

    2024-02-16 21:08:02      47 阅读
  9. Leetcode-709.转换成小写字母

    2024-02-16 21:08:02       54 阅读
  10. Attention Is All Your Need论文笔记

    2024-02-16 21:08:02       58 阅读