├── LICENSE ├── README.md ├── README.pdf ├── SUSTechHomework.cls └── example.tex /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Ziqin WANG 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SUSTech Homework LaTeX Template 2 | 3 | [_Click to read this file in PDF format_](https://github.com/ziqin/LaTeX-SUSTechHomework/blob/master/README.pdf) 4 | 5 | ## Introduction 6 | 7 | This is a LaTeX template designed for writing ~~endless~~ assignments in SUSTech. The design style is inspired by [Henry's work](https://github.com/Henrycobaltech/SUSTechHomeworkTemplate). 8 | 9 | ## Usage 10 | 11 | 1. Download `SUSTechHomework.cls`, and place it in the same directory with your LaTeX document; 12 | 2. Set the `documentclass` to `SUSTechHomework`. 13 | 14 | ## Example 15 | 16 | ```latex 17 | % !TEX TS-program = xelatex 18 | % !TEX encoding = UTF-8 19 | \documentclass[onecolumn,oneside]{SUSTechHomework} 20 | 21 | \author{Name} 22 | \sid{11110000} 23 | \title{Homework 1} 24 | \coursecode{CS101} 25 | \coursename{Introduction to Computer Science} 26 | 27 | \begin{document} 28 | \maketitle 29 | 30 | \section{Introduction} 31 | 32 | Hello World! 33 | 34 | \end{document} 35 | ``` 36 | 37 | ## Tips 38 | 39 | - Currently you need to compile your document with XeLaTeX; 40 | - You may enjoy using [Overleaf](https://www.overleaf.com), [Papeeria](https://www.papeeria.com), or other online LaTeX writing systems. -------------------------------------------------------------------------------- /README.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ziqin/LaTeX-SUSTechHomework/b646599543163d03fd0cdcc4b65995ba2c966f51/README.pdf -------------------------------------------------------------------------------- /SUSTechHomework.cls: -------------------------------------------------------------------------------- 1 | % !TEX TS-program = xelatex 2 | % !TEX encoding = UTF-8 3 | % !Mode:: "TeX:UTF-8" 4 | 5 | \NeedsTeXFormat{LaTeX2e} 6 | \ProvidesClass{SUSTechHomework}[2019/03/09 SUSTech Homework LaTeX class] 7 | 8 | \LoadClass[a4paper]{article} 9 | 10 | \RequirePackage{newpxtext,newpxmath} 11 | \RequirePackage{geometry} 12 | \RequirePackage{graphicx} 13 | \RequirePackage{amsmath} 14 | \RequirePackage{listings} 15 | \RequirePackage{xeCJK} 16 | \RequirePackage[T1]{fontenc} 17 | \RequirePackage{fancyhdr} 18 | \RequirePackage{lastpage} 19 | \RequirePackage{booktabs} 20 | \RequirePackage{parskip} 21 | \RequirePackage[hidelinks]{hyperref} 22 | % \RequirePackage{courier} 23 | \RequirePackage{inconsolata} 24 | 25 | % \DeclareOption{titlepage}{} 26 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} 27 | \ProcessOptions\relax 28 | 29 | \def\sid#1{\gdef\@sid{#1}} 30 | \def\@sid{\@latex@error{No \noexpand\sid given}\@ehc} 31 | 32 | \def\coursename#1{\gdef\@coursename{#1}} 33 | \def\@coursename{\@latex@error{No \noexpand\coursename given}\@ehc} 34 | 35 | \def\coursecode#1{\gdef\@coursecode{#1}} 36 | \def\@coursecode{\@latex@error{No \noexpand\coursecode given}\@ehc} 37 | 38 | \def\univ#1{\gdef\@univ{#1}} 39 | \def\@univ{\@latex@error{No \noexpand\univ given}\@ehc} 40 | 41 | \univ{SUSTech} 42 | 43 | \geometry{ 44 | left=.85in, 45 | right=.85in, 46 | top=1in, 47 | bottom=.8in, 48 | bindingoffset=.15in 49 | } 50 | 51 | \setlength{\parindent}{0pt} 52 | \renewcommand{\baselinestretch}{1.1} 53 | 54 | \newcommand{\mktitle}{ 55 | \noindent\makebox[\linewidth]{ 56 | \begin{minipage}[b]{.7\linewidth} 57 | {\Large\textsf{\@coursecode~$\cdot$~\@coursename}}\\\\ 58 | {\Huge\textbf\@title} 59 | \end{minipage}\hfill 60 | \begin{minipage}[b]{.3\linewidth} 61 | \large\begin{flushright} 62 | \@author~/~\@sid\\ 63 | \vspace{.5em} 64 | \@date 65 | \end{flushright} 66 | \end{minipage} 67 | } 68 | \noindent\rule{\linewidth}{1.5pt} 69 | \if@twocolumn\vspace{.5em}\fi 70 | \thispagestyle{empty} 71 | } 72 | 73 | \if@twocolumn 74 | \renewcommand{\maketitle}{\twocolumn[\mktitle]} 75 | \else 76 | \renewcommand{\maketitle}{\mktitle} 77 | \fi 78 | 79 | \pagestyle{fancy} 80 | \fancyhf{} 81 | \renewcommand{\headrulewidth}{0.3pt} 82 | 83 | \if@twoside 84 | \fancyhead[EL,OR]{\thepage~/~\pageref{LastPage}} 85 | \fancyhead[EC]{\textsc{\@coursename}} 86 | \fancyhead[ER]{\@title} 87 | \fancyhead[OL]{\@univ~$\circ$~\@coursecode} 88 | \fancyhead[OC]{\textsc{\@author $\cdot$ \@sid}} 89 | \else 90 | \lhead{\textsc{\@author $\cdot$ \@sid}} 91 | \chead{\textsc{\@coursename~$\circ$~\@title}} 92 | \rhead{\thepage~/~\pageref{LastPage}} 93 | \fi 94 | 95 | \lstset{ 96 | numbers=left, 97 | basicstyle=\ttfamily, 98 | frame=shadowbox, 99 | columns=flexible, 100 | xleftmargin=1.5em, 101 | xrightmargin=1em 102 | } 103 | -------------------------------------------------------------------------------- /example.tex: -------------------------------------------------------------------------------- 1 | % !TEX TS-program = xelatex 2 | % !TEX encoding = UTF-8 3 | % !Mode:: "TeX:UTF-8" 4 | 5 | \documentclass[onecolumn,oneside]{SUSTechHomework} 6 | 7 | \usepackage{blindtext} 8 | 9 | \author{姓名} 10 | \sid{11110000} 11 | \title{Homework 1} 12 | \coursecode{CS101} 13 | \coursename{Introduction to Computer Science} 14 | 15 | \begin{document} 16 | \maketitle 17 | 18 | \blindtext 19 | 20 | \blinddocument 21 | \end{document} 22 | --------------------------------------------------------------------------------