-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsicp-pdf-preamble.tex
251 lines (218 loc) · 9.96 KB
/
sicp-pdf-preamble.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
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
%===========================================%
% Preamble of the LaTeX version of SICP. %
% It will be read in by texi-to-latex.pl. %
%===========================================%
\documentclass[11pt,oneside]{book}
% New line height: 1.05 * 1.2 = 1.26
\renewcommand{\baselinestretch}{1.05}
% Font settings
\usepackage[no-math]{fontspec} %-----------------------% This exact order
\defaultfontfeatures{% % of declarations
Scale=MatchLowercase, % needed here ... % is important for
} % single quotes not
\setmonofont{Inconsolata LGC} % to turn out curly
% ("typographic")
\defaultfontfeatures{% % in verbatim blocks
Scale=MatchLowercase, % ... and here again % of Scheme code.
Mapping=tex-text, % Now the quote is
SmallCapsFeatures={LetterSpace=2.5,WordSpace=1.05}, % upright and safely
} % copy-pasteable to
\setmainfont{Linux Libertine O} % the REPL without
\setsansfont{Linux Biolinum O} %-----------------------% giving errors.
\usepackage{microtype}
%\usepackage{polyglossia}
%\setdefaultlanguage[variant=american]{english}
%\setotherlanguages{greek,spanish}
\usepackage[spanish,english]{babel}
\selectlanguage{english}
% To be able to use '\-/' in place of '-' inside \code{}
% so that long function names containing hyphens
% can be broken up after the hyphen:
\usepackage[shortcuts]{extdash}
% So that file names with multiple dots don't confuse
% graphicx package when using \includegraphics command:
\usepackage[multidot]{grffile}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames,x11names]{xcolor}
\usepackage{amsmath}
% To use Libertine letters and numbers,
% but tx-style operators in math environment:
\usepackage[libertine]{newtxmath}
% Workaround to fix mismatched left and right math delimiters. Taken from:
% http://tex.stackexchange.com/questions/63410/parentheses-differ-xelatex-fontspec-newtxmath-libertine
\DeclareSymbolFont{parenthesis}{T1}{fxl}{m}{n}
\DeclareMathDelimiter{(}{\mathopen}{parenthesis}{"28}{largesymbols}{"00}
\DeclareMathDelimiter{)}{\mathclose}{parenthesis}{"29}{largesymbols}{"01}
\DeclareMathDelimiter{[}{\mathopen}{parenthesis}{"5B}{largesymbols}{"02}
\DeclareMathDelimiter{]}{\mathclose}{parenthesis}{"5D}{largesymbols}{"03}
\DeclareMathDelimiter{\lbrace}{\mathopen}{parenthesis}{"7B}{largesymbols}{"08}
\DeclareMathDelimiter{\rbrace}{\mathclose}{parenthesis}{"7D}{largesymbols}{"09}
\usepackage{fancyvrb}
\usepackage{imakeidx}
\usepackage[totoc,font=footnotesize]{idxlayout}
\usepackage{fancyhdr}
\pagestyle{plain}
\usepackage[final]{pdfpages} % inserts pages from a pdf file
% Page geometry for 10-inch tablets:
\usepackage[papersize={148mm,197mm},
top=21mm,
textwidth=111mm, % increase one or both of these by 1mm or so to
textheight=148mm, % make the source compile with TeX Live 2013
hcentering, % if you get "Too many unprocessed floats" error
]{geometry}
\usepackage{titlesec} % to change the appearance of section titles
\usepackage{listings} % for syntax highlighted code listings
\usepackage{verbatim} % for simple verbatim and comment environments
\usepackage{enumerate} % allows customized labels in enumerations
\usepackage{hyperref} % makes cross references and URLs clickable
\definecolor{LinkRed}{HTML}{80171F}
\hypersetup{
pdfauthor={Harold Abelson, Gerald Jay Sussman, Julie Sussman},
pdftitle={Structure and Interpretation of Computer Programs, 2nd ed.},
pdfsubject={computer science, programming, abstraction},
colorlinks=true,
linkcolor=LinkRed,
urlcolor=LinkRed,
}
% Document colors
\definecolor{SchemeLight} {HTML} {686868}
\definecolor{SchemeSteel} {HTML} {888888}
\definecolor{SchemeDark} {HTML} {262626}
\definecolor{SchemeBlue} {HTML} {4172A3}
\definecolor{SchemeGreen} {HTML} {487818}
\definecolor{SchemeBrown} {HTML} {A07040}
\definecolor{SchemeRed} {HTML} {AD4D3A}
\definecolor{SchemeViolet} {HTML} {7040A0}
\definecolor{DropCapGray} {HTML} {B8B8B8}
\definecolor{ChapterGray} {HTML} {C8C8C8}
\definecolor{ChapterViolet} {HTML} {AEAECE}
\definecolor{DropCapViolet} {HTML} {9090C0}
\usepackage{lettrine} % adds commands that make drop capitals
\renewcommand{\LettrineFontHook}{\rmfamily\mdseries\color{DropCapViolet}}
\renewcommand{\DefaultLraise}{0.00}
\renewcommand{\DefaultLoversize}{0.02}
\renewcommand{\DefaultLhang}{0.12}
\setlength{\DefaultFindent}{1pt}
\setlength{\DefaultNindent}{0em}
\lstset{%
% Scheme syntax highlighter
columns=fixed,
extendedchars=true,
upquote=true,
showstringspaces=false,
sensitive=false,
mathescape=true,
escapechar=~,
alsodigit={>,<,/,-,=,!,?,*},
alsoletter=',
morestring=[b]",
morecomment=[l];,
% Keyword list taken form functional.py in Pygments package:
morekeywords={lambda, define, if, else, cond, and, or, case,%
let, let*, letrec, begin, do, delay, set!, =>, quote,%
quasiquote, unquote, unquote-splicing, define-syntax, let-syntax,%
letrec-syntax, syntax-rules},
% If keywords are quoted, they must not be highlighted:
emph={'lambda, 'define, 'if, 'else, 'cond, 'and, 'or, 'case,%
'let, 'let*, 'letrec, 'begin, 'do, 'delay, 'set!, '=>, 'quote,%
'quasiquote, 'unquote, 'unquote-splicing, 'define-syntax, 'let-syntax,%
'letrec-syntax, 'syntax-rules},
emphstyle=\color{SchemeDark},
% Paint error red:
emph={[2]error},emphstyle=[2]\color{SchemeRed},%
% Builtins taken from functional.py:
emph={[3]*, +, -, /, <, <=, =, >, >=, abs, acos, angle,
append, apply, asin, assoc, assq, assv, atan,
boolean?, caaaar, caaadr, caaar, caadar, caaddr, caadr,
caar, cadaar, cadadr, cadar, caddar, cadddr, caddr,
cadr, call-with-current-continuation, call-with-input-file,
call-with-output-file, call-with-values, call/cc, car,
cdaaar, cdaadr, cdaar, cdadar, cdaddr, cdadr, cdar,
cddaar, cddadr, cddar, cdddar, cddddr, cdddr, cddr,
cdr, ceiling, char->integer, char-alphabetic?, char-ci<=?,
char-ci<?, char-ci=?, char-ci>=?, char-ci>?, char-downcase,
char-lower-case?, char-numeric?, char-ready?, char-upcase,
char-upper-case?, char-whitespace?, char<=?, char<?, char=?,
char>=?, char>?, char?, close-input-port, close-output-port,
complex?, cons, cos, current-input-port, current-output-port,
denominator, display, dynamic-wind, eof-object?, eq?,
equal?, eqv?, eval, even?, exact->inexact, exact?, exp,
expt, floor, for-each, force, gcd, imag-part,
inexact->exact, inexact?, input-port?, integer->char,
integer?, interaction-environment, lcm, length, list,
list->string, list->vector, list-ref, list-tail, list?,
load, log, magnitude, make-polar, make-rectangular,
make-string, make-vector, map, max, member, memq, memv,
min, modulo, negative?, newline, not, null-environment,
null?, number->string, number?, numerator, odd?,
open-input-file, open-output-file, output-port?, pair?,
peek-char, port?, positive?, procedure?, quotient,
rational?, rationalize, read, read-char, real-part, real?,
remainder, reverse, round, scheme-report-environment,
set-car!, set-cdr!, sin, sqrt, string, string->list,
string->number, string->symbol, string-append, string-ci<=?,
string-ci<?, string-ci=?, string-ci>=?, string-ci>?,
string-copy, string-fill!, string-length, string-ref,
string-set!, string<=?, string<?, string=?, string>=?,
string>?, string?, substring, symbol->string, symbol?,
tan, transcript-off, transcript-on, truncate, values,
vector, vector->list, vector-fill!, vector-length,
vector-ref, vector-set!, vector?, with-input-from-file,
with-output-to-file, write, write-char, zero?},
emphstyle=[3]\color{SchemeViolet},%
%
basicstyle=\color{SchemeLight}\ttfamily,
keywordstyle=\color{SchemeBlue}\bfseries,
identifierstyle=\color{SchemeDark},
stringstyle=\color{SchemeGreen},
commentstyle=\color{SchemeLight}\itshape,
}
\newcommand{\acronym}[1]{\textsc{\fontspec[Numbers={OldStyle}]{Linux Libertine O}\MakeLowercase{#1}}}
\newcommand{\uppersc}[1]{{\fontspec[Letters=UppercaseSmallCaps]{Linux Libertine O}#1}}
\newcommand{\newterm}[1]{\index{#1}\emph{#1}}
\newcommand{\var}[1]{\textsl{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\link}[1]{\hyperref[#1]{#1}}
\newcommand{\heading}[1]{{\sffamily\bfseries #1}}
\newcommand{\dark}{\color{SchemeDark}}
\newcommand{\mono}[1]{\hbox{\ttfamily\scriptsize #1}}
\newcommand{\monoit}[1]{\hbox{\ttfamily\itshape\scriptsize #1}}
\newenvironment{example}%
{\verbatim\small}%
{\endverbatim}
\newenvironment{smallexample}%
{\verbatim\footnotesize}%
{\endverbatim}
\lstnewenvironment{scheme}[1][]
{\lstset{basicstyle=\ttfamily\small\color{SchemeLight},#1}}
{}
\lstnewenvironment{smallscheme}[1][]
{\lstset{basicstyle=\ttfamily\footnotesize\color{SchemeLight},#1}}
{}
\titleformat{\chapter}[display]
{\color{SchemeDark}\normalfont\sffamily\bfseries\LARGE}
{\filright \color{ChapterViolet}\sffamily\mdseries
\fontsize{6em}{0em}\selectfont
\oldstylenums{\thechapter}}
{1em}
{\filright}
\titleformat{\section}
{\color{SchemeDark}\normalfont\Large\sffamily\bfseries}
{\color{DropCapViolet}\thesection}{0.8em}{}
\titleformat{\subsection}
{\color{SchemeDark}\normalfont\large\sffamily\bfseries}
{\color{DropCapViolet}\thesubsection}{0.8em}{}
\titleformat{\subsubsection}
{\color{black}\normalfont\normalsize\sffamily\bfseries}
{\color{DropCapViolet}\thesubsubsection}{0.8em}{}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\frenchspacing
\makeindex
%====================%
% End of preamble. %
%====================%
\begin{document}
\VerbatimFootnotes