%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% L I C E N S E
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ces notes ont été écrites par Jonathan Godin. Il est le
% seul auteur de ce fichier. 
%
% Vous pouvez utiliser des parties ou l'intégralité
% du fichier. Cependant, il faut citer Jonathan Godin
% comme étant l'auteur original.
%
% Pour tout problème, commentaire ou suggestion, écrivez à
% jonathan.godin@umontreal.ca
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Définition des macros pour les notes de cours 
% et spécifications pour la mise en page.
\ifx\formatnote\undefined
  \def\formatnote{}
\else
  \endinput
\fi
\catcode`@=11

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                      Mise en page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Format du papier = letterpaper (XeTeX prend A4 par défaut)
% (C'est le papier par défaut Européen)
\pdfpageheight=11truein
\pdfpagewidth=8.5truein

% Marges
% On laisse une grosse marge à gauche pour pouvoir écrire des notes
% et mettre des images(?).
\def\margesnormales{
  \vsize=11truein
  \advance\vsize by -5truecm
  \voffset=-1truein
  \advance\voffset by 2.5truecm
  % Plus l'entête et le pas de page
  \advance\vsize by -28truept
  \advance\voffset by -14truept
  
  \hsize=8.5truein
  \advance\hsize by -5truecm
  \hoffset=-1truein
  \advance\hoffset by 4truecm
}
\margesnormales
\def\hsizenormal{\hsize8.5truein}

\let\version\null
\def\piednormal{
  \footline{\ifnum\pageno=1\hfill\version \else \hss\hskip-\hoffset\rm\number\pageno\hss\fi}
}
\piednormal
\def\tetenormale{
  \headline{\hfil}
}
\tetenormale

\def\centrermarges{
    \hsize=6.5truein
    \hoffset=0pt
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          Langue
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\l@french\undefined \ifx\lang@french\undefined
  \errhelp{Le francais ne semble pas installer.}
  \errmessage{Impossible de charger le francais.}
\else\language\lang@french\fi
\else\language\l@french\fi
\lccode`'=39
\lefthyphenmin=2
\righthyphenmin=3

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                Macros de mise en page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\titre#1.{\centerline{\vbox{\raggedcenter\titrefonte #1}}\vskip.5\baselineskip}
\font\titrefonte=ecrm1200 at 30pt
\def\soustitre#1.{\centerline{\vbox{\raggedcenter\soustitrefonte #1}}\vskip.5\baselineskip}
\font\soustitrefonte=ecbx1200 at 18pt

\def\@{\null{}} %Pour placer après un point qui ne termine pas une phrase
\def\plusun#1{\global\advance#1 by 1\relax}
\def\raggedcenter{\leftskip=0pt plus4em \rightskip=\leftskip
\parfillskip=0pt \spaceskip=.3333em \xspaceskip=.5em
\pretolerance=9999 \tolerance=9999 \parindent=0pt
\hyphenpenalty=9999 \exhyphenpenalty=9999}
\def\centerfig{\leftskip=0pt plus 1fill\rightskip\leftskip}

\newcount\partieno \partieno=0
\font\partieunfonte=ecrm1200 at 25truept
\font\partiedeuxfonte=ecrm1200 at 20truept
\def\partienum{\expandafter\ifcase\number\partieno \or
  Première\ \or Deuxième\hskip1ex\or Troisième\hskip1ex\or Quatrième
  \or Cinquième\or Sixième\or Septième\or Huitième\or
  Neuvième\fi}
\def\partie#1.{\plusun\partieno
	\secno=0 \soussecno=0 \enonceno=0 \soussousno=0 \exempleno=0%
	\chapno=0\relax
  \par\vfill\supereject
  \vtop to 0pt{\vss
    \special{pdf: dest (partie\number\partieno) [@thispage /XYZ @xpos @ypos 0]}
    \special{pdf: out [-] 1 << /Title (Partie \number\partieno\ #1)
      /A << /S/GoTo /D (partie\number\partieno)>> 
      /C [0 0 0] /F 00 >>}
    \vrule width0pt height30pt}
  \toc{{\bf \partienum partie.} #1\hfill{\bf \number\pageno}\par}
  \centrermarges
  \footline{\hfil}
  \headline{\hfil}
  \noindent\null
  \vfill
  \centerline{\partieunfonte \partienum partie}
  \bgroup
  \raggedcenter
  \vskip1pc
  \partiedeuxfonte #1\par
  \egroup
  \vfill\supereject%
  \margesnormales
  \piednormal
  \tetenormale
}

\newcount\secno \secno=0
\newcount\chapno \chapno=0
\font\secfonte=ecbx1200 at 18truept
\font\chapfonte=ecbx3583 at 45truept
%\special{pdf: dest (aaa) [@thispage /FitH @ypos]}
\def\chapitre#1.{%
  \plusun\chapno \secno=0 \soussecno=0 \enonceno=0 \soussousno=0%
  \filbreak
  \bigbreak
  \vtop to 0pt{\vss
    \special{pdf: dest (chapitre\number\chapno) [@thispage /XYZ @xpos @ypos 0]}
    \special{pdf: out [-] 1 << /Title (Chapitre \number\chapno\ #1)
      /A << /S/GoTo /D (chapitre\number\chapno)>> 
      /C [0 0 0] /F 00 >>}
    \vrule width0pt height30pt}
  \nointerlineskip
  \chapitretoc{#1}%
  \noindent{\chapfonte Chapitre \number\chapno}\par\vskip1em
  \setbox0=\hbox{\secfonte#1}%
  \noindent\copy0\llap{\vrule width\wd0 depth5pt height -3pt}%
  \par\vskip1truepc\noindent\ignorespaces%
}
%
%
\def\section#1.{\plusun\secno \soussecno=0 \enonceno=0 \soussousno=0 \exempleno=0%
  \ifvmode\removelastskip\fi
  \bigbreak\penalty-500
  \nointerlineskip
  \vtop to 0pt{\vss
    \special{pdf: dest (chapitre\number\chapno.section\number\secno) [@thispage /XYZ @xpos @ypos 0]}
    \special{pdf: out [-] 2 << /Title (\number\chapno.\number\secno\ #1)
      /A << /S/GoTo /D (chapitre\number\chapno.section\number\secno)>> 
      /C [0 0 0] /F 00 >>}
    \vrule width0pt height30pt}
  \nointerlineskip
  \sectiontoc{#1}%
  \setbox0=\hbox{\secfonte#1}%
  \noindent{\secfonte\number\chapno.\number\secno. }\copy0\llap{\vrule width\wd0 depth5pt height -3pt}%
  \par\vskip1truepc\noindent\ignorespaces%
}
\def\sectiontoc#1{
  \setbox0=\hbox{#1}%
  \dimen0=\wd0
  \advance\dimen0 by 3pt
  \toc{\qquad\number\chapno.\number\secno. %
      \noexpand\special{pdf: ann width \the\dimen0\noexpand\space height 12pt 
          << /Type /Annot
	     /Subtype /Link
	     /H /P
	     /Border [0 0 0]
	     /Dest (chapitre\number\chapno.section\number\secno)
	  >>}%
	  \special{pdf:begincolor [0 0.4 1]}#1\special{pdf: endcolor}%
	  \xleaders\hbox{\kern1pt.\kern1pt}\hfill\number\pageno\par}%
}

\def\chapitretoc#1{
  \setbox0=\hbox{#1}%
  \dimen0=\wd0
  \advance\dimen0 by 3pt
  \toc{\vskip1em Chapitre \number\chapno. %
      \noexpand\special{pdf: ann width \the\dimen0\noexpand\space height 12pt 
          << /Type /Annot
	     /Subtype /Link
	     /H /P
	     /Border [0 0 0]
	     /Dest (chapitre\number\chapno)
	  >>}%
	  \special{pdf:begincolor [0 0.4 1]}#1\special{pdf: endcolor}%
	  \xleaders\hbox{\kern1pt.\kern1pt}\hfill\number\pageno\par}%
}


\def\sectiontitrelong#1\par#2.{\plusun\secno \soussecno=0 \enonceno=0 \soussousno=0%
  \ifvmode\removelastskip\fi
  \medbreak
  \noindent\setbox0=\hbox{\secfonte#1}%
  \toc{\qquad\number\secno. #1 \ignorespaces#2\xleaders\hbox{\kern1pt.\kern1pt}\hfill\number\pageno\par}%
  {\secfonte \number\secno. }\copy0\llap{\vrule width\wd0 depth5pt height -3pt}%
  \setbox0=\hbox{\secfonte#2}%
  \par\vskip3pt\noindent$\phantom{\hbox{\secfonte\number\secno. }}$%
  \copy0\llap{\vrule width\wd0 depth5pt height -3pt}%
  \par\vskip1truepc\noindent\ignorespaces}

\newcount\sansnum \sansnum=125
\def\sectionsansnum#1.{\plusun\sansnum
  \ifvmode\removelastskip\fi
  \bigbreak
  \nointerlineskip
  \vtop to 0pt{\vss
    \edef\pourSpecial{pdf: dest (a100\number\sansnum) [@thispage /XYZ @xpos @ypos 0]}
    \expandafter\immediate\expandafter\special\expandafter{\pourSpecial}
    \special{pdf: out [-] 1 << /Title (#1)
      /A << /S/GoTo /D (a100\number\sansnum)>> 
      /C [0 0 0] /F 00 >>}
    \vrule width0pt height30pt}
  \nointerlineskip
  \sectionsansnumtoc{#1}%
  \noindent{\secfonte#1}%
  \par\nobreak\smallskip\noindent\ignorespaces}

\def\sectionsansnumtoc#1{
  \setbox0=\hbox{#1}%
  \dimen0=\wd0
  \advance\dimen0 by 3pt
  \edef\pourTOC{\indent\noexpand\special{pdf: ann width \the\dimen0\noexpand\space height 12pt 
          << /Type /Annot
	     /Subtype /Link
	     /H /P
	     /Border [0 0 0]
	     /Dest (a100\number\sansnum)
	  >>}}%
  \expandafter\immediate\expandafter\write\expandafter\@toc\expandafter{\pourTOC
	  \special{pdf:begincolor [0 0.4 1]}#1\special{pdf: endcolor}%
	  \xleaders\hbox{\kern1pt.\kern1pt}\hfill\number\pageno\par}%
}
    
\newcount\soussecno \soussecno=0
\font\soussecfonte=ecbx1200 at 15pt
\def\soussection#1.{\plusun\soussecno \soussousno=0%
  \ifvmode\removelastskip\fi
  \bigbreak
  \nointerlineskip
  \vtop to 0pt{\vss
    \special{pdf: dest (chapitre\number\chapno.soussection\number\secno.\number\soussecno) [@thispage /XYZ @xpos @ypos 0]}
    \special{pdf: out [-] 3 << 
      /Title (\number\chapno.\number\secno.\number\soussecno.\ #1)
      /A << /S/GoTo /D (chapitre\number\chapno.soussection\number\secno.\number\soussecno)>> 
      /C [0 0 0] /F 00 >>}
    \vrule width0pt height30pt
    }
  \nointerlineskip
  \soussectiontoc{#1}
  \noindent{\soussecfonte 
    \number\chapno.\number\secno.\number\soussecno\ #1}
  \par\nobreak\smallskip\noindent\ignorespaces}
\let\sssection=\soussection
\def\soussectiontoc#1{
  \setbox0=\hbox{#1}%
  \dimen0=\wd0
  \advance\dimen0 by 3pt
  \toc{\qquad\qquad\number\chapno.\number\secno.\number\soussecno\  %
      \noexpand\special{pdf: ann width \the\dimen0\noexpand\space height 12pt 
          << /Type /Annot
	     /Subtype /Link
	     /H /P
	     /Border [0 0 0]
	     /Dest (chapitre\number\chapno.soussection\number\secno.\number\soussecno)
	  >>}%
	  \special{pdf:begincolor [0 0.4 1]} #1\relax \special{pdf: endcolor}%
	  \xleaders\hbox{\kern1pt.\kern1pt}\hfill\number\pageno\par}%
}

\newcount\soussousno \soussousno=0
\font\soussousfonte=ecbx1200
\def\soussoussection#1.{\plusun\soussousno%
  \ifvmode\removelastskip\fi
  \medbreak
  \noindent{\soussousfonte 
  %\number\secno.\number\soussecno.\number\soussousno\ 
    #1}
  \par\nobreak\smallskip\noindent\ignorespaces}

\newcount\exerno \exerno=0
\def\exer{\plusun\exerno\bgroup%
  \proclamer* {Exercice \number\exerno{}.} en \rm
  \def\fin{\egroup\medskip\let\fin=\undefined} \ignorespaces%
}
\def\@coin{\ifvmode\errhelp{Placez \string\fin\ %
juste après le texte (sans laisser de ligne vide).}
  \errmessage{On ne peut pas finir un exemple en mode vertical.}\fi
  \vadjust{\vtop to 0pt{\vss\hrule height 1cm width.7pt depth0pt
  \noindent\vrule width3cm height .7pt depth0pt}}}

\def\exerdifficile{%
  \removelastskip
  \smallbreak%
  \bgroup\dixpt%
  \let\smallbreak=\relax%
  \noindent\debutdifficile\proclamer* Exercice. en \rm
  \def\fin{\par\egroup\let\fin\undefined} \ignorespaces
}

\def\exerddifficile{%
  \removelastskip
  \smallbreak%
  \bgroup\dixpt%
  \let\smallbreak=\relax%
  \noindent\debutddifficile\proclamer* Exercice. en \rm
  \def\fin{\par\egroup\let\fin\undefined} \ignorespaces
}

\newif\ifsol
\def\sol{%
  \ifsol
    \removelastskip
    \bgroup\special{pdf:begincolor [1 0 0]}\proclamer* Solution en \rm
    \def\fin{\special{pdf:endcolor}\egroup\medskip\let\fin=\undefined} \ignorespaces
  \else
    \expandafter\solabsent
  \fi
}
\long\def\solabsent#1\fin{}


\newcount\enonceno \enonceno=0
\def\proclamer{\futurelet\next\proclameraction}
\def\proclameraction{\ifx\next*%
  \expandafter\proclamersansnum\else\expandafter\proclameravecnum\fi}

\def\proclameravecnum#1 en #2{\ifvmode\removelastskip\fi%
  \plusun\enonceno
  \smallbreak\noindent
  {\bf #1 \numeroter{}\null{}}%
  \hskip1ex\ignorespaces#2}

\def\proclamersansnum* #1 en #2{\ifvmode\removelastskip\fi%
  \smallbreak\noindent%
  {\bf#1\null{}}#2\hskip1ex\ignorespaces}

\def\deff{\bgroup%
  \smallbreak
  \proclamer Définition en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill****
    \else
      \nobreak\noindent\null\hfill****
    \fi
    \smallskip\penalty-50%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}
\def\restorewidowpenalty{\expandafter\widowpenalty\normalwidowpenalty}
\edef\normalwidowpenalty{\the\widowpenalty}

\def\numeroter{\number\chapno.\number\secno.\number\enonceno.}
\def\theo{\futurelet\next\theoaction}
\def\theoaction{\ifx\next[ \expandafter\theoop\else \expandafter\theosansop\fi}
\def\theoop[#1]{\bgroup%
  \plusun\enonceno
  \proclamer* Théorème {#1} \numeroter{} en \sl
  \def\fin{\smallskip\egroup\let\fin\undefined}\ignorespaces}
\def\theosansop{\bgroup%
  \proclamer Théorème en \sl
  \def\fin{\smallskip\egroup\let\fin\undefined}}

\def\prop{\bgroup%
  \proclamer Proposition en \sl
  \def\fin{\smallskip\egroup\let\fin\undefined}}

\def\lem{\futurelet\next\lemaction}
\def\lemaction{\ifx\next[\expandafter\lemop%
  \else\expandafter\lemsansop\fi}
\def\lemsansop{\bgroup%
  \proclamer Lemme en \sl
  \def\fin{\smallskip\egroup\let\fin\undefined}}
\def\lemop[#1]{\bgroup%
  \plusun\enonceno%
  \proclamer* Lemme \numeroter{} {#1} en \sl
  \def\fin{\smallskip\egroup\let\fin\undefined}}

\def\cor{\bgroup%
  \proclamer Corollaire en \sl
  \global\let\@fin=\fin%
  \def\fin{\smallskip\egroup\let\fin\@fin}%
}

\def\rem{\bgroup%
  \proclamer* \it Remarque. en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill****
    \else
      \nobreak\noindent\null\hfill****
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}

\def\rems{\bgroup%
  \proclamer* \it Remarques. en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill****
    \else
      \nobreak\noindent\null\hfill****
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}

\def\prof{\bgroup
  \dixpt
  \special{pdf:begincolor [0 .5 0]}%
  \def\fin{\special{pdf: endcolor}\egroup\let\fin=\undefined}%
}

%\setbox\sinbox=\vtop to 0pt{\vss\hrule
%  \hbox{\vrule\kern2pt\vbox{\kern2pt \XeTeXpdffile 
%    figures/sinbox/sinbox-1.pdf 
%    \kern2pt}\kern2pt\vrule}\hrule}
%%\showthe\wd\sinbox
%%\showthe\ht\sinbox
%%\showthe\dp\sinbox

\newbox\sinboxmf
\font\sindifficile=figures/sinbox/metafont/sinbox
\setbox\sinboxmf=\hbox{{\sindifficile\char1}\ }
\edef\sinboxwd{\the\wd\sinboxmf}
\def\debutdifficile{%
  \hangindent\sinboxwd\hangafter-2%
  \noindent$\smash{\llap{\copy\sinboxmf}}$}

\def\debutddifficile{%
  \dimen0=\sinboxwd
  \multiply\dimen0 by 2\relax
  \hangindent\dimen0\relax\hangafter-2%
  \noindent$\smash{\llap{\copy\sinboxmf\copy\sinboxmf}}$}

\let\sinbox=\sinboxmf
\setbox0=\hbox{\copy\sinbox\ }

\def\remdifficile{%
  \removelastskip
  \smallbreak
  \bgroup\dixpt%
  \let\smallbreak=\relax\debutdifficile\proclamer* {\it Remarque.} en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill****
    \else
      \nobreak\noindent\null\hfill****
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty\egroup
    \let\fin\undefined}%
  \ignorespaces}

\def\ex{\futurelet\next\exaction}
\let\ex@copie=\ex
\def\exaction{\ifx\next*\expandafter\exsanstitre
  \else\expandafter\exavectitre\fi}

\newcount\exempleno \exempleno=0
\def\exavectitre#1.{\plusun\exempleno\bgroup%
  \par\penalty-250
  \@coinhg
  \proclamer* {Exemple \number\chapno.\number\secno.\number\exempleno{}. \rm #1.} en \rm
  \ignorespaces
  \def\fin{\fin@ex}%
  \ignorespaces}

\def\fin@ex{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
  \penalty10000\null\hfill\@coinbd
  \else
    \errhelp{Il faut probablement placer \fin en mode horizontale.}
    \errmessage{Un exemple doit se terminer en mode horizontale.}
  \fi
  \medskip\penalty-500%
  \restorewidowpenalty
  \egroup
  \let\fin\undefined}%

\def\exsanstitre*{\plusun\exempleno\bgroup%
  \par\penalty-250
  \@coinhg
  \proclamer* {Exemple \number\chapno.\number\secno.\number\exempleno{}.} en \rm
  \def\fin{\fin@ex}%
  \ignorespaces}
\def\@coinhg{
  \setbox0=\vtop to 0pt{\vss
    \noindent\kern-1pc$\smash{\vrule width .4pt height3pt depth 1cm}$%
    \vrule width 2cm height 3pt depth -2.6pt}
  \ht0=0pt \dp0=0pt \wd0=0pt
  \box0}
\def\@coinbd{%
  \setbox0=\hbox to 0pt{\hss%
    \vrule width 4cm height -6pt depth 6.4pt\relax%
    $\smash{\vrule width .4pt height 1cm depth 6.4pt}$\kern-1pc}%
  \wd0=0pt\relax \ht0=0pt\relax \dp0=0pt\relax%
  \box0}

\def\exsansnum#1.{\bgroup%
  \par\penalty-250
  \@coinhg
  \proclamer* {Exemple.} en \rm{\it #1\/}. \ignorespaces
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
    \penalty10000\null\hfill\llap{\quad\@coinbd}
    \else
      \errhelp{Il faut probablement placer \fin en mode horizontale.}
      \errmessage{Un exemple doit se terminer en mode horizontale.}
    \fi
    \medskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}

\def\contreex{\bgroup%
  \par
  \@coinhg
  \proclamer* Contre-exemple. en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
    \penalty10000\null\hfill\@coinbd
    \else
      \errhelp{Il faut probablement placer \fin en mode horizontale.}
      \errmessage{Un exemple doit se terminer en mode horizontale.}
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}
\def\@coinhg{
  \setbox0=\vtop to 0pt{\vss
    \noindent\kern-1pc$\smash{\vrule width .4pt height3pt depth 1cm}$%
    \vrule width 2cm height 3pt depth -2.6pt}
  \ht0=0pt \dp0=0pt \wd0=0pt
  \box0}

\def\exdifficile{\futurelet\next\exdifaction}
\def\exdifaction{\ifx\next*\expandafter\exdifsanstitre%
  \else\expandafter\exdiftitre\fi}
\def\exdifsanstitre*{\bgroup\dixpt%
  \par\smallbreak \let\smallbreak\relax
  \@coinhg
  \debutdifficile\proclamer Exemple en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
    \penalty10000\hfill\@coinbd
    \else
      \errhelp{Il faut probablement placer \fin en mode horizontale.}
      \errmessage{Un exemple doit se terminer en mode horizontale.}
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}
  
\def\exdiftitre#1.{\bgroup\dixpt%
  \par\smallbreak \let\smallbreak\relax
  \@coinhg
  \debutdifficile\proclamer Exemple en \rm{\it #1\/}. \ignorespaces
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
    \penalty10000\hfill\llap{\quad\@coinbd}
    \else
      \errhelp{Il faut probablement placer \fin en mode horizontale.}
      \errmessage{Un exemple doit se terminer en mode horizontale.}
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}


\def\demdifficile{\bgroup\dixpt%
  \smallbreak
  \let\smallbreak=\relax
  \debutdifficile
  \proclamer* {\it Démonstration\/}. en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill\carre
    \else
      \nobreak\noindent\null\hfill\carre
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}

\def\dem{\futurelet\next\demaction}
\let\dem@copie=\dem
\def\demaction{\ifx\next[\expandafter\demop%
  \else\expandafter\demsansop\fi}

\def\demsansop{%
  \bgroup
  \proclamer* {\it Démonstration\/}. en \rm
  \global\let\@fin=\fin%
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill\carre
    \else
      \nobreak\noindent\null\hfill\carre
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\@fin}%
  \ignorespaces}

\def\demop[#1]{\bgroup%
  \proclamer* {\it Démonstration #1\/}. en \rm
  \def\fin{\ifhmode\widowpenalty10000\displaywidowpenalty10000%
      \hfill\penalty-10000\null\hfill\carre
    \else
      \nobreak\noindent\null\hfill\carre
    \fi
    \smallskip\penalty-500%
    \restorewidowpenalty
    \egroup
    \let\fin\undefined}%
  \ignorespaces}
\def\carre{\hbox to 6.1pt{\hss\hsize6pt%
  \vbox{\hrule\hbox{\vrule\vbox{\noindent\vrule height6pt width0pt%
  \hskip6pt}\vrule}\hrule}}}

\def\vliste{\futurelet\next\Vliste}
\def\Vliste{\ifx\next[ \expandafter\vlisteop\else
	\expandafter\vlistesansop\fi}
\def\milieu#1{\omit\hfil\hbox{#1}\hfil}
\def\vlisteop[#1]#2{$\null\,\vcenter{\openup#1\jot\m@th
  \ialign{&\strut\hbox{##}\hfil
      \crcr#2\crcr}}\,$}
\def\vlistesansop#1{$\null\,\vcenter{\openup1\jot\m@th
  \ialign{&\strut\hbox{##}\hfil
      \crcr#1\crcr}}\,$}
\def\vtopliste{\futurelet\next\Vtopliste}
\def\Vtopliste{\ifx\next[ \expandafter\vtoplisteop\else
	\expandafter\vtoplistesansop\fi}
\def\vtoplisteop[#1]#2{$\null\,\vtop{\openup#1\jot\m@th
  \ialign{&\strut\hbox{##}\hfil
      \crcr#2\crcr}}\,$}
\def\vtoplistesansop#1{$\null\,\vtop{\openup1\jot\m@th
  \ialign{&\strut\hbox{##}\hfil
      \crcr#1\crcr}}\,$}


\def\petitedem{\def\fin{$\big]$\let\fin=\undefined}%
  \par\noindent$\big[$\ignorespaces}
\let\petitedem@copie=\petitedem

\newcount\figno \figno=0
\def\fig{\plusun\figno{\bf Figure}~\number\figno}
\def\emph#1{{\it #1\/}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                    Référençage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\@eqno \@eqno=0
\def\eqnum{\global\advance\@eqno by 1\relax
  \eqno(\number\@eqno)} 
\def\label#1 par #2.{%
    \def\arg{#1}%
    \ifx\arg\propmot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\eqmot\edef\@num{\number\@eqno}\fi
    \ifx\arg\theomot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\lemmot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\cormot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\defmot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\exmot\edef\@num{\number\chapno.\number\secno.\number\enonceno}\fi
    \ifx\arg\secmot\edef\@num{\number\chapno.\number\secno}\fi
    \ifx\arg\soussecmot\edef\@num{\number\chapno.\number\secno.\number\soussecno}\fi
    \ifx\arg\exermot\edef\@num{\number\exerno.}\fi
    \ifx\arg\figmot\edef\@num{\number\figno}\fi
    \ifx\arg\chapmot\edef\@num{\number\chapno}\fi
    \ifx\@num\undefined\def\@num{\relax}\fi
    \edef\a{\noexpand\definexref{#1:#2}{\@num}{#1}}%
%    \hldest{xyz}{}{#1:#2}
    \a\let\@num\undefined\ignorespaces}
\def\propmot{prop}
\def\chapmot{chap}
\def\theomot{theo}
\def\eqmot{eq}
\def\lemmot{lem}
\def\cormot{cor}
\def\exmot{ex}
\def\defmot{def}
\def\figmot{fig}
\def\secmot{sec}
\def\figword{figure}
\def\propword{proposition}
\def\secword{section}
\def\defword{définitions}
\def\exword{exemple}
\def\corword{corollaire}
\def\theoword{théorème}
\def\exerword{exercice}
\def\lemword{lemme}
\def\soussecword{section}
\def\soussecmot{soussec}
\def\eqword{équation}
\def\chapword{chapitre}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                   Table des matières
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newread\Toc
\font\gros=ecrm1200 at 15truept
\font\joligros=cmsy10 at 15truept
\def\matieres{
    \noindent{\joligros T\kern-.5pt}{\gros able des matières}\par\vskip.25em
    \vtop to 0pt{\vss
      \special{pdf: dest (matiere1100) [@thispage /XYZ @xpos @ypos 0]}
      \special{pdf: out [-] 1 << /Title (Table des matières)
        /A << /S/GoTo /D (matiere1100)>> 
        /C [0 0 0] /F 00 >>}
      \vrule width0pt height30pt}
    %\openin\Toc=toc.tex
    %\fairematiere
    \edef\temp{\the\parindent}
    \parindent=0pt
		\immediate\openin15=\jobname.toc
		\ifeof15
			\vfill
		\else
			\input \jobname.toc
		\fi
		\immediate\closein15
    \parindent=\temp
    \openout\@toc=\jobname.toc
}
\def\fairematiere{\ifeof\Toc\closein\Toc\let\next\relax
  \else \let\next\@fairematiere\fi\next}
\def\@fairematiere{\immediate\read\Toc to \ligne
  \ligne\par
  \fairematiere}


\newwrite\@toc
\def\toc{\immediate\write\@toc}
\expandafter\def\expandafter\bye\expandafter{\expandafter\closeout\expandafter\@toc\bye}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                       Hyperlien
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\enablehyperlinks
%\def\color#1{}
%\hlopts{bwidth=0}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                   Macros (raccourcis)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\vp{{\rm v.p.}}
\let\del=\partial
\let\ol=\overline
\def\d{{\rm d}}
\def\serie{\sum\limits_0^\infty}
\def\\{\vskip2\jot}
\def\Jac{\mathop{\rm Jac}\nolimits}
\def\grad{\mathop{\rm grad}\nolimits}
\def\Ind{\mathop{\rm Ind}\nolimits}
\let\st=\scriptstyle
\let\sst=\scriptscriptstyle
\let\ds=\displaystyle
\let\ts=\textstyle
\def\inv{^{-1}}
\def\trans{^T}
\def\Par{\par}
\let\ep=\varepsilon
\def\vv{\noalign{\vskip2\jot}}
\def\CR{\cr\vv}
\def\vvv{\noalign{\vskip3\jot}}
\def\VV{\noalign{\vskip4\jot}}
\def\iint{\int\!\!\!\int}
\def\iiint{\int\!\!\!\int\!\!\!\int}
\def\rprime{\vec r\,{}'\!}
\def\Dom{\mathop{\rm Dom}\nolimits}
\def\Aire{\mathop{\rm Aire}\nolimits}
\def\Vol{\mathop{\rm Vol}\nolimits}
\def\div{\mathop{\rm div}\nolimits}
\def\rot{\mathop{\rm rot}\nolimits}
\let\division=\div
\let\phiorig=\phi
\let\phi=\varphi
\def\im{\mathop{\rm im}\nolimits}
\def\boxit#1{\setbox0=\hbox{#1}%
  \hbox{\hsize=\wd0\vbox{\hrule
  \hbox{\vrule\box0\vrule}\hrule}}}
\def\Pp{{\bbb P}}
\def\Ee{{\bbb E}}
\def\Mat{\mathop{\rm Mat}\nolimits}
\def\Matn{\Mat(n\times n)}
\def\topalign{\let\vcenter=\vtop\eqalign}
\def\fbox#1{\hbox{\vrule\vtop{\vbox{\hrule\kern1pt
  \hbox{\thinspace{#1}\thinspace}}
      \kern1pt\hrule}\vrule}}
\def\demskipamount{7pt\relax}
\def\demskip{\futurelet\next\demskipnext}
\def\demskipnext{\ifx\next*%
	\expandafter\demskipsansop\else
	\expandafter\demskipop\fi}
\def\demskipsansop*{\vskip\demskipamount\penalty-50 \noindent\ignorespaces}
\def\demskipop#1 {\vskip\demskipamount\penalty-50 \noindent{\bf #1}~\ignorespaces}
\def\A#1 {{\bf #1}~\ignorespaces}
\catcode`«=13 \chardef«=19
\catcode`»=13 \chardef»=20
\catcode`œ=13 \chardefœ='367
\catcode`æ=13 \chardefæ='346
\catcode`ß=13 \chardefß=255


%\let\circonflexe=^
%\catcode`^=13
%\def^{\ifmmode\expandafter\circonflexe\else\expandafter\indexeaction\fi}
%\def\indexeaction{\futurelet\next\indexeactiondeux}
%\def\indexeactiondeux{\ifx\next|\expandafter\indexer%
%  \else\expandafter\label\fi}
%\def\indexer|#1|{\relax} 

\def\difficile{\medbreak\bgroup\dixpt%
  \ifx\fin\undefined%
    \def\fin{\par\nointerlineskip\noindent\hfil\egroup\let\fin\undefined}%
  \else%
    \global\let\@fin=\fin%
    \def\fin{\par\nointerlineskip\noindent\hfil\egroup\let\fin\@fin}%
  \fi%
  \noindent\debutdifficile%
  \ignorespaces
}
\def\Dfin{\par\nointerlineskip\noindent\hfil\egroup}%
\def\findifficile{\par\nointerlineskip\noindent\hfil\egroup\let\fin\@fin}%

%% Balises pour les différentes versions (prof, étudiante, livre)
\let\LL=\L


\ifx\noteimprime\undefined
  \def\tagL{}
  \def\tagE{}
  \def\tagP{}
\else
  %\def\tagL{\ifvmode\leavevmode\fi\vadjust{%
  %  $\smash{\llap{\bf Livre~: }}$}}
  %\def\tagE{\ifvmode\leavevmode\fi\vadjust{%
  %  $\smash{\llap{\bf Étudiant~: }}$}}
  %\def\tagP{\ifvmode\leavevmode\fi\vadjust{%
  %  $\smash{\llap{\bf Prof~: }}$}}
  \def\tagL{{\bf Livre~: }}
  \def\tagE{{\bf Étudiant~: }}
  \def\tagP{{\bf Prof~: }}
\fi

\newcount\parligne
\parligne=0
\let\fin@ex@copie=\fin@ex

\ifx\noteprof\undefined \ifx\noteetudient\undefined
 \ifx\notelivre\undefined
\let\E=\relax \let\P=\relax \let\L=\relax
\let\Efin=\relax \let\Pfin=\relax \let\Lfin=\relax
\else
\ifx\noteetudiant\undefined
  \long\def\E{\special{pdf:begincolor [.4 0 .8]}\ifvmode\noindent\hskip-2em{\bf Étudiant.}\par\else
    {\bf Étudiant.}\fi}%
  \def\Efin{\special{pdf: endcolor}}%
\else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \E
% Définition pour la version donnée aux étudiant.e.s
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %Pour que les exemples n'apparaîssent pas.
  \ifx\undefined\notevide %pas de vide dans le pdf
    \def\exEtuOptionnel{%
      \long\def\ex##1\fin{\relax}%
      \long\def\dem##1\fin{\relax}%
      \long\def\petitedem##1\fin{\relax}%
    }%
  \else %vide dans le pdf
    \def\exEtuOptionnel{%
      \long\def\ex##1\fin{\parligne=0\relax
        \demvide##1\par}%
      \long\def\dem##1\fin{\parligne=0\relax
        \demvide##1\par}%
      \long\def\petitedem##1\fin{\parligne=0\relax
        \demvide##1\par}%
    }%
  \fi% FIN du if note vide
  \def\E{\let\ex=\ex@copie\let\dem=\dem@copie\let\petitedem=\petitedem@copie}
  \def\Efin{\exEtuOptionnel}
  \exEtuOptionnel
%
  \def\demvide#1\par{%
    \def\arg{#1}%
    \bgroup
    \ifx\arg\empty
      \offinterlineskip
      \advance\parligne by 2\relax
      \loop\ifnum\parligne>0 \noindent\llap{\vrule height15pt width1pt \hskip1cm}\hfil
        \Par\global\advance\parligne by -1\repeat
    \else
      \setbox0=\vbox{#1\par\global\advance\parligne by \prevgraf}%
      \aftergroup\demvide
    \fi
    \egroup}
\fi
\fi\fi\fi

\ifx\notelivre\undefined
  \long\def\L#1\Lfin{\relax}
\else
  \def\L{\special{pdf:begincolor [.2 .7 .1]}\tagL%
    \def\Lfin{\special{pdf: endcolor}}}
\fi

\ifx\noteprof\undefined
  \long\def\P#1\Pfin{\relax}
\else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Définition pour la version de l'enseignant.e
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \def\P{\special{pdf:begincolor [.9 0 .1]}\tagP%
    \def\Pfin{\special{pdf: endcolor}}}
  \long\def\prof@couleur#1\fin{\special{pdf:begincolor [.9 0 .1]}%
    #1\fin\prof@fincouleur}
  \def\prof@fincouleur{\special{pdf: endcolor}}
  \expandafter\def\expandafter\ex\expandafter{\expandafter
    \prof@couleur\ex}
  \long\def\E{\special{pdf:begincolor [.4 0 .8]}\ifvmode\noindent\hskip-2em{\bf Étudiant.}\par\else
      {\bf Étudiant.}\fi}%
    \def\Efin{\special{pdf: endcolor}}
\fi
%

\douzept
\catcode`@=12
\endinput
