Fichiers
typo-cpge/latex/inputTD.sty
2021-08-18 13:48:44 +02:00

126 lignes
4.2 KiB
TeX

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{inputTD}
\makeatletter
\@ifundefined{stylecentrale}
{\@ifundefined{resetlevel}{\def\resetlevel{[subsection]}}{}}
{%
\renewcommand\thesection{\Roman{section}}%
\renewcommand\thesubsection{\thesection.\Alph{subsection}}%
\def\resetlevel{[subsection]}
}
\@ifundefined{geometryenonce}{\def\geometryenonce{\relax}}
\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{\upshape}
\theoremseparator{. }
\theoremsymbol{}
\newtheorem*{important}{Important}
\newtheorem*{rappel}{Rappel}
\RequirePackage{xparse}
\RequirePackage{comment}
\RequirePackage{xr}
\newcount\ys@modecorrige
%% 0 énoncé normal
%% 1 corrigé seul
%% 2 mode prof
%% 3 corrigé de concours
\let\modeenonce0
\let\modecorrseul1
\let\modeprof2
\let\modeconcours3
\def\ifcorrige{\ifnum\ys@modecorrige=2}
\def\ifcorrigeseul{\ifnum\ys@modecorrige=1}
\def\ifenonce{\ifnum\ys@modecorrige=0}
\def\corr{\global\ys@modecorrige=2}
\def\corrseul{\global\ys@modecorrige=1}
\def\corrconcours{\global\ys@modecorrige=3}
\RequirePackage{xstring}
\let\basejobname\jobname
\IfEndWith{\jobname}{\detokenize{-ENONCE}}{\let\corr\relax\let\corrseul\relax\StrCut{\jobname}{\detokenize{-ENONCE}}\basejobname\dummy}{}
\IfEndWith{\jobname}{\detokenize{-PROF}}{\corr\let\corr\relax\let\corrseul\relax\StrCut{\jobname}{\detokenize{-PROF}}\basejobname\dummy}{}
\IfEndWith{\jobname}{\detokenize{-CORRIGE}}{\corrseul\let\corr\relax\let\corrseul\relax\StrCut{\jobname}{\detokenize{-CORRIGE}}\basejobname\dummy}{}
\NewDocumentEnvironment{enumq}{o}
{\IfValueT{#1}{\begin{multicols}{#1}}\begin{enumerate}\renewcommand\theenumi{\alph{enumi}}\@ifundefined{thequestion}{\renewcommand\p@enumi{\thecorrige.}}{\renewcommand\p@enumi{\thequestion.}}}{\end{enumerate}\IfValueT{#1}{\end{multicols}}}
\def\avecenonce{\newenvironment{enonce}{}{}
\edef\@temp{\noexpand\newtheorem{question}{Question}\resetlevel}\@temp
\newtheorem{qcm}{QCM}
%
\NewDocumentEnvironment{qcmrep}{o}
{\IfValueT{##1}{\begingroup\setlength\columnseprule{0pt}\begin{multicols}{##1}}\begin{enumerate}\renewcommand\theenumi{\Alph{enumi}}}{\end{enumerate}\IfValueT{##1}{\end{multicols}\endgroup}}}
\def\setthe#1{\@ifnextchar[{\setthei{#1}}{}}
\def\setthei#1[#2]{%
\expandafter\let\expandafter\@temp\csname the#1\endcsname
\toks@\expandafter{\@temp}%
\expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand\csname the#2\endcsname\@thmcountersep\the\toks@}}
\AtBeginDocument{%
\ifcase\ys@modecorrige
%% 0
\immediate\typeout{Mode enonce}
\geometryenonce
\excludecomment{corrige}
\excludecomment{comcorrige}
\excludecomment{comcorrige*}
\excludecomment{qcmcorr}
\avecenonce
\newenvironment{enonce*}{}{}
\or %% 1
\immediate\typeout{Mode corrige}
%
\let\real@xwmlastpage\r@xwmlastpage % ne pas écraser ces labels depuis le fichier externe
\let\real@lastpage\r@lastpage
\let\r@xwmlastpage\relax
\let\r@lastpage\relax
\externaldocument{\basejobname-ENONCE}
\let\r@xwmlastpage\real@xwmlastpage
\let\r@lastpage\real@lastpage
%
\subtitle{Corrigé}
\excludecomment{enonce}
\excludecomment{enonce*}
\excludecomment{qcmrep}
\edef\@temp{\noexpand\newcounter{question}\resetlevel}\@temp
\specialcomment{question}{\refstepcounter{question}\begingroup\def\ProcessCutFile{}}{\endgroup}
\newtheorem{corrige}{Question}
\edef\@temp{\noexpand\setthe{question}\resetlevel}\@temp
\let\thecorrige\thequestion
%
\newcounter{qcm}
\specialcomment{qcm}{\refstepcounter{qcm}\begingroup\def\ProcessCutFile{}}{\endgroup}
\newtheorem{qcmcorr}{QCM}
\let\theqcmcorr\theqcm
\newenvironment{comcorrige}{}{}
\newenvironment{comcorrige*}{}{}
\or %% 2
\immediate\typeout{Mode professeur}
\subtitle{Corrigé}
\newenvironment{corrige}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\newenvironment{comcorrige}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\newenvironment{qcmcorr}{\begin{mdframed}[backgroundcolor=gray!20, skipbelow=1ex]}{\end{mdframed}}
\avecenonce
\excludecomment{enonce*}
\excludecomment{comcorrige*}
\or %% 3
\subtitle{Corrigé}
\edef\@temp{\noexpand\newtheorem{corrige}{Question}\resetlevel}\@temp
\newenvironment{comcorrige}{}{}
\fi
}
\endinput