|
| 1 | +\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 2 | +\ProvidesPackage{sharzyutil}[2020/10/31 Sharzy's utils] |
| 3 | + |
| 4 | +% infrastructure |
| 5 | +\RequirePackage{fontspec} |
| 6 | +\RequirePackage{amsmath,amsthm,amsfonts,amssymb} |
| 7 | +\RequirePackage{graphicx,float,wrapfig,subcaption} |
| 8 | +\RequirePackage{listings} |
| 9 | +\RequirePackage{algorithm, algpseudocode} |
| 10 | +\RequirePackage{tabularx,booktabs,longtable} |
| 11 | +\RequirePackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{math} |
| 12 | + |
| 13 | +% typography tuning |
| 14 | +\RequirePackage{setspace} |
| 15 | +\RequirePackage{fancyhdr} |
| 16 | +\RequirePackage{chngpage} |
| 17 | +\RequirePackage[shortlabels,inline]{enumitem} |
| 18 | +\RequirePackage[font=small, labelfont=bf]{caption} |
| 19 | + |
| 20 | +% marks, symbols, links |
| 21 | +\RequirePackage{esint,siunitx,bm} |
| 22 | +\RequirePackage[super]{nth} |
| 23 | +\RequirePackage{xcolor} |
| 24 | +\RequirePackage{hyperref} |
| 25 | +\RequirePackage{extramarks} |
| 26 | + |
| 27 | +% macros, TeX internal |
| 28 | +\RequirePackage{xparse,ifthen} |
| 29 | +\RequirePackage{lastpage} |
| 30 | + |
| 31 | +% package setup |
| 32 | +\hypersetup{colorlinks, urlcolor=blue, linkcolor=blue, citecolor=red} |
| 33 | +\setmonofont[Scale=0.9]{Roboto Mono} |
| 34 | + |
| 35 | +\definecolor{keywordcolor}{HTML}{22863a} |
| 36 | +\definecolor{stringcolor}{HTML}{c811ff} |
| 37 | +\definecolor{identifiercolor}{HTML}{6f42c1} |
| 38 | +\lstset{% |
| 39 | + numbers=left, |
| 40 | + stepnumber=1, |
| 41 | + numbersep=5pt, |
| 42 | + tabsize=4, |
| 43 | + breaklines=true, |
| 44 | + breakatwhitespace=true, |
| 45 | + basicstyle=\footnotesize\color{black}\ttfamily, |
| 46 | + numberstyle=\tiny\color{gray}, |
| 47 | + keywordstyle=\color{keywordcolor}, |
| 48 | + stringstyle=\color{stringcolor}, |
| 49 | + commentstyle=\color{gray}, |
| 50 | + identifierstyle=\color{black}, |
| 51 | +} |
| 52 | + |
| 53 | +% customized shortcuts |
| 54 | +\allowdisplaybreaks[1] |
| 55 | +\newcommand{\abs}[1]{\left\lvert #1 \right\rvert} |
| 56 | +\newcommand{\norm}[2][]{\left\lVert #2 \right\rVert_{#1}} |
| 57 | +\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor} |
| 58 | +\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil} |
| 59 | +\newcommand{\inner}[1]{\left\langle #1 \right\rangle} |
| 60 | + |
| 61 | +\DeclareMathOperator*{\argmin}{arg\,min} |
| 62 | +\DeclareMathOperator*{\argmax}{arg\,max} |
| 63 | +\DeclareMathOperator*{\sign}{sign} |
| 64 | + |
| 65 | +\newcommand{\pf}[2]{\frac{\partial #1}{\partial #2}} |
| 66 | +\newcommand{\df}[2]{\frac{\mathrm{d} #1}{\mathrm{d} #2}} |
| 67 | +\let\op=\operatorname |
| 68 | + |
| 69 | +\newcommand{\Li}{\mathrm{Li}} |
| 70 | +\NewDocumentCommand {\E} { o } {% |
| 71 | + \mathbb{E}{\IfNoValueTF{#1} {} {\left[\,#1\,\right]}} |
| 72 | +} |
| 73 | +\RenewDocumentCommand {\Pr} { o } {% |
| 74 | + \mathrm{Pr}{\IfNoValueTF{#1} {} {\left[\,#1\,\right]}} |
| 75 | +} |
| 76 | +\newcommand{\N}{\mathbb{N}} |
| 77 | +\newcommand{\R}{\mathbb{R}} |
| 78 | +\newcommand{\Rp}{\mathbb{R}_+} |
| 79 | +\newcommand{\Z}{\mathbb{Z}} |
| 80 | +\newcommand{\Zp}{\mathbb{Z}_+} |
| 81 | +\newcommand{\Q}{\mathbb{Q}} |
| 82 | +\newcommand{\Qp}{\mathbb{Q}_+} |
| 83 | +\newcommand{\Var}{\mathrm{Var}} |
| 84 | +\newcommand{\T}[1]{#1^{\mathsf T}} |
| 85 | +\newcommand{\e}{\mathrm e} |
| 86 | +\def\d{\,\mathrm{d}} |
| 87 | +\let\+=\mathbf |
| 88 | + |
| 89 | +\newcommand{\TODO}[1][]{\textbf{\textcolor{red}{TODO #1}}} |
| 90 | + |
| 91 | +% localization for Chinese |
| 92 | +\ifdefined\useCN |
| 93 | + \RequirePackage{xeCJK} |
| 94 | + |
| 95 | + \newCJKfontfamily\song{FandolSong} |
| 96 | + \newCJKfontfamily\fangsong{FandolFang} |
| 97 | + \newCJKfontfamily\kai{FandolKai} |
| 98 | + \newCJKfontfamily\hei{FandolHei} |
| 99 | + |
| 100 | + \setCJKmainfont{FandolSong} |
| 101 | + \setCJKmonofont{FandolHei} |
| 102 | + \setCJKsansfont{FandolHei} |
| 103 | + |
| 104 | + \RequirePackage{indentfirst} |
| 105 | + |
| 106 | + \renewcommand{\abstractname}{摘要} |
| 107 | + \newcommand{\releasemode}{\renewcommand{\TODO}[1][1]{}} |
| 108 | + \renewcommand*\contentsname{\centering 目录} |
| 109 | + \renewcommand*{\proofname}{\bf 证明} |
| 110 | + \captionsetup[figure]{name={图}} |
| 111 | + \captionsetup[table]{name={表}} |
| 112 | + |
| 113 | + \ifdefined\theorem\else |
| 114 | + \newtheorem{theorem}{定理}[section] |
| 115 | + \newtheorem*{theorem*}{定理} |
| 116 | + \newtheorem{definition}[theorem]{定义} |
| 117 | + \newtheorem*{definition*}{定义} |
| 118 | + \newtheorem{lemma}[theorem]{引理} |
| 119 | + \newtheorem*{lemma*}{引理} |
| 120 | + \newtheorem{property}{性质}[theorem] |
| 121 | + \newtheorem*{property*}{性质} |
| 122 | + \newtheorem{corollary}[theorem]{推论} |
| 123 | + \newtheorem*{corollary*}{推论} |
| 124 | + \newtheorem{question}[theorem]{问题} |
| 125 | + \newtheorem*{question*}{问题} |
| 126 | + \fi |
| 127 | +\else |
| 128 | + \ifdefined\theorem\else |
| 129 | + \newtheorem{theorem}{Theorem}[section] |
| 130 | + \newtheorem*{theorem*}{Theorem} |
| 131 | + \newtheorem{definition}[theorem]{Definition} |
| 132 | + \newtheorem*{definition*}{Definition} |
| 133 | + \newtheorem{lemma}[theorem]{Lemma} |
| 134 | + \newtheorem*{lemma*}{Lemma} |
| 135 | + \newtheorem{property}{Property}[theorem] |
| 136 | + \newtheorem*{property*}{Property} |
| 137 | + \newtheorem{corollary}[theorem]{Corollary} |
| 138 | + \newtheorem*{corollary*}{Corollary} |
| 139 | + \newtheorem{question}[theorem]{Problem} |
| 140 | + \newtheorem*{question*}{Problem} |
| 141 | + \fi |
| 142 | +\fi |
0 commit comments