J'ai changé (grâce à @touhami, ma question initiale ici) l'apparence des en-têtes des chapitres d'un manuscrit. Cependant, depuis ce correctif, je constate que les bibliographies ne sont plus locales -- et plus préoccupant encore, elles sont présentes sur des éléments n'en ayant pas besoin, comme la table des matières ou les chapitres ne citant rien. Comme si un \nocite{*} était inséré partout.

Voici un ECM qui illustre le problème :

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

\usepackage{lipsum}
\usepackage{geometry}

\usepackage[
backend=biber,
url=true,
isbn=true,
eprint=false,
maxcitenames=10,
maxnames=10,
style=alphabetic,
sortlocale=en_UK]{biblatex}

\begin{filecontents}{bib.bib}
@article{einstein,
    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
    [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004",
    keywords =     "physics"
}

@book{dirac,
    title={The Principles of Quantum Mechanics},
    author={Paul Adrien Maurice Dirac},
    isbn={9780198520115},
    series={International series of monographs on physics},
    year={1981},
    publisher={Clarendon Press},
    keywords = {physics}
}

@online{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/~uno/abcde.html",
    keywords  = "latex,knuth"
}

@inbook{knuth-fa,
    author = "Donald E. Knuth",
    title = "Fundamental Algorithms",
    publisher = "Addison-Wesley",
    year = "1973",
    chapter = "1.2",
    keywords  = "knuth,programming"
}
\end{filecontents}

\addbibresource{bib.bib}

\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}
Ceci est une citation \cite{einstein} \cite{dirac}

\chapter{Le deuxième}
\lipsum{8}
ici aussi une citation \cite{knuth-fa}

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

\end{document}

Est-ce qu'il existe une solution pour remédier à ce problème ? J'ai déjà (vainement) essayé de patcher les commandes de chapitres pour retirer la bibliographie. La seule chose qui fonctionne pour moi pour le moment est de retirer la ligne

\patchcmd{\chapter}{{\YAD@starred@chapter}{\YAD@unstarred@chapter}}
{{\let\@makechapterhead\@makeschapterhead\YAD@starred@chapter}
{\let\@makechapterhead\old@makechapterhead\YAD@unstarred@chapter}}{}{\err}

Mais ça me fait perdre la personnalisation des en-têtes de chapitres non numérotés, ce qui revient essentiellement dans mon cas (hors ECM) à avoir un saut de page non désiré entre le titre d'un chapitre non numéroté (comme le sommaire ou la bibliographie finale) et son contenu.

Posée 30 Sep, 16:41

olirwin's gravatar image

olirwin
11725
Taux d'acceptation : 100%


La classe yathesis embarque de nombreuses fonctionnalités sophistiquées, ce qui se traduit par la complexité de son code (Bravos @denis).

Pour le problème en question, disons que c'est de ma faute, il faut définir la commande \old@makechapterhead au bon moment. Plus précisément, l'instruction \let\old@makechapterhead\@makechapterhead doit être placée dans le bon scope, à savoir à l'intérieur de \AfterPreamble{...}.

Lien permanent

Publiée 01 Oct, 20:59

touhami's gravatar image

touhami
10.3k410
Taux d'acceptation : 52%

Merci @touhami, je regarde tout ça et j'amenderai au besoin :)

(03 Oct, 09:52) olirwin olirwin's gravatar image

Excellent ça à l'air de fonctionner parfaitement ! Merci encore !

(03 Oct, 09:56) olirwin olirwin'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.