3

My question is similar to that of: Bibliographies as a numbered sections in each chapter But the proposed solution doesn't work for me.

I'm trying to write my thesis manuscript, I use Overleaf, \documentclass{book}, \usepackage{biblatex} and \include{Chapter}. The bibliography file is mainb.bib but If necessary I can create a .bib file for each chapter.

Could someone please help me to put the bibliography of each chapter as a section at the end of each chapter, change the name "Bibliography" to "Références," and put the hyperlinks and page numbers in different colors as in the following example picture:

The first part shows that the "Référence" section is displayed in the table of contents enter image description here

The second part shows section 3 "Référence" in Chapter 2. enter image description here

This is my attempt:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage[dvipsnames]{xcolor} 
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{decorule}
\usepackage[french]{minitoc} 
\mtcselectlanguage{french}
 
\usepackage[language=french,style=authoryear,sorting=none,refsection=section]{biblatex} 
\addbibresource{mainb.bib}

\begin{document}
 
\setcounter{mtc}{5}
\part{titre de la partie 1}
\include{Chapters/Chapter1}
\setcounter{mtc}{6}
\part{Titre de la partie 2}
\include{Chapters/Chapter2}

The file chapter1.tex contains :

\section{Introduction}
 Text \cite{cite1}.
     
\cleardoublepage
\section{Références}
\printbibliography

I tried also in chapter1.tex:

\begin{refsection} 
\printbibliography % or \addbibresource 
\end{refsection}

it doesn't give me the expected result.

Thank you for your Help!

1 Answer 1

3

I would post this as a comment but I don't have enough reputation (yet!).

Have you seen this question? Automatically split sources list into bibliography and references It appears to do what you're after.

Essentially using that answer with your MWE, your document would look like:

\documentclass[12pt,a4paper]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{amssymb}
\usepackage[dvipsnames]{xcolor} 
\usepackage{booktabs}
\usepackage{decorule}
\usepackage[french]{minitoc} 
\usepackage{hyperref}
\usepackage{filecontents}   % only for MWE
\usepackage[language=french, style=authoryear, sorting=none, backend=biber, bibencoding=utf8, natbib=true, citecolor=gray]{biblatex}
\mtcselectlanguage{french}

% adapted from:
% https://tex.stackexchange.com/questions/495194/automatically-split-sources-list-into-bibliography-and-references

% hyperlink setup
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    citecolor=gray,
}

% just used for the MWE.
\begin{filecontents}{biblatextest1.bib}
@book{cite1,
    author = {Baker, M.},
    year = {2010},
    title = {The book},
}
\end{filecontents}
%
\begin{filecontents}{biblatextest2.bib}
@book{cite2,
    author = {Smith, E.},
    year = {2008},
    title = {The other book},
}
\end{filecontents}

\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}

% Append keywords to identify different bibliography entries.
% Add a map for every chapter, so that the bibliographies are kept separate.
\DeclareSourcemap{
    \maps[datatype=bibtex, overwrite]{
        \map{
            \perdatasource{biblatextest1.bib}
            \step[fieldset=KEYWORDS, fieldvalue=ch1, append]
        }
        \map{
            \perdatasource{biblatextest2.bib}
            \step[fieldset=KEYWORDS, fieldvalue=ch2, append]
        }
    }
}

% change bibliography from chapter to section
\defbibheading{bibliography}[\bibname]{\section{#1}}

\begin{document}
    
    \tableofcontents
    
    %\setcounter{mtc}{5}
    \part{titre de la partie 1}
    % This goes in your Chapters/Chapter1.tex file
    \chapter{Chapter 1}
    \section{Introduction}
     Text \cite{cite1}.
         
    \cleardoublepage
    \addcontentsline{toc}{section}{Références}
    \printbibliography[title=Références Ch1, keyword=ch1]
    
    %\setcounter{mtc}{6}
    \part{Titre de la partie 2}
    % This goes in your Chapters/Chapter2.tex file
    \chapter{Chapter 2}
    \section{...}
    Some more text \cite{cite2}
    
    \cleardoublepage
    \addcontentsline{toc}{section}{Références}
    \printbibliography[title=Références Ch2, keyword=ch2]

\end{document}

To briefly explain what's going on, you have a separate .bib file for each chapter of your thesis, and reference each text within each file as normal, ensuring that all of your citations in each chapter refer to one file only.

You then display each file at the end of each chapter, using the keyword mappings set up in the preamble.

Some things I've adapted:

  • In the \printbibliography command, you can specify a title.
  • I've used the hyperref package to give you hyperlinks, and made them blue.
  • Since \printbibliography comes with its own title, I'm adding a reference to it in the table of contents with \addcontentsline so that you don't have a blank page in between both.

I'm not sure how to adapt this to use one .bib file only, sorry. Good luck with the rest of your thesis. :)

Your TOC has separate references:

enter image description here

and each reference list is unique:

enter image description here

enter image description here

3
  • 1
    Thanks so much for your brilliant solution! It solved most of my problems in TOC... but I got the references at the end of the chapter not as a section but as a new chapter. Is there a way to change them as a section at the end of the chapter? In the text, the year of the reference appears in green. So I added citecolor=gray, at \hypersetup. Is it possible, in the text, to change the color of the appearance of the NAME (author) of the reference in gray too and to put the year between [ ]? Oct 27, 2020 at 23:43
  • 1
    Ah, I didn't notice that initially. Add this to your preamble to change the references to sections, not chapters: \defbibheading{bibliography}[\bibname]{\section{#1}} I've updated the MWE above.
    – pikopiko
    Oct 28, 2020 at 2:14
  • 1
    Hmm, the reason the 'Author' text is not coloured is because it's not linked as part of the citation - see here: tex.stackexchange.com/questions/15951/… The solution to the above TeX.SE question is somewhat messy - you could create a command that acts as a coloured citation, possibly - something like \newcommand{\graycite}[1]{\textcolor{gray}{\cite{#1}}} could work - you'd then cite with \graycite{} instead of \cite{}. Not the best solution, unfortunately!
    – pikopiko
    Oct 28, 2020 at 2:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .