%=========================================
%Macros personnelles
%christophe.poulain@melusine.eu.org
%création : 25 Septembre 1999
%dernière modification : 28 Avril 2005
%=========================================

\RequirePackage{xlop,fancybox,color,amssymb,ifthen}
\input{xlopsqrt}
\newtheorem{ppte}{Propriété}
\newtheorem{theo}{Théorème}
\newtheorem{defi}{\color{green}Définition}
\newtheorem{lemme}{Lemme}
\newtheorem{coro}{Corollaire}
\newtheorem{prop}{Proposition}
\newtheorem{reg}{Règle}
\newtheorem{conj}{Conjecture}
\newtheorem{remar}{Remarque}
\newtheorem{exem}{Exemple}

\newcommand{\rema}{\underline{Remarque} }
\newcommand{\exe}{\underline{Exemple} }
\newcommand{\pre}{\underline{Preuve}}
\newcommand{\cas}{\underline{Cas particulier}}
\newcommand{\cass}{\underline{Cas particuliers}}
\newcommand{\Not}{\underline{Notation} }
\newcommand{\Si}{\underline{Si} }
\newcommand{\si}{\underline{si} }
\newcommand{\alors}{\underline{alors} }
\newcommand{\cons}{\underline{Conséquence}}
\newcommand{\Comme}{\underline{Comme} }
\newcommand{\comme}{\underline{comme} }

\def\qed{\hfill\raise -2pt\hbox{\vrule\vbox to 10pt{\hrule width4pt\vfill\hrule}\vrule}}
\def\cqfd{\hfill\unskip\kern 6pt\penalty 500\qed\par}

\catcode`\@=11
\def\Eqalign#1{\null\,\vcenter{\openup\jot\m@th\ialign{
\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
&&\quad\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$
\hfil\crcr #1\crcr}}\,}
\catcode`\@=12

\newcommand{\vecteur}[1]
{\overrightarrow{\strut #1}}

\font\tenbb=msbm10
\font\sevenbb=msbm7
\font\fivebb=msbm5
\newfam\bbfam
\textfont\bbfam=\tenbb
\scriptfont\bbfam=\sevenbb
\scriptscriptfont\bbfam=\fivebb
\def\bb{\fam\bbfam\tenbb}
\let\oldbb=\bb
\def\bb #1{{\oldbb #1}}

\def\tvi{\vrule height 12pt depth 5pt width 0pt}
\def\tvj{\vrule height 12pt depth 5pt width 1pt}
\def\hfq{\hfill\,\,}
\def\cc#1{\hfq #1\hfq}
\def\tv{\tvi\vrule}
\def\tw{\tvj\vrule}
\def\traithorizontal{\noalign{\hrule}}
\def\traithorizontale{\noalign{\hrule height 1pt}}

\newcommand{\encadre}[1]
{\begin{center}
\fbox{\begin{minipage}{\linewidth}
{#1}
\end{minipage}}
\end{center}
}

\def\pgcd{\mathop{\rm PGCD}\nolimits}
\def\ppcm{\mathop{\rm PPCM}\nolimits}

\def\cut{{}\hfill\cr \hfill{}}

\newcommand{\biindice}[3]%
{
\renewcommand{\arraystretch}{0.5}
\begin{array}[t]{c}
#1\\
{\scriptstyle #2}\\
{\scriptstyle #3}
\end{array}
\renewcommand{\arraystretch}{1}
}

\newlength{\ltxt}
\newcommand{\compo}[4]{
\setlength{\ltxt}{\linewidth}
\setbox#1=\hbox{\includegraphics[scale=#3]{#2.#1}}
\addtolength{\ltxt}{-\wd#1}
\addtolength{\ltxt}{-10pt}
\begin{minipage}{\wd#1}
\includegraphics[scale=#3]{#2.#1}
\end{minipage}
\hfill
\begin{minipage}{\ltxt}
#4
\end{minipage}
}

\newlength{\lntxt}
\newcommand{\Compo}[4]{
\setlength{\lntxt}{\linewidth}
\setbox#1=\hbox{\includegraphics[scale=#3]{#2}}
\addtolength{\lntxt}{-\wd#1}
\addtolength{\lntxt}{-10pt}
\begin{minipage}{\wd#1}
\includegraphics[scale=#3]{#2}
\end{minipage}
\hfill
\begin{minipage}{\lntxt}
#4
\end{minipage}
}

\newlength{\lnttxt}
\newcommand{\dispo}[3]{
\setlength{\lnttxt}{\linewidth}
\setbox#1=\hbox{#2}
\addtolength{\lnttxt}{-\wd#1}
\addtolength{\lnttxt}{-20pt}
\begin{minipage}{\wd#1}
#2
\end{minipage}
\hfill
\begin{minipage}{\lnttxt}
#3
\end{minipage}
}

\newcounter{num}[section]
\newcommand{\exo}{\addtocounter{num}{1}
\par
\par\underline{\bf Exercice~\thenum} }

\newcommand{\titrage}[2]{
{\Large #1}\hfill#2
\par\rule[+6pt]{\linewidth}{0.5mm}
\par
}

\newcommand{\titragedossier}[1]{
{\small #1}\hfill{\small www.melusine.eu.org/syracuse/poulecl/}
\par\rule[+6pt]{\linewidth}{0.5mm}
\par
}

\newcommand{\partie}[2]{
\begin{center}
\begin{minipage}{#1pt}
\begin{center}
\boxput*(0,0){\colorbox{white}{#2}}
{\rule{\linewidth}{0.5mm}}
\end{center}
\end{minipage}
\end{center}
\par
}

\newenvironment{myenumerate}{
\renewcommand{\theenumi}{\arabic{enumi}}
\def\labelenumi{{\bf \theenumi /}}
\begin{enumerate}}{\end{enumerate}}

\newenvironment{Myenumerate}{
\renewcommand{\theenumi}{\arabic{enumi}}
\def\labelenumi{$\rhd${\bf \theenumi /}}
\begin{enumerate}}{\end{enumerate}}

\newdimen\shadeshift\shadeshift=1pt
\def\shadedtext#1{{\setbox0=\hbox{#1}\leavevmode
        \vtop to 0pt{\rlap{\special{color push rgb 0.75 0.75 0.75}%
        \kern0.1em\lower0.1em\copy0
        \special{color pop}}\vss}\box0}}%
\long\def\shadedparagraph#1\par{{\setbox0=\vbox{\hsize=\hsize#1}%
        \noindent\leavevmode
        \vtop to 0pt{\rlap{\special{color push rgb 0.75 0.75 0.75}%
        \kern0.1em\lower0.1em\copy0
        \special{color pop}}\vss}\box0\par}}%

\newboolean{exact}
\setboolean{exact}{true}

\newcommand{\pythahypo}[5]{
\opset{decimalsepsymbol={,}}
\opcopy{#4}{A1}
\opcopy{#5}{A2}
Dans le triangle $#1#2#3$ rectangle en $#2$, le théorème de Pythagore permet d'écrire :
$$\Eqalign{
#1#3^2&=#1#2^2+#2#3^2\cr
#1#3^2&=\opprint{A1}^2+\opprint{A2}^2\cr
#1#3^2&=\opmul*{A1}{A1}{a1}\opprint{a1}+\opmul*{A2}{A2}{a2}\opprint{a2}\cr
#1#3^2&=\opadd*{a1}{a2}{a3}\opprint{a3}\cr
#1#3&=\sqrt{\opprint{a3}}\cr
\ifthenelse{\boolean{exact}}{#1#3&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opprint{a4}}{#1#3&\approx\opsqrt[maxdivstep=3]{a3}{a4}\opround{a4}{2}{a4}\opunzero{a4}
\opprint{a4}}\cr
}$$
}

\newcommand{\pythadroit}[5]{
\opset{decimalsepsymbol={,}}
\opcopy{#4}{A1}
\opcopy{#5}{A2}
Dans le triangle $#1#2#3$ rectangle en $#2$, le théorème de Pythagore permet d'écrire :
$$\Eqalign{
#1#3^2&=#1#2^2+#2#3^2\cr
\opprint{A1}^2&=#1#2^2+\opprint{A2}^2\cr
\opmul*{A1}{A1}{a1}\opprint{a1}&=#1#2^2+\opmul*{A2}{A2}{a2}\opprint{a2}\cr
#1#2^2&=\opmul*{A1}{A1}{a1}\opprint{a1}-\opmul*{A2}{A2}{a2}\opprint{a2}\cr
#1#2^2&=\opsub*{a1}{a2}{a3}\opprint{a3}\cr
#1#2&=\sqrt{\opprint{a3}}\cr
\ifthenelse{\boolean{exact}}{#1#2&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opprint{a4}}{#1#2&\approx\opsqrt[maxdivstep=3]{a3}{a4}\opround{a4}{2}{a4}\opunzero{a4}
\opprint{a4}}\cr
}$$
}

\newcommand{\Thales}[5]{
Dans le triangle $#1#2#3$, $#4$ est un point de la
 droite $(#1#2)$, $#5$ est un point de la droite
 $(#1#3)$ ; les droites $(#4#5)$ et $(#2#3)$ sont parallèles.
 Le théorème de Thalès permet d'écrire :
$$\frac{#1#4}{#1#2}=\frac{#1#5}{#1#3}=\frac{#4#5}{#2#3}$$
}

\newcommand{\Thalesf}[5]{
Dans le triangle $#1#2#3$, $#4$ est un point du
 segment $[#1#2]$, $#5$ est un point du segment
 $[#1#3]$ ; les droites $(#4#5)$ et $(#2#3)$ sont parallèles.
 L'égalité des 3 rapports permet d'écrire :
$$\frac{#1#4}{#1#2}=\frac{#1#5}{#1#3}=\frac{#4#5}{#2#3}$$
}

\newcommand{\ResolThales}[6]{
\opset{decimalsepsymbol={,}}
\opcopy{#3}{a3}
\opcopy{#4}{a4}
\opcopy{#5}{a5}
On utilise 
$$\Eqalign{
\frac{#1#2}{\opprint{a3}}&=\frac{\opprint{a4}}{\opprint{a5}}\cr
#1#2&=\frac{\opprint{a3}\times\opprint{a4}}{\opprint{a5}}\cr
#1#2&=\frac{\opmul*{a3}{a4}{a6}\opprint{a6}}{\opprint{a5}}\cr
#1#2&=\opdiv*{a6}{a5}{a7}{a8}\opprint{a7}\cr
}$$
La longueur $#1#2$ mesure \opprint{a7}\, #6
}

%%QCM
\newcounter{qqcm}

%définir un booléen qui permet de choisir la correction ou non
\newboolean{solution}

%définir une commande \V qui permet de changer le carré en carré coché suivant la valeur du booléen.
\newcommand{\V}[1]{\ifthenelse{\boolean{solution}}{$\boxtimes$\kern2mm #1}{$\Box$\kern2mm #1}}
\newcommand{\F}[1]{$\Box$\kern2mm #1}
\newcommand{\vr}{\ifthenelse{\boolean{solution}}{$\boxtimes$}{$\Box$}}
\newcommand{\fa}{$\Box$}

%%QCM Version 2
\newenvironment{Qcm}[1][2]{\par\setboolean{solution}{false}
\setcounter{qqcm}{0}\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}b{\linewidth/#1}|*{#1}{l|}}\hline}{\hline\end{tabular}
\renewcommand{\arraystretch}{1}}

\newenvironment{Qcmcor}[1][2]{\par\setboolean{solution}{true}\setcounter{qqcm}{0}\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}b{\linewidth/#1}|*{#1}{l|}}\hline}{\hline\end{tabular}
\renewcommand{\arraystretch}{1}}

\newcommand{\QCM}[3]{\setboolean{solution}{false}
\setcounter{qqcm}{0}
\renewcommand{\arraystretch}{1.5}
\newcounter{taille}
\setcounter{taille}{#1}
\addtocounter{taille}{1}
\begin{tabularx}{\linewidth}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}X|*{#1}{l|}}
\hline
\multicolumn{\thetaille}{|c|}{{\sc #2}}\\
#3
\hline
\end{tabularx}
}

\newcommand{\QCMcor}[3]{\setboolean{solution}{true}
\setcounter{qqcm}{0}
\renewcommand{\arraystretch}{1.5}
\newcounter{taille}
\setcounter{taille}{#1}
\addtocounter{taille}{1}
\begin{tabularx}{\linewidth}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}X|*{#1}{l|}}
\hline
\multicolumn{\thetaille}{|c|}{{\sc #2}}\\
#3
\hline
\end{tabularx}
}

\newcommand{\QCMvar}[4]{\setboolean{solution}{false}
\setcounter{qqcm}{0}
\renewcommand{\arraystretch}{#2}
\newcounter{taille}
\setcounter{taille}{#1}
\addtocounter{taille}{1}
\begin{tabularx}{\linewidth}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}X|*{#1}{l|}}
\hline
\multicolumn{\thetaille}{|c|}{{\sc #3}}\\
#4
\hline
\end{tabularx}
}

\newcommand{\QCMvarcor}[4]{\setboolean{solution}{true}
\setcounter{qqcm}{0}
\renewcommand{\arraystretch}{#2}
\newcounter{taille}
\setcounter{taille}{#1}
\addtocounter{taille}{1}
\begin{tabularx}{\linewidth}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}X|*{#1}{l|}}
\hline
\multicolumn{\thetaille}{|c|}{{\sc #3}}\\
#4
\hline
\end{tabularx}
}

\newenvironment{VF}[1]{\par\setboolean{solution}{false}
\setcounter{qqcm}{0}\renewcommand{\arraystretch}{1.5}
\begin{center}
\begin{tabular}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}b{\linewidth/2}|*{2}{c|}}\hline
\multicolumn{3}{|c|}{#1}\\
\hline
\multicolumn{1}{|c|}{\bf Question}&\multicolumn{1}{c|}{\bf Vrai}&\multicolumn{1}{c|}{\bf Faux}\\
\hline
}{\hline\end{tabular}
\end{center}\renewcommand{\arraystretch}{1}}

\newenvironment{VFcor}[1]{\par\setboolean{solution}{true}\setcounter{qqcm}{0}\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|>{\small\stepcounter{qqcm}{\bf \theqqcm/}\,}b{\linewidth/2}|*{2}{c|}}\hline
\multicolumn{3}{|c|}{#1}\\
\hline
\multicolumn{1}{|c|}{\bf Question}&\multicolumn{1}{c|}{\bf Vrai}&\multicolumn{1}{c|}{\bf Faux}\\
\hline
}{\hline\end{tabular}
\renewcommand{\arraystretch}{1}}