TransWikia.com

Make the bibliography as a section in each included chapter

TeX - LaTeX Asked by Ph.D.Student on December 3, 2020

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!

One Answer

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

Correct answer by pikopiko on December 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP