-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathMain.tex
238 lines (166 loc) · 6.36 KB
/
Main.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
% LaTeX source for textbook ``How to think like a computer scientist''
% Copyright (C) 1999 Allen B. Downey
% Copyright (C) 2009 Thomas Scheffler
\documentclass[a4paper]{book}
\usepackage[ngerman,english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{epsfig}
\usepackage{makeidx}
\usepackage{url}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage[hidelinks]{hyperref}
\usepackage{longtable}
\usepackage{ifthen}
\usepackage{boxedminipage}
\usepackage{todonotes}
% conditional compilation of the document for different languages
%\newboolean{German}
%\setboolean{German}{false}
% the exercise environment
\newcounter{exercisenum}
% by default, the exercise number includes the chapter number
% this way, an exercise label is a complete, unique exercise id
\renewcommand{\theexercisenum}{{\thechapter}.\arabic{exercisenum}}
% Standard font size for exercise/problem text
\newenvironment{exercisesize}{\begin{small}}{\end{small}}
\newcommand{\exerciseheader}[2]{
\begin{exercisesize}
% Use alphabetic chars for subparts of exercises,
% and roman numerals for subparts of them.
\def\theenumi{\alph{enumi}}
\def\labelenumi{\theenumi.}
\def\theenumii{\roman{enumii}}
\def\labelenumii{\theenumii.}
{\bf Exercise {#1}{#2}}\hspace{0.1in}
}
\newcommand{\startexercise}[1]{%
\refstepcounter{exercisenum}
\exerciseheader{\theexercisenum}{#1}
}
\newcommand{\stopexercise}{%
{\hfill}
\end{exercisesize}
}
\newcommand{\normaldif}{}
\newcommand{\bigdif}{\dag{}}
\newcommand{\verybigdif}{\ddag{}}
\newenvironment{exercise}{\startexercise{\normaldif{}}}{\stopexercise}
\newenvironment{hardexercise}{\startexercise{\bigdif{}}}{\stopexercise}
%% end of the exercise environment
%%------------------------------------------------------------
% formatting commands
\sloppy
\setlength{\topmargin}{0.125in}
\setlength{\oddsidemargin}{0.875in}
\setlength{\evensidemargin}{0.875in}
\setlength{\headsep}{3ex}
\setlength{\textheight}{8in}
\setlength{\parindent}{0.0in}
\setlength{\parskip}{1.7ex plus 0.5ex minus 0.5ex}
\renewcommand{\baselinestretch}{1.02}
% see LaTeX Companion page 62
\setlength{\topsep}{-0.0\parskip}
\setlength{\partopsep}{-0.5\parskip}
\setlength{\itemindent}{0.0in}
\setlength{\listparindent}{0.0in}
% see LaTeX Companion page 26
% these are copied from /usr/local/teTeX/share/texmf/tex/latex/base/book.cls
% all I changed is afterskip
\makeatletter
\renewcommand{\section}{\@startsection
{section} {1} {0mm}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{0.7ex \@plus.2ex}%
{\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection {subsection}{2}{0mm}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{0.3ex \@plus .2ex}%
{\normalfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection {subsubsection}{3}{0mm}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{0.3ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
\newcommand{\beforeverb}{\vspace{0.6\parskip}}
\newcommand{\afterverb}{\vspace{0.6\parskip}}
\newcommand{\adjustpage}[1]{\enlargethispage{#1\baselineskip}}
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
\newcommand{\blankpage}{\pagestyle{empty}\vspace*{1in}\newpage}
\newcommand{\beforefig}{\vspace{1.3\parskip}}
\newcommand{\afterfig}{\vspace{-0.2\parskip}}
\newcommand{\myfig}[1]{
\beforefig
\centerline{\epsfig{#1,scale=0.8}}
\afterfig
}
\newcommand{\beforechapter}{
% \clearemptydoublepage
\cleardoublepage
\setcounter{exercisenum}{0}
}
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}
\lhead[\fancyplain{}{\bfseries\thepage}]%
{\fancyplain{}{\bfseries\rightmark}}
\rhead[\fancyplain{}{\bfseries\leftmark}]%
{\fancyplain{}{\bfseries\thepage}}
\cfoot{}
% turn off the rule under the header
%\setlength{\headrulewidth}{0pt}
% the following is a brute-force way to prevent the headers
% from getting transformed into all-caps
\renewcommand\MakeUppercase{}
\sloppy
\setlength{\topmargin}{0.75in}
\setlength{\headsep}{0.5in}
\setlength{\oddsidemargin}{1.0in}
\setlength{\evensidemargin}{.95in}
\makeindex
%%-----------------------------------------------------------
% beginning of the document
\begin{document}
\thispagestyle{empty}
\begin{flushright}
\vspace*{2.5in}
{\huge How to Think Like a Computer Scientist}
\vspace{0.25in}
{\LARGE C Version}
\vspace{1in}
{\Large Thomas Scheffler}
{based on previous work by Allen B. Downey}
\vspace{1in}
{\Large Version 1.10}
{\small June 27th, 2019}
\vfill
\end{flushright}
Copyright (C) 1999 Allen B. Downey\\
Copyright (C) 2009 Thomas Scheffler
\vspace{0.25in}
Permission is granted to copy, distribute, transmit and adapt this
work under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0
International License: \url{https://creativecommons.org/licenses/by-nc/4.0/}.
If you are interested in distributing a commercial version of this
work, please contact the author(s).
The \LaTeX\ source and code for this book is available from: \\
\url{https://github.com/tscheffl/ThinkC}
\frontmatter
\tableofcontents
\mainmatter
\include{Chapter1}
\include{Chapter2}
\include{Chapter3}
\include{Chapter4}
\include{Chapter5}
\include{Chapter6_Iteration}
\include{Chapter7_Array}
\include{Chapter8_String}
\include{Chapter9_Struct}
\appendix
\include{Append1}
\include{ASCII}
\printindex
\end{document}