forked from mikespook/Learning-Go-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go-setup.tex
147 lines (127 loc) · 5.38 KB
/
go-setup.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
\linespread{1.3}
\setmonofont[Path=fonts/,Scale=0.90,BoldFont={SourceCodePro-Bold}]{SourceCodePro-Regular}
%% Fontfeatures after setting the mono font to keep
%% lstlisting fonts happy
%%\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Path=fonts/,ItalicFont={PTS56F},BoldFont={PTS75F}]{PTS55F}
\def\inputGnumericTable{}
\setulmarginsandblock{2.5cm}{2.5cm}{*}
\checkandfixthelayout
\setlength{\textwidth}{1.1\textwidth}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.7ex plus 0.5ex minus 0.2ex}
%% list of answers
\newlistof{listofex}{ex}{练习清单}
\newlistentry{exercise}{ex}{0}
\renewcommand{\tocheadstart}{}
\renewcommand{\aftertoctitle}{\pagestyle{blocks}}
\renewcommand{\aftertoctitle}{\thispagestyle{empty}\afterchaptertitle\pagestyle{blocks}}
%%\renewcommand{\printtoctitle}[1]{}
\renewcommand{\contentsname}{目录}
\renewcommand{\tocmark}{\markboth{\myfamily \typename: \contentsname}{\myfamily \contentsname}}
%% new print the titles as section not as chapter, that explains
%% why the page is headerless. the page style is empty
%% lof
\renewcommand{\lofheadstart}{}
\renewcommand{\afterloftitle}{\thispagestyle{blocks}}
\renewcommand{\printloftitle}[1]{\section*{#1}}
\renewcommand{\lotmark}{\markboth{\myfamily \typename:
\contentsname}{\myfamily \listfigurename}}
%% lot
\renewcommand{\lotheadstart}{}
\renewcommand{\afterlottitle}{\thispagestyle{blocks}}
\renewcommand{\printlottitle}[1]{\section*{#1}}
\renewcommand{\lofmark}{\markboth{\myfamily \typename:
\contentsname}{\myfamily \listtablename}}
%% ex
\renewcommand{\exheadstart}{}
\renewcommand{\afterextitle}{\thispagestyle{blocks}}
\renewcommand{\printextitle}[1]{\section*{#1}}
\renewcommand{\exmark}{\markboth{\myfamily \typename: \contentsname}{\myfamily 练习清单}}
\renewcommand{\bibname}{参考文献}
\nobibintoc
\renewcommand*{\indexmark}{%
\markboth{\myfamily \typename{} \thechapter: \indexname}{\myfamily\indexname}%
}
\onecolindexfalse %% doesn't do its things as advertised
\noindexintoc
\makeindex
%% make quote print italics
\newcommand{\qquote}{{\scalefont{4.00}{``}}}
\expandafter\def\expandafter\quote\expandafter{\quote\em}
%% Listings
\newfontfamily\listingsfont[Path=fonts/,Scale=0.90,BoldFont={SourceCodePro-Bold}]{SourceCodePro-Regular}
\lstdefinelanguage{Go}
{morekeywords={append,break,cap,case,chan,const,continue,copy,default,defer,else,fallthrough,%
for,func,go,goto,if,import,interface,len,make,map,new,package,range,return,select,%
struct,switch,type,var,% % types
uint8,uint16,uint32,uint64,int8,int16,int32,int64,float32,float64,byte,%
complex,complex128,complex64,%
int,rune,uint,bool,uintptr,string,%
error,iota,%
},%
otherkeywords={<-,!,;,\{,\}},% %% nog beter maken
sensitive=true,%
morecomment=[l]{//},%
morecomment=[s]{/*}{*/},%
morecomment=[n]{(*}{*)},%
morestring=[b]",%
morestring=[b]',%
morestring=[b]`,%
}[]%
\lstset{language=Go,inputencoding=utf8,extendedchars=false,texcl,escapechar=\|,basicstyle=\ttfamily,keywordstyle=\bfseries,numbers=none,numberblanklines=false,showstringspaces=false,breaklines=true,numberstyle=\small\ttfamily,xleftmargin=\parindent,xrightmargin=1em,linewidth=0.98\linewidth}
%,literate={"}{\textasciiquote}{1}}
\newcommand{\coderemark}[1]{\sffamily\normalfont\qquad$\leftarrow \textit{\footnotesize #1}$}
%% Cite style
%%\bibpunct{[}{]}{;}{s}{,}{,}
%% Exercises
\renewcommand{\ExerciseHeaderTitle}{\ExerciseTitle}
\renewcommand{\ExerciseHeaderLabel}{}
\renewcommand{\ExerciseName}{} %% was 'Exercise'
\renewcommand{\ExerciseHeaderNB}{\theExercise}
%% This one is actually used
\renewcommand{\ExerciseHeader}{\vspace{.7ex}\noindent\textbf{Q\theExercise}. (\number\ExerciseDifficulty) \ExerciseTitle\quad%
\addcontentsline{ex}{exercise}{\numberline{\theExercise}(\number\ExerciseDifficulty) \ExerciseTitle}}
\renewcommand{\AnswerHeader}{\vspace{.7ex}\noindent\textbf{A\theExercise}. (\number\ExerciseDifficulty) \ExerciseTitle\quad}
%% Style commands
\newcommand{\func}[1]{\texttt{#1}}
\newcommand{\key}[1]{\texttt{#1}}
\newcommand{\type}[1]{\texttt{#1}}
\newcommand{\prog}[1]{\texttt{#1}}
\newcommand{\flag}[1]{\textit{#1}}
\newcommand{\dir}[1]{\texttt{#1}}
\newcommand{\file}[1]{\texttt{#1}}
\newcommand{\var}[1]{\texttt{#1}}
\newcommand{\rem}[1]{\texttt{\textit{#1}}}
\newcommand{\package}[1]{{\textit{#1}}}
\newcommand{\first}[2]{#1\index{#2}}
\newcommand{\error}[1]{\texttt{#1}}
\newcommand{\pr}{\%} %% a prompt (also bold)
\newcommand{\user}[1]{\textbf{#1}} %% text a user should type
\newcommand{\userinput}[1]{\textit{#1}} %% text a user should choose
\newcommand{\gorelease}[1]{\texttt{#1}}
%% Footnotes
\renewcommand*{\thefootnote}{\textbf{\emph\alph{footnote}}}
%% Epigraph
\newcommand{\epi}[2]{\epigraph{#1}{#2}}
\setlength{\epigraphwidth}{1.2\epigraphwidth}
%% Margin notes
\setmarginnotes{0.04\stockwidth}{0.12\stockwidth}{\onelineskip}
\newcommand{\gomarginpar}[1]{%
\marginpar{\itshape\small#1}}
%% typeset text in margin and index arg 2
\newcommand{\gomarginindex}[2]{\gomarginpar{#1}\index{#2}}
\newcommand{\gopher}{%
\begin{figure}[H]%
\includegraphics[scale=0.20, width=.70\marginparwidth]{fig/gopher.png}%
\end{figure}%
}
\setCJKmainfont{文泉驿微米黑}
\newcommand{\ubrace}[3]{%
\draw [thick,decorate,decoration={brace,amplitude=4pt},xshift=0pt,yshift=0pt] %
(#1) -- (#2) node [black,midway,below=4pt,xshift=0pt] %
{\longremark{#3}}; %
}
%% fixes
\newcommand{\exdisfix}{\vspace{1ex}}