\chapter{Comment je crée un nouveau chapitre}

\backgroundimage{img/vieuxlivres}
\thispagestyle{chapterpage}

\newpage

<<OK, tout \c{c}à, c'est bien beau, j'ai compris le principe. Mais je ne vois pas bien comment m'y prendre si je souhaite ajouter un chapitre. 

-- Pas de panique, on y arrive !>>

\section{Modifier la structure}

On ajoute un répertoire (ou dossier) pour ce nouveau chapitre. Attention, avec \LaTeX, le nom d'un fichier ou d'un répertoire ne doit pas contenir d'espaces. On peut utiliser un <<tiret bas>>  (\textunderscore ) à la place. Et en même temps, j'ajoute aussi les répertoires \texttt{img} (pour les images) et \texttt{content} (pour le contenu).


\begin{figure}[h]
\begin{forest}
      for tree={
        font=\ttfamily,
        grow'=0,
        child anchor=west,
        parent anchor=south,
        anchor=west,
        calign=first,
        inner xsep=7pt,
        edge path={
          \noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
        },
        % style for your file node 
        file/.style={edge path={\noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) \forestoption{edge label};},
          inner xsep=2pt,font=\small\ttfamily
                     },
        before typesetting nodes={
          if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
      }  
    [manuels
      [commons]
      [S5
      [manuel.tex,file]
      [ch1\textunderscore premier\textunderscore chapitre]
%        [chapitre.tex,file]
%        [cours.tex,file]
%        [content
%           [
%           crs.tex,file
%           ]
%           [
%           act.tex,file
%           ]
%           [
%           exos.tex,file
%           ]
%        ]
%        [img]
      [ch2\textunderscore second\textunderscore chapitre]
      [ch3\textunderscore troisieme\textunderscore chapitre]
      [ch4\textunderscore mon\textunderscore chapitre
       [content]
       [img]
      ]
      ]
    ]
 \end{forest}
\caption{Ajout du répertoire \texttt{mon\textunderscore chapitre}} 
\end{figure}

Ensuite, dans le fichier \texttt{manuel.tex}, j'ajoute une ligne \verb!\subimport{./ch4_mon_chapitre/}{chapitre}!.

\section{Créer le fichier chapitre.tex }


Voici le fichier \texttt{chapitre.tex} qu'il faut créer. Dans la ligne 1, on trouve le titre du chapitre ainsi qu'un titre résumé (optionnel).

Les lignes 4 et 5  définissent l'image d'illustration de la première page du chapitre. L'image doit être au format jpeg ou png.

Le reste du fichier peut être recopié tel quel.

\begin{tcbinputlisting}{listing options={style=tcblatex,numbers=left,numberstyle=\tiny\color{red!75!black}},colback=red!5!white,colframe=red!75!black,listing only,listing file={ch4_mon_chapitre/chapitre.tex}}
\end{tcbinputlisting}

Enfin, on crée les fichiers \texttt{crs.tex}, \texttt{exos.tex}
et \texttt{act.tex} dans le répertoire \texttt{content}.

\begin{figure}[h]
\begin{forest}
      for tree={
        font=\ttfamily,
        grow'=0,
        child anchor=west,
        parent anchor=south,
        anchor=west,
        calign=first,
        inner xsep=7pt,
        edge path={
          \noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
        },
        % style for your file node 
        file/.style={edge path={\noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) \forestoption{edge label};},
          inner xsep=2pt,font=\small\ttfamily
                     },
        before typesetting nodes={
          if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
      }  
    [manuels
      [commons]
      [S5
      [manuel.tex,file]
      [ch1\textunderscore premier\textunderscore chapitre]
%        [chapitre.tex,file]
%        [cours.tex,file]
%        [content
%           [
%           crs.tex,file
%           ]
%           [
%           act.tex,file
%           ]
%           [
%           exos.tex,file
%           ]
%        ]
%        [img]
      [ch2\textunderscore second\textunderscore chapitre]
      [ch3\textunderscore troisieme\textunderscore chapitre]
      [ch4\textunderscore mon\textunderscore chapitre
       [chapitre.tex,file]
       [content
        [act.tex,file]
        [crs.tex,file]
        [exos.tex,file]
       ]
       [img
         [mon\textunderscore image\textunderscore .jpg,file]
       ]
      ]
      ]
    ]
 \end{forest}
\caption{Ajout du répertoire \texttt{mon\textunderscore chapitre}} 
\end{figure}

\section{Le contenu des fichiers act, crs.tex et exos.tex}

\begin{tcbinputlisting}{colback=red!5!white,colframe=red!75!black,listing only,listing file={ch4_mon_chapitre/content/act.tex},title=act.tex}
\end{tcbinputlisting}

\begin{tcbinputlisting}{colback=red!5!white,colframe=red!75!black,listing only,listing file={ch4_mon_chapitre/content/crs.tex},title=crs.tex}
\end{tcbinputlisting}


\begin{tcbinputlisting}{colback=red!5!white,colframe=red!75!black,listing only,listing file={ch4_mon_chapitre/content/exos.tex},title=exos.tex}
\end{tcbinputlisting}

A nouveau, c'est un peu décevant, ces fichiers ne contiennent que des appels vers d'autre fichiers. On pourrait très bien décider d'y mettre directement les contenu.

\begin{figure}[h]
\begin{forest}
      for tree={
        font=\ttfamily,
        grow'=0,
        child anchor=west,
        parent anchor=south,
        anchor=west,
        calign=first,
        inner xsep=7pt,
        edge path={
          \noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
        },
        % style for your file node 
        file/.style={edge path={\noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(7.5pt,0) |- (.child anchor) \forestoption{edge label};},
          inner xsep=2pt,font=\small\ttfamily
                     },
        before typesetting nodes={
          if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
      }  
      [ch4\textunderscore mon\textunderscore chapitre
       [chapitre.tex,file]
       [content
        [act.tex,file]
        [act1\textunderscore introduction\textunderscore notion.tex,file]
        [act2\textunderscore TP\textunderscore alogorithmique.tex,file]
        [crs1\textunderscore definitions.tex,file]
        [crs2\textunderscore theoremes.tex,file]
        [crs.tex,file]
        [exos.tex,file]
        [exos1\textunderscore faciles.tex,file]
        [exos2\textunderscore moyens.tex,file]
       ]
       [img
         [mon\textunderscore image\textunderscore .jpg,file]
       ]
      ]
 \end{forest}
\caption{Ajout du répertoire \texttt{mon\textunderscore chapitre}} 
\end{figure}


Pour les contenus de ces différents fichiers, on peut se reporter au \cref{structure}, notamment à la section\ref{partie_exos} pour les exercices et à la section \ref{partie_activite} pour les activités. Le cours fera l'objet d'un chapitre supplémentaire.