forked from mikespook/Learning-Go-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocksbook.cls
249 lines (223 loc) · 6.97 KB
/
blocksbook.cls
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{blocksbook}[2006/06/10 v0.1
Layout with blocks]
\RequirePackage{ifthen}
\RequirePackage{scalefnt}
\newenvironment{display}{\def\FrameCommand{\hskip\parindent}%%
\MakeFramed{\advance\hsize-\width\FrameRestore}%%
\vspace*{-2ex}\small\begin{alltt}}%
{\end{alltt}\vspace*{-2ex}\endMakeFramed}
\newenvironment{lbar}[1][]{%
\def\FrameCommand{\rightskip=\parindent\hskip\parindent\vrule width 1pt \hspace{10pt}}%
\MakeFramed{\rightskip=\parindent\advance\hsize-\width\FrameRestore\noindent\hskip-0.6ex}%
{%
\ifthenelse{\equal{#1}{}}{}{\hskip0.6ex\normalfont\myfamily\myheadseries{#1}\\\\}}%
}%
{\endMakeFramed}
%% supported options:
%% draft - place DRAFT in the left hand side and give to memoir
%% serif - don't use sans serif fonts
%% headbold - display the head also in bold
%% bold - use also bold in description, etc
%% Class Options Defaults
\newcommand{\headplaceholder}{}
\newcommand{\myheadplaceholder}{}
\newcommand{\myfamily}{\sffamily}
\newcommand{\myseries}{\bfseries}
\newcommand{\myheadseries}{}
\newcommand{\mytitlepage}{}
\newcounter{bottomline}
\newcommand{\typename}{}
\newlength{\gnat}
\DeclareOption{draft}{
\renewcommand{\myheadplaceholder}
{\myfamily\bfseries\headplaceholder{}\normalfont\scshape{} draft}
\PassOptionsToClass{draft}{memoir}
}
\DeclareOption{serif}{
\renewcommand{\myfamily}{\rmfamily}
}
\DeclareOption{headbold}{
\renewcommand{\myheadseries}{\bfseries}
}
\DeclareOption{bold}{
\renewcommand{\myheadseries}{\myseries}
}
\DeclareOption{bottomline}{
\setcounter{bottomline}{1}
}
\DeclareOption{titlepagenr}{
\renewcommand{\mytitlepage}{
\addtolength{\fboxsep}{0.5ex}
\framebox{\myfamily\thepage}
}
}
%% Pass all unknown options to memoir
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{memoir}}
\ProcessOptions
\LoadClass{memoir}
\setsecnumdepth{chapter} %% nice :-)
\makepagestyle{blocks}
\aliaspagestyle{chapter}{empty}
\aliaspagestyle{part}{empty}
\setlength{\headwidth}{\textwidth}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\makepsmarks{blocks}{
\let\@mkboth\markboth
\def\chaptermark##1{\markboth{\myfamily \typename{} \thechapter: ##1}{\myfamily##1}} %% left & right marks
\def\sectionmark##1{\markright{ %% right mark
\ifnum \c@secnumdepth>\z@
\normalfont\myfamily\myheadseries\thesection{ }
\fi
\normalfont\myheadseries\myfamily##1}}
}
\makerunningwidth{blocks}{\headwidth}
\makeevenhead{blocks}{
\addtolength{\fboxsep}{0.5ex}
\hspace{-0.35cm}
\framebox{\myfamily\thepage}
% hack to get spacing correct
\vspace{-0.1mm}
\hrule
}{
\raisebox{0.2ex}{\parbox{\headwidth}{
\settowidth{\gnat}{\thepage}
\hspace{\gnat}
\hspace{1em}
{ }\normalfont\leftmark %
\vspace{1.1mm}
}}
}{\myheadplaceholder}
\makeoddhead{blocks}{\myheadplaceholder}
{
\raisebox{0.2ex}{\parbox{\headwidth}{
\raggedleft
\normalfont\rightmark %
\hspace{1.2em}
\settowidth{\gnat}{\thepage}
\hspace{\gnat}
\vspace{1.1mm}
} }
}
{
\addtolength{\fboxsep}{0.5ex}
\framebox{\myfamily{\thepage}}
%% hack to get spacing correct
\vspace{-0.14mm}
\hspace{-1.2mm}
\hrule
%% \rule{\linewidth}{0.1mm}
}
\ifthenelse{\value{bottomline} = 1}%
{\makefootrule{blocks}{\headwidth}{\normalrulethickness}{\footruleskip}}%
{}
%% centreert de header wat meer als ik dit uit zet, anders wordt ie
%% echt breed
%%\makeheadposition{blocks}{flushright}{flushleft}{flushright}{flushleft}
\addtolength{\headsep}{\headsep}
%% chapter style
\makechapterstyle{blocks}{%
\renewcommand{\chapterheadstart}{\vspace*{-5em}}
\renewcommand{\printchaptername}{}
\renewcommand{\typename}{\chaptername}
\renewcommand{\chapternamenum}{}
%% \renewcommand{\printchapternonum}{%
%% \addtolength{\fboxsep}{2ex}
%% \framebox{\myseries\myfamily\scalefont{6.0}{*}}
%% \afterchapternum
%%}
\renewcommand{\printchapternum}{%
\addtolength{\fboxsep}{2ex} %% \numtoName
\framebox{\myseries\myfamily\scalefont{6.0}{\thechapter}}
}
\renewcommand{\afterchapternum}{\hskip 5mm}
\renewcommand{\printchaptertitle}[1]{%
\normalfont\raggedright\HUGE{{\myfamily##1}}%
\chaptermark{\myfamily##1}%
}
\renewcommand{\afterchaptertitle}{%
\vskip\onelineskip \vskip\onelineskip}
}
% appendix style
\addtodef{\appendix}{}{\renewcommand{\typename}{\appendixname}}
%% part style
\makepagestyle{part}
\renewcommand{\partname}{}
\renewcommand{\partnumfont}{\myseries\myfamily}
\renewcommand{\parttitlefont}{\myseries\myfamily}
\renewcommand{\printparttitle}[1]{\vspace{10ex}\parttitlefont\scalefont{3.0}{#1}}
\renewcommand{\printpartnum}{%
\raggedright
\addtolength{\fboxsep}{5ex}
\framebox{\partnumfont\scalefont{6.0}{\thepart}}
}
%% bibliography style
\renewcommand{\bibsection}{%
\chapter{\bibname}
\bibmark
\ifnobibintoc\else
\phantomsection
\addcontentsline{toc}{chapter}{\bibname}
\fi
\prebibhook
\markboth{\myfamily \typename{} \thechapter: \bibname}{\myfamily\bibname}
}
%% index style
\makeatletter
\renewenvironment{theindex}{%
\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\ifonecolindex
\onecolumn
\chapter*{\indexname}
\preindexhook
\else
\setlength{\columnseprule}{\indexrule}%
\setlength{\columnsep}{\indexcolsep}%
%% \twocolumn[\@makeschapterhead{\indexname} %% disabled
%% \preindexhook]%
\fi
\indexmark
\ifnoindexintoc\else
\phantomsection
\addcontentsline{toc}{chapter}{\indexname}%
\fi
\thispagestyle{chapter}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\let\item\@idxitem}%
{\if@restonecol\onecolumn\else\twocolumn\fi}
\makeatother
%% title page style - always odd... XXX
\makepagestyle{tblocks}
\makeoddfoot{tblocks}{}{\mytitlepage}{}
%% section style
\setsecheadstyle{\raggedright\myfamily\LARGE}
\setbeforesecskip{-\onelineskip}
\setaftersecskip{\onelineskip}
%% subsection
\setsubsecheadstyle{\sethangfrom{\noindent ##1}\raggedright\myfamily\slshape}
%%\setsubsecheadstyle{\raggedleft\myfamily\thesubsection\raggedright\myfamily\hskip 1em}
\setbeforesubsecskip{-\onelineskip}
\setaftersubsecskip{\onelineskip}
%% subsubsection
\setsubsubsecheadstyle{\sethangfrom{\noindent ##1}\raggedright\myfamily\slshape}
\setbeforesubsubsecskip{-\onelineskip}
\setaftersubsubsecskip{\onelineskip}
%% paragraph
\setparaheadstyle{\sethangfrom{\noindent ##1}\raggedright\myfamily\slshape}
%% description
\renewcommand*{\descriptionlabel}[1]{\hspace\labelsep
\normalfont\rmfamily\textit{#1}\hskip\textwidth}
%% tableofcontents
\renewcommand{\cftpartfont}{\myfamily\myseries}
\renewcommand{\cftchapterfont}{\myfamily\myseries}
%% set the options for the document
\captiontitlefont{\small\myfamily} %% small? TODO
\captionnamefont{\myfamily}
\pagestyle{blocks}
\chapterstyle{blocks}
\aliaspagestyle{title}{tblocks}