You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

293 lines
9.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

%===============================================================
% npreport.cls
% npreport: Lab Report of Network Practice in NUDT
% version 1.0 (2022年10月)
% 国防科技大学网络相关实习实验报告LaTeX模板
% LaTeX Template for Lab Report of Network Practice in NUDT
% by Jing Xia
% 部分参考了“清华大学近代物理实验实验报告LaTeX模板非官方
% https://thu.services/templates/
%===============================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{npreport}
[2021/03/28 v1.0
The LaTeX Template for Lab Report of Network Practice in NUDT]
\typeout{Document Class `npreport' v1.0 by Jing Xia (2022/10)}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexart}}
\ProcessOptions\relax
\LoadClass[twocolumn,twoside,a4paper,UTF8]{ctexart}
%===============================================================
% packages
%===============================================================
\usepackage{fancyhdr}
\usepackage{amsmath,amsfonts,amssymb,graphicx} % EPS 图片支持
\usepackage{subfigure} % 使用子图形
% \usepackage{indentfirst} % 中文段落首行缩进
\usepackage{bm} % 公式中的粗体字符(用命令\boldsymbol
\usepackage{amsthm} % 使用定理
\usepackage{booktabs} % 使用表格
\usepackage{titlesec}
% \usepackage{ccaption}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{environ}
\usepackage{lmodern}
\usepackage{unicode-math}
\usepackage[sort&compress]{gbt7714}
\usepackage{anyfontsize}
\usepackage[colorlinks,bookmarksnumbered,urlcolor=blue,
linkcolor=black,citecolor=red,plainpages=false]{hyperref}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{calc}
%===============================================================
% 基础格式
%===============================================================
% 字体
\setmainfont{Times New Roman}
% 字号设置
\newcommand{\erhao}{\fontsize{22pt}{\baselineskip}\selectfont}
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont}
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont}
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont}
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont}
\newcommand{\myxiaoliuhao}{\fontsize{6.5pt}{\baselineskip}\selectfont}
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont}
\DeclareRobustCommand{\ttfamily}{\fontencoding{T1}\fontfamily{lmtt}\selectfont}
% 图表
\renewcommand{\tablename}{}
\renewcommand{\figurename}{}
% \captiondelim{123}
\setlength{\abovecaptionskip}{2pt}
\setlength{\belowcaptionskip}{2pt}
\DeclareCaptionFont{heiti}{\heiti}
\captionsetup{format=plain,labelformat=simple,
labelsep=space,justification=centering,
font={small,heiti}}
\captionsetup[sub]{font=footnotesize}
\DeclareMathSizes{10.5}{10}{6.8}{4.2}
\setlength{\abovedisplayskip}{2.5mm}
\setlength{\belowdisplayskip}{2.5mm}
% 页边距(符合中文刊物习惯)
\usepackage{lettrine}
\setlength{\parindent}{2em}
\setlength{\voffset}{-4mm}
\setlength{\parskip}{1pt}
\renewcommand{\baselinestretch}{1.15} %定义行间距1.15
\renewcommand\section{\@startsection {section}{1}{\z@}%
{1.5ex }%
{1.5ex}%
{\normalfont\bfseries\sihao}}
\renewcommand\subsection{\@startsection {subsection}{1}{\z@}%
{-1pt }%
{1pt}%
{\normalfont\bfseries\heiti\wuhao}}
\renewcommand\subsubsection{\@startsection {subsubsection}{1}{\z@}%
{-1pt }%
{1pt}%
{\normalfont\wuhao}}
\usepackage{geometry}
\newgeometry{
top=25.4mm, bottom=22.5mm, left=20mm, right=20mm,
headsep=5mm, headheight=10mm, footskip=10mm,
}
\savegeometry{mastergeometry}
\loadgeometry{mastergeometry}
\setlength{\columnsep}{10mm}
% 枚举
\newcommand*\bigcdot{\mathpalette\bigcdot@{1.2}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\usepackage{enumitem}
\setenumerate[1]{itemsep=0pt,partopsep=0pt,parsep=\parskip,topsep=0pt}
\setitemize[1]{itemsep=0pt,partopsep=0pt,parsep=\parskip,topsep=0pt,label={$\bigcdot$}}
%===============================================================
% 文档风格
%===============================================================
% 停用CTex模板文档参数
\title{}
\author{}
\date{}
% 全局图片目录
\graphicspath{{./figures/}}
% npreport 内置文档参数
\newcommand{\coursename}[1]{ % 课程名称
\def\@coursename{#1}}
\newcommand{\studentname}[1]{ % 学生姓名
\def\@studentname{#1}}
\newcommand{\studentid}[1]{ % 学号
\def\@studentid{#1}}
\newcommand{\studenttype}[1]{ % 培养类型
\def\@studenttype{#1}}
\newcommand{\studentgrade}[1]{% 年级
\def\@studentgrade{#1}}
\newcommand{\major}[1]{ % 专业
\def\@major{#1}}
\newcommand{\school}[1]{ % 所属学院
\def\@school{#1}}
\newcommand{\teacher}[1]{ % 授课教员
\def\@teacher{#1}}
% 封面
\newcommand{\makecover}{
\thispagestyle{empty}
\begin{tikzpicture}[overlay,remember picture]
\node[anchor=center,scale=3] at
([yshift=8.5cm]current page.center) {\heiti\ \ \ \ \ };
\node[anchor=center,scale=1.6,inner sep=0pt] at
([yshift=5cm]current page.center) {课程名称:\underline{\quad\quad\@coursename\quad\quad}};
\node[anchor=center,scale=1.3,inner sep=0pt] at
([yshift=-1cm]current page.center) {
\renewcommand{\arraystretch}{0.8}
\begin{tabular}{b{1.7cm}b{2.5cm}<{\centering}b{2cm}p{2.5cm}<{\centering}}
学  员: & \@studentname &  学  号: & \@studentid \\
\cline{2-2} \cline{4-4}
\\
培养类型: & \@studenttype &  年  级: & \@studentgrade \\
\cline{2-2} \cline{4-4}
\\
专  业: & \multicolumn{3}{c}{\@major} \\
\cline{2-4}
\\
所属学院: & \@school &  授课教员: & \@teacher \\
\cline{2-2} \cline{4-4}
\end{tabular}
\renewcommand{\arraystretch}{1}
};
\node at ([xshift=0.5cm,yshift=-9.5cm]current page.center)
{\includegraphics[width=6cm]{logo-long}};
\end{tikzpicture}
\clearpage{\thispagestyle{empty}\cleardoublepage}
}
% 目录
\ctexset{contentsname=目~~~~录}
\renewcommand\tableofcontents{%
\onecolumn
\thispagestyle{empty}
\pdfbookmark[0]{\contentsname}{toc}
\centerline{\erhao\heiti\contentsname}
\vspace*{0.5em}
\@starttoc{toc}
\clearpage{\thispagestyle{empty}\cleardoublepage}
}
\addtocontents{toc}{\let\string\CTEX@spaceChar\relax}
% 页眉页脚
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CO]{{\footnotesize \@coursename \quad 实验报告}}
\fancyhead[CE]{{\footnotesize \leftmark}}
\fancyhead[LE,RO]{~~~\footnotesize\thepage ~~~}
\lfoot{}
\cfoot{}
\rfoot{}
% 摘要 & 关键词
\NewEnviron{Abstract}{
\setcounter{page}{1}
\twocolumn[
\begin{@twocolumnfalse}
\begin{center}
\parbox{\textwidth}{
\wuhao\setlength{\parindent}{2em}
\newlength{\somelength}
{\heiti\wuhao \makebox[\widthof{【关键词】}][s]{【摘 要】}}
{\xiaowuhao
\BODY
}
{\heiti\wuhao \makebox[\widthof{【关键词】}][s]{【关键词】}}
\heiti \wuhao \@keyword
\vspace*{1.5em}}
\end{center}
\end{@twocolumnfalse}
]
}
\newcommand{\keyword}[1]{
\def\@keyword{#1}
}
%===============================================================
% 代码着色支持
%===============================================================
\usepackage[breakable,minted]{tcolorbox}
\newtcblisting{code}[1][]{
center,
width=\linewidth,
listing only,
breakable=true,
minted language=#1,
extras={frame empty},
fontupper=\linespread{1.3}\footnotesize,
% minted style=colorful,
minted options={ %自动移除前置空白、制表为4字符、mathhe和||内的不处理
fontfamily=tt,
autogobble,
tabsize=2,
startinline,
breaklines,
mathescape
}
}
%===============================================================
% 参考文献
%===============================================================
\renewcommand\refname{\heiti\wuhao\centerline{参考文献}\global\def\refname{参考文献}}
\vskip 12pt
\let\OLDthebibliography\thebibliography
\renewcommand\thebibliography[1]{
\OLDthebibliography{#1}
\setlength{\parskip}{0pt}
\setlength{\itemsep}{0pt plus 0.3ex}
}
\newcommand{\makebibliography}[1]{
{
\vspace*{1em}
\renewcommand{\baselinestretch}{0.9}
\liuhao
\bibliographystyle{gbt7714-numerical}
\bibliography{#1}
}
}