summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cahierprof/cahierprof.sty
blob: 59850eef8f184aa0730187ed90f3b9e9005da862 (plain)
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
%% Informations générales
%% Dernière modification le 2023-07-12 at 08:23
\NeedsTeXFormat{LaTeX2e}[1999/01/01]
\ProvidesPackage{cahierprof}
  [2023-07-12 v0.91 Les commandes pour le cahier Professeur]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Options du package commande
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pas d'options
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chargement des extensions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{geometry}
\RequirePackage[table]{xcolor}
\RequirePackage{tabularx}
\RequirePackage{tikz}
  \usetikzlibrary{math}  
  \usetikzlibrary{calc}
\RequirePackage[babel=true,kerning=true]{microtype}
\RequirePackage{lscape}
\RequirePackage{ifthen}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Définitions des compteurs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Compteurs day/month/year pour la date courante
\newcounter{day}
\newcounter{month}
\newcounter{year}
%
% Compteurs pour les vacances scolaires
% Toussaint
\newcounter{dayToussaint}
\newcounter{monthToussaint}
\newcounter{dayToussaintFin}
\newcounter{monthToussaintFin}
% Noel
\newcounter{dayNoel}
\newcounter{monthNoel}
\newcounter{dayNoelFin}
\newcounter{monthNoelFin}
% Hiver
\newcounter{dayHiver}
\newcounter{monthHiver}
\newcounter{dayHiverFin}
\newcounter{monthHiverFin}
% Printemps
\newcounter{dayPrintemps}
\newcounter{monthPrintemps}
\newcounter{dayPrintempsFin}
\newcounter{monthPrintempsFin}
% Jours Feriés 
\newcounter{dayPaques}
\newcounter{monthPaques}
\newcounter{dayAscension}
\newcounter{dayAscensionPont}
\newcounter{monthAscension}
\newcounter{dayPentecote}
\newcounter{monthPentecote}
%
% Définition de nouveaux compteurs pour Vendredi Jour/Mois/Année
\newcounter{friday}
\newcounter{frimonth}
\newcounter{friyear}
%
% Gestion des années bissextiles.
\newcounter{FinFevrier}%
% Est-ce que l'année est bissextile?%
\pgfmathparse{int(mod(\theyear,4))}%
\ifthenelse{\pgfmathresult>0}%
{%
  % if (year is not divisible by 4) then (it is a common year)%
  \setcounter{FinFevrier}{28}%
}{%
  % else if (year is not divisible by 100) then (it is a leap year)%
  \pgfmathparse{int(mod(\theyear,100))}%
  \ifthenelse{\pgfmathresult>0}%
  {%
    \setcounter{FinFevrier}{29}%
  }{%
    % else if (year is not divisible by 400) then (it is a common year)%
    \pgfmathparse{int(mod(\theyear,400))}%
    \ifthenelse{\pgfmathresult>0}%
    {%
      \setcounter{FinFevrier}{28}%
    }{%
      % else (it is a leap year)%
      \setcounter{FinFevrier}{29}%
    }%
  }%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Nouvelles macros 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Liste des macros définies:
% - \nextday : pour passer au jour d'après
% - \weekend : pour passer les week-ends ou les vacances scolaires 
% - \getdate : afficher la date au format day/month/year
% - \getWeek : afficher la semaine au format 
%   Du lundi Day Month Year au Vendredi Day Month Year
% - \Semaine : afficher la première ligne du tableau du cahier de texte (Lundi
%   day/month, Mardi day/month, etc)
% - EmploiDuTemps[1] : afficher l'emploi du temps prof. #1 : l'emploi du temps,
%   au format tableau avec une colonne par jour.
% - \sem[2] : Cours 1 semaine sur 2. Affiche le contenu de #2 si la semaine #1
%   est paire (0) ou impaire (1).
% - \TableauClasse[2] : Afficher un tableau pour la classe. #1: le nom de la
%   classe. #2: la liste des élèves séparées par des virgules.
% - \Classe[2] : Afficher 8 tableaux de classe. #1: le nom de la classe. #2: la
%   liste des élèves.
% - \ListeEleves : créer un fichier ListeEleves.tex qui contient la liste des
%   élèves puis insère le fichier (compiler deux fois, comme \tableofcontents).
%
% Passer au jour d'après
\newcommand{\nextday}%
{% 
  % Les mois à 30 jours : Avril, Juin, Septembre, Novembre
  % Les mois à 31 jours : Janvier, Mars, Mai, Juillet, Août, Octobre, Décembre
  % Février à \theFinFevrier jours.
  \ifthenelse{
      \(\theday=30 \and \(\themonth=4 \or \themonth=6 \or \themonth=9 \or \themonth=11\)\)
  \or \(\theday=31 \and \(\themonth=1 \or \themonth=3 \or \themonth=5 \or \themonth=7 \or
        \themonth=8 \or \themonth=10 \or\themonth=12\)\) 
  \or \(\theday=\theFinFevrier \and \themonth=2\)}%
  {
    % Si on est en décembre, on change d'année et month=1, day=1
    \ifthenelse{\themonth=12}%
    {
      \stepcounter{year}
      \setcounter{month}{1}
      \setcounter{day}{1}
    }{
      % Dans les autres cas, on change de mois et on recommence à day= 1
      \stepcounter{month}%
      \setcounter{day}{1}%
    }%
  }{
    % Sinon, on augmente juste le compteur jour
    \stepcounter{day}%
  }%
}%
%
% Gestions des vacances et week-end
\newcommand{\weekend}{
  % Vacances de Toussaint 
  \ifthenelse{ \theday=\thedayToussaint \and \themonth=\themonthToussaint}
  {
    \setcounter{day}{\thedayToussaintFin}
    \setcounter{month}{\themonthToussaintFin}
    Vacances de la Toussaint
  }{
    % Vacances de Noël
    \ifthenelse{ \theday=\thedayNoel \and \themonth=\themonthNoel}
    {
      \setcounter{day}{\thedayNoelFin}
      \setcounter{month}{\themonthNoelFin}
      \stepcounter{year}
      Vacances de Noël
    }{
      % Vacances d'Hiver
      \ifthenelse{ \theday=\thedayHiver \and \themonth=\themonthHiver}
      {
        \setcounter{day}{\thedayHiverFin}
        \setcounter{month}{\themonthHiverFin}
        Vacances d'hiver 
      }{
        % Vacances de Printemps
        \ifthenelse{ \theday=\thedayPrintemps \and \themonth=\themonthPrintemps}
        {
          \setcounter{day}{\thedayPrintempsFin}
          \setcounter{month}{\themonthPrintempsFin}
          Vacances de printemps
        }{
          % sinon c'est juste un week-end
          \nextday\nextday
        }%
      }%
    }%
  }%
}
%
% Obtenir la date
\newcommand{\getDate}{%
  % On affiche la date
  \theday/\themonth/\theyear%
  % On affiche $\star$Ferié$\star$ si le jour est ferié.
  \ifthenelse{%
    % Jour de l'an, 1er janvier
    \(\theday=1 \and \themonth=1\)%
    % Lundi de Paques
    \or\(\theday=\thedayPaques \and \themonth=\themonthPaques\)%
    % Fête du travail, le 1er mai
    \or\(\theday=1 \and \themonth=5\)%
    % Victoire 1945, le 8 mai
    \or\(\theday=8 \and \themonth=5\)%
    % Jeudi de l'ascension
    \or\(\theday=\thedayAscension \and \themonth=\themonthAscension\)%
    % Pont du vendredi de l'ascension
    \or\(\theday=\thedayAscensionPont \and \themonth=\themonthAscension\)%
    % Lundi de Pentecote
    \or\(\theday=\thedayPentecote \and \themonth=\themonthPentecote\)%
    % Fête Nationale, le 14 juillet
    \or\(\theday=14 \and \themonth=7\)%
    % Assomption, le 15 août
    \or\(\theday=15 \and \themonth=8\)%
    % Toussaint, le 1er novembre
    \or\(\theday=1 \and \themonth=11\)%
    % Armistice 1914-1918, le 11 novembre
    \or\(\theday=11 \and \themonth=11\)%
    % Noël, le 25 décembre
    \or\(\theday=25 \and \themonth=12\)%
  }{
    \hfil $\star$Ferié$\star$%
  }{}%
}%
%
% Affichage de la semaine.%
\newcommand{\getWeek}{%
  \setcounter{friday}{\theday}%
  \setcounter{frimonth}{\themonth}%
  \setcounter{friyear}{\theyear}%
  % Si le mois a 31 jours.%
  % Les mois à 31 jours : Janvier, Mars, Mai, Juillet, Août, Octobre, Décembre%
  \ifthenelse{\themonth=1 \or \themonth=3 \or \themonth=5 \or \themonth=7 \or \themonth=8 \or \themonth=10 \or \themonth=12}%
  {%
    % Alors si on est avant le 28 du mois, on ajoute 4 jours%
    \ifthenelse{\theday < 28}%
    {%
      \addtocounter{friday}{4}%
    }{%
      % Sinon, on change de mois %
      \stepcounter{frimonth}%
      % Changement d'année pour décembre%
      \ifthenelse{\themonth=12}{\stepcounter{friyear}}{}%
      % Lundi 31 - Mar 1, Mer 2, Jeu 3, Ven 4%
      \ifthenelse{\theday=31}{\setcounter{friday}{4}}{}%
      % Lundi 30 - Mar 31, Mer 1, Jeu 2, Ven 3%
      \ifthenelse{\theday=30}{\setcounter{friday}{3}}{}%
      % Lundi 29 - Mar 30, Mer 31, Jeu 1, Ven 2%
      \ifthenelse{\theday=29}{\setcounter{friday}{3}}{}%
      % Lundi 28 - Mar 29, Mer 30, Jeu 31, Ven 1%
      \ifthenelse{\theday=28}{\setcounter{friday}{1}}{}%
    }%
  }{%
    % Sinon, si on est au mois de février%
    \ifthenelse{\themonth=2}%
    {%
      % Si le mois de février a 28 jours%
      \ifthenelse{\theFinFevrier=28}%
      {%
        % Si on est avant le 25%
        \ifthenelse{\theday < 25}%
        {%
          % Alors on ajoute 4 jours%
          \addtocounter{friday}{4}%
        }{%
          % Sinon, on change de mois%
          \stepcounter{frimonth}%
          % Lundi 28 - Mar 1, Mer 2, Jeu 3, Ven 4%
          \ifthenelse{\theday=28}{\setcounter{friday}{4}}{}%
          % Lundi 27 - Mar 28, Mer 1, Jeu 2, Ven 3%
          \ifthenelse{\theday=27}{\setcounter{friday}{3}}{}%
          % Lundi 26 - Mar 27, Mer 28, Jeu 1, Ven 2%
          \ifthenelse{\theday=26}{\setcounter{friday}{2}}{}%
          % Lundi 25 - Mar 26, Mer 27, Jeu 28, Ven 1%
          \ifthenelse{\theday=25}{\setcounter{friday}{1}}{}%
        }%
      }{%
        % sinon le mois de février a 29 jours%
        % si on est avant le 26%
        \ifthenelse{\theday < 26}%
        {%
          % alors on ajoute 4 jours%
          \addtocounter{friday}{4}%
        }{%
          % sinon, on change de mois%
          \stepcounter{frimonth}%
          % lundi 29 - mar 1, mer 2, jeu 3, ven 4%
          \ifthenelse{\theday=29}{\setcounter{friday}{4}}{}%
          % lundi 28 - mar 29, mer 1, jeu 2, ven 3%
          \ifthenelse{\theday=28}{\setcounter{friday}{3}}{}%
          % lundi 27 - mar 28, mer 29, jeu 1, ven 2%
          \ifthenelse{\theday=27}{\setcounter{friday}{2}}{}%
          % lundi 26 - mar 27, mer 28, jeu 29, ven 1%
          \ifthenelse{\theday=26}{\setcounter{friday}{1}}{}%
        }%
      }%
    }{%
      % Sinon le mois a 30 jours%
      % Les mois de 30 jours : Avril, Juin, Septembre, Novembre%
      % Si on est avant le 27, on ajoute 4 jours%
      \ifthenelse{\theday < 27}%
      {%
        \addtocounter{friday}{4}%
      }{%
        % Sinon, on change de mois%
        \stepcounter{frimonth}%
        % Lundi 30 - Mar 1, Mer 2, Jeu 3, Ven 4%
        \ifthenelse{\theday=30}{\setcounter{friday}{4}}{}%
        % Lundi 29 - Mar 30, Mer 1, Jeu 2, Ven 3%
        \ifthenelse{\theday=29}{\setcounter{friday}{3}}{}%
        % Lundi 28 - Mar 29, Mer 30, Jeu 1, Ven 2%
        \ifthenelse{\theday=28}{\setcounter{friday}{2}}{}%
        % Lundi 27 - Mar 28, Mer 29, Jeu 30, Ven 1%
        \ifthenelse{\theday=27}{\setcounter{friday}{1}}{}%
      }%
    }%
  }%
  Du lundi \theday{}
  \ifthenelse{\themonth=1}{janvier}{}%
  \ifthenelse{\themonth=2}{février}{}%
  \ifthenelse{\themonth=3}{mars}{}%
  \ifthenelse{\themonth=4}{avril}{}%
  \ifthenelse{\themonth=5}{mai}{}%
  \ifthenelse{\themonth=6}{juin}{}%
  \ifthenelse{\themonth=7}{juillet}{}%
  \ifthenelse{\themonth=8}{août}{}%
  \ifthenelse{\themonth=9}{septembre}{}%
  \ifthenelse{\themonth=10}{octobre}{}%
  \ifthenelse{\themonth=11}{novembre}{}%
  \ifthenelse{\themonth=12}{décembre}{}
  \theyear{}
  au vendredi
  \thefriday{}
  \ifthenelse{\thefrimonth=1}{janvier}{}%
  \ifthenelse{\thefrimonth=2}{février}{}%
  \ifthenelse{\thefrimonth=3}{mars}{}%
  \ifthenelse{\thefrimonth=4}{avril}{}%
  \ifthenelse{\thefrimonth=5}{mai}{}%
  \ifthenelse{\thefrimonth=6}{juin}{}%
  \ifthenelse{\thefrimonth=7}{juillet}{}%
  \ifthenelse{\thefrimonth=8}{août}{}%
  \ifthenelse{\thefrimonth=9}{septembre}{}%
  \ifthenelse{\thefrimonth=10}{octobre}{}%
  \ifthenelse{\thefrimonth=11}{novembre}{}%
  \ifthenelse{\thefrimonth=12}{décembre}{}
  \thefriyear
}%
%
% Affichage de la semaine
\newcommand{\Semaine}
{
  & Lundi \getDate\nextday
  & Mardi \getDate\nextday 
  & Mercredi \getDate\nextday
  & Jeudi \getDate\nextday
  & Vendredi \getDate\nextday 
}
\newcommand{\EmploiDuTemps}[1]%
{
  \foreach \n in {1,...,37}
  {
    {\Large\textsc{Semaine \no\n{} --- \getWeek}}
    \vfil
    \begin{tabularx}{\linewidth}{|c||X|X|X|X|X|} \hline
      \Semaine \\ \hline
      #1
    \end{tabularx}
    \vfil
    \hfil \weekend \hfil
    \newpage
  }%
}%
%
% Cours 1 semaine sur 2
% La commande \sem a deux arguments:
% - #1 pour le cours en semaine impaire.
% - #2 pour le cours en semaine paire.
\newcommand{\sem}[2]%
{
  \pgfmathparse{int(mod(\n,2))}
  \ifthenelse{\pgfmathresult=1}{#1}{#2}
}%
% Réaliser le tableau pour une classe
% En argument: 
% - #1 : la classe.
% - #2 la liste des élèves, séparée par des virgules (sauf le dernier).
\newcommand{\TableauClasse}[2]
{
  \begin{tikzpicture}
    % En tête et nom de la classe.
    \tikzmath{\largeurLigne=18; \largeurNom=3.5;\largeurColonne=\largeurLigne-\largeurNom;}
    \draw[fill=gray!50] (0,-.5)  rectangle (\largeurLigne,.5);
    \draw ({\largeurNom/2},0) node{\Large #1};
    \draw[shift={(\largeurNom,-.5)}] (0,0) grid[xstep=\largeurColonne/20] 
    ++(\largeurColonne,1);
    \foreach[count=\n] \NomPrenom in {#2}
    {
      % Griser une ligne sur 2 (les lignes paires)
      \pgfmathparse{int(mod(\n,2))}
      \ifnum0=\pgfmathresult\relax
        \fill[gray!25] (0,{-.5*\n}) rectangle ++(\largeurLigne,-.5);
      \fi
      % Ecrire le numéro de l'élève et son nom
      \draw (0,{-.5*\n}) node[text width=3.5cm,below right]
      {\tiny \n. \NomPrenom} rectangle ++(\largeurNom,-.5);
      \draw[shift={(\largeurNom,-.5*\n)}] (0,0) grid[xstep=14.5/20,ystep=.5]
      (\largeurColonne,-.5);
    }
  \end{tikzpicture}
}%
%
% Réaliser les tableaux de classe.
% \TableauClasse a 3 arguments:
% - #1 : la classe
% - #2 : le nombre de fois qu'on voit la classe par semaine
% - #3 : la liste des élèves
%% Il y a 20 colonnes par tableaux. Il faut ~2 tableaux pour faire 37 semaines
%% Le nombre de tableaux est donc deux fois le nombre de fois qu'on voit les
%% élèves par semaine.
%
%
\newcommand{\Classe}[3]
{
  \immediate\write\outputstream{#1}
  \immediate\write\outputstream{\string \begin{enumerate}}
      % Ecrire les noms des élèves dans le bon fichier
      \foreach \i in {#3}
      {
      \immediate\write\outputstream{\string\item\space \i}
      }
  \immediate\write\outputstream{\string \end{enumerate}}
  \begin{center}
    \tikzmath{\NbTableaux=2*#2;}
    \foreach \i in {1,...,\NbTableaux}
    {
      \TableauClasse{#1}{#3} \\[.50cm] 
    }
  \end{center}
}

% Liste des élèves
\newcommand{\ListeEleves}
{
  %insère le fichier ListeEleves.tex s'il existe
  \IfFileExists{ListeEleves.tex}{
    \input{ListeEleves.tex}
  }{
    % Else : do nothing.
  }
  % Stocker le nom des élèves dans un fichier externe.
  \newwrite\outputstream
  \immediate\openout\outputstream=ListeEleves.tex
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Divers 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pas d'indentation des paragraphes
\setlength{\parindent}{0pt}
%
% Fin du package.
\endinput