forked from aosabook/500lines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path500L.tex
321 lines (240 loc) · 9.99 KB
/
500L.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\definecolor{TableBorder}{rgb}{0.0078,0.6824,0.7882}
\def \tablegradient {0.95}
\definecolor{TableEven}{rgb}{\tablegradient,\tablegradient,\tablegradient}
\definecolor{TableOdd}{rgb}{1,1,1}
% \rowcolors{2}{TableOdd}{TableEven}
%% PANDOC SYNTAX HIGHLIGHTING
\usepackage{fixltx2e} % provides \textsubscript
\usepackage[utf8]{inputenc}
\usepackage{amsmath} % bmatrix
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
%\usepackage{color}
\usepackage{fancyvrb}
\DefineShortVerb[commandchars=\\\{\}]{\|}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
%\newcommand{\KeywordTok}[1]{\textbf{{#1}}}
%\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.50,0.00,0.00}{{#1}}}
%\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,1.00}{{#1}}}
%\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,1.00}{{#1}}}
%\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.50,0.00,0.50}{{#1}}}
%\newcommand{\CharTok}[1]{\textcolor[rgb]{1.00,0.00,1.00}{{#1}}}
%\newcommand{\StringTok}[1]{\textcolor[rgb]{0.87,0.00,0.00}{{#1}}}
%\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.50,0.50,0.50}{\textit{{#1}}}}
%\newcommand{\OtherTok}[1]{{#1}}
%\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.00,1.00,0.00}{\textbf{{#1}}}}
%\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.50}{{#1}}}
%\newcommand{\RegionMarkerTok}[1]{{#1}}
%\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
%\newcommand{\NormalTok}[1]{{#1}}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\usepackage{graphicx}
% END PANDOC SYNTAX HIGHLIGHTING
% BEGIN PANDOC IMAGE WIDTH
% We will generate all images so they have a width \maxwidth. This means
% that they will get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
% \makeatletter
% \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
% \else\Gin@nat@width\fi}
% \makeatother
% \let\Oldincludegraphics\includegraphics
% \renewcommand{\includegraphics}[1]{ \Oldincludegraphics[width=\maxwidth]{#1} }
% END PANDOC IMAGE WIDTH
\usepackage[hyphens]{url} % this package doesn't make proper clickable links, but
% \usepackage{hyperref} % this package breaks the build.
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{microtype}
\usepackage{amssymb}
\usepackage{framed} % for sidebars
\usepackage[includefoot]{geometry} % for margins
\usepackage{tocloft} % to typeset table of contents
\usepackage{titlesec} % to format chapter title pages
\usepackage{fancyhdr} % to format headers/footers
\pagestyle{fancy}
\usepackage{sectsty}
\usepackage{xspace}
\usepackage{wrapfig}
\usepackage[small]{caption} % make caption text size smaller
\usepackage{enumitem} % to manage spacing in and around lists
\usepackage{multicol} % to break the list of reviewers into columns
\usepackage[hang,flushmargin]{footmisc} % To not indent footnotes
\usepackage[T1]{fontenc}
\usepackage{tgtermes} % body font
\usepackage{inconsolata} % fixed width font
\usepackage{tgheros} % sans-serif font
% Make links footnotes instead of hotlinks:
\newcommand{\href}[2]{{#2}\footnote{\code{\url{#1}}}}
\author{Tavish Armstrong}
% define page size and margins etc
\geometry{paperwidth=18.91cm,paperheight=24.589cm,
vmargin=1.9cm, % top and bottom margins
inner=1.9cm, % inside margin
outer=2.29cm, % outside margin
bindingoffset=0.89cm % gutter
}
% define headers (empty) and footers
% fiddle with chaptermark so we can make it not all caps
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
% next get rid of existing header and footer and header rule
\fancyhead{}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
% now make the footer the way we want it:
% page number on right side of footer for odd pages
\rfoot[]{\small{\textsf{\chapterauthor \hspace{0.25cm} \thepage}}}
\fancyhfoffset[EL]{0cm} % this looks like it doesn't do anything, but
% it seems to remind it to line up headers with the
% rest of the text
% page number and chapter name on left side of footer for even pages
\lfoot[\small{\textsf{\thepage \hspace{0.25cm} \leftmark}}]{}
% make plain pages have no headers or footers
\fancypagestyle{plain}{\fancyhf{}}
% set all section headers to be sans serif
\allsectionsfont{\normalfont\sffamily}
% format the table of contents
\renewcommand{\cftchapfont}{\sffamily\small} % set TOC entries to sserif
\renewcommand{\cftchappagefont}{\sffamily} % set TOC page numbers to sserif
% make all verbatim (code blocks) text smaller, just because it was bugging me
\let\oldverbatim\verbatim
\renewcommand\verbatim{\small\oldverbatim}
% format title of TOC: make sure this matches chapter head format as set below
\renewcommand{\cfttoctitlefont}{\hfill\Huge\sffamily}
\setcounter{tocdepth}{0} % sets what level of header is shown in the TOC
\setcounter{secnumdepth}{1} % sets what level of subsect. are numbered
% introduce penalty for widows and orphans (can increase to 10 000, although
% not recommended)
% upped the widow/orphan penalty to 600 from 300; seems to have removed
% all widows and orphans -- ARB Mar 30 2012
\widowpenalty=600
\clubpenalty=600
\title{500 Lines or Less}
\date{}
\newcommand{\chapterauthor}{}
\newcommand{\chapterauthortoc}{}
\newenvironment{aosachapter}[3]
{ \renewcommand{\chapterauthor}{#3} \chapter{#1} \label{#2}
\addtocontents{toc}{\hspace{1cm}\textit{\textsf{\small by \chapterauthor}}\protect\par} } { }
\newenvironment{aosachaptertoc}[4]
{ \renewcommand{\chapterauthor}{#3}
\renewcommand{\chapterauthortoc}{#4}
\chapter{#1} \label{#2}
\addtocontents{toc}{\hspace{1cm}\textit{\textsf{by \chapterauthortoc}}\protect\par} } { }
\newcommand{\aosasecti}[1]{\section{#1}}
\newcommand{\aosasectii}[1]{\subsection{#1}}
\newcommand{\aosasectiii}[1]{\subsubsection*{#1}}
\newenvironment{aosabox}[1]
{ \begin{figure}[h!]\vspace{-0.7cm}\centering \rule[-.7cm]{13.83cm}{0.75pt} \begin{minipage}[t]{13.83cm}\begin{framed}\centerline{{\textbf{#1}}} }
{ \end{framed}\end{minipage} \rule{13.83cm}{0.75pt} \end{figure} }
\newenvironment{aosadescription}
{\begin{description}[itemsep=-0.1ex,parsep=0.3ex,topsep=0.2ex,leftmargin=10mm]}
{\end{description}}
\newenvironment{aosaenumerate}
{\begin{enumerate}[itemsep=-0.8ex,topsep=0.2ex,leftmargin=10mm]}
{\end{enumerate}}
% new environment for second-level nested enumerated lists
\newenvironment{aosaenumerate2}
{\begin{enumerate}[itemsep=-0.7ex,topsep=-1ex,leftmargin=10mm]}
{\end{enumerate}}
\newenvironment{aosaitemize}
{\begin{itemize}[itemsep=-0.8ex,topsep=0.2ex,leftmargin=8.5mm]}
{\end{itemize}}
% new environment for second-level nested itemized lists
\newenvironment{aosaitemize2}
{\begin{itemize}[itemsep=-0.5ex,topsep=-1ex,leftmargin=9mm]}
{\end{itemize}}
\newcommand{\aosaboxref}[1]{Box~\ref{#1}}
\newcommand{\aosachapref}[1]{Chapter~\ref{#1}}
\newcommand{\aosafigref}[1]{Figure~\ref{#1}}
\newcommand{\aosasecref}[1]{Section~\ref{#1}}
\newcommand{\aosatblref}[1]{Table~\ref{#1}}
\newcommand{\aosafigure}[4][375pt]{\begin{figure}[h!]\centering\includegraphics[width={#1}]{#2}\caption{#3}\label{#4}\end{figure}}
\newcommand{\aosafigureTop}[4][375pt]{\begin{figure}[t]\centering\includegraphics[width={#1}]{#2}\caption{#3}\label{#4}\end{figure}}
%% Make the space above and below captions smaller
\setlength{\abovecaptionskip}{1.2ex}
\setlength{\belowcaptionskip}{-1.5ex}
\newcommand{\aosagraphics}[2][375pt]{\includegraphics[width={#1}]{#2}}
\newcommand{\aosaquestion}[1]{\begin{textbf}{#1}\end{textbf}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\smcode}[1]{\small\texttt{#1}\normalsize}
% GHC commands
\newcommand{\clift}[1]{\lfloor{#1}\rfloor}
\newcommand{\ol}[1]{\overline{#1}}
\newcommand{\tcase}[2]{\mathbf{case}\;{#1}\;\mathbf{of}\;\ol{#2}}
\newcommand{\tlet}[4]{\mathbf{let}\;{#1}{:}{#2} = {#3}\;\mathbf{in}\;{#4}}
\newcommand{\tcast}[2]{{#1}\xspace{\triangleright}\xspace{#2}}
%% Tavish: for highlighting the italicized text
%% (To see if I made mistakes)
% \newcommand{\oldemph}[1]{\emph{#1}}
% \renewcommand\emph[1]{\begin{textbf}{{\Huge#1}}\end{textbf}}
% format chapter title pages
\titleformat{\chapter}
[display] % shape/type of title
{\ttfamily} % formatting commands applied to both label and title
{\vspace{-2cm} \hfill \large [chapter\kern0.15em\thechapter]}
{2cm} % separation between number and chapter title
{\huge\sffamily} % code preceding title. Last cmd can take arg, which is title
[ % everything inside [] comes after the title
% \hspace*{1cm} % indent author name
\Large % make text that follows large
\thispagestyle{plain} % suppress page numbers
\chapterauthor % insert chapter author name
]% end of what comes after title
% Code for creating empty pages
% No headers/footers on empty pages before new chapter, if prev
% chapter ends on right side
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{plain}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}
% list of hard-to-hyphenate words with correct possible hyphenation-points
\hyphenation{Free-RTOS}
\raggedbottom
\begin{document}
\frontmatter
\include{frontmatter}
\tableofcontents
\include{intro}
\mainmatter
\include{image-filters}
\include{dagoba}
\include{ocr}
\include{contingent}
\include{same-origin-policy}
\include{blockcode}
\include{interpreter}
\include{web-server}
\include{static-analysis}
\include{functionalDB}
\include{flow-shop}
\include{template-engine}
\include{pedometer}
\include{sampler}
\include{spreadsheet}
\include{cluster}
\include{data-store}
\include{objmodel}
\include{ci}
\include{crawler}
\include{modeller}
\bibliographystyle{alpha}
\bibliography{500L}
\makeatletter
\@openrightfalse
%% \renewcommand*\cleardoublepage{\clearpage\if@twoside
%% \ifodd\c@page \hbox{}\newpage\if@twocolumn\hbox{}%
%% \newpage\fi\fi\fi}
\makeatother
\backmatter
\include{colophon}
\end{document}