-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpython-screen.sty
More file actions
513 lines (444 loc) · 16 KB
/
python-screen.sty
File metadata and controls
513 lines (444 loc) · 16 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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
% \mainfolder est ../ si compilation d'un chapitre, sinon c'est vide
\ProvidesPackage{\mainfolder python-screen}
% ----------------------------------------------------------------------
% Format de la page
\usepackage[a4paper,
nomarginpar, nofoot,
margin = 2cm,
%top=0.5in,
%right=0.8in, left=0.8in, top=0.5in, bottom=0.7in,
bindingoffset=0cm,
headsep=21pt, heightrounded,
% showframe,
]{geometry}
% pas de retrait
\setlength{\parindent}{0cm}
% Espace interligne (+ xx%)
\linespread{1.1}
% ======================================================================
\usepackage{\mainfolder python-common}
% ======================================================================
% ----------------------------------------------------------------------
% Police par defaut
\usepackage[charter,cal=cmcal]{mathdesign}
% Police pour l'entete
%\newcommand{\entetefonte}[1]{\fontfamily{lmss}\selectfont\textls[-10]{\textsc{#1}}}
\newcommand{\entetefonte}[1]{\textls[-10]{\textsc{#1}}}
% Police pour les sections
\newcommand{\sectionfonte}{\fontfamily{phv}\bfseries}
% ----------------------------------------------------------------------
% Microtype
%\frenchbsetup{AutoSpacePunctuation=false}
\usepackage[kerning=true,activate={true,nocompatibility},final,tracking=true,spacing=true,factor=1100,stretch=20,shrink=20]{microtype}
% activate={true,nocompatibility} - activate protrusion and expansion
% final - enable microtype; use "draft" to disable
% tracking=true, kerning=true, spacing=true - activate these techniques
% factor=1100 - add 10% to the protrusion amount (default is 1000)
% stretch=10, shrink=10 - reduce stretchability/shrinkability (default is 20/20)
%\SetExtraKerning[name=frenchdefault,context=french,unit=space]{encoding={OT1,T1,LY1}}{'= {200,100},}
% ----------------------------------------------------------------------
% Overfull/Underfull
\tolerance=250%
\emergencystretch=1.5em%
\hfuzz=2pt % Pas de warning overfull horizontal
\vfuzz=2pt % Pas de warning overfull vertical
\hbadness=10000 % Pas de warning underfull
\vbadness=10000 % Pas de warning underfull
% ----------------------------------------------------------------------
% saut de page
\usepackage{needspace}
% ----------------------------------------------------------------------
% reduction espace pour les environnement align and co
\usepackage{etoolbox}
\newcommand{\smalldisplayskips}{%
\setlength{\abovedisplayskip}{4pt plus 3pt}%
\setlength{\belowdisplayskip}{4pt plus 3pt}%
\setlength{\abovedisplayshortskip}{1pt plus 3pt}%
\setlength{\belowdisplayshortskip}{1pt plus 3pt}%
}
\appto{\normalsize}{\smalldisplayskips}
\appto{\small}{\smalldisplayskips}
\appto{\footnotesize}{\smalldisplayskips}
% ----------------------------------------------------------------------
% Sommaire
\usepackage[titles]{tocloft} % pour l'indentation des pages > 100
\setlength{\cftchapnumwidth}{2.55em}
\setlength{\cftsecindent}{2.55em}
%\usepackage{titletoc} % Inutile
%\addto\captionsfrancais{\def\contentsname{Sommaire}} % Ne marche pas !
\AtBeginDocument{\renewcommand{\contentsname}{Sommaire}}
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% Définition d'un terme, mise en relief
% Définition d'un terme, mise en relief
\newcommand{\defi}[1]{{\color{myorange}\textbf{\emph{#1}}}}
\newcommand{\evidence}[1]{{\color{blue}\textbf{\emph{#1}}}}
\newcommand{\assertion}[1]{{\og\emph{#1}\fg}} % pour chapitre logique
% ----------------------------------------------------------------------
% Titre du livre
\newcommand{\montitre}[1]{
% Pour la numerotation d'avant chapitres
%\pdfcatalog{%
% /PageLabels<<%
% /Nums[%
% % Page numbers are zero based.
% % Uppercase roman numbers starting with first page.
% 0<</S/a>>%
% % Arabic numbers starting with current page.
% \the\numexpr\value{page}-1\relax<</S/r>>%
% ]%
% >>%
%}
\pagestyle{empty}\thispagestyle{empty}
\begin{center}
\Huge #1
\end{center}
\begin{center}
\LogoExoSept{5}
\end{center}
%\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\tableofcontents
\pagestyle{chapterpage}
}
% ----------------------------------------------------------------------
% Les chapitres
% Pour figure titre \part python2
\usetikzlibrary{lindenmayersystems}
\usetikzlibrary[shadings]
\pgfdeclarelindenmayersystem{Sierpinski arrow}{
\symbol{X}{\pgflsystemdrawforward}
\symbol{Y}{\pgflsystemdrawforward}
\rule{X -> Y-X-Y}
\rule{Y -> X+Y+X}
}
\newcommand{\mylsystem}[1]{
\begin{center}
\begin{tikzpicture}
\def\k{#1+2}
\begin{scope}[scale=0.25]
\shadedraw[bottom color=red!80,top color=red!10,draw=red!80!black,rotate=30-30*(-1)^(\k)] % rotate=30-30*(-1)^\k
[lindenmayer system={Sierpinski arrow,angle=60,axiom=X,step=200pt/2^\k,order=\k}]
lindenmayer system;
\end{scope}
\end{tikzpicture}
\end{center}
}
% Fin figure \part python2
\newcommand{\debutchapitres}{\cleardoublepage\pagestyle{main}\thispagestyle{empty}\setcounter{page}{1}
% Pour la numerotation coherente pdf/latex
\pdfcatalog{%
/PageLabels<<%
/Nums[%
% Page numbers are zero based.
% Uppercase roman numbers starting with first page.
0<</S/R>>%
% Arabic numbers starting with current page.
\the\numexpr\value{page}-1\relax<</S/D>>%
]%
>>%
}
}
%\usepackage[explicit,pagestyles]{titlesec} %-> Baculer dans scratch-common.sty-
\ifPDFTeX % PDFLaTeX
\newcommand{\ugqfont}{\fontfamily{ugq}}
\else
\newcommand{\ugqfont}{\fontspec{URWGrotesk-bold.ttf}}
\fi
\titleformat{\part}[display]
{\Huge\center\scshape}% format
{\titlerule[3pt]\vspace{3pt}\titlerule[1pt]\vspace{20pt}%
\partname~\thepart\\[25pt]%
\mylsystem{\value{part}}
%\includegraphics[width = 6cm]{divers/logoScratchAuCollege}
%\\
\MakeLowercase{#1}}% label
{15pt}% sep
{% the title
\titlerule[1pt]\vspace{3pt}\titlerule[3pt]\vspace{4pc}
}
\titleformat{\chapter}[block]
{\raggedleft\ugqfont}% format
{}% label
{0pt}% sep
{% the title
\begin{tikzpicture}
\node[black, above left, inner ysep=0pt, text width=.7\linewidth, align=right, node font=\huge]{\color{Firebrick4}#1};
\draw[lightgray,line width=5pt] (0,-.1) -- (0,2.1);
\ifstandalone % Style chapitre si on compile un seul chapitre : pas numéro
\else % Style chapitre si on compile un seul livre
\coordinate (C) at (2,1.7);
\node[left, lightgray, inner sep=0pt] at (C) {\chaptertitlename};
\node[left, lightgray, inner sep=0pt, scale=3] at ([yshift=-20pt]C) {~\thechapter};
\fi
\end{tikzpicture}
}
\titleformat{name=\chapter,numberless}[block]
{\raggedleft\ugqfont}% format
{}% label
{0pt}% sep
{% the title
\begin{tikzpicture}
\node[black, above left, inner ysep=0pt, text width=.7\linewidth, align=right, node font=\huge]{\color{Firebrick4}#1};
\draw[lightgray,line width=5pt] (0,-.1) -- (0,2.1);
\end{tikzpicture}
}
\newcommand{\chapitre}[2][]{
\clearemptydoublepage\thispagestyle{empty}
%\setcounter{theoreme}{0}
%\setcounter{proposition}{0}
%\setcounter{lemme}{0}
%\setcounter{corollaire}{0}
%\setcounter{definition}{0}
%\setcounter{exemple}{0}
%\setcounter{tp}{0}
%\setcounter{exercicecours}{0}
%\setcounter{equation}{0}
\setcounter{activite}{0}
%\setcounter{exemple}{0}
\setcounter{cours}{0}
\ifx&\chapter{#2}\else\chapter[#1]{#2}\fi
}
\newcommand{\finchapitre}{}
% les sections
\makeatletter
\renewcommand{\thesection}{\@arabic\c@section}
% \renewcommand{\thechapter}{}
% \renewcommand{\chaptername}{}
\makeatother
\titleformat{\section}
{\Needspace{10\baselineskip}\sectionfonte\selectfont\color{Firebrick3}\LARGE}% format
{}% label
{0pt}% sep
{\thesection.~#1}
\titleformat{name=\section,numberless}
{\Needspace{10\baselineskip}\sectionfonte\selectfont\color{Firebrick3}\LARGE}% format
{}% label
{0pt}% sep
{#1}
% les sous-sections
\titleformat{\subsection}
{\Needspace{5\baselineskip}\sectionfonte\selectfont\color{Firebrick1}\Large}% format
{}% label
{0pt}% sep
{\thesubsection.~#1}
\titleformat{name=\subsection, numberless}
{\Needspace{5\baselineskip}\sectionfonte\selectfont\color{Firebrick1}\Large}% format
{}% label
{0pt}% sep
{#1}
% ----------------------------------------------------------------------
% Format en-têtes
%\usepackage{titleps} % chargé par titlesec, je suppse
\newpagestyle{main}[\small]{
\setheadrule{0pt}%{.55pt}
\sethead[{\color{gray}\entetefonte{\chaptertitle}}]% even-left
[]% even-center
[\large\textbf{\thepage}]% even-right
{{\color{gray}\entetefonte{\chaptertitle}}}% odd-left
{}% odd-center
{\large\textbf{\thepage}}% odd-right
%\renewcommand\makeheadrule{\color{lightgray}\rule[-.3\baselineskip]{\linewidth}{0.4pt}}
}
\newpagestyle{chapterpage}[\small]{
\setheadrule{0pt}%
\sethead[]% even-left
[]% even-center
[]% even-right
{}% odd-left
{}% odd-center
{}% odd-right
%\renewcommand\makeheadrule{\color{lightgray}\rule[-.3\baselineskip]{\linewidth}{0.4pt}}
}
\assignpagestyle{\chapter}{chapterpage}
\pagestyle{main}
% ----------------------------------------------------------------------
% Personnalisation pour les théorèmes,...
\usepackage{amsthm}
\newtheoremstyle{theoremeexo7}% name
{3pt}% Space above
{3pt}% Space below
{\itshape}% Body font
{}% Indent amount
{\bfseries}% Theorem head font
{.\newline}% Punctuation after theorem head
{0pt\Needspace{3\baselineskip}}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’ )
\newtheoremstyle{definitionexo7}% name
{3pt}% Space above
{3pt}% Space below
{\upshape}% Body font
{}% Indent amount
{\bfseries}% Theorem head font
{.\newline}% Punctuation after theorem head
{0pt\Needspace{3\baselineskip}}% Space after theorem head
{}% Theorem head spec (can be left empty, meaning ‘normal’ )
\theoremstyle{theoremeexo7}
\newtheorem{theoreme}{Théorème}
\newtheorem{proposition}{Proposition}
\newtheorem*{propriete*}{Propriété}
\newtheorem{lemme}{Lemme}
\newtheorem{corollaire}{Corollaire}
\theoremstyle{definitionexo7}
\newtheorem{activite}{Activité}
\newtheorem{cours}{Cours}
\newtheorem*{algorithme}{Algorithme}
\newtheorem*{moncode}{Code}
\newtheorem{enigme}{\'Enigme}
\newtheorem*{exemple}{Exemple}
% legèrement personnalisées
\usepackage{tcolorbox}
\tcbuselibrary{theorems, skins, breakable}
\tcbuselibrary{listings}
\tcbset{listing engine=listings}
\tcbset{
leftlined/.style 2 args={
blanker, breakable,
borderline west={#1}{0pt}{#2},left={#1*14/10+7pt},top=2.5ex, bottom=2.5ex
}
}
\tcolorboxenvironment{activite}{leftlined={5pt}{gray}}
\tcolorboxenvironment{enigme}{leftlined={5pt}{gray}}
\tcolorboxenvironment{algorithme}{leftlined={3pt}{lightgray}}
\tcolorboxenvironment{exemple}{leftlined={3pt}{lightgray}}
\tcolorboxenvironment{cours}{leftlined={3pt}{lightgray,decorate,decoration={name=zigzag}}}
% Code
%\tcolorboxenvironment{moncode}{leftlined={5pt}{gray}}
\tcolorboxenvironment{moncode}{fonttitle=\bfseries\upshape,fontupper=\itshape,
colframe=red!50!black,colback=black!5!white,colbacktitle=green!20!white,coltitle=blue!75!black,titlerule=3mm}
% ----------------------------------------------------------------------
% Encadrement auteurs
\newcommand{\auteurs}[1]{\vspace*{\fill}\textbf{\ugqfont\selectfont\color{gray}Auteurs du chapitre }#1
}
% ----------------------------------------------------------------------
% Encadrement des formules
\usepackage{fancybox}
%\setlength{\fboxsep}{7pt}
%\newcommand{\mybox}[1]{\begin{center}\shadowbox{#1}\end{center}}
%\newcommand{\myboxinline}[1]{\raisebox{-2ex}{\shadowbox{#1}}}
% ---- autre version
\usepackage{varwidth}
\tikzset{
block/.style = {
minimum height=1em,
inner xsep=.8em, inner ysep=.45em,
draw=black, thick, %rounded corners,
execute at begin node={\begin{varwidth}{\linewidth}\begin{center}},
execute at end node={\end{center}\end{varwidth}}
},
inline/.style = {
inner sep=.35em, draw=black, thick,
}
}
\newcommand{\mybox}[1]{\begin{center}\tikz{\node[block]{#1};}\end{center}}
\newcommand{\myboxinline}[1]{\tikz[baseline=(X.base)]{\node[inline](X){#1};}}
% ----------------------------------------------------------------------
% Package liens hypertexts
% Attention : hyperref doit être après titletoc !!!
% En règle général il doit être le dernier package chargé.
% pdfencoding=auto : d'après http://tex.stackexchange.com/questions/24445
\usepackage[hypertexnames=true,pdfencoding=auto]{hyperref}
%\usepackage[hypertexnames=true,plainpages=false,pdfpagelabels,pagebackref]{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue,
pdftitle={Python au lycée - tome 2}, pdfauthor={Arnaud Bodin}}
% --- Liens vers vidéo Youtube
% variable myvideo : 0 pas de video, sinon la référence youtube
\newcommand{\video}[1]{\def\myvideo{#1}}
\newcommand{\insertvideo}[2]{\video{#1}%
{\hfill\small\texttt{\href{http://www.youtube.com/watch?v=\myvideo}{Vidéo $\blacksquare$ #2}}}}
% --- Liens vers les fiches d'exercices
\newcommand{\mafiche}[1]{\def\mymafiche{#1}}
\newcommand{\insertfiche}[2]{\mafiche{#1}%
{\small\texttt{\href{http://exo7.emath.fr/ficpdf/\mymafiche}{Fiche d'exercices $\blacklozenge$ #2}}}}
% --- Indication des couleurs (pour couleur #1, pour nb #2)
\newcommand{\couleurnb}[2]{#1}
% ----------------------------------------------------------------------
% Constantes pour l'inclusion des figures
\newcommand{\myscale}{1}
% Pour afficher/cacher les solutions
\usepackage{comment}
%\newenvironment{code}{\begin{center}}{\end{center}}
\newenvironment{solution}{\bigskip\textbf{Solution.}}{}
%\tcolorboxenvironment{solution}{leftlined={3pt}{lightgray,decorate,decoration={name=zigzag}}}
\def\myzero{0}
\ifx \displaysolutions \myzero \excludecomment{solution}\let\endsolution\relax\else\fi
\ifx \displaysolutions \myzero \excludecomment{code}\let\endsolution\relax\else\fi
\newcommand{\onesolution}[3]{
\tcbox[center title,fonttitle = \bfseries,title={#1 \\ #2},halign=center,box align=top,nobeforeafter]
{#3}
}
% ----------------------------------------------------------------------
% Algorithmes
% bloc de code (\insertcode)
\newcommand{\insertcode}[2]{%
\begin{tcolorbox}[title={#2},breakable,fonttitle=\bfseries\upshape,fontupper=\itshape, colback=black!5!white,colbacktitle=black!10!white,coltitle=red!75!black,toptitle=5pt,bottomtitle=4pt,
arc=0pt,outer arc=0pt,
left=5pt,right=0pt,top=2pt,
arc=0pt,
boxrule=0pt,
leftrule=5pt,
colframe=black!50]%
\myinputlisting{#1}%
\end{tcolorbox}
}
%\newcommand{\insertcode}[2]{%
%\begin{moncode}[#2]%
%\myinputlisting{#1}%
%\end{moncode}
%}
%\newcommand{\fonction}[2][]{
%\begin{center}
%\begin{minipage}{0.7\textwidth}
%Titre : #1 \\
%#2
%\end{minipage}
%\end{center}
%}
\newenvironment{fonction}[1][\unskip]{%
\begin{center}
\begin{minipage}{0.8\textwidth}
\begin{tcolorbox}[colback=white,colframe=lightgray,coltitle=black,title=#1,halign title=center]
}
{\end{tcolorbox}
\end{minipage}
\end{center}}
\newenvironment{fonctionpython}[1][\unskip]{%
\begin{center}
\begin{minipage}{0.8\textwidth}
\begin{tcolorbox}[title=#1,halign title=center]
}
{\end{tcolorbox}
\end{minipage}
\end{center}}
\newenvironment{code}[1][\unskip]{%
\begin{center}
\begin{minipage}{0.49\textwidth}
\begin{tcolorbox}[title=#1,halign title=left,subtitle style={boxrule=0.6pt,
colback=lightgray}]
%\begin{lstlisting}
}
{
%\end{lstlisting}
\end{tcolorbox}
\end{minipage}
\end{center}}
\newcommand{\soustitre}[1]{\tcbsubtitle{#1}}
\newcommand{\objectifs}[1]{
\sauteligne
\begin{center}
\begin{minipage}{0.9\textwidth}
\emph{#1}
\end{minipage}
\end{center}
}
% code en ligne (\codeinline)
%\newcommand{\codeinline}[1]{\lstinline[showstringspaces=false]!#1!}
\newcommand{\codeinline}[1]{\lstinline[showstringspaces=false,breaklines=true,breakatwhitespace=true]!#1!}
\newcommand{\ci}[1]{\codeinline{#1}}
% Ligne bien centrée ()sans utiliser \centerline)
\newenvironment{nscenter}
{\parskip=0pt\par\nopagebreak\centering}
{\par\noindent\ignorespacesafterend}
\newcommand{\mycenterline}[1]{\begin{nscenter}#1\end{nscenter}}
%\renewcommand{\centerline}[1]{\erreur} % A commenter après débugage