\NeedsTeXFormat{LaTeX2e}

\ProvidesClass{td}[2020/06/30 TD Class, V0.2]
 
% classe de base
 
\LoadClass[a4paper,11pt,twoside]{report}
 
% extensions

\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{enumerate}
\RequirePackage{palatino}
\RequirePackage{amsmath,amssymb,esint,mathabx}
\RequirePackage{bm}
\RequirePackage{vmargin}
\RequirePackage{marginnote}
\RequirePackage{fancyhdr}
\RequirePackage{graphicx}
\RequirePackage{rotating}
\RequirePackage{wrapfig}
\RequirePackage[section]{placeins}
\RequirePackage{url}
\RequirePackage{color}
\RequirePackage[french]{babel}
\RequirePackage[figurename=Fig.,labelfont={sl}]{caption}

% \RequirePackage{ifthen}
\RequirePackage{comment}
\RequirePackage{etoolbox}

\RequirePackage{lastpage}

\RequirePackage[breaklinks=false,colorlinks=true,linkcolor=black,urlcolor=blue]{hyperref}

% ----- Global variables ------------------------------------------

%\makeatletter
\let\@diploma\relax
\let\@module\relax
\let\@academicyear\relax
\let\@examdate\relax
\let\@rules\relax
%
\def\diploma#1{\gdef\@diploma{#1}}
\def\module#1{\gdef\@module{#1}}
\def\academicyear#1{\gdef\@academicyear{#1}}
\def\examdate#1{\gdef\@examdate{#1}}
\def\rules#1{\gdef\@rules{#1}}
%\makeatother

% ----- Options ---------------------------------------------------

\newtoggle{answer}   % should we include the answer?
\togglefalse{answer} % not the default

\newtoggle{marks}   % should we include the marks?
\togglefalse{marks} % not the default

\DeclareOption{answer}{\toggletrue{answer}}
\DeclareOption{marks}{\toggletrue{marks}}

\ProcessOptions

% ----- Questions and answers

\definecolor{ptscolor}{rgb}{0.2,0.,0.4}
\renewcommand*{\marginfont}{\color{ptscolor}\bf}
% \newcommand*{\marginfont}{\color{ptscolor}\bf}
\reversemarginpar

\newcounter{askc}[section]
\newcommand{\ask}[1][\null]{%
  \addtocounter{askc}{1}%
  \iftoggle{marks}{%
  \hskip-1.3cm\hbox to 0pt{\marginfont #1}\hskip1.3cm%
  % \marginnote[\hbox to 1cm{#1\hfill}]{\hbox to 1cm{#1\hfill}}%
  }{\relax}
  \textbf{\arabic{section}.%
  % \arabic{askc}\marginpar{\hbox to 1cm{#1\hfill}}%
  \arabic{askc}%
  %% \iftoggle{marks}{%
  %% \marginnote[\hbox to 1cm{#1\hfill}]{\hbox to 1cm{#1\hfill}}%
  %% }{\relax}
  % \arabic{askc}\marginnote[\hbox to 1cm{#1\hfill}]{}%
  ~---}~}
\def\theask{\arabic{askc}.}

\newcommand{\markremark}[1]{%
  \iftoggle{marks}{%
  {\marginfont #1}%
  % \marginnote[\hbox to 1cm{#1\hfill}]{\hbox to 1cm{#1\hfill}}%
  }{\relax}
}

%% \newcounter{askc}[section]
%% \def\ask{\addtocounter{askc}{1}\textbf{\arabic{section}.\arabic{askc} ---}~}
%% % \def\ask{\addtocounter{askc}{1}\textbf{\arabic{askc}. ---}~}
%% \def\theask{\arabic{askc}.}
%% %

% \ifthenelse{\boolean{answer}}{\includecomment{answer}}{\excludecomment{answer}}


\iftoggle{answer}%
{\definecolor{answercolor}{rgb}{0.5,0.,0.2}%
\newenvironment{answer}%
% {\begingroup\bf\color{answercolor}}{\endgroup}
%% {\begin{solution}\begingroup\color{answercolor}}%
%% {\endgroup\end{solution}}
{\begingroup\color{answercolor}}%\captionsetup{font={answercolor}}}%
{\endgroup}}%
{\excludecomment{answer}}
%% {\excludecomment{solution}}%


\def\addexercice#1{%
  % \def\Ginput@path{ { logos/ } { #1/ } }
  % \show\Ginput@path
  \input{#1/enonce}
}


% ----- Personal setup --------------------------------------------

% Some useful macros
 
\def\T#1{\text{#1}}
\def\unk{\square}
\def\dd{\mathrm{d}}


% Maths...

% Ici changer les notations des vecteurs selon les préférences...

\def\vv#1{\mathbf{\bm{#1}}}  % 3-vectors (bold)
% \def\vv#1{\vec{#1}}  % 3-vectors (flèche)
% \def\qv#1{\widetilde{\boldsymbol{#1}}}  % 4-vectors (bold with tilde)
\def\qv#1{\widetilde{\mathbf{#1}}}  % 4-vectors (bold with tilde)
% \def\qv#1{\underline{\mathbf{#1}}}  % 4-vectors (bold with tilde)

\newcommand{\axis}[1]{\mathbf{e_{#1}}}
\def\co#1{\texttt{#1}}

\newcommand{\argsinh}{\mathop\mathrm{argsinh}}
\newcommand{\argcosh}{\mathop\mathrm{argcosh}}
\newcommand{\argtanh}{\mathop\mathrm{argtanh}}
\newcommand{\argsh}{\mathop\mathrm{argsh}}
\newcommand{\argch}{\mathop\mathrm{argch}}
\newcommand{\argth}{\mathop\mathrm{argth}}
\newcommand{\sh}{\mathop\mathrm{sh}}
\newcommand{\ch}{\mathop\mathrm{ch}}
\newcommand{\tgh}{\mathop\mathrm{th}}  % \th already exists
%% \newcommand{\sh}{\mathop\mathrm{sh}}
%% \newcommand{\ch}{\mathop\mathrm{ch}}
%% \newcommand{\th}{\mathop\mathrm{th}}

\def\dst{\displaystyle}
\def\TT{\text{\Large$\mathstrut$}}
\def\TTT{\vrule depth4mm height6mm width0mm}
\def\TTTT{\vrule depth16mm height16mm width0mm}

% Nuclear physics

\newcommand{\nucl}[3]{%
\ensuremath{%
\phantom{\ensuremath{^{#1}_{#2}}}
\llap{\ensuremath{^{#1}}}
% \llap{\ensuremath{_{\rule{0pt}{.75em}#2}}}
\llap{\ensuremath{_{\rule{0pt}{.65em}#2}}}
\mbox{#3}}}


\def\thesection{\arabic{section}.\!\!\!}
\def\thesubsection{\arabic{section}.\,\arabic{subsection}.\!\!\!}

\AtBeginDocument{%
%% \parindent0pt
%% % \pagestyle{empty}
%% \definecolor{lightgray}{gray}{0.85}
%% %
%% \headheight=13.6pt
%% \pagestyle{fancy}
%% \pagenumbering{arabic}
%% \fancyhf{}
%% \makeatletter
%% \fancyhead[OL]{\@module}
%% \fancyhead[ER]{\@module}
%% \fancyhead[OR]{\@academicyear}
%% \fancyhead[EL]{\@academicyear}
%% \makeatother
%% \fancyfoot[OR]{\thepage}
%% \fancyfoot[EL]{\thepage}
%% \renewcommand{\headrulewidth}{0pt}
%% \renewcommand{\footrulewidth}{0pt}
%% \thispagestyle{empty}
}

\def\maketitle{%
\null\vglue-20mm
%\medskip\null
\null%\vglue-20mm
%\medskip\null
\centerline{%
   \begin{minipage}[c]{.25\linewidth}
      \includegraphics[scale=0.08]{figures/SU-Sciences-logo.jpg}
   \end{minipage}%
   \hfill
}
\bigskip
\begin{center}
%% {\large Université Pierre et Marie Curie\\[\medskipamount]
%% École Normale Supérieure de Cachan}
\bigskip\null\bigskip
% {\large\sc \@diploma\ --- \@module}
{\LARGE Préparation à l'Agrégation\\[\medskipamount]}
{\\[\medskipamount]\LARGE\textbf{\textsc{Python -- Exercices %
\iftoggle{answer}{--- \textcolor{answercolor}{Corrigé}}{\relax}%
\\[\bigskipamount]}}}
% {\@academicyear}\\[\bigskipamount]
% {\@examdate}\\[\bigskipamount]
{\@academicyear}
\\[\medskipamount]
Intervenant : L. Le Guillou (Sorbonne Université / LPNHE)
% \iftoggle{answer}{\relax}{\textbf{\@rules}}
\end{center}
\medskip
\vskip1cm
% \null\bigskip
}


%% ---------- page formatting

\parskip=\medskipamount
\setpapersize{A4}
% \setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
\setmargrb{2cm}{1.5cm}{2cm}{1.5cm}
%
\parindent0pt
% \pagestyle{empty}
\definecolor{lightgray}{gray}{0.85}
%
\headheight=13.6pt
\pagestyle{fancy}
\pagenumbering{arabic}
\fancyhf{}
\makeatletter
\fancyhead[OL]{\@module}
\fancyhead[ER]{\@module}
\fancyhead[OR]{\@academicyear}
\fancyhead[EL]{\@academicyear}
\makeatother
% \fancyfoot[OR]{\thepage/\pageref{LastPage}}
% \fancyfoot[EL]{\thepage/\pageref{LastPage}}
\fancyfoot[OR]{\thepage}
\fancyfoot[EL]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\thispagestyle{empty}


\endinput


