├── LICENSE ├── README.md ├── chw.cls ├── cpp.bib ├── cpp.cls ├── cpp.tex ├── hw.cls ├── hw.pdf └── hw.tex /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Homework Template 2 | 3 | ## LaTeX Template for Homework 4 | 5 | This repository establishes a LaTeX template for homework. 6 | 7 | ### Features 8 | 9 | * Beautiful yet simple typesetting. 10 | * Fully customizable problem sets. 11 | 12 | ### Key Commands 13 | 14 | * `\documentclass{hw}` specifies this template. 15 | 16 | * `\newproblemset{problem}{Problem}{Problems}` 17 | 18 | Creats a problem set named `Problems`, where each problem is named `Problem`. This command creates arbitrary kinds of problems set. For example, you may create problem sets with name of `Questions` a/o `Computer Exercises` as well. 19 | 20 | Technically, this command creates two environment, i.e. `problem` and `problem*`, which will be explained in details below. Besides, it creates a command `\makeproblem` which outputs the title of `Problems` as well. 21 | 22 | * `problem` environments (caveat: `problem` is defined by the first argument of the previous command `\newproblemset`): 23 | 24 | * ```latex 25 | \begin{problem}[optional problem subtitle] 26 | problem description here. 27 | \end{problem} 28 | ``` 29 | 30 | Note that equations within `problem` will be numbered in the format of `Px.y`, where `P` is the first character of `Problem`, `x` is the number of problem, `y` is the number of equation. 31 | 32 | Replacing `problem` with `problem*` gives title without auto numbering and equations with plain format (only the number of equation). 33 | 34 | * `answer` environment: 35 | 36 | ```latex 37 | \begin{answer} 38 | answer here. 39 | \end{answer} 40 | ``` 41 | 42 | Similarly, using `answer*` corresponding to `problem*` environment gives equations with plain format. 43 | 44 | * Other metadata necessary for homework: 45 | 46 | ```latex 47 | \course 48 | {LaTeX Practice} 49 | {Fall 2019} 50 | {Local University} 51 | 52 | \assignment 53 | {Assignment 1} 54 | {Get Ready for LaTeX} 55 | 56 | \student 57 | {Student Name} 58 | {2019000000} 59 | {Student Affliation} 60 | {name.student@mail.com} 61 | ``` 62 | 63 | You may leave the second argument of `\assignment` empty. Other fields are mandatory. 64 | 65 | * Chinese is supported. Default SinoType fonts installed on macOS are default. You may modify font names specified in `hw.cls`. 66 | 67 | * Please refer to `hw.tex` for usage and `hw.pdf` for demo. 68 | 69 | ### Downloads 70 | 71 | - Click [here](https://github.com/SXKDZ/homework-template/releases) to download 72 | 73 | ### Licence 74 | 75 | Apache 2.0 76 | 77 | ## LaTeX作业模板 78 | 79 | 本仓库为LaTeX作业模板。 80 | 81 | ### 特性 82 | 83 | - 简洁优美的排版 84 | - 完全自定义题目设置 85 | 86 | ### 核心命令 87 | 88 | - `\documentclass{hw}` 使用本模板。 89 | 90 | - `\newproblemset{problem}{Problem}{Problems}` 91 | 92 | 该命令创建了一个题库,命名为`Problems`,其中每道题被命名为`Problem`。可以根据实际情况对题库的名称进行自定义,如`Questions`或者`Computer Exercises`。 93 | 94 | 该命令定义了两个环境(environment),即`problem` 和`problem*`。此外,该命令还定义了一个命令`\makeproblem`用于输出`Problems`标题。 95 | 96 | - `problem` 环境使用方法(注意:此处`problem`是由`\newproblemset`的第一个参数定义而来) 97 | 98 | - ```latex 99 | \begin{problem}[可选问题副标题] 100 | 问题描述 101 | \end{problem} 102 | ``` 103 | 104 | 注意:`problem`环境中的公式将被自动编号为`Px.y`,其中`P`是`Problem`的首字母,`x`是问题的序号,`y`是公式的序号。将`problem`替换为`problem*`得到不自动编号标题的版本,且公式将使用普通格式(仅含公式的序号)。 105 | 106 | - `answer`环境: 107 | 108 | ```latex 109 | \begin{answer} 110 | 答案写在这里 111 | \end{answer} 112 | ``` 113 | 114 | 类似地,对`problem*`使用`answer*`环境。 115 | 116 | - 用下列命令定义作业的其他定义元数据: 117 | 118 | ```latex 119 | \course 120 | {LaTeX Practice} 121 | {Fall 2019} 122 | {Local University} 123 | 124 | \assignment 125 | {Assignment 1} 126 | {Get Ready for LaTeX} 127 | 128 | \student 129 | {Student Name} 130 | {2019000000} 131 | {Student Affliation} 132 | {name.student@mail.com} 133 | ``` 134 | 135 | `\assignment`的第二个参数可留空。其他参数是必要的。 136 | 137 | - 支持中文,默认使用macOS中的SinoType系列字体。请在`hw.cls`中修改有关字体名称。 138 | 139 | - 请查阅 `hw.tex`以获取相关使用方法,并且查阅 `hw.pdf` 查看演示效果。 140 | 141 | ### 下载 142 | 143 | - 点击[这里](https://github.com/SXKDZ/homework-template/releases)下载 144 | 145 | ### 开源协议 146 | 147 | 本模板遵循Apache 2.0协议。 -------------------------------------------------------------------------------- /chw.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[2007/10/19] 2 | \ProvidesClass{chw}[2019/09/25 v0.0.2 The LaTeX template for homework (Chinese version)] 3 | \typeout{Document Class `chw' v0.0.2 by SXKDZ (2020/02/17)} 4 | 5 | \LoadClass[zihao=5,linespread=1.3,a4paper,oneside]{ctexart} 6 | 7 | \ctexset{punct=banjiao} 8 | 9 | \RequirePackage{xeCJK} 10 | \xeCJKsetcharclass{`①}{`⑩}{1} 11 | 12 | \setCJKmainfont[BoldFont=FZHei-B01S, ItalicFont=FZKai-Z03S,Mapping=fullwidth-stop]{FZShuSong-Z01S} 13 | \setCJKmonofont[Mapping=fullwidth-stop]{FZKai-Z03S} 14 | 15 | \setCJKfamilyfont{kai}[Mapping=fullwidth-stop]{FZKai-Z03S} 16 | \setCJKfamilyfont{hei}[Mapping=fullwidth-stop]{FZHei-B01S} 17 | \setCJKfamilyfont{cuhei}[Mapping=fullwidth-stop]{FZDaHei-B02S} 18 | \setCJKfamilyfont{songhei}[Mapping=fullwidth-stop]{FZSongHei-B07S} 19 | 20 | \newcommand{\kaiti}{\CJKfamily{kai}} 21 | \renewcommand{\heiti}{\CJKfamily{hei}} 22 | \newcommand{\cuheiti}{\CJKfamily{cuhei}} 23 | \newcommand{\songheiti}{\CJKfamily{songhei}} 24 | 25 | \RequirePackage[top=30mm,bottom=25mm,left=30mm,right=30mm]{geometry} 26 | 27 | \RequirePackage[xetex,unicode]{hyperref} 28 | \hypersetup{colorlinks} 29 | 30 | \RequirePackage{url} 31 | \PassOptionsToPackage{hyphens}{url} 32 | \def\UrlFont{\ttfamily} 33 | \newcommand{\mailto}[1]{\href{mailto:#1}{\texttt{#1}}} 34 | 35 | \RequirePackage{amsmath,amssymb,amsfonts,mathrsfs,bm} 36 | %\everymath{\displaystyle} 37 | \RequirePackage[amsmath,thmmarks,hyperref]{ntheorem} 38 | \RequirePackage{lmodern} 39 | \DeclareMathOperator*{\argmin}{argmin} 40 | \DeclareMathOperator*{\argmax}{argmax} 41 | 42 | \RequirePackage{graphicx,float} 43 | 44 | \RequirePackage{listings,xcolor} 45 | \lstset{ 46 | backgroundcolor=\color{white}, 47 | basicstyle=\zihao{5}\ttfamily, 48 | columns=flexible, 49 | breakatwhitespace=false, 50 | breaklines=true, 51 | captionpos=b, 52 | frame=single, 53 | numbers=left, 54 | numbersep=5pt, 55 | showspaces=false, 56 | showstringspaces=false, 57 | showtabs=false, 58 | stepnumber=1, 59 | rulecolor=\color{black}, 60 | tabsize=2, 61 | texcl=true, 62 | title=\lstname, 63 | escapeinside={\%*}{*)}, 64 | extendedchars=false, 65 | mathescape=true, 66 | xleftmargin=3em, 67 | xrightmargin=3em, 68 | } 69 | \lstset{ 70 | numberstyle=\color{gray}, 71 | keywordstyle=\color{blue}, 72 | commentstyle=\itshape\color{green!40!black}, 73 | stringstyle=\color{orange}, 74 | } 75 | 76 | \RequirePackage[linesnumbered,ruled,vlined]{algorithm2e} 77 | \DontPrintSemicolon 78 | \SetKwInOut{KwIn}{输入} 79 | \SetKwInOut{KwOut}{输出} 80 | \newcommand{\commentstyle}[1]{\texttt{#1}} 81 | \SetCommentSty{commentstyle} 82 | \renewcommand{\algorithmcfname}{算法} 83 | 84 | \RequirePackage{booktabs} 85 | 86 | \RequirePackage{fancyhdr} 87 | 88 | \setlength{\headheight}{15pt} 89 | \setlength{\footskip}{15pt} 90 | 91 | \pagestyle{fancy} 92 | \fancyhf{} 93 | \lhead{\hw@assignmentnumber} 94 | \chead{\kaiti \hw@coursetitle~(\hw@semester)} 95 | \rhead{\hw@university} 96 | \renewcommand{\headrulewidth}{0.75pt} 97 | 98 | \cfoot{\thepage} 99 | \renewcommand{\footrulewidth}{0pt} 100 | \setlength{\footskip}{30pt} 101 | 102 | \RequirePackage{multirow,dcolumn,float} 103 | 104 | \newcommand{\newproblemset}[4]{ 105 | \newcounter{#1}[section] 106 | \@namedef{make#1}{\section*{#3}\renewcommand{\theequation}{#4\arabic{#1}.\arabic{equation}}} 107 | 108 | \newenvironment{#1}[1][\empty]{ 109 | \refstepcounter{#1} 110 | \setcounter{equation}{0} 111 | 112 | \ifx\empty##1\subsection*{#2 \csname the#1\endcsname}\else\subsection*{#2 \csname the#1\endcsname: ##1}\fi 113 | \kaiti}{} 114 | 115 | \newenvironment{#1*}[1][\empty]{ 116 | \ifx\empty##1\subsection*{#2}\else\subsection*{#2: ##1}\fi 117 | \kaiti}{} 118 | } 119 | 120 | \newenvironment{answer}{ 121 | \vspace*{2mm} 122 | \noindent 123 | \textbf{解}\enskip}{} 124 | 125 | \newenvironment{proof}{ 126 | \vspace*{2mm} 127 | \noindent 128 | \textbf{证明}\enskip}{} 129 | 130 | \newenvironment{answer*}{ 131 | \renewcommand{\theequation}{\arabic{equation}} 132 | \vspace*{2mm} 133 | \noindent 134 | \textbf{解}\enskip}{} 135 | 136 | \newcommand{\oldmaketitle}{\maketitle} 137 | \renewcommand{\maketitle}{ 138 | \pagestyle{fancy} 139 | \thispagestyle{plain} 140 | \newpage 141 | \setcounter{page}{1} 142 | \noindent 143 | \begin{center} 144 | \framebox[\textwidth][c]{ 145 | \vbox{ 146 | \vspace{2mm} 147 | 148 | \makebox[0pt][l]{\quad {\kaiti \hw@coursetitle~(\hw@semester)}}% 149 | \hfill 150 | \makebox[0pt][r]{\today \quad} 151 | 152 | \vspace{3mm} 153 | \begin{center} 154 | \ifx\hw@assignmenttitle\empty\textbf{\Large \hw@assignmentnumber}\else\textbf{\Large \hw@assignmentnumber:~\hw@assignmenttitle}\fi 155 | \end{center} 156 | 157 | \vspace{3mm} 158 | \makebox[\textwidth][c]{\hw@studentname} 159 | \makebox[\textwidth][c]{\hw@studentnumber} 160 | \makebox[\textwidth][c]{\hw@studentaffliation} 161 | \makebox[\textwidth][c]{\mailto{\hw@studentemail}} 162 | 163 | \vspace{2mm} 164 | } 165 | } 166 | \end{center} 167 | \vspace*{1mm} 168 | } 169 | 170 | \def\hw@coursetitle{} 171 | \def\hw@semester{} 172 | \def\hw@university{} 173 | \def\hw@assignmenttitle{} 174 | \def\hw@assignmentnumber{} 175 | \def\hw@studentname{} 176 | \def\hw@studentnumber{} 177 | \def\hw@studentaffliation{} 178 | \def\hw@studentemail{} 179 | \newcommand{\course}[3]{% 180 | \def\hw@coursetitle{#1} 181 | \def\hw@semester{#2} 182 | \def\hw@university{#3} 183 | } 184 | \newcommand{\assignment}[2]{% 185 | \def\hw@assignmentnumber{#1} 186 | \def\hw@assignmenttitle{#2} 187 | } 188 | \newcommand{\student}[4]{% 189 | \def\hw@studentname{#1} 190 | \def\hw@studentnumber{#2} 191 | \def\hw@studentaffliation{#3} 192 | \def\hw@studentemail{#4} 193 | } 194 | -------------------------------------------------------------------------------- /cpp.bib: -------------------------------------------------------------------------------- 1 | @article{Bottou:2018cv, 2 | author = {Bottou, L{\'e}on and Curtis, Frank E. and Nocedal, Jorge}, 3 | title = {{Optimization Methods for Large-Scale Machine Learning}}, 4 | journal = {SIAM Review}, 5 | year = {2018}, 6 | volume = {60}, 7 | number = {2}, 8 | pages = {223--311}, 9 | month = may 10 | } 11 | -------------------------------------------------------------------------------- /cpp.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[2007/10/19] 2 | \ProvidesClass{cpp}[2020/05/19 v0.0.1 The LaTeX template for Chinese papers] 3 | \typeout{Document Class `cpp' v0.0.1 by SXKDZ (2020/05/19)} 4 | 5 | \LoadClass[11pt,linespread=1.3,a4paper,twoside]{ctexart} 6 | 7 | \ctexset{punct=banjiao} 8 | 9 | \RequirePackage{xeCJK} 10 | \xeCJKsetcharclass{`①}{`⑩}{1} 11 | 12 | \setCJKmainfont[BoldFont=FZHei-B01S, ItalicFont=FZKai-Z03S,Mapping=fullwidth-stop]{FZShuSong-Z01S} 13 | \setCJKmonofont[Mapping=fullwidth-stop]{FZKai-Z03S} 14 | 15 | \setCJKfamilyfont{kai}[Mapping=fullwidth-stop]{FZKai-Z03S} 16 | \setCJKfamilyfont{hei}[Mapping=fullwidth-stop]{FZHei-B01S} 17 | \setCJKfamilyfont{cuhei}[Mapping=fullwidth-stop]{FZDaHei-B02S} 18 | \setCJKfamilyfont{songhei}[Mapping=fullwidth-stop]{FZSongHei-B07S} 19 | 20 | \newcommand{\kaiti}{\CJKfamily{kai}} 21 | \renewcommand{\heiti}{\CJKfamily{hei}} 22 | \newcommand{\cuheiti}{\CJKfamily{cuhei}} 23 | \newcommand{\songheiti}{\CJKfamily{songhei}} 24 | 25 | \RequirePackage[top=30mm,bottom=30mm,left=30mm,right=30mm]{geometry} 26 | 27 | \RequirePackage[xetex,unicode]{hyperref} 28 | \hypersetup{colorlinks} 29 | 30 | \RequirePackage{url} 31 | \PassOptionsToPackage{hyphens}{url} 32 | \def\UrlFont{\ttfamily} 33 | \newcommand{\mailto}[1]{\href{mailto:#1}{\texttt{#1}}} 34 | 35 | \RequirePackage{amsmath,amssymb,amsfonts,mathrsfs,bm} 36 | \RequirePackage[amsmath,thmmarks,hyperref]{ntheorem} 37 | \RequirePackage{lmodern} 38 | 39 | \DeclareMathOperator*{\argmin}{argmin} 40 | \DeclareMathOperator*{\argmax}{argmax} 41 | \def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}} 42 | 43 | \RequirePackage{accents} 44 | % left arrow over text 45 | \DeclareRobustCommand{\cev}[1]{% 46 | \mathpalette\do@cev{#1}% 47 | } 48 | \newcommand{\do@cev}[2]{% 49 | \fix@cev{#1}{+}% 50 | \reflectbox{$\m@th#1\vec{\reflectbox{$\fix@cev{#1}{-}\m@th#1#2\fix@cev{#1}{+}$}}$}% 51 | \fix@cev{#1}{-}% 52 | } 53 | \newcommand{\fix@cev}[2]{% 54 | \ifx#1\displaystyle 55 | \mkern#23mu 56 | \else 57 | \ifx#1\textstyle 58 | \mkern#23mu 59 | \else 60 | \ifx#1\scriptstyle 61 | \mkern#22mu 62 | \else 63 | \mkern#22mu 64 | \fi 65 | \fi 66 | \fi 67 | } 68 | 69 | \RequirePackage[authoryear,compress]{natbib} 70 | 71 | \RequirePackage{fancyhdr,lastpage} 72 | 73 | \setlength{\headheight}{40pt} 74 | \setlength{\footskip}{20pt} 75 | 76 | \newcommand*{\tabref}[1]{\tablename~\ref{#1}} 77 | \newcommand*{\figref}[1]{\figurename~\ref{#1}} 78 | \newcommand*{\algoref}[1]{算法~\ref{#1}} 79 | \newcommand*{\listingref}[1]{\lstlistingname~\ref{#1}} 80 | \renewcommand*{\eqref}[1]{公式(\ref{#1})} 81 | \newcommand*{\secref}[1]{第~\ref{#1}~节} 82 | \newcommand*{\chapref}[1]{第~\ref{#1}~章} 83 | 84 | \RequirePackage[skip=3pt,width=.8\textwidth,font=small,labelsep=space]{caption} 85 | 86 | \RequirePackage{subcaption} 87 | \DeclareCaptionLabelFormat{quanjiaoparens}{({#2})} 88 | \captionsetup[sub]{font=small,labelformat=quanjiaoparens} 89 | 90 | \RequirePackage{graphicx,float} 91 | \RequirePackage{multirow,booktabs} 92 | 93 | \RequirePackage{listings} 94 | \RequirePackage[dvipsnames]{xcolor} 95 | \lstset{ 96 | backgroundcolor = \color{white}, 97 | basicstyle = \zihao{5}\ttfamily, 98 | columns = flexible, 99 | breakatwhitespace = false, 100 | breaklines = true, 101 | captionpos = b, 102 | frame = single, 103 | numbers = left, 104 | numbersep = 5pt, 105 | showspaces = false, 106 | showstringspaces = false, 107 | showtabs = false, 108 | stepnumber = 1, 109 | rulecolor = \color{black}, 110 | tabsize = 2, 111 | texcl = true, 112 | title = \lstname, 113 | escapeinside = {\%*}{*)}, 114 | extendedchars = false, 115 | mathescape = true, 116 | xleftmargin = 3em, 117 | xrightmargin = 3em, 118 | } 119 | \lstset{ 120 | numberstyle = \color{gray}, 121 | keywordstyle= \color{blue}, 122 | commentstyle= \itshape\color{green!40!black}, 123 | stringstyle = \color{orange}, 124 | } 125 | 126 | \renewcommand{\lstlistingname}{代码} 127 | 128 | \RequirePackage[linesnumbered,ruled,vlined]{algorithm2e} 129 | \renewcommand{\algorithmcfname}{算法} 130 | \SetKwInput{KwIn}{输入} 131 | \SetKwInput{KwOut}{输出} 132 | \newcommand{\commentstyle}[1]{\texttt{#1}} 133 | \SetCommentSty{commentstyle} 134 | 135 | \RequirePackage{hyperref} 136 | \colorlet{CPPlinkcolor}{violet!85!black} 137 | \colorlet{CPPcitecolor}{YellowOrange!85!black} 138 | \colorlet{CPPurlcolor}{Aquamarine!85!black} 139 | \hypersetup{ 140 | linkcolor = CPPlinkcolor, 141 | citecolor = CPPcitecolor, 142 | urlcolor = CPPurlcolor, 143 | colorlinks = true, 144 | breaklinks = true 145 | } 146 | 147 | \RequirePackage{authblk} 148 | \renewcommand\Authsep{\quad} 149 | \renewcommand\Authand{\quad} 150 | \renewcommand\Authands{\quad} 151 | %\renewcommand\Authfont{\kaiti} 152 | \renewcommand\Affilfont{\kaiti} 153 | \setlength{\affilsep}{0.5em} 154 | 155 | \def\@email{} 156 | \def\@subtitle{} 157 | \newcommand{\email}[1]{\renewcommand{\@email}{#1}} 158 | \newcommand{\subtitle}[1]{\renewcommand{\@subtitle}{#1}} 159 | 160 | \newcommand{\oldmaketitle}{\maketitle} 161 | \renewcommand{\maketitle}{ 162 | \begin{center} 163 | \vspace*{1.5\baselineskip} 164 | {\huge\cuheiti{\noindent\ignorespaces\@title}\par} 165 | \ifx\@subtitle\empty{}\else{\vskip .5em{\Large\textbf{\noindent\ignorespaces\@subtitle}\par}}\fi 166 | \vskip 1.5em 167 | \ifnum\value{authors}=0{}\else{{\noindent\ignorespaces\@author\par}}\fi 168 | \ifx\@email\empty{}\else{\noindent\ignorespaces\mailto\@email\par}\fi 169 | \end{center} 170 | \vskip 2em 171 | \thispagestyle{empty} 172 | } 173 | -------------------------------------------------------------------------------- /cpp.tex: -------------------------------------------------------------------------------- 1 | \documentclass{cpp} 2 | 3 | \title{我是标题} 4 | \subtitle{我是副标题} 5 | \author[1]{张三} 6 | \author[2]{李四} 7 | \author[2]{王五} 8 | \affil[1]{单位1} 9 | \affil[2]{单位2} 10 | \email{hello@world.com} 11 | 12 | \begin{document} 13 | 14 | \maketitle 15 | 16 | \begin{abstract} 17 | 本文提出了一种方法。 18 | \end{abstract} 19 | 20 | \section{标题1} 21 | \citep{Bottou:2018cv} 22 | 23 | \bibliographystyle{unsrtnat} 24 | \bibliography{cpp.bib} 25 | 26 | \end{document} 27 | -------------------------------------------------------------------------------- /hw.cls: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e}[2007/10/19] 2 | \ProvidesClass{hw}[2019/09/26 v0.0.2 The LaTeX template for homework] 3 | \typeout{Document Class `hw' v0.0.2 by SXKDZ (2019/09/26)} 4 | 5 | \LoadClass[zihao=5,scheme=plain,linespread=1.2,a4paper,oneside]{ctexart} 6 | 7 | \ctexset{punct=banjiao} 8 | 9 | \RequirePackage{xeCJK} 10 | \xeCJKsetcharclass{`①}{`⑩}{1} 11 | 12 | \setCJKmainfont[BoldFont=STHeiti, ItalicFont=STKaiti,Mapping=fullwidth-stop]{STSong} 13 | \setCJKmonofont[Mapping=fullwidth-stop]{STKaiti} 14 | 15 | \setCJKfamilyfont{kai}[Mapping=fullwidth-stop]{STKaiti} 16 | \setCJKfamilyfont{hei}[Mapping=fullwidth-stop]{STHeiti} 17 | 18 | \newcommand{\kaiti}{\CJKfamily{kai}} 19 | \renewcommand{\heiti}{\CJKfamily{hei}} 20 | 21 | \RequirePackage[top=30mm,bottom=25mm,left=30mm,right=30mm]{geometry} 22 | 23 | \RequirePackage[xetex,unicode]{hyperref} 24 | \hypersetup{colorlinks} 25 | 26 | \RequirePackage{url} 27 | \PassOptionsToPackage{hyphens}{url} 28 | \def\UrlFont{\ttfamily} 29 | \newcommand{\mailto}[1]{\href{mailto:#1}{\texttt{#1}}} 30 | 31 | \RequirePackage{amsmath,amssymb,amsfonts,mathrsfs,bm} 32 | \RequirePackage[amsmath,thmmarks,hyperref]{ntheorem} 33 | \RequirePackage{lmodern} 34 | \DeclareMathOperator*{\argmin}{argmin} 35 | \DeclareMathOperator*{\argmax}{argmax} 36 | 37 | \RequirePackage{graphicx,float} 38 | 39 | \RequirePackage{listings,xcolor} 40 | \lstset{ 41 | backgroundcolor=\color{white}, 42 | basicstyle=\zihao{5}\ttfamily, 43 | columns=flexible, 44 | breakatwhitespace=false, 45 | breaklines=true, 46 | captionpos=b, 47 | frame=single, 48 | numbers=left, 49 | numbersep=5pt, 50 | showspaces=false, 51 | showstringspaces=false, 52 | showtabs=false, 53 | stepnumber=1, 54 | rulecolor=\color{black}, 55 | tabsize=2, 56 | texcl=true, 57 | title=\lstname, 58 | escapeinside={\%*}{*)}, 59 | extendedchars=false, 60 | mathescape=true, 61 | xleftmargin=3em, 62 | xrightmargin=3em, 63 | } 64 | \lstset{ 65 | numberstyle=\color{gray}, 66 | keywordstyle=\color{blue}, 67 | commentstyle=\itshape\color{green!40!black}, 68 | stringstyle=\color{orange}, 69 | } 70 | 71 | \RequirePackage[linesnumbered,ruled,vlined]{algorithm2e} 72 | \SetKwInput{KwIn}{Input} 73 | \SetKwInput{KwOut}{Output} 74 | \newcommand{\commentstyle}[1]{\texttt{#1}} 75 | \SetCommentSty{commentstyle} 76 | 77 | \RequirePackage{booktabs} 78 | 79 | \RequirePackage{fancyhdr} 80 | 81 | \setlength{\headheight}{15pt} 82 | \setlength{\footskip}{15pt} 83 | 84 | \pagestyle{fancy} 85 | \fancyhf{} 86 | \lhead{\hw@assignmentnumber} 87 | \chead{\textit{\hw@coursetitle~(\hw@semester)}} 88 | \rhead{\hw@university} 89 | \renewcommand{\headrulewidth}{0.75pt} 90 | 91 | \cfoot{\thepage} 92 | \renewcommand{\footrulewidth}{0pt} 93 | 94 | \RequirePackage{multirow,dcolumn,float} 95 | 96 | \RequirePackage{stringstrings} 97 | 98 | \newcommand{\newproblemset}[3]{ 99 | \newcounter{#1}[section] 100 | \@namedef{make#1}{\section*{#3}\renewcommand{\theequation}{\substring{#2}{1}{1}\arabic{#1}.\arabic{equation}}} 101 | 102 | \newenvironment{#1}[1][\empty]{ 103 | \refstepcounter{#1} 104 | \setcounter{equation}{0} 105 | 106 | \ifx\empty##1\subsection*{#2 \csname the#1\endcsname}\else\subsection*{#2 \csname the#1\endcsname: ##1}\fi 107 | \kaiti}{} 108 | 109 | \newenvironment{#1*}[1][\empty]{ 110 | \setcounter{equation}{0} 111 | \renewcommand{\theequation}{\arabic{equation}} 112 | \ifx\empty##1\subsection*{#2}\else\subsection*{#2: ##1}\fi 113 | \kaiti}{} 114 | } 115 | 116 | \newenvironment{answer}{ 117 | \vspace*{2mm} 118 | \noindent 119 | \textit{Answer:}\enskip}{} 120 | 121 | \newenvironment{answer*}{ 122 | \renewcommand{\theequation}{\arabic{equation}} 123 | \vspace*{2mm} 124 | \noindent 125 | \textit{Answer:}\enskip}{} 126 | 127 | \newcommand{\oldmaketitle}{\maketitle} 128 | \renewcommand{\maketitle}{ 129 | \pagestyle{fancy} 130 | \thispagestyle{plain} 131 | \newpage 132 | \setcounter{page}{1} 133 | \noindent 134 | \begin{center} 135 | \framebox[\textwidth][c]{ 136 | \vbox{ 137 | \vspace{2mm} 138 | 139 | \makebox[0pt][l]{\quad \textit{\hw@coursetitle~(\hw@semester)}}% 140 | \hfill 141 | \makebox[0pt][r]{\today \quad} 142 | 143 | \vspace{3mm} 144 | \begin{center} 145 | \ifx\hw@assignmenttitle\empty\textbf{\Large \hw@assignmentnumber}\else\textbf{\Large \hw@assignmentnumber: 146 | \hw@assignmenttitle}\fi 147 | \end{center} 148 | 149 | \vspace{3mm} 150 | \makebox[\textwidth][c]{\hw@studentname} 151 | \makebox[\textwidth][c]{\hw@studentnumber} 152 | \makebox[\textwidth][c]{\hw@studentaffliation} 153 | \makebox[\textwidth][c]{\mailto{\hw@studentemail}} 154 | 155 | \vspace{2mm} 156 | } 157 | } 158 | \end{center} 159 | \vspace*{1mm} 160 | } 161 | 162 | \def\hw@coursetitle{} 163 | \def\hw@semester{} 164 | \def\hw@university{} 165 | \def\hw@assignmenttitle{} 166 | \def\hw@assignmentnumber{} 167 | \def\hw@studentname{} 168 | \def\hw@studentnumber{} 169 | \def\hw@studentaffliation{} 170 | \def\hw@studentemail{} 171 | \newcommand{\course}[3]{% 172 | \def\hw@coursetitle{#1} 173 | \def\hw@semester{#2} 174 | \def\hw@university{#3} 175 | } 176 | \newcommand{\assignment}[2]{% 177 | \def\hw@assignmentnumber{#1} 178 | \def\hw@assignmenttitle{#2} 179 | } 180 | \newcommand{\student}[4]{% 181 | \def\hw@studentname{#1} 182 | \def\hw@studentnumber{#2} 183 | \def\hw@studentaffliation{#3} 184 | \def\hw@studentemail{#4} 185 | } 186 | -------------------------------------------------------------------------------- /hw.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SXKDZ/homework-template/5b3d73b7e8e39d56f5d10c26749e49b467a45def/hw.pdf -------------------------------------------------------------------------------- /hw.tex: -------------------------------------------------------------------------------- 1 | \documentclass{hw} 2 | 3 | \course 4 | {LaTeX Practice} 5 | {Fall 2019} 6 | {Local University} 7 | 8 | \assignment 9 | {Assignment 1} 10 | {Get Ready for LaTeX} 11 | 12 | \student 13 | {Student Name} 14 | {2019000000} 15 | {Student Affliation} 16 | {name.student@mail.com} 17 | 18 | \begin{document} 19 | 20 | \newproblemset{problem}{Problem}{Problems} 21 | \newproblemset{computerexercise}{Computer Exercise}{Computer Exercises} 22 | 23 | \maketitle 24 | 25 | \makeproblem 26 | 27 | \begin{problem*}[无标号问题] 28 | 在一个10类的模式识别问题中,有3类单独满足多类情况1,其余的类别满足多类情况2。问该模式识别问题所需判别函数的最少数目是多少? 29 | \end{problem*} 30 | 31 | \begin{answer*} 32 | 答案写在此处。 33 | \end{answer*} 34 | 35 | \begin{problem} 36 | 37 | Consider the following decision rule for a two-category one-dimensional problem: 38 | Decide \(\omega_1\) if \(x > \theta\); otherwise decide \(\omega_2\). 39 | (a) Show the probability of error for this rule is given by 40 | \[ 41 | P(\text{error}) = P\left(\omega_{1}\right) \int_{-\infty}^{\theta} p\left(x | \omega_{1}\right) \mathrm{d}x+P\left(\omega_{2}\right) \int_{\theta}^{\infty} p\left(x | \omega_{2}\right) \mathrm{d}x. 42 | \] 43 | (b) By differentiating, show that a necessary condition to minimize \(P(\text{error})\) is that satisfy 44 | \[ 45 | p(\theta | \omega_1) P(\omega_1) = p(\theta | \omega_2) P(\omega_2). 46 | \] 47 | (c) Does this equation define \(\theta\) uniquely? 48 | (d) Give an example where a value of \(\theta\) satisfying the equation actually maximizes the probability of error. 49 | 50 | \end{problem} 51 | 52 | \begin{answer} 53 | 考虑分类错误率的条件概率: 54 | \begin{equation} 55 | P(\text{error} | x) = 56 | \begin{cases} 57 | p(\omega_1 | x), & \text{if we decide }\omega_2, \\ 58 | p(\omega_2 | x), & \text{otherwise.} 59 | \end{cases} 60 | \label{eq:error-conditional-probability} 61 | \end{equation} 62 | 63 | 根据式 (\ref{eq:error-conditional-probability}) 对\(x\)进行积分,可得: 64 | \begin{align} 65 | P(\text{error}) & = \int_{-\infty}^\infty P(\text{error} | x) p(x) \mathrm{d} x \\ 66 | & = P(x \leq \theta , x \text{ is } \omega_1 ) + P(x > \theta , x \text{ is } \omega_2 ) \\ 67 | & = p(x \leq \theta | \omega_1) P(\omega_1) + p(x > \theta | \omega_2) P(\omega_2) \\ 68 | & = P\left(\omega_{1}\right) \int_{-\infty}^{\theta} p\left(x | \omega_{1}\right) \mathrm{d} x + P\left(\omega_{2}\right) \int_{\theta}^{\infty} p\left(x | \omega_{2}\right) \mathrm{d} x. \label{eq:error-probability} 69 | \end{align} 70 | \end{answer} 71 | 72 | \makecomputerexercise 73 | 74 | Several of the computer exercises will rely on the following data. 75 | 76 | 此处还可以插入一些说明。 77 | 78 | \begin{computerexercise} 79 | Illustrate the fact that the average of a large number of independent random variables will approximate a Gaussian by the following: 80 | (a) Write a program to generate n random integers from a uniform distribution \(U(x_l, x_u)\). 81 | 82 | (b) Now write a routine to choose \(x_l\) and \(x_u\) randomly, in the range \(-100 \leq x_l < x_u \leq 100\), and \(n\) (the number of samples) randomly in the range \(0 < n \leq 1000\). 83 | (c) Generate and plot a histogram of the accumulation of \(10^4\) points sampled as just described. 84 | (d) Calculate the mean and standard deviation of your histogram, and plot it. 85 | (e) Repeat the above for \(10^5\) and for \(10^6\). Discuss your results. 86 | \end{computerexercise} 87 | 88 | \begin{answer} 89 | 答案写在此处,如代码~\ref{lst:python}~所示。 90 | 91 | \begin{lstlisting}[language=python,caption=代码测试,label=lst:python] 92 | print('Hello, world!') 93 | \end{lstlisting} 94 | 95 | 为了得到\(p(x | \omega) \sim \mathcal{N}(0, 1)\): 96 | \begin{equation} 97 | p(x | \omega_i) = \frac{1}{\sqrt{2 \pi} \sigma}\exp{\left[- \frac{1}{2} \left(\frac{x - \mu}{\sigma}\right)^2\right]} 98 | \label{eq:Gaussian-distribution} 99 | \end{equation} 100 | 101 | 对式 (\ref{eq:Gaussian-distribution}),我们可以进行一些计算。 102 | 103 | \end{answer} 104 | 105 | \end{document} 106 | --------------------------------------------------------------------------------