% ========== 页面布局 ==========
\usepackage[top=2.54cm, bottom=2.54cm, left=3.17cm, right=3.17cm]{geometry}

% ========== 行距 ==========
\usepackage{setspace}
\onehalfspacing

% ========== 修复页眉高度警告 ==========
\setlength{\headheight}{14.49998pt}

% ========== 页眉页脚 ==========
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\fancyhead[RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}

% ========== 数学 ==========
\usepackage{amsmath,amssymb,mathtools}

% ========== 表格 ==========
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{diagbox}

% ========== 图形 ==========
\usepackage{graphicx}
\usepackage{subfig}
\graphicspath{{figures/}{figures/ch01/}{figures/ch02/}{figures/ch03/}{figures/ch04/}{figures/ch05/}{figures/ch06/}{figures/ch07/}{figures/ch08/}{figures/ch09/}{figures/ch10/}{figures/ch11/}{figures/ch12/}{figures/ch13/}}

% ========== 代码 ==========
\usepackage{listings}
\lstset{
  basicstyle=\ttfamily\small,
  breaklines=true,
  frame=single,
  backgroundcolor=\color{gray!10},
  keywordstyle=\color{blue},
  commentstyle=\color{green!60!black},
  stringstyle=\color{red},
  numbers=left,
  numberstyle=\tiny\color{gray},
  xleftmargin=2em,
}

% ========== 颜色 ==========
\usepackage{xcolor}

% ========== 超链接 ==========
\usepackage{hyperref}
\usepackage{bookmark}
\hypersetup{
  colorlinks=true,
  linkcolor=blue!70!black,
  citecolor=green!50!black,
  urlcolor=blue!80!black,
  bookmarksopen=true,
}

% ========== 参考文献 ==========
\usepackage[numbers,sort&compress]{natbib}
\bibliographystyle{plainnat}

% ========== 其他 ==========
\usepackage{enumitem}
\usepackage{tcolorbox}

% ========== 修复 pandoc longtable 无标题表格 ==========
\newcounter{none}

% ========== 修复 pandoc tightlist ==========
\providecommand{\tightlist}{}

% ========== 修复 pandoc passthrough ==========
\providecommand{\passthrough}[1]{#1}

% ========== 章节格式 ==========
\ctexset{
  chapter = {
    format = \huge\bfseries\centering,
    nameformat = {},
    titleformat = {},
    beforeskip = 1ex,
    afterskip = 2ex,
  },
  section = {
    format = \Large\bfseries,
  },
  subsection = {
    format = \large\bfseries,
  },
}
