Je cherche à changer le style des chapitres d'un document écrit avec yathesis. En bidouillant un peu, on trouve \@makechapterhead et son équivalent pour les chapitres étoilés \@makeschapterhead.

Quand je teste sur l'ECM suivant :

\documentclass[
mainlanguage=english, french,
localtocs,
localbibs*,
secnumdepth=subsubsection,
titlesec={pagestyles}]{yathesis}

\usepackage{lipsum}
\usepackage{geometry}

\makeatletter
  \def\@makechapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     % --- Chapter number line with colored text and rule ---
     \ifnum \c@secnumdepth >\m@ne
       \if@mainmatter
         \Huge\bfseries\color{gray}\@chapapp~\thechapter\par\nobreak
         \vskip -7\p@ % tighten spacing above the rule
         {\color{black}\rule{0.9\linewidth}{0.2pt}}\par % horizontal rule
         \vskip 7\p@  % space between rule and title
       \fi
     \fi
     % --- Chapter title line ---
     \LARGE\bfseries\color{blue} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
    \clearpage
  }
  \def\@makeschapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     \LARGE\bfseries\color{red} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
} %
\makeatother

\geometry{
  paper=a4paper
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Début du document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Caractéristiques du document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Préparation des pages de couverture et de titre
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Les caractéristiques de la thèse sont saisies dans le fichier
% « characteristics.tex » (situé dans le dossier « configuration »).
%
% Production des pages de couverture et de titre
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\maketitle[frametitle=ovalbox]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Début de la partie liminaire de la thèse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% (Facultatif) Production de la page de clause de non-responsabilité
%\makedisclaimer
%
% (Facultatif) Production de la page de mots clés
%\makekeywords
%
% (Facultatif) Production de la page affichant les logo, nom et coordonnées du
% ou des laboratoires (ou unités de recherche) où la thèse a été préparée
%\makelaboratory
%
% (Facultatif) Dédicace(s)
% \input{liminaires/dedicaces}
%
% (Facultatif) Épigraphe(s)
% \input{liminaires/epigraphes}
%
% Résumés succincts
% \input{liminaires/resumes}
%
% (Facultatif) Chapitre de remerciements
% \include{liminaires/remerciements}
%
% (Facultatif) Chapitre d'avertissement
% \include{liminaires/avertissement}
%
% (Facultatif) Liste des acronymes
% \printacronyms
%
% (Facultatif) Liste des symboles
% \printsymbols
%
% (Facultatif) Chapitre d'avant-propos
% \include{liminaires/avant-propos}
%
% Sommaire
\tableofcontents[depth=section]
%
% (Facultatif) Liste des tableaux
% \listoftables
%
% (Facultatif) Table des figures
% \listoffigures
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Début de la partie principale (du « corps ») de la thèse
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mainmatter

\chapter{Le premier}
\lipsum{4}

\chapter{Le deuxième}
\lipsum{8}

\chapter*{Un test non num}
\lipsum{6}

\end{document}

Les chapitres numérotés sont bien modifiés (avec le titre en bleu, ne me jugez pas c'est pour le test), mais les non numérotés utilisent aussi \@makechapterhead et sont donc en bleu également (et non pas en rouge comme demandé).

Je ne trouve pas grand chose sur internet qui m'aide dans cette situation. J'ai essayé d'utiliser ces commandes à différents endroits sans succès et clairement, même sans package externe ça me fait le coup.

À noter que ça agit aussi logiquement sur la bibliographie et la table des matières, mais je ne comprends pas pourquoi la commande dédiée n'est pas utilisée...

EDIT (au cas où): je compile chez moi avec lualatex -shell-escape

Posée hier

olirwin's gravatar image

olirwin
7314
Taux d'acceptation : 100%

Modifiée hier


Voici une autre solution (plus simple), qui répond à la question posée en commentaires.

\documentclass[
mainlanguage=english, french,
localtocs,
localbibs*,
secnumdepth=subsubsection,
titlesec={pagestyles}]{yathesis}

\usepackage{lipsum}
\usepackage{geometry}

\makeatletter    
  \def\@makechapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     % --- Chapter number line with colored text and rule ---
     \ifnum \c@secnumdepth >\m@ne
       \if@mainmatter
         \Huge\bfseries\color{gray}\@chapapp~\thechapter\par\nobreak
         \vskip -7\p@ % tighten spacing above the rule
         {\color{black}\rule{0.9\linewidth}{0.2pt}}\par % horizontal rule
         \vskip 7\p@  % space between rule and title
       \fi
     \fi
     % --- Chapter title line ---
     \LARGE\bfseries\color{blue} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
    \clearpage
  }
  \def\@makeschapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     \LARGE\bfseries\color{red} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
}\let\old@makechapterhead\@makechapterhead
\AfterPreamble{%
\patchcmd{\chapter}{{\YAD@starred@chapter}{\YAD@unstarred@chapter}}{{\let\@makechapterhead\@makeschapterhead\YAD@starred@chapter}{\let\@makechapterhead\old@makechapterhead\YAD@unstarred@chapter}}{}{\err}
}
\makeatother

\geometry{
  paper=a4paper
}
%
\begin{document}

\tableofcontents[depth=section]
\mainmatter

\chapter{Le premier}
\lipsum{4}

\chapter{Le deuxième}
\lipsum{8}

\chapter*{Un test non num}
\lipsum{6}

\end{document}

Voici une solution.

\documentclass[
mainlanguage=english, french,
localtocs,
localbibs*,
secnumdepth=subsubsection,
titlesec={pagestyles}]{yathesis}

\usepackage{lipsum}
\usepackage{geometry}

\makeatletter
\patchcmd{\YAD@globalstyle}{\chapter*}{\chapter*[]}{}{\err}
\AfterPreamble{%
\RenewDocumentCommand{\YAD@tmp@chapter}{sO{}O{}m}{%
    \ifthenelse{\isempty{#2}}{%
      \ifthenelse{\isempty{#3}}{%
        \IfBooleanTF{#1}{\YAD@ORI@chapter*{#4}}{\YAD@ORI@chapter{#4}}%
      }{%
        \IfBooleanTF{#1}{\YAD@ORI@chapter*{#4}}{\YAD@ORI@chapter{#4}}%
        \chaptermark{#3}%
      }%
    }{%
      \ifthenelse{\isempty{#3}}{%
        \IfBooleanTF{#1}{\YAD@ORI@chapter*[#2]{#4}}{\YAD@ORI@chapter[#2]{#4}}%
      }{%
        \IfBooleanTF{#1}{\YAD@ORI@chapter*[#2]{#4}}{\YAD@ORI@chapter[#2]{#4}}%
        \chaptermark{#3}%
      }%
    }%
  }
\RenewDocumentCommand{\YAD@starred@chapter}{O{}O{}m}{%
    \booltrue{YAD@nonnumbered@chapter}%
    \booltrue{YAD@nonnumbered@section}%
    \booltrue{YAD@nonnumbered@subsection}%
    \booltrue{YAD@nonnumbered@subsubsection}%
    \booltrue{YAD@nonnumbered@paragraph}%
    \booltrue{YAD@nonnumbered@subparagraph}%
    \YAD@setsecnumdepth{none}%
    \YAD@tmp@chapter*[#1][#2]{#3}%
}}
  \def\@makechapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     % --- Chapter number line with colored text and rule ---
     \ifnum \c@secnumdepth >\m@ne
       \if@mainmatter
         \Huge\bfseries\color{gray}\@chapapp~\thechapter\par\nobreak
         \vskip -7\p@ % tighten spacing above the rule
         {\color{black}\rule{0.9\linewidth}{0.2pt}}\par % horizontal rule
         \vskip 7\p@  % space between rule and title
       \fi
     \fi
     % --- Chapter title line ---
     \LARGE\bfseries\color{blue} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
    \clearpage
  }
  \def\@makeschapterhead#1{%
    \vspace*{0\p@}% (no extra top margin)
    {\parindent \z@ \centering \normalfont\sffamily
     \LARGE\bfseries\color{red} #1\par}%
    \vskip 30\p@ % space below chapter title
    % --- Insert leadchapter text, if provided ---
    \@ifundefined{YAD@leadchapter}{}{%
       \noindent\YAD@leadchapter\par
       \let\YAD@leadchapter\relax
    }%
    % --- Insert local chapter TOC, if enabled ---
    \ifbool{YAD@localtocs}{%
       \YAD@localtoc
       \renewcommand{\YAD@localtoc}{\YAD@default@localtoc}%
       \ifbool{YAD@nextwithlocaltoc}{%
          \boolfalse{YAD@localtocs}\boolfalse{YAD@nextwithlocaltoc}}{}%
       % (no extra gap here; adjust with \vskip if desired)
    }{}%
    \@afterheading
}
\makeatother

\geometry{
  paper=a4paper
}
%
\begin{document}
\tableofcontents[depth=section]
\mainmatter

\chapter{Le premier}
\lipsum{4}

\chapter{Le deuxième}
\lipsum{8}

\chapter*{Un test non num}
\lipsum{6}

\end{document}
Lien permanent

Publiée 22 heures auparavant

touhami's gravatar image

touhami
10.1k410
Taux d'acceptation : 52%

Modifiée 1 heure auparavant

Je vais voir ce qui ce passe avec la bibliographie plus tard.

(22 heures auparavant) touhami touhami's gravatar image

Hello, merci pour la réponse ! J'ai deux questions quand je vois ça : 1. est-ce que du coup c'est yathesis qui surcharge de manière un peu cachée la définition d'un chapter* ? 2. est-ce que c'est possible d'avoir quand même les chapitres non numérotés dans la table des matières ?

(13 heures auparavant) olirwin olirwin's gravatar image

Pour la question 1) oui. Pour 2) voir la nouvelle solution proposée.

(2 heures auparavant) touhami touhami's gravatar image

Solution modifiée.

(1 heure auparavant) touhami touhami's gravatar image
Votre réponse
(dés)activer l'aperçu

Suivre cette question

Par courriel :

Une fois que vous serez enregistré, vous pourrez souscrire à n'importe quelle mise à jour ici

Par flux RSS :

Réponses

Réponses et commentaires

Bases de Markdown

  • *italique* ou _italique_
  • **gras** ou __gras__
  • Lien ::[texte](http://url.com/ "Titre ")
  • Image : ?![alt texte](/path/img.jpg "Titre ")
  • Liste numérotée : 1. Foo 2. Bar
  • Pour ajouter un passage à la ligne, ajoutez deux espaces à l'endroit où vous souhaitez que la ligne commence.
  • Les balises HTML de base sont également prises en charge.