% ----------------------------------------------------- % 加边框的命令 % 参考:https://tex.stackexchange.com/questions/531559/how-to-add-the-page-border-for-first-two-pages-in-latex \usepackage{tikz} \usetikzlibrary{calc} \usepackage{eso-pic} \AddToShipoutPictureBG{% \begin{tikzpicture}[overlay,remember picture] \draw[line width=0.6pt] % 边框粗细 ($ (current page.north west) + (0.6cm,-0.6cm) $) rectangle ($ (current page.south east) + (-0.6cm,0.6cm) $); % 边框位置 \end{tikzpicture}} \usepackage{xcolor} \definecolor{c1}{HTML}{2752C9} % 目录颜色 \definecolor{c2}{RGB}{190,20,83} % 引用颜色 \usepackage{ctex} \usepackage[top=28mm,bottom=28mm,left=15mm,right=15mm]{geometry} % 调整边距 \usepackage{hyperref} \hypersetup{ colorlinks, linktoc = section, % 给目录加的超链接位置,选项有 section, page, all linkcolor = c1, % linkcolor 目录颜色 citecolor = c1 % citecolor 引用颜色 } \usepackage{amsmath,enumerate,multirow,float} \usepackage{tabularx} \usepackage{tabu} \usepackage{subfig} \usepackage{fancyhdr} \usepackage{graphicx} \usepackage{wrapfig} \usepackage{physics} \usepackage{appendix} \usepackage{amsfonts} \usepackage{annotate-equations} % 公式标注 \usepackage{pgfplots} % pgf 绘图 % --------------------------------------------------------------------- % 定义了两类colorbox \usepackage{tcolorbox} \tcbuselibrary{skins,breakable} \newtcolorbox{tbox}[2][]{ colframe=black!70!, breakable, enhanced, % 跨页后不会显示下边框 boxrule =0.5pt, title = {#2}, fonttitle = \large\bfseries, drop fuzzy shadow, #1 } \newtcolorbox[auto counter,number within=section]{question}[1][]{ top=2pt,bottom=2pt,arc=1mm, boxrule=0.5pt, breakable, enhanced, % 跨页后不会显示下边框 coltitle=c1!80!gray, colframe=c1, colback=c1!3!white, drop fuzzy shadow, title={题目~\thetcbcounter:\quad}, fonttitle=\bfseries, attach title to upper, #1 } % --------------------------------------------------------------------- % 利用 cleveref 改变引用格式,\cref 是引用命令https://latex.ustc.edu.cn/project/67dbe69d1a54d74ac4111d57 \usepackage{cleveref} \crefformat{figure}{#2{\textcolor{c2}{图 #1}}#3} % 图片的引用格式 \crefformat{equation}{#2{(\textcolor{c2}{#1})}#3} % 公式的引用格式 \crefformat{table}{#2{\textcolor{c2}{表 #1}}#3} % 表格的引用格式 % --------------------------------------------------------------------- % 页眉页脚设置 \fancypagestyle{plain}{\pagestyle{fancy}} \pagestyle{fancy} \lhead{\kaishu 中山大学 \quad 智能工程学院} % 左边页眉,学院 + 课程 \rhead{\kaishu C++实验报告} % 右边页眉,实验报告标题 \cfoot{\thepage} % 页脚,中间添加页码 \setlength{\headheight}{13.6pt} % --------------------------------------------------------------------- % 对目录、章节标题的设置 \renewcommand{\contentsname}{\centerline{\huge 目录}} \usepackage{titlesec} \usepackage{titletoc} % \titleformat{章节}[形状]{格式}{标题序号}{序号与标题间距}{标题前命令}[标题后命令] \titleformat{\section}{\centering\LARGE}{}{1em}{} \newcommand{\nsection}[3]{% \section{#1 #2 \hspace{11pt} \textbf{#3}}% } % --------------------------------------------------------------------- % listing代码环境设置 \usepackage{listings} \lstloadlanguages{python} \lstdefinestyle{pythonstyle}{ backgroundcolor=\color{gray!5}, language=python, frameround=tftt, frame=shadowbox, keepspaces=true, breaklines, columns=spaceflexible, basicstyle=\ttfamily\small, % 基本文本设置,字体为 teletype,大小为 small keywordstyle=[1]\color{c1}\bfseries, keywordstyle=[2]\color{Red!70!black}, stringstyle=\color{Purple}, showstringspaces=false, commentstyle=\ttfamily\scriptsize\color{green!40!black}, % 注释文本设置,字体为 teletype,大小为 scriptsize tabsize=2, morekeywords={as}, morekeywords=[2]{np, plt, sp}, numbers=left, % 代码行数,位置在左 numberstyle=\it\tiny\color{gray}, % 代码行数的数字字体设置 stepnumber=1, rulesepcolor=\color{gray!30!white} } \lstloadlanguages{C++} \lstdefinestyle{cppstyle}{ backgroundcolor=\color{gray!5}, language=C++, frameround=tftt, frame=shadowbox, keepspaces=true, breaklines, columns=spaceflexible, basicstyle=\ttfamily\small, % 基本文本 keywordstyle=[1]\color{c1}\bfseries, % 主要关键字 keywordstyle=[2]\color{Red!70!black}, % 用户自定义关键字 stringstyle=\color{Purple}, % 字符串颜色 showstringspaces=false, commentstyle=\ttfamily\scriptsize\color{green!40!black}, % 注释 tabsize=2, morekeywords={constexpr,nullptr,size_t,override,final}, % 额外C++关键字 morekeywords=[2]{std,cout,cin,vector,string,map}, % 常用库命名空间 numbers=left, % 行号在左 numberstyle=\it\tiny\color{gray}, % 行号样式 stepnumber=1, rulesepcolor=\color{gray!30!white} } \lstdefinestyle{bashstyle}{ backgroundcolor=\color{gray!5}, language=bash, frameround=tftt, frame=shadowbox, keepspaces=true, breaklines, columns=spaceflexible, basicstyle=\ttfamily\small, % 基本文本 keywordstyle=[1]\color{blue!70!black}\bfseries, % shell 关键字 keywordstyle=[2]\color{orange!90!black}, % 常用命令 stringstyle=\color{Purple}, % 字符串 commentstyle=\ttfamily\scriptsize\color{green!40!black}, % 注释 showstringspaces=false, tabsize=2, numbers=left, numberstyle=\it\tiny\color{gray}, stepnumber=1, rulesepcolor=\color{gray!30!white}, morekeywords={if,then,else,elif,fi,for,while,do,done,in,case,esac,break,continue,return,exit}, % shell 控制结构 morekeywords=[2]{echo,cat,grep,awk,sed,ls,cd,pwd,cp,mv,rm,mkdir,rmdir,chmod,chown,tar,zip,unzip,make,g++,gcc,cmake,git,sudo,apt,systemctl}, % 常用命令 } % --------------------------------------------------------------------- % 将表格封装起来 \newcommand{\scoresTable}[8]{ \begin{table} \renewcommand\arraystretch{1.7} \begin{tabularx}{\textwidth}{ |X|X|X|X |X|X|X|X|} \hline \multicolumn{2}{|c|}{预习报告} & \multicolumn{2}{|c|}{实验记录} & \multicolumn{2}{|c|}{分析讨论} & \multicolumn{2}{|c|}{总成绩} \\ \hline \centering#1&\centering#2 &\centering#3 &\centering#4 &\centering#5 &\centering#6 &\centering#7 &{\centering#8} \\ \hline \end{tabularx} \end{table} } \newcommand{\infoTable}[6]{ \begin{table} \renewcommand\arraystretch{1.7} \begin{tabularx}{\textwidth}{|X|X|X|X|} \hline 学院:& #1 &专业:& #2\\ \hline 姓名:& #3 & 学号:\\ \hline 完成时间: & 年级: \\ \hline \end{tabularx} \end{table} } % --------------------------------------------------------------------- % 其他设置 \def\degree{${}^{\circ}$} % 角度 \graphicspath{{./images/}} % 插入图片的相对路径 \allowdisplaybreaks[4] %允许公式跨页 \usetikzlibrary{patterns,decorations.markings,arrows.meta,bending} % TikZ 包的拓展