Historique des modifications [retour]
cliquez ici pour masquer/afficher la révision 2
passages en code

17 Fév '16, 00:58

Pathe's gravatar image

Pathe
7.6k49210252

Récupérer le nom d'un chapitre

J'utilise le package answers `answers` et j'aimerais afficher dans le chapitre des corrigés le nom du chapitre d'où ce corrigé vient. dudit chapitre. La commande \thechapter `\thechapter` permet de récupérer le bon numéro du chapitre ; mais comment récupérer son nom ? \leftmark `\leftmark` renvoie le nom et numéro du chapitre contenant les corrigés... Voici un exemple minimal : \documentclass[a4]{book} \usepackage{answers} \Newassociation{solution}{Solution}{ans} \newcounter{exercice}[chapter] \newenvironment{exercice}[1][] {\refstepcounter{exercice}\textbf{Exercice \arabic{exercice}}} \begin{document} \tableofcontents \chapter{Matrices} \Opensolutionfile{ans}[ans-matrices] \Writetofile{ans}{\protect\section{Corrections du chapitre \thechapter}} \Writetofile{ans}{\protect\leftmark devrait etre "Matrices"} \begin{exercice} Calculer $A^3$ \begin{solution} On trouve : $A^3=A$ \end{solution} \end{exercice} \Closesolutionfile{ans} \chapter{Th de Fermat} \Opensolutionfile{ans}[ans-fermat] \Writetofile{ans}{\protect\section{Corrections du chapitre \thechapter}} \Writetofile{ans}{\protect\leftmark devrait etre "Th de Fermat"} \begin{exercice} Donner une autre preuve que celle de Wiles \begin{solution} Pas la place ici... \end{solution} \end{exercice} \Closesolutionfile{ans} \chapter{Corrections} \include{ans-matrices} \include{ans-fermat} \end{document}
cliquez ici pour masquer/afficher la révision 1

17 Fév '16, 00:32

rboulle's gravatar image

rboulle
1351611

Récupérer le nom d'un chapitre

J'utilise le package answers et j'aimerais afficher dans le chapitre des corrigés le nom du chapitre d'où ce corrigé vient. La commande \thechapter permet de récupérer le bon numéro du chapitre mais comment récupérer son nom ? \leftmark renvoie le nom et numéro du chapitre contenant les corrigés... Voici un exemple minimal : \documentclass[a4]{book} \usepackage{answers} \Newassociation{solution}{Solution}{ans} \newcounter{exercice}[chapter] \newenvironment{exercice}[1][] {\refstepcounter{exercice}\textbf{Exercice \arabic{exercice}}} \begin{document} \tableofcontents \chapter{Matrices} \Opensolutionfile{ans}[ans-matrices] \Writetofile{ans}{\protect\section{Corrections du chapitre \thechapter}} \Writetofile{ans}{\protect\leftmark devrait etre "Matrices"} \begin{exercice} Calculer $A^3$ \begin{solution} On trouve : $A^3=A$ \end{solution} \end{exercice} \Closesolutionfile{ans} \chapter{Th de Fermat} \Opensolutionfile{ans}[ans-fermat] \Writetofile{ans}{\protect\section{Corrections du chapitre \thechapter}} \Writetofile{ans}{\protect\leftmark devrait etre "Th de Fermat"} \begin{exercice} Donner une autre preuve que celle de Wiles \begin{solution} Pas la place ici... \end{solution} \end{exercice} \Closesolutionfile{ans} \chapter{Corrections} \include{ans-matrices} \include{ans-fermat} \end{document}