-
Notifications
You must be signed in to change notification settings - Fork 0
/
template_Daily.tex
118 lines (111 loc) · 3.01 KB
/
template_Daily.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
% 需要 litemize 的统一样式
% 需要一个 BNF 的代码语法格式
\usepackage{textcomp, listings, xcolor-material, enumitem, tabularx,amsmath,multirow, latexsym, amssymb}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm, algorithmicx}
\usepackage[hmargin=1.25in, vmargin=1in]{geometry}
%\usepackage[T1]{fontenc}
\usepackage{hyperref}
\hypersetup{
colorlinks,%
}
% TODO: golang 的语言规范移除单独成文件或包!
\lstdefinelanguage{golang} {
morekeywords={
break,default,func,interface,select,
case,defer,go,map,struct,
chan,else,goto,package,switch,
const,fallthrough,if,range,type,
continue,for,import,return,var,
}, % 关键词
morekeywords=[2] {
bool,byte,complex64,complex128,error,float32,float64,
int,int8,int16,int32,int64,rune,string,
uint,uint8,uint16,uint32,uint64,uintptr,
}, % 预声明类型
morekeywords=[3] {
true,false,iota,nil
}, % 预声明常量,nil 这里视为常量
morekeywords=[4] {
append,cap,close,complex,copy,delete,imag,len,
make,new,panic,print,println,real,recover
}, % 预声明函数
sensitive=true,
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]",
morestring=[b]`,
}
\lstdefinelanguage{EBNF} {
morestring=[b]',
morestring=[b]",
morecomment=[s]{/*}{*/},
}
\lstset{
basicstyle=\small \ttfamily,
stringstyle= \color{MaterialRed},
commentstyle=\itshape \color{MaterialBlueGrey},
tabsize=4,
upquote=true,
showstringspaces=false,
numbers=left,
xleftmargin=1.2\parindent,
xrightmargin=\parindent,
framexleftmargin=\parindent,
% texcl=true,
flexiblecolumns=true,
fontadjust=true,
columns=fullflexible,
breaklines=true,
keepspaces=true,
escapechar=@,
frame=single,
frameround=tttt,
rulecolor=\color{MaterialBlueGrey},
}
\lstdefinestyle{golang}{
language=golang,
keywordstyle= \color{MaterialCyan}, % keywords
keywordstyle=[2]{ \color{MaterialTeal}}, % 预声明类型
keywordstyle=[3]{ \color{MaterialIndigo}}, % 预声明常量
keywordstyle=[4]{ \color{MaterialIndigo}}, % 预声明函数
}
\lstdefinestyle{EBNF}{
language=EBNF,
identifierstyle = \color{MaterialCyan},
}
\setlist{noitemsep}
\setlist[1]{
labelindent=\parindent,
leftmargin=*
}
\setlist[description]{font=\ttfamily}
%\newenvironment*{code}[1][golang]
%{\begin{lstlisting}[style=#1]}
%{\end{lstlisting}}
% \renewcommand{\ldots}{…}
\hypersetup{
colorlinks=true,
allcolors=MaterialCyan,
anchorcolor=MaterialCyan,
pdfauthor=sanfusu,
pdfkeywords=golang,
}
\newcommand{\code}{\lstinline}
\newcommand{\gocode}{\lstinline[language=golang, style=golang]}
\newcommand{\hreftext}[1]{\textsuperscript{{\scriptsize\textrm{[\ref{#1}]}}}}
% TODO language 和 style 可能重复
% FIXME depreciated
\lstnewenvironment{golang}[1][left]{
\lstset{language=golang, style=golang, numbers=#1}
}{}
\lstnewenvironment{EBNF}[1][left]{
\lstset{language=EBNF, style=EBNF, numbers=#1}
}{}
\lstnewenvironment{goblock}[1][left]{
\lstset{language=golang, style=golang, numbers=#1}
}{}
\lstnewenvironment{EBNFblock}[1][left]{
\lstset{language=EBNF, style=EBNF, numbers=#1}
}{}