-
Notifications
You must be signed in to change notification settings - Fork 3
/
macro.tex
153 lines (131 loc) · 5.19 KB
/
macro.tex
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
143
144
145
146
147
148
149
150
151
152
153
\documentclass[a4paper,zihao=-4,UTF8]{ctexart}
\pagestyle{plain}
\date{}
\usepackage[top=1.0in, bottom=1.0in, left=1.25in, right=1.25in]{geometry} % set margins for A4 paper
\usepackage[bodytextleadingratio=1.67]{zhlineskip} % use line skip optimized for Chinese text
\usepackage{zhnumber} % for converting number to Chinese numbering
\usepackage{abstract} % for abstract
\usepackage{indentfirst} % for indenting the first paragraph of each section
\setlength{\parindent}{2em} % set indent for each paragraph
\usepackage{graphicx} % for including images
\usepackage{hyperref} % for setting hyper-ref styles
\hypersetup{
colorlinks=true, % set true if you want colored links
linktoc=all, % set to all if you want both sections and subsections linked
linkcolor=black, % we want all links to be black
urlcolor=black,
citecolor=black
}
\usepackage{booktabs} % for better table rules
\usepackage{multirow} % for multirow cells in tables
\usepackage{enumitem} % for better control of itemize and enumerate
\usepackage{amsmath,amssymb} % for mathematical symbols
\usepackage{algorithm} % for algorithm environment
\usepackage{algpseudocode} % for algorithm pseudocodes
% numbering restarts at each section
\numberwithin{figure}{section}
\numberwithin{table}{section}
\numberwithin{equation}{section}
\numberwithin{algorithm}{section}
\usepackage{xcolor,colortbl} % for colorful tables and better color mixing
\usepackage[capitalize]{cleveref} % for setting cross-referencing names
\crefname{figure}{图}{图}
\crefname{table}{表}{表}
\crefname{equation}{公式}{公式}
\crefname{algorithm}{算法}{算法}
% convenient commands for changing font
\newcommand{\hei}[1]{\heiti\sffamily #1}
\newcommand{\song}[1]{\songti\rmfamily #1}
% set up style for table of contents
\usepackage{titlesec} % for setting styles of section titles
\usepackage{titletoc} % for setting styles of TOC
\renewcommand{\contentsname}{\zihao{2} \heiti 目录}
\addtocontents{toc}{\vspace{\baselineskip}}
\titlecontents{section}[0em]
{\zihao{-4}\bfseries\heiti}
{\contentspush{第\zhnumber{\thecontentslabel}章\quad}}
{\hspace{0em}}
{\titlerule*[2pt]{$.$}\contentspage}
\titlecontents{subsection}[2em]
{\zihao{-4}}{\contentslabel{2em}}
{\hspace{-2em}}
{\titlerule*[0.2pc]{$.$}\contentspage}
\titlecontents{subsubsection}[4em]
{\zihao{-4}}
{\contentslabel{3em}}
{\hspace{-3em}}
{\titlerule*[0.2pc]{$.$}\contentspage}
% update references to Chinese style, font size and type can also be set here
\usepackage{caption} % for tuning caption styles
\titleformat{\section}{\centering\hei\zihao{-2}}{第\chinese{section}章}{1em}{}[]
\titleformat{\subsection}{\song\zihao{3}\bfseries}{\arabic{section}.\arabic{subsection}}{1em}{}[]
\titleformat{\subsubsection}{\song\zihao{-3}\bfseries}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}{1em}{}[]
\renewcommand{\abstractnamefont}{\hei\zihao{-2}}
\renewcommand{\abstracttextfont}{}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}
\renewcommand{\thefigure}{\arabic{section}-\arabic{figure}}
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{section}-\arabic{table}}
\renewcommand{\thealgorithm}{\arabic{section}-\arabic{algorithm}}
\makeatletter
\renewcommand{\ALG@name}{算法} % change title prefix in algorithm environment
\makeatother
\captionsetup{labelsep=space}
% title text
\newcommand{\mytitle}{番茄炒蛋}
% header
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\newcommand{\if@sectionstar}[2]{ % check whether we are in a \section* or \section
\ifnum\value{@instarsection}=0
{#1}
\else
{#2}
\fi
}
\renewcommand{\sectionmark}[1]{\markboth{\if@sectionstar{第\chinese{section}章~}{}#1}{}} % only add prefix "第x章" in header for sections without star (i.e. \section*).
\makeatother
\fancyhead[L]{\song{\zihao{-5}\mytitle}}
\fancyhead[R]{\song{\zihao{-5}\leftmark}}
\renewcommand\headrulewidth{.5pt}
\renewcommand\footrulewidth{0pt}
% for hyper-reference of "section*" to work properly
\usepackage{xparse}
\let\oldsection\section
\makeatletter
\newcounter{@secnumdepth}
\newcounter{@instarsection}
\RenewDocumentCommand{\section}{s o m}{%
\IfBooleanTF{#1}
{\setcounter{@secnumdepth}{\value{secnumdepth}}% Store secnumdepth
\setcounter{secnumdepth}{0}% Print only up to \chapter numbers
\setcounter{@instarsection}{1} % mark that we are in a \section*. See \if@sectionstar.
\oldsection{#3}% \section*
\setcounter{secnumdepth}{\value{@secnumdepth}}}% Restore secnumdepth
{\setcounter{@instarsection}{0} % mark that we are in a \section. See \if@sectionstar.
\IfValueTF{#2}% \section
{\oldsection[#2]{#3}}% \section[.]{..}
{\oldsection{#3}} % \section{..}
}
}
\makeatother
% use GB/T 7714—2015 BibTeX Style
\usepackage{gbt7714}
\bibliographystyle{gbt7714-numerical}
\citestyle{numbers} % use number "[1]" instead of super "^{[1]}"
% set the separate spacing for lists like enum, item
\setlist{
noitemsep,
topsep=0pt,
parsep=0pt,
partopsep=0pt,
leftmargin=*
}
% set the separate spacing for bibs
\setlength{\bibsep}{0pt}
% set the font size in tables
\DeclareCaptionFont{tablefont}{\zihao{5}}
\captionsetup[table]{font=tablefont}
\AtBeginEnvironment{tabular}{\zihao{5}}