-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsdureport.cls
134 lines (123 loc) · 4.49 KB
/
sdureport.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
\ProvidesClass{sdureport}[2019/10/01 v0.9 Standard LaTeX Template for Experiment Report in SDU]
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%%%% 承诺书
\newcommand*\sdu@tokens@college{}
\newcommand*\sdu@tokens@course{}
\newcommand*\sdu@tokens@sdudentId{}
\newcommand*\sdu@tokens@name{}
\newcommand*\sdu@tokens@class{}
\newcommand*\sdu@tokens@experimentalTopics{}
\newcommand*\sdu@tokens@experimentalHours{}
\newcommand*\sdu@tokens@date{}
%% Loading Class
\LoadClass[a4paper,12pt]{article}
%% --------------------------- Loading Package ----------------------------
\RequirePackage{ifxetex}
\RequireXeTeX
\ifxetex\else
\ClassError{sdureport}{You must use the `xelatex' driver. Please choose `xelatex'}{Just choose `xelatex', no `pdflatex' or `latex' and so on.}
\fi
\RequirePackage{xeCJK} % 中文
\RequirePackage[texcoord]{eso-pic} % 作图
\RequirePackage{geometry} % 页面布局
\newgeometry{left=1.7cm, right=1.7cm, top=2cm, bottom=2cm}
\RequirePackage{framed} % framed
\RequirePackage{titlesec} % titlesec
% 图片
\RequirePackage{graphicx}
\RequirePackage{float}
\RequirePackage{subfigure}
% 设置代码环境
\RequirePackage{listings}
\RequirePackage{xcolor}
% 列表
\RequirePackage{enumitem}
% 书签
\RequirePackage[breaklinks,colorlinks,linkcolor=black,citecolor=black,urlcolor=black]{hyperref}
%% ----------------------------- setting -----------------------------------
% 字体
\setmainfont{Consolas}
\setmonofont{Courier New}
\setCJKmainfont[Path=fonts/,BoldFont={SourceHanSansHWSC-Bold.otf}]{SourceHanSansHWSC-Regular.otf}
% \titleformat{\section}[block]{\large\bfseries}{}{0em}{\begin{picture}(1,1)\put(-9,26.1){\line(1,0){500}}\end{picture}}
\titleformat{\section}[block]{\large\bfseries}{}{0em}{\begin{picture}(1,1)\put(-9,22.5){\line(1,0){500}}\end{picture}}
\titleformat{\subsection}[block]{\large\bfseries}{\chinese{subsection}}{0.5em}{}
\titleformat{\subsubsection}[block]{}{\arabic{subsection}.\arabic{subsubsection}}{0.5em}{}
% \setlength{\parindent}{0pt}
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{10pt}%
% \setlength{\textfloatsep}{5pt}
\pagestyle{plain} % 页脚
% 代码样式
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
columns=fullflexible,
captionpos=b,
numbers=left,
breaklines=true,
captionpos=b,
tabsize=4,
stringstyle=\ttfamily,
numberstyle= \tiny,
keywordstyle= \color{ blue!70},
commentstyle= \color{red!50!green!50!blue!50},
frame=tb,
rulecolor=\color{gray!35},
backgroundcolor=\color{gray!5},
escapeinside=``, % 英文分号中可写入中文
showstringspaces=false,
xleftmargin=2em, aboveskip=1em,
framexleftmargin=2em,
breaklines = true,
breakatwhitespace = true,
}
%% ----------------------------- define command-----------------------------
% new document
\newenvironment{sduDocument}
{
\begin{center}
\huge{山东大学\underline{~\sdu@tokens@college~}学院 \\
\underline{~\sdu@tokens@course~}课程实验报告}
\end{center}
\begin{framed}
\AddToShipoutPictureBG*{%
\setlength{\unitlength}{1mm}
% \put( 17, -45.6){\line(1,0){176}} % 上横线
\put( 20, -51.0){\makebox(0,0)[l]{学号:\sdu@tokens@sdudentId}}
\put( 77, -55.1){\line(0,1){8.3}}
\put( 80, -51.0){\makebox(0,0)[l]{姓名:\sdu@tokens@name}}
\put( 137, -55.1){\line(0,1){8.3}}
\put( 140, -51.0){\makebox(0,0)[l]{班级:\sdu@tokens@class}}
\put( 17, -55.1){\line(1,0){176}} % 下横线
\put( 20, -59.2){\makebox(0,0)[l]{实验题目:\sdu@tokens@experimentalTopics}}
\put( 17, -63.3){\line(1,0){176}} % 下横线
\put( 20, -67.5){\makebox(0,0)[l]{实验学时:\sdu@tokens@experimentalHours}}
\put( 77, -71.5){\line(0,1){8.1}}
\put( 80, -67.5){\makebox(0,0)[l]{实验日期:\sdu@tokens@date}}
% \put( 17, -75.6){\line(1,0){176}} % 下横线
}
\vspace{18.4mm}
}
{
\end{framed}
% \vspace{4 mm}\begin{center}\huge{附录}\end{center}
}
\newcommand\sduAppendix{\vspace{4 mm}\begin{center}\huge{附录}\end{center}}
\newcommand*\sduCollege[1]{
\renewcommand{\sdu@tokens@college}{#1}}
\newcommand*\sduCourse[1]{
\renewcommand{\sdu@tokens@course}{#1}}
\newcommand*\sduSdudentId[1]{
\renewcommand{\sdu@tokens@sdudentId}{#1}}
\newcommand*\sduName[1]{
\renewcommand{\sdu@tokens@name}{#1}}
\newcommand*\sduClass[1]{
\renewcommand{\sdu@tokens@class}{#1}}
\newcommand*\sduExperimentalTopics[1]{
\renewcommand{\sdu@tokens@experimentalTopics}{#1}}
\newcommand*\sduExexperimentalHours[1]{
\renewcommand{\sdu@tokens@experimentalHours}{#1}}
\newcommand*\sduDate[1]{
\renewcommand{\sdu@tokens@date}{#1}}