• (13.2)Latex图片、表格的绘制与排布


    一、表格

    1、三线表

    制作三线表需要导入包

    \usepackage{booktabs}
    
    • 1
    • 样例
    \begin{table}[!htbp] 
    \caption{describtion}
    % \begin{center}
    \resizebox{\linewidth}{!}{  % 自适应页面宽度
        \begin{tabular}{llll} % 4列
            \toprule % 表格头部粗线
            & A & B & C \\
            \midrule % 表头下的线条
              Type1  & 0.1 & 0.2 & 0.3\\
              Type2  & 0.1 & 0.2 & 0.3\\
            \bottomrule %添加表格底部粗线
        \end{tabular}
    }
    % \end{center}
    \end{table}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    在这里插入图片描述

    以下是一些更换或含义

    • 对齐和竖线
    % \begin{tabular}{????} 中
    % c代表居中, l代表左对齐, r代表右对齐
    % 加上竖线代表两侧的线条
    |c|c|c|c|  %如下图
    
    • 1
    • 2
    • 3
    • 4

    image-20220917202419268

    • 横线

    通过以下代码为内容加上横线

    \hline
    
    • 1
    • 内容换行

    如果想让表格内的文字换行,则用以下代码

    \makecell[c]{?? \\ ??}
    
    • 1

    例如修改代码

    \makecell[c]{Type \\ 1}
    
    • 1

    就会变成

    在这里插入图片描述

    参考链接

    使用latex做三线表

    二、图片

    需要导入包

    \usepackage{graphics} % for pdf, bitmapped graphics files
    \usepackage{graphicx}
    \usepackage{subfigure}
    
    • 1
    • 2
    • 3

    1、仅图片和标题

    • 样例
    \begin{figure}[thpb]
    	\centering  % 图片居中显示
    	\includegraphics[scale=0.3]{a.png}  % 插入图片
    	\caption{\textbf{xxx.} Describtion. }   % 图例信息(+小标题)
    \end{figure}
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述

    以下是相关的说明

    • thpb
    [h] 表示当前位置(here),也就是说图片将放在你设置的当前位置,但是如果这一页的空间不足以放下这个图片,此时图片会转到下一页;
    [t] 顶端(top),此时优先将图片放置在页面的顶部;
    [b] 底部(bottom)此时优先将图片放置在页面底部;
    [p] 将图片设置为浮动状态,系统会自动排版图片的位置
    % 一般推荐[ht]、[htbp]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • scale/height/width
    [scale=0.2] 表示缩小成原图的0.2倍
    [height = 1cm, width = 2cm] 表示固定宽高
    [width = 2cm] 表示固定宽, 高按原比例调整; 反之一样
    
    • 1
    • 2
    • 3

    2、多图并排

    • 样例
    \begin{figure*}[htbp]
    \centering
    \subfigure[fig 1]
    {
        \begin{minipage}[b]{.4\linewidth}
            \centering
            \includegraphics[scale=0.2]{a.png}
        \end{minipage}
    }
    \subfigure[fig 2]
    {
     	\begin{minipage}[b]{.4\linewidth}
            \centering
            \includegraphics[scale=0.2]{a.png}
        \end{minipage}
    }
    \caption{\textbf{xxx.} Describtion.}
    \end{figure*}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    image-20220917210421404

    以下是一些说明

    • {.4\linewidth}

    代表占页面宽度的0.4,这样可以放2张图,如果0.3就可以放1/3≈3张图,以此类推

    • \subfigure[fig x]
    在\subfigure后面:
    加上[fig 1], 会标号+显示内容, 即(a) fig 1
    加上[], 会标号, 即(a)
    也可以什么都不加
    
    • 1
    • 2
    • 3
    • 4

    []代表添加序号,如果不加方括号,就不会有(a)、(b)的序号

    3、分组标号 + 左标题

    • 样例(横排为例)
    \begin{figure*}[htbp]
    \centering
    \subfigure[fig 1]
    {
        \rotatebox{90}{\scriptsize{~~~Title1}}
        \begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
        \begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
        \begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
    }
    \subfigure[fig 2]
    {
        \rotatebox{90}{\scriptsize{~~Title1}}
     	\begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
        \begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
        \begin{minipage}[b]{.3\linewidth}
            \centering
            \includegraphics[scale=0.1]{a.png}
        \end{minipage}
    }
    \caption{\textbf{xxx.} Describtion.}
    \end{figure*}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    image-20220917211206414

    以下是一些说明

    • \subfigure[fig 2]{}

    \subfigure来分组,同组放在同一个\subfigure下;竖排同理

    • \rotatebox{90}{\scriptsize{~~~Title1}}
    90:数字代表标题的逆时针旋转角度
    ~~~:可以当空格使用, 手动调整 title的位置
    
    • 1
    • 2

    参考链接

    LaTex笔记一:图片的插入及排版方法

    Latex图片横排和竖排,并在图片下方和左方添加子标题

    三、其他

    1、占用整栏

    对于分栏(例如2栏)的文章中,想让图片或表格占用整个文档宽的空间而不是一栏,就在表格的头尾加 * 号,例如:

    \begin{table*}[!htbp] 
    \end{table*}
    
    • 1
    • 2

    在这里插入图片描述

    2、自适应页面宽度

    resizebox包住板块内容,就可以让整个板块自适应页面宽度,例如:

    \begin{table}[!htbp] 
    \resizebox{\linewidth}{!}{
    }
    \end{table}
    
    • 1
    • 2
    • 3
    • 4
  • 相关阅读:
    【广州华锐互动】钢厂铸锻部VR沉浸式实训系统
    Prime Path(广度优先搜索)
    初识swagger
    go语言基于Gin集成后台管理系统开发定时任务管理cron/v3好用又好看
    RHEL8安装FreeIPA服务器
    从趋势到挑战,资深工程师一站式解读:操作系统运维和可观测性
    语音处理:Python实现Wav序列的声道拆分与合并
    Spring MVC视图解析器
    (尚硅谷)2021 版 SpringMVC 教程笔记
    xlsxStyle + xlsx.full.min 导出数据,并设置导出样式
  • 原文地址:https://blog.csdn.net/Netceor/article/details/126910949