-
Notifications
You must be signed in to change notification settings - Fork 2
/
homework.sty
143 lines (118 loc) · 3.94 KB
/
homework.sty
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
135
136
137
138
139
140
141
142
% 模板的风格配置文件
%
% 包的引入
%
\usepackage{fancyhdr} % header,footer的设置
\usepackage{extramarks}
\usepackage{amsmath} % 数学公式
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz} % 绘图
\usepackage{algorithm} % 算法
\usepackage{algorithmicx}
\usepackage{algpseudocode} % 伪代码
\usepackage[UTF8]{ctex} % 支持中文
\usepackage{multirow} % 表格多行
\usepackage{float} % 强制图片在当前位置
\usepackage{enumitem} % 列表缩进
\usepackage{listings} % 代码块
\usepackage{fontspec} % 字体
\usepackage{indentfirst} % 首行自动缩进
\usetikzlibrary{automata,positioning}
%
% 设置页面
%
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in
\linespread{1.1}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt}
\setlength{\parindent}{2em} % 首行缩进两个中文
%
% 用fancyhdr设置header和footer
%
\pagestyle{fancy}
\lhead{\hmwkClass\ : \hmwkTitle}
\rhead{\hmwkAuthorName}
%\chead{\hmwkClass\ (\hmwkClassInstructor\ \hmwkClassTime): \hmwkTitle}
%\chead{\hmwkClass\ : \hmwkTitle}
%\rhead{\firstxmark}
%\lfoot{\lastxmark}
\cfoot{\thepage}
% 设置代码块字体
\setmonofont{Consolas}
%
% %%%%%%%%%%%%%% 自定义的命令 %%%%%%%%%%%%%%
%
% Homework Problem 命令的相关设置
\newcommand{\enterProblemHeader}[1]{
\nobreak\extramarks{}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
}
\newcommand{\exitProblemHeader}[1]{
\nobreak\extramarks{Problem \arabic{#1} (continued)}{Problem \arabic{#1} continued on next page\ldots}\nobreak{}
\stepcounter{#1}
\nobreak\extramarks{Problem \arabic{#1}}{}\nobreak{}
}
\setcounter{secnumdepth}{0}
\newcounter{partCounter}
\newcounter{homeworkProblemCounter}
\setcounter{homeworkProblemCounter}{1}
\nobreak\extramarks{Problem \arabic{homeworkProblemCounter}}{}\nobreak{}
% Homework Problem Environment
% 该环境可以获取一个参数,用于指定问题的编号。如果给定了该参数,则使用它,否则的话会自动生成。
\newenvironment{homeworkProblem}[1][-1]{
\ifnum#1>0
\setcounter{homeworkProblemCounter}{#1}
\fi
\section{Problem \arabic{homeworkProblemCounter}}
\setcounter{partCounter}{1}
\enterProblemHeader{homeworkProblemCounter}
}{
\exitProblemHeader{homeworkProblemCounter}
}
% 封面的相关命令设置
% - 标题
% - 子标题
% - 课程名称
% - 老师
% - 学生信息
\newcommand{\hmwkTitle}{标题}
%\newcommand{\hmwkDueDate}{November 18, 2019}
\newcommand{\hmwkSubTitle}{子标题}
\newcommand{\hmwkClass}{《课程名称》}
\newcommand{\hmwkCompleteTime}{November 23, 2019 at 20:51pm}
\newcommand{\hmwkClassInstructor}{Professor:教授}
\newcommand{\hmwkAuthorName}{\textbf{学生} }
\newcommand{\hmwkAuthorStuID}{\textbf{2017xxxxxxxxxxx} }
% 文档中有用的命令
% Useful for algorithms
\newcommand{\alg}[1]{\textsc{\bfseries \footnotesize #1}}
% For derivatives
\newcommand{\deriv}[1]{\frac{\mathrm{d}}{\mathrm{d}x} (#1)}
% For partial derivatives
\newcommand{\pderiv}[2]{\frac{\partial}{\partial #1} (#2)}
% Integral dx
\newcommand{\dx}{\mathrm{d}x}
% Alias for the Solution section header
\newcommand{\solution}{\textbf{\large Solution}}
% Probability commands: Expectation, Variance, Covariance, Bias
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\newcommand{\Bias}{\mathrm{Bias}}
% 表格单元格中换行
% 使用:\tabincell{c}{单元格内容1 \\ 单元格内容2}
% - c表示居中
% - \\ 表示换行
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%
% 将算法中的\Require替换为Input,将\Ensure替换为Output
%
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm