forked from exo7math/deepmath-exo7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
python-print.sty
602 lines (525 loc) · 19.8 KB
/
python-print.sty
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
% \mainfolder est ../ si compilation d'un chapitre, sinon c'est vide
\ProvidesPackage{\mainfolder python-print}
% ----------------------------------------------------------------------
% Format de la page
\usepackage[
papersize={7.5in,9.25in},
% old Python/Scratch papersize={8.5in,11in},
% algebre/analyse papersize={7.5in,9.25in},
nomarginpar, nofoot,
%margin = 0.7in, % OLD v1.0
%old margin = 0.9in,
%top=0.9in,
%right=0.8in, left=0.8in, top=0.5in, bottom=0.7in,
right=0.7in, left=0.7in, top=0.8in, bottom=0.6in,% NEW left=right, top+bottom=0.7+0.7
bindingoffset=0.5in,
headsep=21pt, heightrounded,
% showframe,
]{geometry}
% pas de retrait
\setlength{\parindent}{0cm}
% Espace interligne (+ xx%)
\linespread{1.1}
% ----------------------------------------------------------------------
% PDF/X (print ou test), nécessaire pour l'impression sur Amazon par exemple.
\usepackage{iftex}
\ifXeTeX\else
\pdfobjcompresslevel=0%
\pdfminorversion=4%
\fi
% ======================================================================
\usepackage{\mainfolder python-common}
% ======================================================================
% Cette partie ne s'applique pas à la création des images en PDF
% Elle rajoute des informations aux PDF nécéssaires pour l'impression sur Amazon par exemple.
\ifXeTeX\else
\tikzifexternalizing{}{
\pdfinfo{
/Title (Deepmath)
/Author (Arnaud Bodin et François Recher)
/Subject (algorithmes et programmation)
/Keywords (informatique, mathématiques, algorithme, python)
/GTS_PDFXVersion (PDF/X-3:2002)
}%
\pdfcatalog{
/PageMode /UseNone
/OutputIntents [ <<
/Info (none)
/Type /OutputIntent
/S /GTS_PDFX
/OutputConditionIdentifier (createspace.com)
/RegistryName (http://www.color.org/)
>> ]
}%
% http://tex.stackexchange.com/a/248911/831
\makeatletter
\edef\pwpt{\strip@pt\dimexpr0.996264009963\paperwidth\relax} %paper width in PS points
\edef\phpt{\strip@pt\dimexpr0.996264009963\paperheight\relax} %paper height in PS points
\makeatother
\edef\mypdfpageattr{
/MediaBox [0 0 \pwpt\space\phpt]^^J
/BleedBox [0.00000 0.00000 \pwpt\space\phpt]^^J
/CropBox [0 0 \pwpt\space\phpt]^^J
/TrimBox [0.00000 0.00000 \pwpt\space\phpt]
}
\expandafter\pdfpageattr\expandafter{\mypdfpageattr}
} % fin \tikzifexternalizing
\fi
% ----------------------------------------------------------------------
\usepackage{etex} % http://tex.stackexchange.com/a/38609
% ----------------------------------------------------------------------
% Police par defaut
\ifPDFTeX\else
\setmainfont
[ BoldFont = texgyrepagella-bold.otf ,
ItalicFont = texgyrepagella-italic.otf ,
BoldItalicFont = texgyrepagella-bolditalic.otf ]
{texgyrepagella-regular.otf}
\fi
\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[unit=space]{encoding={T1}, family={bch}, series={m}, size={*}, shape={it}}{'={100,200}}
%\SetExtraKerning[name=frenchdefault,context=french,unit=space]{encoding={OT1,T1,LY1}}{'= {1000,1000},}
% ----------------------------------------------------------------------
% 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}
\renewcommand\cftchapafterpnum{\vskip-4pt}
%\setlength{\cftbeforepartskip}{0pt} % espace entre avant un titre de partie
\setlength{\cftparskip}{-3pt} % espace entre les titres de chapitres
%\renewcommand\cftsecafterpnum{\vskip15pt}
%\usepackage{titletoc} % Inutile
%\addto\captionsfrancais{\def\contentsname{Sommaire}} % Ne marche pas !
\AtBeginDocument{\renewcommand{\contentsname}{Sommaire}}
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% Définition d'un terme, mise en relief
% \newcommand{\defi}[1]{\underline{\underline{\textbf{\emph{#1}}}\index{#1}}}
% \usepackage{soul}
% \setul{1pt}{.4pt} % 1pt sous la baseline
% \newcommand{\defi}[1]{\ul{\textbf{\emph{#1}}}\index{#1}}
\usepackage[normalem]{ulem}
% \setlength{\ULdepth}{3pt}
% \newcommand{\defi}[1]{\uuline{\textbf{#1\hphantom{\!}}}\,\index{#1}}
\setlength{\ULdepth}{1.5pt}
\renewcommand{\ULthickness}{0.6pt}
\newcommand{\defi}[1]{\uline{\textbf{#1}}}
\newcommand{\evidence}[1]{\textbf{#1}}
\newcommand{\assertion}[1]{{\og\emph{#1}\fg}} % pour chapitre logique
% ----------------------------------------------------------------------
% Titre du livre
\newcommand{\montitre}[1]{
\pagestyle{empty}\thispagestyle{empty}
\begin{center}
\Huge #1
\end{center}
\begin{center}
\LogoExoSept{5}
\end{center}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\tableofcontents
\pagestyle{chapterpage}
}
% ----------------------------------------------------------------------
% Les chapitres
% Pour figure titre \part deepmath
\newcommand\mynetwork[1]{
\def\numpart{\the\numexpr\value{part}}
\begin{center}
\begin{tikzpicture}
\pgfmathsetmacro\k{1+2*\numpart}
\pgfmathsetmacro\kk{\k +2}
\pgfmathsetmacro\halfk{\k/2}
\pgfmathsetmacro\halfkk{\kk/2}
\pgfmathsetmacro\scale{3/\k}
\def\layersep{4 cm}
\tikzstyle{every pin edge}=[<-,shorten <=1pt,thick]
\tikzstyle{neuron}=[circle,fill=black!25,minimum size=10*\scale pt,inner sep=0pt]
\tikzstyle{entree}=[];
\tikzstyle{input neuron}=[neuron, fill=green!50];
\tikzstyle{output neuron}=[neuron, fill=red!50];
\tikzstyle{hidden neuron}=[neuron, fill=blue!50];
\tikzstyle{annot} = [text width=4em, text centered]
% Premiere couche
\foreach \name / \y in {1,...,\k}{
% This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4}
\path[yshift=-\halfk*\scale cm,yshift=-0.5*\scale cm]
node[input neuron] (I-\name) at (0,\y*\scale) {};
}
%Seconde couche
\foreach \name / \y in {1,...,\kk}{
\path[yshift=-\halfkk*\scale cm,yshift=-0.5*\scale cm]
node[hidden neuron] (H-\name) at (\layersep,\y*\scale cm) {};
}
% Connect every node in the input layer with every node in the
% hidden layer.
\foreach \source in {1,...,\k}{
\foreach \dest in {1,...,\kk}{
\path[thick] (I-\source) edge (H-\dest);
}
}
\end{tikzpicture}
\end{center}
}
% Fin figure \part deepmath
\newcommand{\debutchapitres}{\clearpage\pagestyle{main}\thispagestyle{empty}\setcounter{page}{1}}
%\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]%
\mynetwork{\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{darkgray}\LARGE}% format
{}% label
{0pt}% sep
{\thesection.~#1}
\titleformat{name=\section,numberless}
{\Needspace{10\baselineskip}\sectionfonte\selectfont\color{darkgray}\LARGE}% format
{}% label
{0pt}% sep
{#1}
% les sous-sections
\titleformat{\subsection}
{\Needspace{5\baselineskip}\sectionfonte\selectfont\color{gray}\Large}% format
{}% label
{0pt}% sep
{\thesubsection.~#1}
\titleformat{name=\subsection, numberless}
{\Needspace{5\baselineskip}\sectionfonte\selectfont\color{gray}\Large}% format
{}% label
{0pt}% sep
{#1}
% ----------------------------------------------------------------------
% Format en-têtes
%\usepackage{titleps} % chargé par titlesec, je suppse
\newpagestyle{main}[\small]{
\setheadrule{0pt}%{.55pt}
\sethead[{\large\textbf{\thepage}}\quad{\large\color{gray}\entetefonte{\chaptertitle}}]% even-left
[]% even-center
[]% even-right
{}% odd-left
{}% odd-center
{{\large\color{gray}\entetefonte{\chaptertitle}}\quad{\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}
\assignpagestyle{\part}{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*{definition}{Définition}
\newtheorem*{remarque*}{Remarque}
\newtheorem*{exercicecours}{Exercice}
\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.1ex, bottom=2.1ex
}
}
%\tcolorboxenvironment{activite}{leftlined={5pt}{gray}}
%\tcolorboxenvironment{enigme}{leftlined={5pt}{gray}}
%\tcolorboxenvironment{solution}{leftlined={3pt}{lightgray}}
%\tcolorboxenvironment{exemple}{leftlined={3pt}{lightgray,decorate,decoration={name=zigzag}}}
%\tcolorboxenvironment{cours}{leftlined={3pt}{lightgray}}
%\tcolorboxenvironment{algorithme}{leftlined={3pt}{lightgray}}
%% 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}
\tcolorboxenvironment{activite}{leftlined={5pt}{gray}}
\tcolorboxenvironment{algorithme}{leftlined={3pt}{lightgray}}
\tcolorboxenvironment{exemple}{leftlined={3pt}{lightgray}}
\tcolorboxenvironment{cours}{leftlined={3pt}{lightgray,decorate,decoration={name=zigzag}}}
% ----------------------------------------------------------------------
% 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}},
execute at end node={\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};}}
% ----------------------------------------------------------------------
% Alignement vertical des item
% \renewcommand{\labelitemi}{\raisebox{0ex}{\footnotesize$\bullet$}\hskip0.1em}
% \renewcommand{\labelitemii}{\raisebox{0.12ex}{$-$}\hskip0.1em}
% ----------------------------------------------------------------------
% simple affichage des href pour l'impression
\providecommand{\href}[2]{#2}
% --- Liens vers vidéo Youtube
% \usepackage{qrcode}
% \newcommand{\insertvideo}[2]{
% \qrcode[height=1cm]{https://www.youtube.com/watch/?v=\detokenize{#1}}\hspace{3mm}
% \parbox[c][1cm]{\textwidth-1cm}{\fontsize{10pt}{7pt}\selectfont{\ugqfont\selectfont{\color{gray} Vidéo~}#2}\\[1pt]\texttt{\color{gray}{\small https://www.youtube.com/watch/?v=}\detokenize{#1}}}
% }
\newcommand{\insertvideo}[2]{}
\newcommand{\video}[1]{\insertvideo{#1}{--- Titre manquant ---}}
% --- Liens vers les fiches d'exercices
\newcommand{\insertfiche}[2]{
\qrcode[height=1cm]{http://exo7.emath.fr/ficpdf/\detokenize{#1}}\hspace{3mm}
\parbox[c][1cm]{\textwidth-1cm}{\fontsize{10pt}{7pt}\selectfont{\ugqfont\selectfont{\color{gray} Fiche d'exercices~}#2}\\[1pt]\texttt{\color{gray}{\small http://exo7.emath.fr/ficpdf/}\detokenize{#1}}}
}
\renewcommand{\insertfiche}[2]{}
\newcommand{\mafiche}[1]{\insertfiche{#1}{--- Titre manquant ---}}
% --- Indication des couleurs (pour couleur #1, pour nb #2)
\newcommand{\couleurnb}[2]{#2}
% ----------------------------------------------------------------------
% Constantes pour l'inclusion des figures
\newcommand{\myscale}{0.8}
% Pour afficher/cacher les solutions
\usepackage{comment}
%\newenvironment{code}{\begin{center}}{\end{center}}
\newenvironment{solution}{\bigskip\begin{minipage}{0.8\textwidth}\textbf{Solution.}}{\end{minipage}}
%\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,enlarge by=2mm]
%,enlarge top initially by=3mm,enlarge bottom finally by=3mm,show bounding box]
{#3}
%,nobeforeafter
}
% --- les figures avec échelle éventuel
\renewcommand{\myfigure}[2]{% entrée : échelle, fichier(s) figure à inclure
\begin{center}\small
\tikzstyle{every picture}=[scale=0.95*#1]% mise en échelle + 10% (automatiquement annulé à la fin du groupe)
#2
\end{center}}
% ----------------------------------------------------------------------
% 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