% !TEX Fiche « Le cavalier » — source générée par le_cavalier_generateur.php
% Design « fiches » commun au site (cf. coll/latex_fiche_commun.py).
\documentclass[a4paper,11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}
\usepackage[a4paper,top=3.2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}
\usepackage{qrcode}
\usepackage[table]{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\AtBeginDocument{%
  \setlist[itemize]{leftmargin=1.8em,itemsep=0.5ex,topsep=0.4ex,parsep=0pt}%
  \setlist[itemize,1]{label=\textcolor{red!75!black}{\small\textbullet}}%
  \setlist[itemize,2]{label=\textcolor{red!75!black}{\scriptsize\textbullet}}%
}
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{1.4ex}{0.6ex}
\titlespacing*{\subsection}{0pt}{1.0ex}{0.3ex}
\usepackage{multicol}
\setlength{\columnsep}{1.5em}
\usepackage{needspace}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\usepackage{tgheros}
\usepackage{xskak,chessboard}
\setchessboard{showmover=false,boardfontsize=12pt}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{75pt}
\setlength{\headsep}{10pt}

\newcommand{\logowouf}{%
\begin{tikzpicture}[baseline={(current bounding box.center)},scale=0.55,
                    line cap=round,line join=round]
    \path[use as bounding box] (-2.20,-1.45) rectangle (2.20,2.20);
    \path[
        postaction={decorate},
        decoration={
            text along path,
            text={|\fontfamily{qhv}\bfseries\fontsize{9}{9}\selectfont|site2wouf.fr},
            text align={center},
            raise=0.03ex
        }
    ] (-1.29,0.48) arc[start angle=160,end angle=20,radius=1.29];
    \begin{scope}[xshift=-0.06cm]
        \fill[black] (-0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] ( 0.66,0.14) ellipse (0.21 and 0.31);
        \fill[black] (-0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black] ( 0.23,0.49) ellipse (0.22 and 0.35);
        \fill[black]
            (0,-0.10)
            .. controls (-0.36,-0.02) and (-0.63,-0.24) .. (-0.58,-0.58)
            .. controls (-0.52,-0.93) and (-0.16,-1.12) .. (0,-0.90)
            .. controls (0.16,-1.12) and (0.52,-0.93) .. (0.58,-0.58)
            .. controls (0.63,-0.24) and (0.36,-0.02) .. (0,-0.10)
            -- cycle;
    \end{scope}
\end{tikzpicture}%
}
\newcommand{\titre}{Le cavalier et ses libert\'es}
\newcommand{\soustitre}{Cycle 3 et Cycle 4 · Fiche personnalisée}

\fancyhead[C]{%
\raisebox{4pt}{%
\begin{minipage}[c]{0.15\textwidth}
    \centering
    \logowouf
\end{minipage}
\begin{minipage}[c]{0.62\textwidth}
    \centering
    {\Large\bfseries \titre\par}
    {\small\color{gray} \soustitre}
\end{minipage}
\begin{minipage}[c]{0.21\textwidth}
    \centering
    \qrcode[height=1.5cm]{https://site2wouf.fr/le_cavalier.php?t=e1.c5-f6}\\[2pt]
    {\small\ttfamily\bfseries\color{red} e1.c5-f6}
\end{minipage}%
}
}

\begin{document}
\newchessgame

\noindent Aux \'echecs, le \textbf{cavalier} se d\'eplace en \textbf{L} (deux cases puis une, perpendiculairement) et c'est la seule pi\`ece qui peut \textbf{sauter} par-dessus les autres. Par exemple, depuis la case \textbf{e5}, il peut aller sur les cases surlign\'ees : \texttt{c4, c6, d3, d7, f3, f7, g4, g6}.
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=green!45,markfields={c4,c6,d3,d7,f3,f7,g4,g6},setpieces={Ne5}]
\end{center}
\begin{enumerate}[label=\textbf{\arabic*.},leftmargin=*,itemsep=1.4ex]
  \item \textbf{Un cavalier en e1.} On pose un cavalier en \textbf{e1}. Sur quelles cases peut-il aller ? Combien a-t-il de libert\'es ?
  \item \textbf{Une enqu\^ete.} Un cavalier peut se rendre en \textbf{c5} et \textbf{f6}. Sur quelle(s) case(s) est-il situ\'e ?
  \item \textbf{Les libert\'es selon la case.} \'Etudie, \`a l'aide d'un diagramme colori\'e et l\'egend\'e, le nombre de libert\'es du cavalier \emph{en fonction de sa case de d\'epart}. Que remarques-tu ?
\end{enumerate}
\newpage
\section*{Corrig\'e}
\noindent\textbf{1.} Le cavalier en e1 a \textbf{4 libert\'es} : \texttt{c2, d3, f3, g2}.
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=green!45,markfields={c2,d3,f3,g2},setpieces={Ne1}]
\end{center}
\smallskip\noindent\textbf{2.} Un cavalier qui peut se rendre en \textbf{c5} et \textbf{f6} se trouve sur \textbf{d7} ou \textbf{e4}. Les fl\`eches pointent, depuis chaque cavalier, vers les deux cases-indices (un saut de cavalier).
\begin{center}
  \chessboard[clearboard,showmover=false,pgfstyle=color,color=yellow!70,markfields={c5},color=blue!35,markfields={f6},setpieces={Nd7, Ne4},pgfstyle=straightmove,arrow=to,linewidth=0.15em,color=green!55!black,markmoves={d7-c5,d7-f6,e4-c5,e4-f6}]
\end{center}
\nopagebreak\begin{center}\footnotesize
\colorbox{yellow!70}{~~}~case-indice c5 \quad \colorbox{blue!35}{~~}~case-indice f6 \quad \textcolor{green!55!black}{\textbf{\textrightarrow}}~cavaliers vers les indices
\end{center}
\smallskip\noindent\textbf{3.}
\begin{center}
\begin{tikzpicture}[scale=0.60,line join=round]
  \fill[red!0!yellow] (0,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,0.5) {2};
  \fill[red!17!yellow] (1,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,0.5) {3};
  \fill[red!33!yellow] (2,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,0.5) {4};
  \fill[red!33!yellow] (3,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,0.5) {4};
  \fill[red!33!yellow] (4,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,0.5) {4};
  \fill[red!33!yellow] (5,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,0.5) {4};
  \fill[red!17!yellow] (6,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,0.5) {3};
  \fill[red!0!yellow] (7,0) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,0.5) {2};
  \fill[red!17!yellow] (0,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,1.5) {3};
  \fill[red!33!yellow] (1,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,1.5) {4};
  \fill[red!67!yellow] (2,1) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,1.5) {6};
  \fill[red!67!yellow] (3,1) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,1.5) {6};
  \fill[red!67!yellow] (4,1) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,1.5) {6};
  \fill[red!67!yellow] (5,1) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,1.5) {6};
  \fill[red!33!yellow] (6,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,1.5) {4};
  \fill[red!17!yellow] (7,1) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,1.5) {3};
  \fill[red!33!yellow] (0,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,2.5) {4};
  \fill[red!67!yellow] (1,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (1.5,2.5) {6};
  \fill[red!100!yellow] (2,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,2.5) {8};
  \fill[red!100!yellow] (3,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,2.5) {8};
  \fill[red!100!yellow] (4,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,2.5) {8};
  \fill[red!100!yellow] (5,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,2.5) {8};
  \fill[red!67!yellow] (6,2) rectangle +(1,1);
  \node[font=\tiny,text=white] at (6.5,2.5) {6};
  \fill[red!33!yellow] (7,2) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,2.5) {4};
  \fill[red!33!yellow] (0,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,3.5) {4};
  \fill[red!67!yellow] (1,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (1.5,3.5) {6};
  \fill[red!100!yellow] (2,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,3.5) {8};
  \fill[red!100!yellow] (3,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,3.5) {8};
  \fill[red!100!yellow] (4,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,3.5) {8};
  \fill[red!100!yellow] (5,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,3.5) {8};
  \fill[red!67!yellow] (6,3) rectangle +(1,1);
  \node[font=\tiny,text=white] at (6.5,3.5) {6};
  \fill[red!33!yellow] (7,3) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,3.5) {4};
  \fill[red!33!yellow] (0,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,4.5) {4};
  \fill[red!67!yellow] (1,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (1.5,4.5) {6};
  \fill[red!100!yellow] (2,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,4.5) {8};
  \fill[red!100!yellow] (3,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,4.5) {8};
  \fill[red!100!yellow] (4,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,4.5) {8};
  \fill[red!100!yellow] (5,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,4.5) {8};
  \fill[red!67!yellow] (6,4) rectangle +(1,1);
  \node[font=\tiny,text=white] at (6.5,4.5) {6};
  \fill[red!33!yellow] (7,4) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,4.5) {4};
  \fill[red!33!yellow] (0,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,5.5) {4};
  \fill[red!67!yellow] (1,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (1.5,5.5) {6};
  \fill[red!100!yellow] (2,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,5.5) {8};
  \fill[red!100!yellow] (3,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,5.5) {8};
  \fill[red!100!yellow] (4,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,5.5) {8};
  \fill[red!100!yellow] (5,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,5.5) {8};
  \fill[red!67!yellow] (6,5) rectangle +(1,1);
  \node[font=\tiny,text=white] at (6.5,5.5) {6};
  \fill[red!33!yellow] (7,5) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,5.5) {4};
  \fill[red!17!yellow] (0,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,6.5) {3};
  \fill[red!33!yellow] (1,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,6.5) {4};
  \fill[red!67!yellow] (2,6) rectangle +(1,1);
  \node[font=\tiny,text=white] at (2.5,6.5) {6};
  \fill[red!67!yellow] (3,6) rectangle +(1,1);
  \node[font=\tiny,text=white] at (3.5,6.5) {6};
  \fill[red!67!yellow] (4,6) rectangle +(1,1);
  \node[font=\tiny,text=white] at (4.5,6.5) {6};
  \fill[red!67!yellow] (5,6) rectangle +(1,1);
  \node[font=\tiny,text=white] at (5.5,6.5) {6};
  \fill[red!33!yellow] (6,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,6.5) {4};
  \fill[red!17!yellow] (7,6) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,6.5) {3};
  \fill[red!0!yellow] (0,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (0.5,7.5) {2};
  \fill[red!17!yellow] (1,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (1.5,7.5) {3};
  \fill[red!33!yellow] (2,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (2.5,7.5) {4};
  \fill[red!33!yellow] (3,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (3.5,7.5) {4};
  \fill[red!33!yellow] (4,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (4.5,7.5) {4};
  \fill[red!33!yellow] (5,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (5.5,7.5) {4};
  \fill[red!17!yellow] (6,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (6.5,7.5) {3};
  \fill[red!0!yellow] (7,7) rectangle +(1,1);
  \node[font=\tiny,text=black] at (7.5,7.5) {2};
  \draw[gray!55,line width=0.3pt] (0,0) grid (8,8);
  \draw[black,line width=0.7pt] (0,0) rectangle (8,8);
  \node[font=\tiny] at (0.5,-0.32) {a};
  \node[font=\tiny] at (1.5,-0.32) {b};
  \node[font=\tiny] at (2.5,-0.32) {c};
  \node[font=\tiny] at (3.5,-0.32) {d};
  \node[font=\tiny] at (4.5,-0.32) {e};
  \node[font=\tiny] at (5.5,-0.32) {f};
  \node[font=\tiny] at (6.5,-0.32) {g};
  \node[font=\tiny] at (7.5,-0.32) {h};
  \node[font=\tiny] at (-0.32,0.5) {1};
  \node[font=\tiny] at (-0.32,1.5) {2};
  \node[font=\tiny] at (-0.32,2.5) {3};
  \node[font=\tiny] at (-0.32,3.5) {4};
  \node[font=\tiny] at (-0.32,4.5) {5};
  \node[font=\tiny] at (-0.32,5.5) {6};
  \node[font=\tiny] at (-0.32,6.5) {7};
  \node[font=\tiny] at (-0.32,7.5) {8};
\end{tikzpicture}
\end{center}
\nopagebreak\begin{center}\footnotesize
\colorbox{red!0!yellow}{~~}~2 \quad \colorbox{red!17!yellow}{~~}~3 \quad \colorbox{red!33!yellow}{~~}~4 \quad \colorbox{red!67!yellow}{~~}~6 \quad \colorbox{red!100!yellow}{~~}~8 \quad libert\'es
\end{center}
\noindent Le cavalier est la pi\`ece la plus \textbf{p\'enalis\'ee par les bords} : \`a peine \textbf{2} libert\'es dans un coin contre \textbf{8} au centre. D'o\`u le proverbe des \'echecs : \og un cavalier au bord est un cavalier mort \fg{}.
\end{document}
