-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmapl.tex
More file actions
310 lines (261 loc) · 9.53 KB
/
Copy pathmapl.tex
File metadata and controls
310 lines (261 loc) · 9.53 KB
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
%\RequirePackage{etex}
\documentclass[openany]{book}
\usepackage{etex}
\reserveinserts{28}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{epigraph}
\usepackage{fancyvrb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage[dvips]{color}
\usepackage[arrow,curve,matrix,frame]{xy}
\usepackage{indentfirst} % Русская типографика требует красную строку
%\usepackage{MnSymbol}
\usepackage{array}
\usepackage{ifmtarg}
\usepackage{centernot}
\usepackage{empheq}
\usepackage{needspace}
\usepackage{colonequals}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes,shadows,trees}
%\usepackage{tikz-qtree}
\usepackage{mdwlist}
\usepackage{Khartiya}
%\usepackage{hevea}
%\usepackage{fancybox}
%% Я хотел использовать fancybox ради \ovalbox, но он определяет свой
%% собственный Verbatim, который конфликтует с fancyvrb.
%% В конце концов нужно будет либо выдернуть оттуда определение
%% \ovalbox, либо отказаться от fancyvrb. Пока что я просто не делаю
%% круглых углов.
\newcommand{\ovalbox}[1]{\fbox{#1}}
\setlength{\epigraphwidth}{7cm}
\usepackage{longtable,citehack,enumerate}
\usepackage{tocbibind}
%\usepackage[unicode,colorlinks=true,a4paper]{hyperref}
\usepackage[unicode,a4paper]{hyperref}
\definecolor{pfpcolorint}{rgb}{0,0.4,0}
\definecolor{pfpcolorext}{rgb}{0,0,0.6}
\hypersetup{colorlinks,
linkcolor=pfpcolorint,
citecolor=pfpcolorint,
filecolor=pfpcolorext,
urlcolor=pfpcolorext,
bookmarksopen,bookmarksopenlevel=0,
pdffitwindow,
pdftitle={Магнус Лай Хетланд. Алгоритмы в Python},
% pdfsubject={},
% pdfkeywords={}
}
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox[rgb]{0.91,0.92,0.93}{\parbox{\textwidth}{\rmfamily #1#2#3}}}
\captionsetup[lstlisting]{format=listing, singlelinecheck=false, margin=0pt}
\interfootnotelinepenalty=10000
% 70х100/16 -> 170mmх240mm
\usepackage[papersize={165mm,240mm},hmargin={1.6cm,2cm},vmargin={2cm,2cm},twoside]{geometry}
\usepackage[dvipdfm]{accsupp} % Контролирует эффект копирования из PDF
\definecolor{MyGray}{rgb}{0.91,0.92,0.93}
\makeatletter\newenvironment{graybox}{%
\noindent\begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}}{\end{minipage}\end{lrbox}%
\colorbox{MyGray}{\usebox{\@tempboxa}}
}\makeatother
\makeatletter
\newenvironment{notice}[1]{
\vspace{1em}
\begin{graybox}
\begin{center}
\vspace{0.2em}
\bf\MakeUppercase{#1}
% \vspace{0.2em}
\end{center}
\end{graybox}
\sffamily
\parindent=1.27em
% \vspace{0.3em}
}
{
\vspace{0.4em}
\centering\rule{\columnwidth}{1pt}
}
\makeatother
% headers & footers
\usepackage{fancyhdr}
\pagestyle{fancy}
%\include{version}
\fancyhead{}
\fancyhead[LE]{\slshape{\leftmark{}}}
\fancyhead[RO]{\slshape{\rightmark{}}}
%\fancyhead[LE,RO]{\thepage{}}
%\fancyfoot{}
%\fancyfoot[LE,RO]{rev. \svnInfoMaxRevision}
%
\usepackage{graphicx}
\usepackage[round]{natbib}
\bibliographystyle{plainnat}
\renewcommand{\cite}{\citep*}
\newcommand{\citeterse}{\citep}
\newcommand{\citeyr}[1]{(\citeyear{#1})}
\newcommand{\citeyropen}[1]{\citeyear{#1}}
\newcommand{\fulllongcite}[1]{\citeauthor*{#1} \citeyearpar{#1}}
\newcommand{\citeopen}[1]{\citealp*{#1}}
\newcommand{\citeopenterse}[1]{\citealp{#1}}
%%\usepackage{algorithm}
\usepackage{listings}
%\usepackage{courier}
\lstloadlanguages{Python,bash}
\definecolor{listingcomment}{gray}{0.3}
\lstset{%
basicstyle=\ttfamily,
columns=fullflexible,
showtabs=false,
showspaces=false,
showstringspaces=false,
tabsize=2,
language=Python,
commentstyle=\color{listingcomment},
extendedchars=\true{},
mathescape=\true{},% allows to use math symbols in listings - may be
% dangerous
keywordstyle={}}
% замена буквосочетаний на симпатичные символы
\lstset{literate={->}{{$\to{}$}}1 {=>}{{$\Rightarrow$}}2 {|>}{{$\triangleright{}$}}1}
% \lstinline мешается в таблицах (пока не понял, почему) -- goga
%\newcommand{\code}[1]{\lstinline[mathescape]!#1!}
\newcommand{\code}[1]{\noindent\texttt{#1}}
%% proper captions for figures, etc
%\RequirePackage{caption}
\captionsetup{labelsep=period,labelfont=bf}
% Добавляем точку после номера раздела
\usepackage{titlesec}
\titlelabel{\thetitle.\quad}
\usepackage[dotinlabels]{titletoc}
% settings for floating objects
\renewcommand{\topfraction}{.9}
\renewcommand{\textfraction}{.1}
\renewcommand{\bottomfraction}{.9}
%\renewcommand{\floatpagefraction}{.9}
%\renewcommand{\dblfloatpagefraction}{\floatpagefraction}
% \setcounter{topnumber}{4}
% \setcounter{bottomnumber}{4}
% \setcounter{totalnumber}{4}
% \setlength{\floatsep}{8pt plus 2pt minus 2pt}
% \setlength{\textfloatsep}{8pt plus 2pt minus 2pt}
% \setlength{\intextsep}{12pt plus 2pt minus 2pt}
% Custom commands
\newcommand{\<}{\langle}
\renewcommand{\>}{\rangle}
\newcommand{\nbdash}{\mbox{-}}
\newcommand{\nosol}{\nrightarrow}
\newcommand{\recommended}{\textsc{Рекомендуется}}
\newcommand{\lambdaterm}[1]{\mbox{\code{#1}}}
\newcommand{\nbcode}[1]{\mbox{\code{#1}}}
\newcommand{\ocode}[1]{\overline{\vphantom{A}\code{#1}}}
\newcommand{\defterm}[1]{\emph{#1}}
\newcommand{\ruleid}[1]{\mbox{\textsc{#1}}}
\newcommand{\ruletag}[1]{\tag{\textsc{#1}}\index{правило!\textsc{#1}}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\dom}{\textit{dom}}
\newcommand{\range}{\textit{range}}
\newcommand{\fail}{\textit{неудача}}
\newcommand{\function}[1]{\mbox{\textit{#1}\,}}
\newcommand{\interpreter}[1]{\texttt{#1}\index{интерпретатор!\texttt{#1}}}
\newcommand{\Fsub}{F$_{\code{<:}}$}
\newcommand{\Fomega}{F$_\omega$}
\newcommand{\Fsubomega}{F$_{\code{<:}}^\omega$}
\renewcommand{\L}{\ensuremath{\lambda}}
\newcommand{\eqdef}{\stackrel{\text{\tiny def}}{=}}
\newcommand{\size}[1]{\bar #1 \bar}
\newcommand{\varrow}{\mbox{\strut\ensuremath{\:\Mapstochar\shortrightarrow\:}}}
\newcommand{\notsub}{\ensuremath{\centernot{\code{\textnormal{<:}}}}}
\definecolor{gray}{gray}{0.75}
\newcommand{\graybg}[1]{\colorbox{gray}{\mbox{#1}}}
\makeatletter
\newcommand{\translationnotemark}{{\renewcommand{\@makefnmark}{\mbox{$^*$}}\footnotemark{}}}
\newcommand{\translationnotetext}[1]{{\renewcommand{\@makefnmark}{\mbox{$^*$}}\footnotetext{#1~---~{\it прим. перев.}}}\addtocounter{footnote}{-1}}
\newcommand{\translationnote}[1]{\translationnotemark{}\translationnotetext{#1}}
\newcommand{\unmarkednote}[1]{{\renewcommand{\@makefnmark}{}\footnotemark{}\footnotetext{#1}}\addtocounter{footnote}{-1}}
\makeatother
\newcommand{\wearelazy}{\translationnote{При верстке перевода это правило не соблюдалось.}}
\newtheorem{definition}{\texttt{Определение}}[section]
\newtheorem{exercise}[definition]{\texttt{Упражнение}}
\newtheorem{axiom}[definition]{\texttt{Аксиома}}
\newtheorem{proposition}[definition]{\texttt{Утверждение}}
\newtheorem{lemma}[definition]{\texttt{Лемма}}
\newtheorem{theorem}[definition]{\texttt{Теорема}}
\newtheorem{convention}[definition]{\texttt{Соглашение}}
\newtheorem{corollary}[definition]{\texttt{Следствие}}
\newtheorem{example}[definition]{\texttt{Пример}}
\newtheorem{examples}[definition]{\texttt{Примеры}}
\newcommand{\errata}[1]{\relax}
\newcommand{\muheight}{\ensuremath{\mu\mbox{-height}}}
\newcommand{\recordc}[4]{\ensuremath{\code{#1}_#2{}^{#2\in #3..#4}}}
\newenvironment{exsolution}[1]
{\par\smallskip\noindent
\ref{#1}. \textsc{Решение:}}{}
%%%
%%% НОВАЯ ВЕРСТКА ТАБЛИЦ
%%%
%%% сначала идёт параграф с заголовком...
\newcommand{\displayNew}[3]{#1
%%% ... потом верхняя рамка
\rule[-1ex]{.4pt}{1ex}\rule{\mapltablewidth}{.4pt}\rule[-1ex]{.4pt}{1ex}\smallskip
%%% ... потом две minipage, стоящие рядом через черточку
\begin{minipage}[t]{.5\mapltablewidth}
#2
\end{minipage}
\vline
\begin{minipage}[t]{.5\mapltablewidth}
#3
\end{minipage}
%%% ... потом нижняя рамка
\rule{.4pt}{1ex}\rule{\mapltablewidth}{.4pt}\rule{.4pt}{1ex}\par
}
\makeatletter
\newcommand{\tablesection}[2]{\textit{#1}\@ifmtarg{#2}{\relax}{\hfill\fbox{#2}}}
\makeatother
\newcommand{\displayOneCol}[2]{
{ % hold \arraystretch redefinition inside the display
#1 \\
\renewcommand{\arraystretch}{0}
\begin{tabular}{|c|}
\hline
\rule{0pt}{1ex} \\
\multicolumn{1}{c}{
\renewcommand{\arraystretch}{1}
\begin{tabular}{l}
#2
\end{tabular}
} \\
\rule{0pt}{1ex} \\
\hline
\end{tabular}
}
}
\title{Алгоритмы в Python. Проектирование алгоритмов на языке Python}
\author{Магнус Лай Хетланд}
\begin{document}
\newlength{\mapltablewidth}
\setlength{\mapltablewidth}{\linewidth}
\addtolength\mapltablewidth{-2.8pt}
\VerbatimFootnotes
\selectlanguage{russian}%
\frenchspacing
\righthyphenmin=2
\sloppy
\setcounter{topnumber}{1}
\maketitle
%%% здесь можно комментировать одно и раскомментировать другое, чтобы
%%% быстро тестировать компиляцию по главам
%\input{chapter-13.tex}
\input{all-chapters.tex}
\end{document}
%%% Local Variables:
%%% mode: pdflatex
%%% TeX-master: t
%%% End: