carry 7cc26feaa9 fix(latex): 中文样式
调整了 LaTeX 文档中的标题格式和目录样式,使其更加统一和规范。移除了旧的章节计数器,并重新定义了 `titlesec` 和 `titletoc` 的样式,以更好地符合文档需求。
2025-04-25 17:56:05 +08:00

151 lines
3.6 KiB
TeX

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{ctex}
\usepackage{indentfirst}
%\graphicspath{{chapter/}{figures/}}
\usepackage{CJK}
\usepackage{amsmath}%数学
%\usepackage[colorlinks,linkcolor=red]{hyperref}%超链接
\usepackage{fancyhdr} %使用fancyhdr包自定义页眉页脚
%\pagestyle{empty}
\pagestyle{fancy}
%\pagestyle{plain}%没有页眉,页脚放页数
\usepackage{titlesec}%设置章节标题与正文间距为2行
\titlespacing{\section}{0pt}{0pt}{2em}
\usepackage{enumerate}%项目编号
\renewcommand{\figurename}{}%将figure改为图
\usepackage[]{caption2}%去掉图片编号后的":"
\renewcommand{\captionlabeldelim}{}
\renewcommand {\thefigure} {\thesection{}.\arabic{figure}}%图片索引该为按照章节
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
\usepackage{booktabs}%表格用
\usepackage{titlesec}%修改标题格式宏包
\titleformat{\section}{\centering\zihao{3}\songti\bfseries}{\arabic{section}.}{0.5em}{}%修改section标题格式
% 设置目录格式为宋体
\renewcommand\contentsname{\songti 目录}
\usepackage{multirow}%跨行表格
\usepackage{abstract}%摘要
\usepackage{setspace} %行间距的宏包
\usepackage{makecell}%表格竖线连续
\def\I{\vrule width1.2pt}
%!\I 就可以代替| 来画表格了
%可固定下划线长度
\makeatletter
\newcommand\dlmu[2][4cm]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
\makeatother
\usepackage{float}%可以用于禁止浮动体浮动
%目录超链接
\usepackage[colorlinks,linkcolor=black,anchorcolor=blue,citecolor=black]{hyperref}
\usepackage{listings}%可以插入代码
\usepackage{xcolor}%语法高亮支持
%代码格式
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\usepackage{fontspec}
\setmonofont{Consolas}
\lstset{ %
numbers=left,
basicstyle=\tiny\ttfamily,
numberstyle=\tiny,
tabsize=4,
numbersep=5pt,
keywordstyle= \color{blue!70}, %关键词为蓝色
commentstyle=\color{gray}, %注释为灰色
frame=shadowbox, % 框架阴影效果
rulesepcolor= \color{ red!20!green!20!blue!20} ,
escapeinside={\%*}{*)},
xleftmargin=2em, % 边界选项
xrightmargin=2em, % 边界选项
aboveskip=1em, % 边界选项
framexleftmargin=2em, % 边界选项
breaklines,%过长代码自动换行
}
\usepackage{titlesec}
\titleformat{\section}{\centering\Large\bfseries}{\,\thesection\,}{1em}{}
\usepackage{titletoc}
\titlecontents{section}[0pt]{\addvspace{1.5pt}\filright\bf}
{\contentspush{\thecontentslabel\ \quad}}
{}{\titlerule*[8pt]{.}\contentspage}
%设置页面格式
\usepackage[left=3.0cm, right=2.6cm, top=2.54cm, bottom=2.54cm]{geometry}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 封面部分
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{chapters/cover}
\renewcommand{\abstractname}{\scriptsize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 摘要和关键词部分
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{chapters/abstract}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 目录部分
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\contentsname}{\centerline{\zihao{-2}\textbf{目录}}}
\tableofcontents
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 正文部分
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
\setlength{\baselineskip}{23pt}
% 引入各章节文件
\newpage
\input{chapters/introduction}
\newpage
\input{chapters/conclusion}
\newpage
\input{chapters/acknowledgement}
\newpage
% 引入参考文献
\input{chapters/references}
}
\end{document}