Debian Codegraph @

texmf-dist/source/latex/fascicules/fascicules.dtx

raw
1 % \iffalse
2 %<*driver>
3 \ProvidesFile{fascicules.dtx}
4 %</driver>
5 %<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
6 %<class>\ProvidesPackage{fascicules}
7 %<*class>
8 [2018/12/18 v1 fascicules package]
9 %</class>
10 %
11 %<*driver>
12 \documentclass{ltxdoc}
13 \EnableCrossrefs
14 \CodelineIndex
15 \RecordChanges
16 \begin{document}
17 \DocInput{fascicules.dtx}
18 \end{document}
19 %</driver>
20 % \fi
21 %
22 % \CheckSum{0}
23 %
24 % \CharacterTable
25 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
26 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
27 % Digits \0\1\2\3\4\5\6\7\8\9
28 % Exclamation \! Double quote \" Hash (number) \#
29 % Dollar \$ Percent \% Ampersand \&
30 % Acute accent \' Left paren \( Right paren \)
31 % Asterisk \* Plus \+ Comma \,
32 % Minus \- Point \. Solidus \/
33 % Colon \: Semicolon \; Less than \<
34 % Equals \= Greater than \> Question mark \?
35 % Commercial at \@ Left bracket \[ Backslash \\
36 % Right bracket \] Circumflex \^ Underscore \_
37 % Grave accent \` Left brace \{ Vertical bar \|
38 % Right brace \} Tilde \~}
39 %
40 %
41 % \changes{v1.0}{2018/12/17}{Initial version}
42 %
43 % \GetFileInfo{fascicules.dtx}
44 %
45 % \DoNotIndex{\newcommand,\newenvironment}
46 %
47 % \newcommand{\blackbox}{\rule{0.65em}{0.65em}}
48 %
49
50 %
51 %
52 % \newcommand*{\NEWfeature}[1]{%
53 % \hskip 1sp \marginpar{\small\sffamily\raggedright
54 % New feature\\#1}}
55 %
56 % \title{fascicules package: creating mathematics secondary book using \LaTeX{}}
57 %
58 % \author{Martin Moritz\\ \texttt{[email protected]}\\{\large European School of Helsinki}}
59 %
60 % \date{Version \fileversion, \filedate}
61 %
62 % \maketitle
63 %
64 %
65 % \tableofcontents
66 %
67 %
68 % \section{Introduction} \label{sec:introduction}
69 %
70 % This is a package intended to help teachers creating mathematics books for secondary/upper secondary.
71 %
72 % \section{Usage} \label{sec:usage}
73 %
74 % \subsection{Options of the package} \label{ssec:options}
75 %
76 % There are 4 keys thant can be given as an option : \texttt{exercises}, \texttt{activities}, \texttt{lesson} or \texttt{solutions}. All these keys can have two values : \texttt{true} or \texttt{false}.
77 %
78 % When the values are false, the corresponding part of the book will not appear in the document. If it's true, it will appear.
79 %
80 % For these 4 keys, the default value is true.
81 %
82 % If you want a book that contains only the exercises (and the solutions),
83 % call the package that way :
84 %
85 % \begin{quote}
86 % |\usepackage|[lesson=false,activities=false]\{fascicules\}
87 % \end{quote}
88 %
89 % There is another possible value for solutions : \texttt{inside}. In that case, the solutions appear inside the exercises part, right after the exercise. The goal is to make it easier to check, when you want to type or modify the solutions.
90 %
91 % There is also another possible value for lesson : \texttt{methods}. In that case, only the methods appear inside the lesson part (actually, there is in that case a method part that replaces the lesson part). In that case, the lesson will be compiled somewhere else, as a beamer presentation.
92 %
93 % \subsection{Make the title page} \label{ssec:title}
94 %
95 %\DescribeMacro{\fasciculestitle} This commands replace the \LaTeX command |\maketitle|. It uses the well-known \LaTeX commands |\title{}|, |\subtitle{}|, |\author{}|, |\publishers{}| and |\date{}|,
96 % \subsection{Create a chapter} \label{ssec:chapter}
97 % Start a new chapter with the \LaTeX command |\chapter|\{title of the chapter\}
98 %
99 % You can have an image in the background with the following code :
100 %
101 % \begin{quote}
102 % |\backgroundimage|\{\textsl{paths/to/image}\}
103 %
104 % |\thispagestyle|\{chapterpage\}
105 % \end{quote}
106 %
107 % \subsection{The table of contents} \label{ssec:tableofcontents}
108 %
109 %\DescribeMacro{\listofmethods}
110 % In addition to the latex command |\tableofcontents| the package provides the command |\listofmethods| in order to print the list of the methods. The methods are numbered in the way 1.1, where the first number is the number of the chapter and the second the number of the method.
111 %
112 % \subsection{Organisation of the chapters} \label{ssec:organisation}
113 %
114 % \DescribeEnv{lesson} \DescribeEnv{activities} \DescribeEnv{exercises}
115 % These three environments start the pages for the lesson,the activities and the exercises. Each chapter can have these type of pages.The exercises are displayed in a twocolumn environment.
116 %
117 %\DescribeEnv{solutions} This environment is to display the solutions of the exercises. All the solutions of the different chapter will appear at the end of the book.
118 %
119 %
120 % \subsection{Exercises} \label{ssec:exercises}
121 %\DescribeMacro{\onecolumnexos}
122 % The exercises always appear in a twocolumn layout. If for some reason, we want to avoid it, we can use this command
123 % \begin{quote}
124 % |\onecolumnexos|\marg{the text in one column}
125 % \end{quote}
126 %
127 %
128 %
129 %
130 %\DescribeMacro{\groupexos}
131 % This commands can appear before exercises that match the same learning goal. The title will appear clearly in the middle of the columns
132 % \begin{quote}
133 % |\groupexos|\marg{title}
134 % \end{quote}
135 %
136 %\DescribeEnv{exo} This environment contains the text of one exercise. The exercises are numbered starting at 1 for each new chapter. The exercise have optionnal argument.
137 % \begin{itemize}
138 % \item title : is the title of the exercise, if any (none by default).
139 % \item type : |solution| (there is a solution printed usually at the end of the book). In that case, the number of the exercise appears in another color.
140 %
141 % |method| This exercice is supposed to appear in the lesson, right after a method. The number appears also in a specific color.
142 %\end{itemize}
143 % \begin{quote}
144 % |\begin{exo}|\oarg{title=,type=}\\
145 % \ldots \meta{text} \ldots\\
146 % |\end{exo}|
147 %\end{quote}
148 %
149 % \DescribeEnv{sol} \DescribeEnv{sol*}
150 % Those environments contain the text of the answers. The solution will appear on another page and only for the teachers for the environment \texttt{sol*}
151 %
152 % \subsection{Activities} \label{ssec:activities}
153 %
154 %\DescribeMacro{\activity} This command starts a new activity, the activities are numbered starting at 1 for each chapter.
155 %
156 %\DescribeEnv{objective} An environment where you can write the objective of this activity (if any).
157 %
158 %
159 % \subsection{Lesson} \label{ssec:lesson}
160 %
161 % After the lesson command, you can start writing your lesson.
162 % the lessons are divided into sections and subsections.
163 %
164 %\DescribeEnv{method} \DescribeEnv{theorem} \DescribeEnv{definition} \DescribeEnv{property} \DescribeEnv{formula}
165 % All those environments must have a title (possibly empty). A label can be given as an optionnal argument, so that it can be referred to in other parts of the book (e.g. in the exercises).
166 % \begin{quote}
167 % |\begin{method}|\oarg{yourlabel}\marg{title}\\
168 % \ldots \meta{text} \ldots\\
169 % |\end{method}|
170 %\end{quote}
171 %
172 %
173 % \DescribeEnv{remark} \DescribeEnv{proof}
174 % Those are also straightforward. No argument, they just work on their own.
175 %
176 %
177 %
178 % \subsection{Graphics} \label{ssec:graphics}
179 % Graphics are quite important in a secondary mathematics book. The following commands are here to ensure that the graphics have all the same style.
180 %
181 %\DescribeMacro{\window}
182 % This command defines the window where the graphic will be drawn. The x-axes is horizontal and the y-axes is vertical.
183 %
184 % \begin{quote}
185 % |\window|\marg{Xmin}\marg{Xmax}\marg{Ymin}\marg{Ymax}
186 % \end{quote}
187 % \DescribeMacro{\axeH} \DescribeMacro{\axeV} \DescribeMacro{\tickX} \DescribeMacro{\tickY}
188 % Those commands enable to draw rapidly the axes (vertical and horizontal) and to mark the first graduation. By default, the axes are labeled $x$ and $y$ and the graduation is put at $1$. It can be changed by using the optional argument.
189 % \begin{quote}
190 % |\axeH|\oarg{label}
191 % \end{quote}
192 % \begin{quote}
193 % |\axeV|\oarg{label}
194 % \end{quote}
195 % \begin{quote}
196 % |\tickX|\oarg{graduation}
197 % \end{quote}
198 % \begin{quote}
199 % |\tickY|\oarg{graduation}
200 % \end{quote}
201 %
202 % \DescribeEnv{windowsratio}
203 % Finally, you can force the ratio of the rectangle window. The height/width is by default 0.66, so that the graphics looks moreorless like the screen of a calulator, the ratio can be changed.
204 %
205 %
206 % \begin{quote}
207 % |\begin{windowsratio}|\oarg{ratio}\\
208 % \ldots \meta{text} \ldots\\
209 % |\end{windowsratio}|
210 %\end{quote}
211 %
212 % \section{Implementation}
213 % \begin{macrocode}
214 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
215 \ProvidesPackage{fascicules}[2018/02/22]
216 \RequirePackage[svgnames]{xcolor} % nice colors with nice names
217 \@ifclassloaded{scrbook}{
218 \RequirePackage[noxcolor]{beamerarticle}
219 }{}
220
221 \RequirePackage{amsthm}
222 \RequirePackage{keyval}
223 \RequirePackage{comment}
224 \RequirePackage{ifthen}
225 \@ifclassloaded{scrbook}{
226 \RequirePackage{enumitem}
227 }
228
229 % ligne vide necessaire après la condition
230
231 \RequirePackage{multicol}
232 \RequirePackage{calc} %commande widthof
233 \RequirePackage{tikz}
234 \RequirePackage{nameref}
235 \usetikzlibrary{calc}
236 \RequirePackage{tcolorbox} % differentes box colorées
237 \tcbuselibrary{theorems}
238 \RequirePackage{pgfopts} % use keyval option in the package
239 \RequirePackage{environ} % new command \NewEnviron
240 \RequirePackage{comment} % include environment as a comment. The goal here is to include or not the lessons, the activities or the exercises
241 \RequirePackage{tagging} % conditionnal compiling (used for the methods)
242 \RequirePackage{xcomment} % to comment everything but some environments (used for the methods)
243 \RequirePackage{hyperref} % references
244 \RequirePackage{cleveref} % clever references
245
246 % \end{macrocode}
247 %
248 % To be able to use the old commands \bf and \it
249 %
250 % \begin{macrocode}
251
252
253 \DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
254 \DeclareOldFontCommand{\it}{\normalfont\bfseries}{\mathit}
255
256 % \end{macrocode}
257 %
258 % The colors and the name of the part of the book, in French
259 %
260 % \begin{macrocode}
261
262
263 \newcommand{\methodscolor}{DarkOrchid}
264 \newcommand{\lessoncolor}{LimeGreen}
265 \newcommand{\exercisescolor}{SlateBlue}
266 \newcommand{\activitiescolor}{OrangeRed}
267 \newcommand{\solutionscolor}{red}
268 \newcommand{\notez}{}
269 \newlength{\fascicules@groupexoswidth}
270 \newcommand{\esbook@lessonname}{cours}
271 \newcommand{\esbook@activitiesname}{activit\'es}
272 \newcommand{\esbook@activityname}{activit\'e}
273 \newcommand{\esbook@exercisesname}{exercices}
274 \newcommand{\esbook@solutionsname}{corrig\'es}
275 \newcommand{\esbook@methodsname}{m\'ethodes}
276
277
278
279 % \end{macrocode}
280 %
281 % Definition of the theorem-like environment for the lesson
282 %
283 % \begin{macrocode}
284 \renewenvironment{theorem}[2][]{\begin{theo}[label=#1]{#2}{}}{\end{theo}}
285 \renewenvironment{definition}[2][]{\begin{defi}[label=#1]{#2}{}}{\end{defi}}
286 \newenvironment{objective}{\begin{obj}{}{}}{\end{obj}}
287 \newenvironment{property}[2][]{\begin{prop}[label=#1]{#2}{}}{\end{prop}}
288 \newenvironment{formula}[2][]{\begin{form}[label=#1]{#2}{}}{\end{form}}
289
290 % \end{macrocode}
291 %
292 % The method environment vary if we are in a beamer or not. In order to get the list of methods also in beamer
293 %
294 % \begin{macrocode}
295
296 \@ifclassloaded{scrbook}{
297
298
299 % \end{macrocode}
300
301 % Personnalisation de la numerotation, utilise le package enumitem.
302 % La numérotation est le plus compacte possible, serrée sur la marge
303 % ,afin de laisser de la place pour le texte (notamment quand il y a deux colonnes)
304 % \begin{macrocode}
305
306
307 \setitemize{itemsep=0pt,parsep=0pt,leftmargin=*,labelsep=1pt,noitemsep}
308 \setenumerate{wide,nosep,noitemsep,labelsep=0pt}
309 \setenumerate[1]{label=\bf{\arabic*.}\; }
310 \setenumerate[2]{label=\bf{\alph*)\;} }
311
312
313 \newenvironment{method}[2][]{\begin{meth}[label=#1]{#2}{} }{\end{meth}}
314 }
315 {}
316 \@ifclassloaded{beamer}{
317 \newenvironment{method}[2][]{\begin{meth}[label=#1]{#2}{} %
318 \only<1>{\addcontentsline{lom}{method}{m\'ethode \protect\ref{#1} .#2\par} }}{\end{meth}}
319 }
320 {}
321
322 \makeatletter
323
324 \newtcbtheorem{theo}{Th\'eorème}
325 {code={\NR@gettitle{#2}},colback=green!5,colframe=green!35!black,%
326 fonttitle=\bfseries,theorem name,separator sign none,%
327 description delimiters parenthesis,label type=theorem}{th}
328
329
330 \@ifclassloaded{scrbook}{
331 \newtcbtheorem[list inside=method,number within=chapter]%
332 {meth}{m\'ethode}{code={\NR@gettitle{#2}},%
333 colback=blue!5,colframe=blue!30,coltitle=black,fonttitle=\bfseries,%
334 theorem name and number,separator sign colon,description delimiters none,%
335 label type=method}{}
336 }
337 {}
338 \@ifclassloaded{beamer}{
339 \newtcbtheorem{meth}{m\'ethode}{code={\NR@gettitle{#2}},colback=blue!5,colframe=blue!30%
340 ,coltitle=black,fonttitle=\bfseries,theorem name and number,separator sign colon,%
341 description delimiters none,label type=method}{}
342 }
343 {}
344
345
346 \newtcbtheorem{prop}{Propri\'et\'e}{code={\NR@gettitle{#2}},colback=green!5,%
347 colframe=green!35!black,fonttitle=\bfseries,theorem name,separator sign none,%
348 description delimiters parenthesis,label type=property}{}
349
350 \newtcbtheorem{obj}{Objectif}{colback=orange!5,colframe=orange!35!black,%
351 fonttitle=\bfseries,theorem name,separator sign none,description delimiters parenthesis}{}
352
353 \newtcbtheorem{form}{Formule}{code={\NR@gettitle{#2}},colback=orange!5,colframe=green!35!black,%
354 fonttitle=\bfseries,theorem name,separator sign none,label type=formula}{}
355
356 \newtcbtheorem{defi}{D\'efinition}{code={\NR@gettitle{#2}},colback=red!5,%
357 colframe=red!35!black,fonttitle=\bfseries,theorem name,separator sign none,%
358 description delimiters parenthesis,label type=definition}{}
359
360 \newenvironment{remark}{ \begin{tikzpicture}[baseline] %
361 \node[fill=orange!30,anchor=base,circle,draw=orange,line width=1pt]%
362 at (0,0) {NB:}; \end{tikzpicture} \begin{minipage}{.8\columnwidth}}{\end{minipage}}
363
364 \renewenvironment{proof}{\textbf{D\'emonstration:} \par}{\hfill \qed}
365
366 % \end{macrocode}
367 %
368 % The code is specific to the book. It does not concern beamer lessons
369 %
370 % \begin{macrocode}
371
372
373
374 \@ifclassloaded{scrbook}{
375
376 % \end{macrocode}
377 %
378 % Definition of the title
379 %
380 % \begin{macrocode}
381 % pour importer des presentations beamer dans le manuel
382 \RequirePackage[noxcolor]{beamerarticle}
383
384 \makeatletter
385 \def\fasciculestitle{
386 \begin{titlepage}
387 %=========================
388 \begin{center}
389 \hspace{0pt}\\
390 \vspace{4cm}
391 {\Large\bfseries \@author}\\
392 \vspace{3cm}
393 {\scalebox{1.5}{\Huge\bfseries \@title }}\\
394 \vspace{0.8cm}
395 {\LARGE\bfseries \@subtitle}\\[10pt]
396 % ----------------------------------------------------------------
397 \vfill
398 \@publishers\\
399 \@date
400 % ----------------------------------------------------------------
401 \end{center}
402
403 % ---------------
404
405 \thispagestyle{empty}
406
407 \clearpage
408 \end{titlepage}
409 }
410 \makeatother
411 % \end{macrocode}
412 %
413 % Processing the options
414 %
415 % \begin{macrocode}
416
417
418 \pgfkeys{
419 /include/.is family,/include,
420 default/.style = {exercises = true,lesson = true,activities=true,solutions=true},
421 exercises/.store in=\fascicules@modeexercises,
422 lesson/.store in=\fascicules@modelesson,
423 activities/.store in=\fascicules@modeactivities,
424 solutions/.store in=\fascicules@modesolutions,
425 }
426 \pgfkeys{/include,/include/default}
427 \ProcessPgfOptions{/include}
428
429 % \end{macrocode}
430 %
431 % If we want to have the solutions of the exercises inside exercices pages.
432 %
433 % \begin{macrocode}
434 \ifthenelse
435 {\equal{\fascicules@modesolutions}{inside}}
436 {\PassOptionsToPackage{nosolutionfiles}{answers}}
437 {}
438
439 \RequirePackage{answers}
440
441 % activates pagestyle scrheadings
442
443 \RequirePackage[headsepline=1pt,footsepline=1pt]{scrlayer-scrpage}
444 \clearpairofpagestyles
445
446 \addtokomafont{pagehead}{\color{white} \bfseries} % font for the page headers
447 \addtokomafont{pagefoot}{\large \bfseries} % font for the page headers
448
449 \newcommand*{\headcontents}[1]{%
450 \raisebox{0pt}[\ht\strutbox][\dimexpr\headheight-\ht\strutbox\relax]{#1}}
451
452 \newpairofpagestyles[scrheadings]{lesson}%
453 {\ihead{\esbook@lessonname} \ohead{\leftmark} \ofoot{\thepage} }
454 \newpairofpagestyles[scrheadings]{activities}%
455 {\ihead{\esbook@activitiesname} \ohead{\leftmark} \ofoot{\thepage} }
456 \newpairofpagestyles[scrheadings]{exercises}%
457 {\ihead{\esbook@exercisesname} \ohead{\leftmark} \ofoot{\thepage} }
458 \newpairofpagestyles[scrheadings]{solutions}%
459 {\ihead{\esbook@solutionsname} \ofoot{\thepage} }
460 \newpairofpagestyles[scrheadings]{methods}%
461 {\ihead{\esbook@methodsname} \ohead{\leftmark} \ofoot{\thepage} }
462
463 % \end{macrocode}
464 %
465 % Here are the definitions of the layers
466 %
467 % \begin{macrocode}
468 \newcommand*\headcoloredbg[1]{%
469 \begin{tikzpicture}
470 \fill[color=#1](0,0)rectangle({\layerwidth},{\layerheight});
471 \end{tikzpicture}
472 }
473 \DeclareNewLayer[background,topmargin,
474 addheight=20pt,
475 contents=\headcoloredbg{\lessoncolor}
476 ]{lesson.bg}
477 \DeclareNewLayer[background,topmargin,
478 addheight=20pt,
479 contents=\headcoloredbg{\exercisescolor}
480 ]{exercises.bg}
481 \DeclareNewLayer[background,topmargin,
482 addheight=20pt,
483 contents=\headcoloredbg{\activitiescolor}
484 ]{activities.bg}
485 \DeclareNewLayer[background,topmargin,
486 addheight=20pt,
487 contents=\headcoloredbg{\solutionscolor}
488 ]{solutions.bg}
489 \DeclareNewLayer[background,topmargin,
490 addheight=20pt,
491 contents=\headcoloredbg{\methodscolor}
492 ]{methods.bg}
493
494 \AddLayersAtBeginOfPageStyle{lesson}{lesson.bg}
495 \AddLayersAtBeginOfPageStyle{exercises}{exercises.bg}
496 \AddLayersAtBeginOfPageStyle{activities}{activities.bg}
497 \AddLayersAtBeginOfPageStyle{solutions}{solutions.bg}
498 \AddLayersAtBeginOfPageStyle{methods}{methods.bg}
499
500
501 \newpairofpagestyles[scrheadings]{chapterpage}{}
502 \makeatletter
503 % \end{macrocode}
504 %
505 % The background image for the chapter page
506 %
507 % \begin{macrocode}
508 \newcommand*\@backgroundimage{}
509 \newcommand*\backgroundimage[1]{%
510 \ifstr{#1}{}{\gdef\@backgroundimage{}}{%
511 \gdef\@backgroundimage{\includegraphics[width=\layerwidth\relax]{#1}}%
512 }}
513
514 \colorlet{backgroundcolor}{white}
515 \newcommand*\coloredbg{%
516 \tikz\fill[backgroundcolor,opacity=.5](0,0)rectangle({\layerwidth},{\layerheight});}
517 \DeclareNewLayer[background,textarea,
518 addvoffset=-5pt,addhoffset=-5pt,addwidth=10pt,addheight=10pt,
519 contents=\coloredbg
520 ]{text.bg}
521 \DeclareNewLayer[background,
522 textarea, mode=picture,align=t,
523 contents={
524 \putLL{\begin{tikzpicture}
525 \fill[top color=PeachPuff,bottom color=PapayaWhip] (0,0) rectangle (\layerwidth,\layerheight/4+\layerheight/10);
526 \draw (0,\layerheight/5) rectangle (\layerwidth,\layerheight/2+\layerheight/5);
527 \shade[top color=Peru,bottom color=PeachPuff] (0,\layerheight/2) rectangle (\layerwidth,\layerheight);
528 \clip (0,\layerheight/5) rectangle (\layerwidth,\layerheight/2+\layerheight/5);
529 \node at (\layerwidth/2,\layerheight/4+\layerheight/10) {\@backgroundimage};
530 \end{tikzpicture}
531 }}
532 ]{image.bg}
533 \AddLayersAtBeginOfPageStyle{chapterpage}{text.bg,image.bg}
534
535
536 % \end{macrocode}
537 %
538 % Solutions with the package answers.
539 %
540 % \begin{macrocode}
541 \Newassociation{sol}{Solution}{solution}
542 \Newassociation{sol*}{Solution}{soluce}
543
544 \renewcommand{\Solutionlabel}[1]{\tikz{\node[rectangle,draw=red!50,fill=red!20] at(0,0) {#1}; }}
545
546
547
548
549 \newcommand{\headerFormat}{\color{white} \Large \bf } %le format des header des sections
550 \newcommand{\groupexosFormat}{\color{blue}} %le format de l'intitule des groupes d'exos
551 % le format de l'intitule des groupes d'exos
552 \newcommand{\activitytitleFormat}{\color{\activitiescolor} \Large \bf}
553 \newcommand{\fascicules@exocolour}{} % la couleur des étiquettes des exercices
554
555
556 \newcounter{fascicules@exo}
557 \newcounter{fascicules@activity}
558 \newenvironment{activities}{
559 \setcounter{fascicules@activity}{0}
560 \newpage
561 \pagestyle{activities}
562 }{ \clearpage}
563
564 % \end{macrocode}
565 %
566 % Exercices are always in a two column environment, sometimes we don't want it.
567 %
568 % \begin{macrocode}
569
570
571 \newcommand{\onecolumnexos}[1]
572 {
573 \end{multicols}
574 \thispagestyle{exercises}
575 #1
576 \pagestyle{exercises}
577 \begin{multicols}{2}
578 }
579
580
581 \NewEnviron{exercises}{
582 \newpage
583 \begin{multicols}{2}
584 \pagestyle{exercises}
585 \Opensolutionfile{solution}[solutions/ch\thechapter]
586 \Opensolutionfile{soluce}[solutions/ch\thechapter_prof]
587 \BODY
588 \clearpage
589 \Closesolutionfile{solution}
590 \Closesolutionfile{soluce}
591 \end{multicols}
592 }
593
594 \NewEnviron{solutions}{
595 \newpage
596 \pagestyle{solutions}
597 \begin{multicols}{2}
598 \BODY
599 \clearpage
600 \end{multicols}
601 }
602
603 \newenvironment{lesson}{
604 \setcounter{fascicules@exo}{0}
605 \newpage
606 \ifthenelse{\equal{\fascicules@modelesson}{true}}%
607 {\pagestyle{lesson}}{}
608 \ifthenelse{\equal{\fascicules@modelesson}{methods}}{
609 \pagestyle{methods}
610 \Opensolutionfile{solution}[solutions/ch\thechapter_methods]
611 }{}
612 }
613 {
614 \clearpage
615 \ifthenelse{\equal{\fascicules@modelesson}{methods}}{
616 \pagestyle{methods}
617 \Closesolutionfile{solution}
618 }{}
619 }
620
621
622
623 \newcommand{\activity}[1]{
624 \refstepcounter{fascicules@activity}
625 {
626 \activitytitleFormat \esbook@activityname~\thefascicules@activity. #1}
627 \medskip
628 }
629
630 \newcommand{\groupexos}[1]
631 {
632 \setlength{\fascicules@groupexoswidth}{\minof{\widthof{#1}}{.4\textwidth}}
633
634 \begin{center}
635 \begin{minipage}{\fascicules@groupexoswidth}
636 \groupexosFormat
637 \dotfill \par
638 #1
639 \end{minipage}
640 \end{center}
641 }
642
643 % \end{macrocode}
644 % The parts to include or exclude, depending of the package options
645 % \begin{macrocode}
646
647 \ifthenelse
648 {\equal{\fascicules@modeexercises}{true}}
649 {}
650 {\excludecomment{exercises}}
651 \ifthenelse
652 {\equal{\fascicules@modeactivities}{true}}
653 {}
654 {\excludecomment{activities}}
655 \ifthenelse
656 {\equal{\fascicules@modelesson}{true}}
657 {}
658 {}
659 \ifthenelse
660 {\equal{\fascicules@modelesson}{false}}
661 {\excludecomment{lesson}}
662 {}
663 \ifthenelse
664 {\equal{\fascicules@modelesson}{methods}}
665 {\usetag{method}} % will print only the methods
666 {}
667 \ifthenelse
668 {\equal{\fascicules@modesolutions}{false}}
669 {\excludecomment{solutions}}
670 {}
671 \ifthenelse
672 {\equal{\fascicules@modesolutions}{inside}}
673 {\excludecomment{solutions}}
674 {}
675
676 % \end{macrocode}
677 % Exercises have optional arguments. The color of the number varies if there are solutions or not in the manual.
678 % \begin{macrocode}
679 \pgfkeys{
680 /fascicules/.is family,/fascicules,
681 default/.style = {title = ,type = none},
682 title/.estore in = \exotitle,
683 type/.estore in = \exotype,
684 }
685
686 % \end{macrocode}
687 % Tricky environment...
688 % \begin{macrocode}
689
690
691 \newenvironment{exo}[1][]
692 {%
693 \pgfkeys{/fascicules, default, #1}%
694 \vspace{3mm}
695 \refstepcounter{fascicules@exo}
696
697 \ifthenelse{\equal{\exotype}{solution}}{\renewcommand{\fascicules@exocolour}{red}}
698 {
699 \ifthenelse{\equal{\exotype}{method}}{
700 \renewcommand{\fascicules@exocolour}{\methodscolor}
701 \untagged{method}{
702 \begin{multicols}{2}
703 \bgroup
704 \renewenvironment{sol}{{\bfseries solution:}}{}
705 }
706
707 }{
708 \renewcommand{\fascicules@exocolour}{blue}
709 }
710 }
711 \tikz \node[rectangle,draw=\fascicules@exocolour!50,fill=\fascicules@exocolour!20] {\thefascicules@exo};
712 \ifthenelse{\equal{\exotitle}{}}{}{{\bf \exotitle.}}
713 }
714 {
715 \ifthenelse{\equal{\exotype}{method}}{
716 \untagged{method}{\egroup \end{multicols}}
717 }{}
718 \penalty -1000 \par
719 }
720
721
722
723 \setkomafont{chapter}{\color{white} \usefont{T1}{qhv}{b}{n}\selectfont\huge}
724 \renewcommand\chapterformat{%
725 \begin{tikzpicture}
726 \node[rotate=90]at (0,0) {\Large \chapapp};
727 \node[rectangle,draw,fill=Olive] at (1,0) {\thechapter};
728 \end{tikzpicture}
729 }
730 \addtokomafont{subsection}{\fontsize{12pt}{12pt}\color{LimeGreen}\selectfont}
731 \addtokomafont{section}{\fontsize{14pt}{14pt}\color{LimeGreen}\selectfont}
732 \newkomafont{sectionnumber}{\fontsize{18pt}{18pt}\selectfont\rmfamily\color{white}}
733 \makeatletter
734 \renewcommand\sectionlinesformat[4]{%
735 \makebox[0pt][l]{\rule[-5pt]{\textwidth}{1pt}}%
736 \@hangfrom{#3}{#4}%
737 }
738 \makeatother
739
740
741 \makeatletter
742
743 \renewcommand{\thesection}{\arabic{section}}
744 \renewcommand\sectionformat{%
745 \setlength\fboxsep{5pt}%
746 \raisebox{-4pt}{\colorbox{LimeGreen}{%
747 \enskip{\usekomafont{sectionnumber} \thesection\autodot}\enskip}%
748 \quad%
749 }}
750
751
752 % \end{macrocode}
753 % How to manage the references with the cref package
754 %
755 % \begin{macrocode}
756 \makeatletter
757 \def\cref@getref#1#2{%
758 \xdef\@lastusedlabel{#1}%
759 \expandafter\let\expandafter#2\csname r@#1@cref\endcsname%
760 \expandafter\expandafter\expandafter\def%
761 \expandafter\expandafter\expandafter#2%
762 \expandafter\expandafter\expandafter{%
763 \expandafter\@firstoftwo#2}}%
764 \crefformat{method}{\color{\lessoncolor} M\'ethode #2#1#3 \nameref*{\@lastusedlabel} }
765 \crefformat{section}{\color{\lessoncolor} \S #2#1#3 \nameref*{\@lastusedlabel} }
766 \crefformat{fascicules@activity}{\color{\activitiescolor} \esbook@activityname~#2#1#3 \nameref*{\@lastusedlabel} }
767
768 % \end{macrocode}
769 % The command listofmethods for the book
770 %
771 % \begin{macrocode}
772 \newcommand\listofmethods{\tcblistof[\section*]{method}{Liste des M\'ethodes} }
773
774
775
776
777
778
779 } % class scrbook uniquement
780 {}
781
782
783 % \end{macrocode}
784 % Then what is specific to the beamer slides
785 % \begin{macrocode}
786 \makeatother
787 \makeatletter
788 \@ifclassloaded{beamer}
789 {
790
791 \usecolortheme{rose}
792 \useoutertheme[hideallsubsections,height=8pt]{sidebar}
793 \setbeamertemplate{section in toc}[sections numbered]
794 \setbeamercolor{structure}{fg=\lessoncolor, bg=green!10}
795 \resetcounteronoverlays{tcb@cnt@meth} % reset counters for methods
796
797
798
799 \AtBeginSection[
800 {
801 \begin{frame}<beamer>
802 \begin{centering}
803 \begin{beamercolorbox}[sep=12pt,center]{part title}
804 \usebeamerfont{section title} \insertsection\par
805 \end{beamercolorbox}
806 \end{centering}
807
808 \vfill
809 \tableofcontents[currentsection,sectionstyle=hide/hide,subsectionstyle=show/show/hide]
810 \vfill
811 \end{frame}
812 }
813 ]
814 {
815 \begin{frame}<beamer>
816 \begin{centering}
817 \begin{beamercolorbox}[sep=12pt,center]{part title}
818 \usebeamerfont{section title}\S \thesection.~ \insertsection\par
819 \end{beamercolorbox}
820 \end{centering}
821
822 \vfill
823 \tableofcontents[currentsection,sectionstyle=hide/hide,subsectionstyle=show/show/hide]
824 \vfill
825 %
826 %\frame{\sectionpage}
827 %\frametitle{\insertsection}
828 % \tableofcontents[currentsection, hideothersubsections]
829 \end{frame}
830 }
831
832 \newenvironment{cours}[1][]{
833 \title{\Cref{#1}. \nameref{#1}}
834 \begin{frame}
835 \titlepage
836 \end{frame}
837 % table des matières
838 \begin{frame}
839 \setcounter{tocdepth}{1}
840 \tableofcontents
841 \setcounter{tocdepth}{2}
842 \end{frame}
843 }{}
844
845 % \end{macrocode}
846 %
847 % This trick (found on the net) to make possible the usage of cleveref (with tcolorbox list inside option) in beamer
848 %
849 % \begin{macrocode}
850
851 \AtBeginDocument{
852 \def\beamer@label<#1>{%
853 \def\hack@arg{#1}%
854 \@ifnextchar[\beamer@label@opt\beamer@label@noopt
855 }%
856 \def\beamer@label@opt[#1]#2{%
857 \expandafter\alt\expandafter<\hack@arg>%
858 {\beamer@origlabel[#1]{#2}\beamer@nameslide{#2}}%
859 {\beamer@dummynameslide}%
860 }%
861 \def\beamer@label@noopt#1{%
862 \expandafter\alt\expandafter<\hack@arg>%
863 {\beamer@origlabel{#1}\beamer@nameslide{#1}}%
864 {\beamer@dummynameslide}%
865 }%
866 }
867
868 \renewcommand{\notez}{
869 \mode<beamer>{
870 \begin{tikzpicture}[remember picture,overlay]
871 \node[scale=2,text opacity=0.1]
872 at (current page.center) {\includegraphics{../../commons/img/crayon}
873 };
874 \end{tikzpicture}
875 }
876 }
877
878 % \end{macrocode}
879 % The commands list of methods vary if we are in a beamer
880 % \begin{macrocode}
881
882 \makeatletter
883 \newcommand\listofmethods{\@starttoc{lom}}
884 \makeatother
885
886 % \end{macrocode}
887 % The exercises that appear in the beamer lessons
888 % \begin{macrocode}
889
890 \newcounter{beamerExo}
891 \resetcounteronoverlays{beamerExo}
892
893 \pgfkeys{
894 /fascicules/.is family,/fascicules,
895 default/.style = {title = ,type = none},
896 title/.estore in = \exotitle,
897 type/.estore in = \exotype,
898 }
899
900
901 \newenvironment{exo}[1][]
902 { \pgfkeys{/fascicules, default, #1}%
903 \refstepcounter{beamerExo}
904 \tikz \node[rectangle,draw=\methodscolor!50,fill=\methodscolor!20] {\thebeamerExo};
905 \ifthenelse{\equal{\exotitle}{}}{}{{\bf \exotitle.}}
906 }
907
908
909 \newenvironment{sol}
910 {{\bfseries r\'eponse :}}
911 {}
912
913
914
915
916 }
917 {}
918 \makeatother
919
920
921 % \end{macrocode}
922 % Commandes pour tracer des jolies courbes
923 % \begin{macrocode}
924
925
926 \tikzstyle{general}=[line width=0.3mm, >=latex, x=1cm, y=1cm,line cap=round, line join=round]
927 \tikzstyle{grid}=[line width=0.3mm, color=LightBlue]
928 \tikzstyle{courbe} = [draw=blue,line width=1.2pt]
929
930 \newcommand{\window}[4]
931 {
932 \def\poslabelX{above left}
933 \def\poslabelY{below right}
934 \pgfmathsetmacro{\windowwidth}{7}; % la largeur par défaut d'une window
935
936 \pgfmathsetmacro{\Xmin}{#1}; %
937 \pgfmathsetmacro{\Xmax}{#2}; %
938 \pgfmathsetmacro{\Ymin}{#3}; %
939 \pgfmathsetmacro{\Ymax}{#4}; %
940 }
941
942 \newenvironment{windowsratio}[1][0.66]
943 {
944 \begin{scope}[xscale=\windowwidth/(\Xmax-\Xmin),yscale=(\windowwidth * #1)/(\Ymax-\Ymin)]
945 }
946 {
947 \end{scope}
948 }
949 \newcommand{\axeH}[1][$x$]{\draw[line width=1.5pt,->] (\Xmin,0)--(\Xmax,0) node[\poslabelX]{#1};}
950 \newcommand{\axeV}[1][$y$]{\draw[line width=1.5pt,->] (0,\Ymin)--(0,\Ymax) node[\poslabelY]{#1};}
951 \newcommand{\tickX}[1][1]{\draw (#1,0) node {\scriptsize$+$} node[below]{#1};}
952 \newcommand{\tickY}[1][1]{\draw (0,#1) node {\scriptsize$+$} node[left]{#1}; }
953 % \end{macrocode}
954 %
955 % \PrintIndex
956 % \PrintChanges
957 % \Finale
958 \endinput