-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsujet.sty
431 lines (344 loc) · 12.7 KB
/
sujet.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% XeLaTeX Template
% (20/11/2018)
%
% author:
% Salim bou ([email protected])
%
% Important notes:
% This template needs to be compiled with XeLaTeX
% Used fonts: Amiri, AlBattar, Traditional Arabic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sujet}[2018/11/20]
%%%%%%%%%%%%
% packages %
%%%%%%%%%%%%
\RequirePackage[margin=2cm]{geometry}
\RequirePackage{amsmath,amsfonts,amssymb}
\RequirePackage{tikz}
\RequirePackage[totpages,user]{zref}
\RequirePackage[explicit,compact]{titlesec}
\RequirePackage{fancyhdr}
\RequirePackage{array}
\RequirePackage{longtable}
\RequirePackage{polyglossia}
\RequirePackage{sujetset}
% fonts===========================================
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{\Arabicfont}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{\Arabicfontsf}
\newfontfamily\arabicfonttt[Script=Arabic]{\Arabicfonttt}
\newfontfamily\englishfont{\Latinfont}
\newfontfamily\englishfontsf{\Latinfontsf}
\newfontfamily\englishfonttt{\Latinfonttt}
\newfontfamily\frenchfont{\Latinfont}
\newfontfamily\frenchfontsf{\Latinfontsf}
\newfontfamily\frenchfonttt{\Latinfonttt}
%=============================================================
\newcount\c@nbrlines
\c@nbrlines=2
\newcount\c@stretchlab
\newdimen\d@lastcol
\d@lastcol=\dimexpr .125\textwidth-3\tabcolsep-2\arrayrulewidth\relax
\newdimen\d@addnote
\d@addnote=\dimexpr 2\tabcolsep+\arrayrulewidth+.5\d@lastcol\relax
\newif \if@mlarabic \@mlarabictrue
\newif \if@mlenglish \@mlenglishfalse
\newif \if@name \@namefalse
\newif \if@LTR \@LTRfalse
\newif \if@border \@bordertrue
\newif \if@correction \@correctionfalse
\def\settempdimen{\newdimen\tempn \tempn=.5\arrayrulewidth \advance \tempn by \tabcolsep\relax}
\def\@stretch#1{%
&& \write\@auxout{%
\gdef\expandafter\string\csname stretch@#1\endcsname{%
\string\\[\the\dimexpr\the\pdflastypos sp -75pt\relax]}}\pdfsavepos%
\expandafter\ifx\csname stretch@#1\endcsname\relax
\expandafter\\%
\else
\csname stretch@#1\expandafter\endcsname
\fi}
\def\stretchtable{\global\advance\c@stretchlab 1 \expandafter\@stretch\expandafter{\romannumeral\c@stretchlab}}
\pgfkeys{/pgf/number format/.cd,fixed}
\def\Gpgfmathsetmacro#1#2%
{\pgfmathsetmacro\result{#2}\global\let#1\result}
\Gpgfmathsetmacro\gresult{0}
\def\@nte#1{%
\Gpgfmathsetmacro\gresult{\gresult + #1}%
\vadjust{\vbox to 0pt{\vss%
\hbox to \hsize{\hskip\hsize\hskip\d@addnote\hbox to 0pt{\hss\pgfmathprintnumber{#1}\hss}\hss}%
\vskip.8ex}}}
\def\@Nte#1{%
\advance\d@addnote by\dimexpr2\tabcolsep+\d@lastcol+\arrayrulewidth\relax%
\vadjust{\vbox to 0pt{\vss%
\hbox to \hsize{\hskip\hsize\hskip\d@addnote \hbox to 0pt{\hss\pgfmathprintnumber{#1}\hss}\hss}%
\vskip.8ex}}}
\def~#1:#2{%
\ifx #2+%
\@nte{#1}%
\else%
\ifx #2=%
\begingroup\@nte{#1}\@Nte{\gresult}\Gpgfmathsetmacro\gresult{0}\endgroup%
\else%
\PackageError{sujet}{You must use + or = to add note or to show sum of notes}
\fi%
\fi%
}
\DeclareOption{arabic}{%
\@mlarabictrue
}
\DeclareOption{english}{%
\@mlarabicfalse
\@mlenglishtrue
\gdef\@mainlanguage{english}
}
\DeclareOption{french}{%
\@mlarabicfalse
\gdef\@mainlanguage{french}
}
\DeclareOption{correction}{%
\def\corr@enumi{\if@RTL \advance\@totalleftmargin \dimexpr 3\tabcolsep\relax\fi}
\@correctiontrue
\newenvironment{correction}{
\begin{longtable}{|>{\corr@enumi}b{.75\textwidth}|>{\centering\arraybackslash}b{\d@lastcol}|>{\centering\arraybackslash}b{\d@lastcol}|}
\hline
\centering\sffamily\vtop to 0pt{\vskip0pt عناصر الإجابة\vss} &
\multicolumn{2}{c|}{\sffamily العلامة}\\
\cline{2-3}
&
\sffamily مـجزأة
&
\sffamily المجموع\\
\hline
}{
\end{longtable}
}
}
\DeclareOption{landscape}{
\geometry{landscape}
\if@twocolumn
\ifdefined\renewfontfamily
\renewfontfamily\arabicfontsf[Script=Arabic,Scale=1]{\Arabicfontsf}
\else
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1]{\Arabicfontsf}
\fi
\geometry{hmargin=1cm}
\fi
}
\DeclareOption{2in1}{
\geometry{landscape,hmargin=1cm}
\@twocolumntrue
\ifdefined\renewfontfamily
\renewfontfamily\arabicfont[Script=Arabic,Scale=1]{\Arabicfont}
\renewfontfamily\arabicfontsf[Script=Arabic,Scale=1]{\Arabicfontsf}
\else
\newfontfamily\arabicfont[Script=Arabic,Scale=1]{\Arabicfont}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1]{\Arabicfontsf}
\fi
\renewcommand{\columnseprule}{1pt}
\setlength\columnsep{\Gm@rmargin}
\multiply \columnsep by 2
}
\DeclareOption*{\PackageWarning{sujet}{Unknown ‘\CurrentOption’ option}}
\ExecuteOptions{arabic}
\ProcessOptions\relax
\if@mlarabic
\setmainlanguage[numerals=maghrib]{arabic}
\else
\setmainlanguage{\@mainlanguage}
\fi
\def\copycolumn{\if@twocolumn\newpage\setbox\@outputbox=\vbox{\copy\@leftcolumn} \box\@outputbox %
\else \PackageWarning{sujet}{\noexpand\copycolumn used only with twocolumn option} \fi}
\tikzset{Rnode/.style={font=\beginR}}
\newcommand{\namebox}{
\begin{tikzpicture}
\draw [dotted](3mm,0)--(\columnwidth-3mm,0);
\node[fill=white,left,Rnode] at (\columnwidth-3\pgflinewidth,0){اللقب والإسم:};
\node[fill=white,left,yshift=2pt,Rnode] at (0.25\columnwidth,0){العلامة:};
\draw [rounded corners,thick](0,-0.6)rectangle(\columnwidth-4\pgflinewidth,0.6);
\end{tikzpicture}
\par
}
\def\schyear{
\newcount\altyear
\altyear=\year
\ifnum\month>8 %
\advance \altyear by 1 %
\the\year\ - \the\altyear
\else %
\advance \altyear by -1 %
\the\altyear\ - \the\year
\fi
}
\def\theschooyear{\@schoolyear}
\newcommand{\schoolyear}[1]
{\gdef\@schoolyear{#1}}
\def\theschool{\@school}
\newcommand{\school}[1]
{\gdef\@school{#1}}
\def\theduration{\@duration}
\newcommand{\duration}[1]
{\gdef\@duration{#1}}
\def\thelevel{\@level}
\newcommand{\level}[1]
{\gdef\@level{#1}}
\newcommand{\name}[1][\@name]{\expandafter\csname @name#1\endcsname\if@name\namebox \fi}
\long\def\@head#1{\begingroup
\sffamily\begingroup\large\leavevmode\hfill #1 \hfill\ \endgroup\par
\rule{\linewidth}{1pt}
\@level\ \hfill \@duration \par \endgroup}
\newcommand{\head}[1]{\long\gdef\@head{\begingroup #1\par\endgroup}}
% define keys ================================================
\define@key{sujetkeys}{school}{\school{#1}}
\define@key{sujetkeys}{level}{\level{#1}}
\define@key{sujetkeys}{duration}{\duration{#1}}
\define@key{sujetkeys}{year}{\schoolyear{#1}}
\define@key{sujetkeys}{name}[true]{\renewcommand{\name}[1][true]{\csname @name#1\endcsname\if@name\namebox \fi}}
\define@key{solboxkeys}{lines}{\c@nbrlines=#1}
\define@key{solboxkeys}{LTR}[true]{\csname @LTR#1\endcsname}
\define@key{solboxkeys}{border}[true]{\csname @border#1\endcsname}
%define sujetset command ======================================
\newcommand\sujetset[2][]{%
\setkeys{sujetkeys}{#1}
\fancyhead{}% clear all header fields
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\headrulewidth}{1pt}
\chead{\sffamily \ifnum\the\c@page=1 \@school\hfill\ifGm@landscape\if@twocolumn\@schoolyear\hskip\columnsep\@school\fi\fi\hfill\@schoolyear\fi}
\cfoot{\ifnum\ztotpages>1 \newcount\c@totpage \c@totpage=\ztotpages \hfill \pagename\ \thepage\ \if@mlarabic من\else\if@mlenglish of\else de\fi\fi\ %
\@arabic{\c@totpage} \hfill \ifGm@landscape \pagename\ \thepage\ \if@mlarabic من\else\if@mlenglish of\else de\fi\fi\ \@arabic{\c@totpage} \hfill \fi\fi}
\pagestyle{fancy}
\if@correction
\else
\AfterEndPreamble{\@head{#2}\name}
\fi
}
\setlength{\headsep}{12pt}% defaut 25pt
\setlength{\headheight}{15.4pt}
\setlength{\itemsep}{3cm}
\arraycolsep=1.4pt
\parindent=0pt
% box for solutions ===========================================
\newcommand\solbox[2][]{%
\setkeys{solboxkeys}{#1}
\par
\begin{tikzpicture}[thick]
\foreach \i in{1,...,\the\c@nbrlines}{\draw[dotted](5mm,\i)--(\linewidth-5mm,\i);}
\if@LTR%
\node[anchor=west,fill=white,xshift=-1mm,yshift=-0.1mm,inner sep=0pt,minimum size=0pt,align=left] at (5mm,\the\c@nbrlines){#2};
\else
\node[anchor=east,fill=white,xshift=1mm,yshift=0.3mm,inner sep=0pt,minimum size=0pt,Rnode] at (\linewidth-5mm,\the\c@nbrlines){#2};
\fi
\useasboundingbox (0,0.3) rectangle (\linewidth-2.9\pgflinewidth,\the\c@nbrlines+0.8);
\if@border%
\draw [rounded corners](0,0.3) rectangle (\linewidth-2.9\pgflinewidth,\the\c@nbrlines+0.8);
\fi
\end{tikzpicture}
\par
\@LTRfalse
\@bordertrue
\c@nbrlines=2
}
% define \twoparts command =====================================
\newcommand{\twoparts}[3][0.5]{%
\par
\begin{minipage}[t]{#1\textwidth}
#2
\end{minipage}
\hfill
\begin{minipage}[t]{\textwidth- #1\textwidth -3mm}
#3
\end{minipage}
\par
}
% section format =============================================
\def\@note{0}
\def\note#1{\gdef\@note{#1}}
\def\formatnote#1{\begingroup\normalfont\footnotesize\color{red!60!black}\mbox{(\@note\kern .5 ex #1)}\endgroup}
\titleformat{\section}
{\large\sffamily}{}{0em}{\underline{#1} %
\ifdim\@note pt > 0 pt%
\ifdim\@note pt >10 pt%
\formatnote{\if@mlarabic نقطة\else points\fi}%
\else %
\formatnote{\if@mlarabic نقاط\else points\fi}%
\fi%
\fi%
\note{0}
}
% define command \help =========================================
\def\bverb#1{\begingroup\englishfonttt \textcolor{blue}{#1}\endgroup}
\def\gverb#1{\begingroup\englishfonttt \footnotesize \textcolor{gray!40!black}{#1}
\endgroup}
\long\def\help{%
\fontsize{10}{15}
\selectfont
\setRTL
الحزمة
\bverb{sujet}
هي حزمة معدة لكتابة أوراق أسئلة للإختبارات، الفروض والواجبات، توفر التعليمة :
\centerline{\LR{\bverb{\string\sujetset[<keys=value>]\{title\}}}}
حيث
\bverb{keys}
هي كلمات مفتاحية وهي بالتفصيل :
\bigskip
\begin{LTR}
{\centering
\begin{tabular}{@{\hskip1em}lp{6cm}p{2.5cm}}
\hline
\englishfonttt key & \englishfonttt definition & \englishfonttt default\\
\hline
\bverb{school} & \textarabic{مؤسسة العمل} & \gverb{\textarabic{اسم المؤسسة هنا}}\\
\bverb{level} & \textarabic{المستوى الدراسي} & \gverb{\textarabic{1 ج م ع تك}}\\
\bverb{duration} & \textarabic{مدة الإختبار (الفرض)} & \gverb{\textarabic{ساعة}}\\
\bverb{name} & {\englishfonttt (boolean)}\textarabic{إطار لكتابة اسم الطالب} & \gverb{false}\\
\bverb{year} & \textarabic{الموسم الدراسي} & \gverb{\textarabic{السنة الدراسيةبصبصح}}\\
\hline
\end{tabular}
\par\bigskip
}
\end{LTR}
إذا لم تحدد الكلمات المفتاحية في التعليمة
\bverb{sujetset}
فإن البرنامج يستعمل القيم الإفتراضية،
والتي يمكن تغييرها بالملف sujetset.sty
\medskip
\textcolor{red}{تعليمات إضافية}\\
توفر الحزمة تعليمات للمساعدة هي :
\begin{english}
-\makebox[0.85\columnwidth][l]{\bverb{\LR{\string\solbox[<key=value>]\{text\}}}=\textarabic{إطار لكتابة الإجابة
}}
{\setRTL
\textarabic{حيث الكلمات المفتاحية هي:}
}
\bigskip
{\centering
\begin{tabular}{@{\hskip1em}lp{6.5cm}p{1.5cm}}
\hline
\englishfonttt key & \englishfonttt definition & \englishfonttt default\\
\hline
\bverb{lines} & \textarabic{لتعيين عدد الأسطر بالإطار} & \gverb{2}\\
\bverb{LTR} & {\englishfonttt (boolean)} \textarabic{اتجاه الكتابة من اليسار إلى اليمين } & \gverb{false}\\
\bverb{border} & {\englishfonttt (boolean)} \textarabic{لرسم أو إزالة الإطار} & \gverb{true}\\
\hline
\end{tabular}
\par }
\bigskip
-\bverb{\LR{\string\note\{n\}}} = \textarabic{لتعيين علامة لكل تمرين } \hfill \gverb{(no default)}
l
-\bverb{\LR{\string\twoparts[fraction]\{first part\}\{second part\}}} = \textarabic{تقسيم الصفحة إلى جزءين} \hfill \gverb{(default=0.5)}
\end{english}
\bigskip
الحزمة توفر الخيارات
\bverb{landscape}
للكتابة على الصفحة بشكل عرضي، يمكن عندها كتابة نسختين لنفس الفرض على عمودين في حالة الخيار
\bverb{twocolumn}
مفعل الحزمة توفر عندها التعليمة
\bverb{\LR{\string\copycolumn}}
لنسخ العمود الأيمن إلى العمود الأيسر.
الخيار
\bverb{correction}
يوفر الوسط {\englishfonttt(correction)} يمكن من كتابة تصحيح على شكل جدول بثلاث أعمدة، إضافة نقطة في موضع يتم بإدخالها على الشكل
\bverb{\LR{~1:+}}
\bigskip
}
\endinput