【LaTeX】latex 常用命令及模板

785 阅读9分钟

简介

LaTeX 是一种基于 TeX 的排版系统,用于生成高质量的技术与科学文档。它广泛应用于学术界、出版业和工业界等领域。

与 Microsoft Word 等常见文字处理软件不同,LaTeX 采用了“所见即所得”的方式来编写文档。用户需要通过编写代码来描述文档的结构和内容,然后使用 LaTeX 编译器将代码转换为可打印的 PDF 文件。

LaTeX 具有许多优点,例如:

  • 高质量的排版效果
  • 可以轻松管理大型文档
  • 支持数学公式和符号的输入和排版
  • 提供了丰富的排版样式和模板
  • 可以自动化参考文献和目录的生成

尽管 LaTeX 学习曲线相对较陡峭,但掌握了它的使用方法后,可以极大地提高文档的制作效率和质量。

1 数学公式

1.1 基本知识

  • 段落中数学公式应置于 ()$$ 或者 \begin{math}\end{math} 之间

  • 较大的数学式子最好使用显示式样来排版:

    • 置于 []\begin{displaymath}\end{displaymath},此时排出公式无编号。
    • 需要编号可使用 \begin{equation}\end{equation}
  • 利用 \label\ref 公式加以引用

     \begin{equation} \label{eq:eps}
       \epsilon > 0
     \end{equation}
     From (\ref{eq:eps}), we gather \ldots
    
  • 数学模式中

    1. 空格和分行都将被忽略。所有的空格或是由数学表达式逻辑的衍生,或是由特殊的命令如 ,\quad\qquad 来得到。
    2. 不允许有空行,每个公式中只能有一个段落。
    3. 每个字符都将被看作是一个变量名并以此来排版。如果你希望在公式中出现普通的文本(使用正体字并可以有空格),那么你必须使用命令 \textrm{...} 来输入这些文本。
  • 空心粗体可用 amsfonts 或 amssymb 宏包中的命令 \mathbb{} 来得到

1.2 数学模式中的分组

{...}

1.3 建立数学公式模块

  • ^_ -- 指数和下标

  • \sqrt[n]{} -- n 次平方根

  • \surd[] -- 仅显示平方根符号

  • \overline\underline -- 表达式上下方水平线

  • \overbrace\underbrace -- 表达式上下方大括号

  • \widetilde\widehat -- 可覆盖多个字符的宽重音符号。

  • ' -- 求导 '(prime)

  • \vec\overrightarrow\overleftarrow -- 向量

  • \cdot -- 圆点

  • 重要函数名

    • \arccos \cos \csc \exp \ker \limsup \min \arcsin \cosh \deg \gcd \lg \ln \Pr \arctan \cot
    • \det \hom \lim \log \sec \arg \coth \dim \inf \liminf \max \sin \sinh \sup \tan \tanh
  • 模函数

    • \bmod -- 二元运算符
    • \pmod -- 表达式
  • \frac{...}{...} -- 分数

  • 二项式系数

    • 有括号 -- {... \choose ...}
    • 无括号 -- {... \atop ...}
    • 注意:这些旧命令在 amsmath 宏集中禁止使用,而是用 \binom\genfrac 来代替。后者是所有相关结构的超集,例如可以通过 \newcommand{newatop}[2]%\genfrac{}{}{0pt}{1}{#1}{#2}} 来得到 \atop 的一个类似结构
  • \stackrel{...}{...} -- 二元关系符号堆在一起

  • 运算符

    • \int -- 积分运算符
    • \sum -- 求和运算符
    • \prod -- 乘积运算符
  • 如果将命令 \left 放在分隔符前,TEX会自动决定分隔符的正确大小。

    • 注意必须用对应的右分隔符 \right 来关闭每一个左分隔符 \left,并且只有当这两个分隔符排在同一行时大小才会被正确确定。
    • 某些情况下有必要手工指出数学分隔符的正确大小,这可以使用命令 \big, \Big, \bigg\Bigg 作为大多数分隔符命令的前缀。
    • AMS-LATEX另外有多行上标/下标。
    • 如果使用了改变大小的命令或者指定了11pt或12pt选项,这些命令并不像预料的那样起作用。使用exscale或amsmath宏集来修正这种行为。
  • 圆点

    • \ldots -- 基线
    • \cdots -- 居中
    • \vdots -- 垂直
    • \ddots -- 对角

1.4 数学空格

  • , -- \frac{3}{18} quad
  • : -- \frac{4}{18} quad
  • ; -- \frac{5}{18} quad
  • \ -- 中等大小的空格
  • \quad\qquad -- 大空格
  • \quad -- 字符‘M’的宽度
  • ! -- -\frac{3}{18} quad

注意微分中的 d 按惯例设为罗马字体。

  • \iint\iiint\iiiint\idotsint -- amsmath宏集中微调多重积分符号间空格

1.5 垂直对齐

  • 排版数组 arrays 使用 array,类似于 tabular 环境。

    \begin{displaymath}
        \mathbf{X} =
        \left( \begin{array}{ccc}
        x_{11} & x_{12} & \ldots \
        x_{21} & x_{22} & \ldots \
        \vdots & \vdots & \ddots
        \end{array} \right)
    \end{displaymath}
    
  • array 环境可以使用 . 作为隐藏右分隔符来排版只有一个大分隔符的表达式。

    \begin{displaymath}
        y = \left{ \begin{array}{ll}
        a & \textrm{if $d>c$}\
        b+x & \textrm{in the morning}\
        l & \textrm{all day long}
        \end{array} \right.
    \end{displaymath}
    
  • 像在 tabular 环境中一样,也可以在 array 环境中画线。例如分隔矩阵中的元素。

     \begin{displaymath}
         \left(\begin{array}{c|c}
         1 & 2 \
         \hline
         3 & 4
         \end{array}\right)
     \end{displaymath}   
    
  • 多行公式或方程组时使用 eqnarray (每一行一个方程编号)或 eqnarray* (不对方程进行编号),等号两边公式可以通过设定 \setlength\arraycolsep{2pt} 来减小空格。

     \begin{eqnarray}
         f(x) & = & \cos x \
         f'(x) & = & -\sin x \
         \int_{0}^{x} f(y)dy &
         = & \sin x
     \end{eqnarray}
    
  • 长方程组指定分割位置及缩进多少。\nonumber 不为此方程生成编号。

    {\setlength\arraycolsep{2pt}
         \begin{eqnarray}
         \sin x & = & x -\frac{x^{3}}{3!}
         +\frac{x^{5}}{5!}-{}
         \nonumber\
         & & {}-\frac{x^{7}}{7!}+{}\cdots
    \end{eqnarray}}    
    
    \begin{eqnarray}
        \lefteqn{ \cos x = 1
        -\frac{x^{2}}{2!} +{} }
        \nonumber\
        & & {}+\frac{x^{4}}{4!}
        -\frac{x^{6}}{6!}+{}\cdots
    \end{eqnarray}
    
  • 更有用方法见 splitalign 环境。

1.6 幻影

  • \phantom 为不在最终输出中出现的字符预留空间。

    \begin{displaymath}
        {}^{12}_{\phantom{1}6}\textrm{C}
        \qquad \textrm{versus} \qquad
        {}^{12}_{6}\textrm{C}
    \end{displaymath}
    
    \begin{displaymath}
        \Gamma_{ij}^{\phantom{ij}k}
        \qquad \textrm{versus} \qquad
        \Gamma_{ij}^{k}
    \end{displaymath}
    

1.7 数学字体大小

  • 使用 \mathrm 可将上标字体修改为罗马字体,但 \mathrm 只对于较短的项起作用,空格及重音字符不起作用。

    \begin{equation}
        2^{\textrm{nd}} \quad
        2^{\mathrm{nd}}
    \end{equation}
    
  • 数学模式字体大小可以用 \displaystyle\textstyle\scriptstyle, \scriptscriptstyle 四个命令设定。

  • 改变式样也会影响上下界显示的方式。

    \begin{displaymath}
        \mathop{\mathrm{corr}}(X,Y)=
        \frac{\displaystyle
        \sum_{i=1}^n(x_i-\overline x)
        (y_i-\overline y)}
        {\displaystyle\biggl[
        \sum_{i=1}^n(x_i-\overline x)^2
        \sum_{i=1}^n(y_i-\overline y)^2
        \biggr]^{1/2}}
    \end{displaymath}
    

    这个例子中,我们需要比标准的 \left[\right] 还要大一些的括号。

1.8 定理、定义

  • \newtheorem{name}[counter]{text}[section] 用来排版”引理“、”定义“、”公理“以及类似结构。

    • name 是短关键字,用于标识“定理”。
    • text 定义“定理”的真实名称,会在最终文件中打印出来。
    • 方括号中的选项是任意的, 可以用于指定“定理”中使用的标号。
    • counter 可以指定先前声明的“定理”的 name。然后新“定理”会按同样的顺序编号。
    • section 指定“定理”编号所在的章节层次。
  • JuryLaw 定理使用同一个计数器,编号是顺序排列的。

    % definitions for the document
    % preamble
        \newtheorem{law}{Law}
        \newtheorem{jury}[law]{Jury}
        %in the document
        \begin{law} \label{law:box}
        Don't hide in the witness box
        \end{law}
        \begin{jury}[The Twelve]
        It could be you! So beware and
        see law~\ref{law:box}\end{jury}
    \begin{law}No, No, No\end{law}
    
  • Murphy 定理的编号与当前节相链接。也可以使用其它单位,例如章或小节。

    \flushleft
    \newtheorem{mur}{Murphy}[section]
    \begin{mur}
    If there are two or more
    ways to do something, and
    one of those ways can result
    in a catastrophe, then
    someone will do it.\end{mur}
    

1.9 粗体符号

  • 使用工具包中的 amsby(包含在 amsmath 中)和 bm 包含的 \boldsymbol 可以使数学符号斜体加粗。

    \begin{displaymath}
        \mu, M \qquad
        \boldsymbol{\mu}, \boldsymbol{M}
    \end{displaymath}
    

1.10 数学符号表

2 配置文件

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt,a4paper]{article}% 文档格式
\usepackage{ctex}
\usepackage{hyperref}% 输出汉字
\usepackage{times}% 英文使用Times New Roman
\usepackage[T1]{fontenc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\fontsize{20pt}{30pt}\selectfont% 小四字号,1.5倍行距
{\heiti \vspace{-6em}论文题目 \vspace{-3em}}}% 题目
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\author{\fontsize{12pt}{18pt}\selectfont% 小四字号,1.5倍行距
%	{\fangsong 姓名}{Xing Ming}\
%	{200001}\
%	{Software Engineering Class 2, Course, University}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\date{}% 日期(这里避免生成日期)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath,amsfonts,amssymb}% 为公式输入创造条件的宏包
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}% 图片插入宏包
\usepackage{subfigure}% 并排子图
\usepackage{float}% 浮动环境,用于调整图片位置
\usepackage[export]{adjustbox}% 防止过宽的图片
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{bibentry}
\usepackage[square,sort&compress,comma,numbers]{natbib}% 以上2个为参考文献宏包
\newcommand{\upcite}[1]{\textsuperscript{\textsuperscript{\cite{#1}}}}
\renewcommand{\refname}{参考文献}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{appendix} %附录
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{abstract}% 两栏文档,一栏摘要及关键字宏包
\renewcommand{\abstracttextfont}{\fangsong}% 摘要内容字体为仿宋
\renewcommand{\abstractname}{\textbf{\fontsize{16pt}{24pt}摘\quad 要}}% 更改摘要二字的样式
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcolor}% 字体颜色宏包
\newcommand{\red}[1]{\textcolor[rgb]{1.00,0.00,0.00}{#1}}
\newcommand{\blue}[1]{\textcolor[rgb]{0.00,0.00,1.00}{#1}}
\newcommand{\green}[1]{\textcolor[rgb]{0.00,1.00,0.00}{#1}}
\newcommand{\darkblue}[1]
{\textcolor[rgb]{0.00,0.00,0.50}{#1}}
\newcommand{\darkgreen}[1]
{\textcolor[rgb]{0.00,0.37,0.00}{#1}}
\newcommand{\darkred}[1]{\textcolor[rgb]{0.60,0.00,0.00}{#1}}
\newcommand{\brown}[1]{\textcolor[rgb]{0.50,0.30,0.00}{#1}}
\newcommand{\purple}[1]{\textcolor[rgb]{0.50,0.00,0.50}{#1}}% 为使用方便而编辑的新指令
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{url}% 超链接
\usepackage{bm}% 加粗部分公式
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{epstopdf}
\usepackage{epsfig}
\usepackage{longtable}% 长表格
\usepackage{supertabular}% 跨页表格
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{changepage}% 换页
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{enumerate}% 短编号
\usepackage{enumitem}
\usepackage{caption}% 设置标题
\captionsetup[figure]{name=\fontsize{10pt}{15pt}\selectfont Figure}% 设置图片编号头
\captionsetup[table]{name=\fontsize{10pt}{15pt}\selectfont Table}% 设置表格编号头
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}% 中文首行缩进
\usepackage[left=1.00cm,right=1.00cm,top=2.80cm,bottom=2.50cm]{geometry}
% 页边距设置(调整摘要)
\renewcommand{\baselinestretch}{1.5}% 定义行间距(1.5)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr} %设置全文页眉、页脚的格式
\pagestyle{fancy}
\hypersetup{colorlinks=true,linkcolor=black,citecolor=black}% 去除引用红框,改变颜色
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand*\contentsname{\hfill Contents \hfill} %目录居中
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xeCJK}
\usepackage{pythonhighlight}
\usepackage{multirow}
\usepackage{longtable}

\begin{document}% 以下为正文内容
\maketitle% 产生标题,没有它无法显示标题
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\lhead{}% 页眉左边设为空
\chead{}% 页眉中间设为空
\rhead{}% 页眉右边设为空
\lfoot{}% 页脚左边设为空
\cfoot{\thepage}% 页脚中间显示页码
\rfoot{}% 页脚右边设为空
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

3 摘要和关键词

% 摘要关键词	
\begin{abstract}
\par % 换行
\textbf{} % 加粗
$$ % 行内公式
\end{abstract}

\begin{adjustwidth}{1.06cm}{1.06cm}
\fontsize{10.5pt}{15.75pt}\selectfont{\heiti{关键词:}\fangsong{ }}\ % 换行
\end{adjustwidth}

4 正文目录结构

\newpage
\newgeometry{left=2.50cm,right=2.50cm,top=2.80cm,bottom=2.50cm}
% 重新设置正文页边距
\setcounter{page}{1}   % 从下面开始编页码
\setlength{\parindent}{2em} % 空两格

\section{\centering 问题提出} % 一级标题(居中)
    \subsection{背景简述} % 二级标题
    \subsection{研究意义}
    \subsection{问题重述}

\section{\centering 条件假设}
\section{\centering 符号约定}
\section{\centering 问题分析}
\section{\centering 模型的建立与求解}
\section{\centering 模型的评价与改进}

5 图表

5.1 三线表

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{符号约定}
    \begin{tabular}{cc}
        \toprule[2pt]
        符号 & 意义 \ 
        \midrule
        符号 & 意义 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}
\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{算法比较}
    \begin{tabular}{cccccc}
        \toprule[2pt]
        算法 & 数据集 & 准确率 & 召回率 & 精确率 & F1 \
        \midrule
        \multirow{2}*{决策树} & 训练集 & 0.875 & 0.875 & 0.886 & 0.876  \
         & 测试集 & 0.667 & 0.667 & 0.736 & 0.667 \
        \hline
        \bottomrule[2pt]
    \end{tabular}
\end{table}

5.2 单张图片

\begin{figure}[H]% 插入一张图片,H表示浮动环境下的here
    \centering
    \begin{minipage}{0.83\textwidth}% 小页面尺寸,可自行调节
        \centering
        \includegraphics[width=1.0 % 图片尺寸,可自行调节
        \textwidth]{问题一总思路图}% 图片名称(图片需与tex文件在同一文件夹)
        \renewcommand{\figurename}{图}
        \caption{问题一总思路图}% 图例
    \end{minipage}
\end{figure}

5.3 多张图片

\begin{figure}[H]% 插入两张图片并且并排
    \centering
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{英国病例总数随时间发展情况}
        \renewcommand{\figurename}{图}
        \caption{英国病例总数随时间发展情况}
    \end{minipage}
        \hspace{0cm} % 图片间距
        \hfill % 撑满整行
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{英国每日新增病例随时间发展情况}
        \renewcommand{\figurename}{图}
        \caption{英国每日新增病例随时间发展情况}
    \end{minipage}
\end{figure}

5.4 三级标题下正文缩进

\subsubsection{}
    \ 
    \newline
    \indent % 三级标题正文缩进

5.5 有序列表

\begin{enumerate}[leftmargin = *,listparindent =2em]
    \item
    \begin{enumerate}[leftmargin = *,listparindent =2em]
            \item
    \end{enumerate}
\end{enumerate}

5.6 公式

\begin{equation}
\end{equation}

6 文献

\newpage
\setcounter{page}{1}
\begin{thebibliography}{99} % 参考文献,{}内表示序号最大位数(两位)
\bibitem{ref1}xxxxxxx, xxxxxx, xxxxxx
\end{thebibliography}

7 附录

\newpage
\appendix
\begin{center}
\section*{附录}
\end{center}
% 附录正文

\begin{python}
    % 在此粘贴Python代码
\end{python}

\end{document}% 结束正文内容

8 暂存

8.1 问题一交叉分析列联表

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题一交叉分析列联表}
    \begin{tabular}{ccccc}
        \toprule[2pt]
        \multirow{2}*{成分} & \multirow{2}*{名称} & \multicolumn{2}{c}{表面风化} & \multirow{2}*{总计} \
                 & & 无风化 & 风化 & \
        \midrule
        \multirow{3}*{纹饰} & A & 11 (50.0%) & 11 (50.0%) & 22 \
                 & B & 0 (0.0%) & 6 (100.0%) & 6 \
                 & C & 13 (43.3%) & 17 (56.7%) & 30 \
                \hline
        \multirow{2}*{类型} & 高钾 & 12 (30.0%) & 28 (70.0%) & 40 \
                 & 铅钡 & 12 (66.7%) & 6 (33.3%) & 18 \
                \hline
        \multirow{9}*{颜色} & NaN & 0 (0.0%) & 4 (100.0%) & 4 \
                 & 浅绿 & 2 (66.7%) & 1 (33.3%) & 3 \
                 & 浅蓝 & 8 (40.0%) & 12 (60.0%) & 20 \
                 & 深绿 & 3 (42.9%) & 4 (57.1%) & 7 \
                 & 深蓝 & 2 (100.0%) & 0 (0.0%) & 2 \
                 & 紫 & 2 (50.0%) & 2 (50.0%) & 4 \
                 & 绿 & 1 (100.0%) & 0 (0.0%) & 1 \
                 & 蓝绿 & 6 (40.0%) & 9 (60.0%) & 15 \
                 & 黑 & 0 (0.0%) & 2 (100.0%) & 2 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.2 问题一十种算法模型准确率比较

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题一十种算法模型准确率比较}
    \begin{tabular}{c|cccc|cccc}
        \toprule[2pt]
        \multirow{2}*{算法} & \multicolumn{4}{c|}{训练集(70%)} & \multicolumn{4}{c}{测试集(30%)} \
         & 准确率 & 召回率 & 精确率 & F1 & 准确率 & 召回率 & 精确率 & F1 \
        \midrule
                逻辑回归 & 0.825 & 0.825 & 0.839 & 0.817 & 0.722 & 0.722 & 0.722 & 0.72 \
        决策树 & 0.875 & 0.875 & 0.886 & 0.876 & 0.667 & 0.667 & 0.736 & 0.667 \
                朴素贝叶斯 & 0.7 & 0.7 & 0.7 & 0.682 & 0.556 & 0.556 & 0.546 & 0.544 \
        随机森林 & 0.875 & 0.875 & 0.9 & 0.873 & 0.667 & 0.667 & 0.667 & 0.667 \
        AdaBoost & 0.875 & 0.875 & 0.9 & 0.873 & 0.667 & 0.667 & 0.667 & 0.667 \
        GBDT & 0.925 & 0.925 & 0.926 & 0.926 & 0.667 & 0.667 & 0.643 & 0.646 \
        CatBoost & 0.875 & 0.875 & 0.9 & 0.873 & 0.556 & 0.556 & 0.852 & 0.578 \
                Extra_Tree & 0.9 & 0.9 & 0.914 & 0.896 & 0.667 & 0.667 & 0.667 & 0.667 \
                XGBoost & 0.875 & 0.875 & 0.896 & 0.868 & 0.722 & 0.722 & 0.821 & 0.699 \
                LightGBM & 0.8 & 0.8 & 0.846 & 0.768 & 0.5 & 0.5 & 0.781 & 0.425 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}	

8.3 问题一三种初始算法中三种属性对表面风化影响权重

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{三种初始算法中三种属性对表面风化影响权重}
    \begin{tabular}{cccc}
        \toprule[2pt]
        算法 & 属性 & 系数 & 权重 \
        \midrule
        \multirow{3}*{XGBoost} & 纹饰 & & 0.40 \
                 & 类型 & & 0.47 \
                 & 颜色 & & 0.14 \
                \hline
        \multirow{3}*{逻辑回归} & 纹饰 & 0.78390541 & 0.31 \
                 & 类型 & 1.67834831 & 0.66 \
                 & 颜色 & -0.0927040432 & 0.04 \
                \hline
                \multirow{3}*{随机森林} & 纹饰 & & 0.36 \
                 & 类型 & & 0.28 \
                 & 颜色 & & 0.36 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.4 问题一化学成分均值统计

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题一化学成分均值统计1}
    \begin{tabular}{ccccccccc}
        \toprule[2pt]
        玻璃类型 & 亚类 & $SiO_2$ & $Na_2O$ & $K_2O$ & $CaO$ & $MgO$ & $Al_2O_3$ & $Fe_2O_3$ \
        \midrule
        \multirow{3}*{高钾玻璃} & 严重风化 & 17.110 & 0.000 & 0.000 & 0.000 & 1.110 & 3.650 & 0.000 \
                 & 未风化 & 54.660 & 1.683 & 0.219 & 1.320 & 0.640 & 4.456 & 0.737 \
                 & 风化 & 28.458 & 0.323 & 0.366 & 2.662 & 0.693 & 2.970 & 0.677 \
                \hline
                \multirow{2}*{铅钡玻璃} & 未风化 & 66.941 & 0.758 & 9.323 & 5.817 & 1.038 & 6.945 & 2.107 \
                 & 风化 & 93.963	 & 0.000 & 0.543 & 0.870 & 0.197 & 1.930 & 0.265 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}
\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题一化学成分均值统计2}
    \begin{tabular}{ccccccccc}
        \toprule[2pt]
        玻璃类型 & 亚类 & $CuO$ & $PbO$ & $BaO$ & $P_2O_5$ & $SrO$ & $SnO_2$ & $SO_2$ \
        \midrule
        \multirow{3}*{高钾玻璃} & 严重风化 & 1.340 & 58.460 & 0.000 & 14.130 & 1.120 & 0.000 & 0.000 \
                 & 未风化 & 1.432 & 22.085 & 9.002 & 1.049 & 0.268 & 0.047 & 0.159 \
                 & 风化 & 2.174 & 41.897 & 10.038 & 4.569 & 0.359 & 0.074 & 0.189 \
                \hline
                \multirow{2}*{铅钡玻璃} & 未风化 & 2.675 & 0.449 & 0.653 & 1.406 & 0.039 & 0.000 & 0.111 \
                 & 风化 & 1.562 & 0.000 & 0.000 & 0.280 & 0.000 & 0.000 & 0.000 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.5 降维聚类算法效果比较

\begin{figure}[H]% 插入两张图片并且并排
    \centering
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{PCA-DBSCAN}
        \renewcommand{\figurename}{图}
        \caption{PCA-DBSCAN}
    \end{minipage}
        \hspace{0cm}% 图片间距
        \hfill% 撑满整行
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{PCA-KMeans}
        \renewcommand{\figurename}{图}
        \caption{PCA-KMeans}
    \end{minipage}
\end{figure}

\begin{figure}[H]% 插入两张图片并且并排
    \centering
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{PCA-光谱聚类}
        \renewcommand{\figurename}{图}
        \caption{PCA-光谱聚类}
    \end{minipage}
        \hspace{0cm}% 图片间距
        \hfill% 撑满整行
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{UMAP-DBSCAN}
        \renewcommand{\figurename}{图}
        \caption{UMAP-DBSCAN}
    \end{minipage}
\end{figure}

\begin{figure}[H]% 插入两张图片并且并排
    \centering
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{UMAP-KMeans}
        \renewcommand{\figurename}{图}
        \caption{UMAP-KMeans}
    \end{minipage}
        \hspace{0cm}% 图片间距
        \hfill% 撑满整行
    \begin{minipage}{0.48\textwidth}
        \centering
        \includegraphics[width=0.83\textwidth]{UMAP-光谱聚类}
        \renewcommand{\figurename}{图}
        \caption{UMAP-光谱聚类}
    \end{minipage}
\end{figure}

8.6 问题二分类模型对两类玻璃分类结果评估表

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题二分类模型对两类玻璃分类结果评估表}
    \begin{tabular}{cccccc}
        \toprule[2pt]
        玻璃类型 & 是否风化 & 分类模型 & 准确率 & 精确率 & 召回率 \
        \midrule
         \multirow{4}*{高钾玻璃} & \multirow{2}*{未风化} & 符号回归 & 1.0 & 1.0 & 1.0 \
                 & & 逻辑回归 & 1.0 & 1.0 & 1.0 \
                \cline{2-6}
          & \multirow{2}*{风化} & 符号回归 & 1.0 & 1.0 & 1.0 \
                 & & 逻辑回归 & 1.0 & 1.0 & 1.0 \
                \hline
         \multirow{4}*{铅钡玻璃} & \multirow{2}*{未风化} & 符号回归 & 0.652 & 0.652 & 1.0 \
                 & & 逻辑回归 & 0.958 & 0.857 & 1.0 \
                \cline{2-6}
          & \multirow{2}*{风化} & 符号回归 & 0.958 & 0.857 & 1.0 \
                 & & 逻辑回归 & 0.958 & 1.0 & 0.833 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.7 问题三预测结果

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题三预测结果}
    \begin{tabular}{cc}
        \toprule[2pt]
        文物编号 & 预测所属分类 \
        \midrule
        A1 & 高钾玻璃 \
        A2 & 铅钡玻璃 \
        A3 & 铅钡玻璃 \
        A4 & 铅钡玻璃 \
        A5 & 铅钡玻璃 \
        A6 & 高钾玻璃 \
        A7 & 高钾玻璃 \
        A8 & 铅钡玻璃 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.8 问题四回归模型拟合公式

\begin{table}[H]% 插入表格
    \centering
    \renewcommand{\tablename}{表}
    \caption{问题四回归模型拟合公式}
    \begin{tabular}{ccccc}
        \toprule[2pt]
        \multirow{2}*{玻璃种类} & \multirow{2}*{成分} & \multirow{2}*{公式} & \multicolumn{2}{c}{决定系数} \
                 & & & $R^2$ & 调整$R^2$ \
        \midrule
        \multirow{6}*{铅钡玻璃} & \multirow{2}*{$CuO$} & $y=-0.983+0.246*BaO$ & \multirow{2}*{0.689} & \multirow{2}*{0.668} \
                 & & $+0.821*SO_2+0.113*P_2O_5$ \
                \cline{2-5}
         & \multirow{3}*{$PbO$} & $y=98.577-1.001*SiO_2-0.421*CuO$ & \multirow{3}*{0.978} & \multirow{3}*{0.974} \
                 & & $-5.657*K_2O-0.798*Al_2O_3-1.231*BaO$ & & \
                & & $-1.375*P_2O_5-1.164Na_2O-1.448*CaO$ & & \
                \cline{2-5}
         & $BaO$ & $y=7.147+2.069*CuO-2.278*MgO$ & 0.651 & 0.636 \
                \hline
        \multirow{17}*{高钾玻璃} & $K_2O$ & $y=42.388-0.442*SiO_2-1.599*Fe_2O_3$ & 0.911 & 0.898 \
                \cline{2-5}
                 & \multirow{2}*{$CaO$} & $y=21.788-0.221*SiO_2-1.308*P_2O_5$ & \multirow{2}*{0.968} & \multirow{2}*{0.958} \
                 & & $-20.514*SrO+0.687*Fe_2O_3$ & & \
                \cline{2-5}
                 & \multirow{2}*{$P_2O_5$} & $y=-0.036+0.57*Fe_2O_3-$ & \multirow{2}*{0.925} & \multirow{2}*{0.907} \
                 & & $0.233*CaO+0.225*Al_2O_3$ & & \
                \cline{2-5}
                 & \multirow{2}*{$Na_2O$} & $y=-0.222+0.319*CaO-$ & \multirow{2}*{0.823} & \multirow{2}*{0.782} \
                 & & $4.84*SO_2-0.563*BaO$ & & \
                \cline{2-5}
                 & \multirow{2}*{$MgO$} & $y=-0.245+0.205*Al_2O_3-$ & \multirow{2}*{0.919} & \multirow{2}*{0.901} \
                 & & $0.304*Na_2O+1.032*SO_2$ & & \
                \cline{2-5}
                 & \multirow{2}*{$Al_2O_3$} & $y=18.728-0.169*SiO_2+$ & \multirow{2}*{0.908} & \multirow{2}*{0.887} \
                 & & $0.991*P_2O_5-0.716*CuO$ & & \
                \cline{2-5}
                 & \multirow{2}*{$Fe_2O_3$} & $y=-0.024+1.077*P_2O_5+0.543*CaO$ & \multirow{2}*{0.954} & \multirow{2}*{0.934} \
                 & & $-0.182*K_2O+14.193*SrO-0.201*Al_2O_3$ & & \
                \cline{2-5}
                 & $CuO$ & $y=1.919+0.86*BaO$ & 0.267 & 0.218 \
                \cline{2-5}
                 & $PbO$ & $y=-0.022+0.454*BaO+0.245*Na_2O$ & 0.649 & 0.599 \
                \cline{2-5}
                 & \multirow{2}*{$BaO$} & $y=-0.292+0.957*PbO+5.598*SrO$ & \multirow{2}*{0.911} & \multirow{2}*{0.87} \
                 & & $-0.323*Na_2O+0.244*CuO-1.469*SO_2$ & & \
                \cline{2-5}
                 & $SrO$ & $y=-0.003+0.02*P_2O_5+0.02*BaO$ & 0.911 & 0.87 \
        \bottomrule[2pt]
    \end{tabular}
\end{table}

8.9 假设、推论关联图

\begin{figure}[H]% 插入一张图片,H表示浮动环境下的here
    \centering
    \begin{minipage}{0.83\textwidth}% 小页面尺寸,可自行调节
        \centering
        \includegraphics[width=1.0 % 图片尺寸,可自行调节
        \textwidth]{假设、推论关联图}% 图片名称(图片需与tex文件在同一文件夹)
        \renewcommand{\figurename}{图}
        \caption{假设、推论关联图}% 图例
    \end{minipage}
\end{figure}