2

I am running the following bibliography setup:

\usepackage[backend=bibtex,style=authoryear,natbib=true]{biblatex}
\addbibresource{Chap1.bib} 

With Chap1.bib including all references of the book. However, I am currently only able to print a single bibliography at the end of my thesis and would like to produce separate bibliographies for each chapter, replacing the single one at the end.

I am more of a starter with LaTex and not able to adapt the code accordingly even though I am trying so for a few days now. Help would be much appreciated :)

\documentclass[
11pt, 
english, 
onehalfspacing, 
nolistspacing,
liststotoc, 
toctotoc, 
headsepline]{MastersDoctoralThesis} 
\usepackage[utf8]{inputenc} characters
\usepackage[T1]{fontenc} 
\usepackage{awesomebox}
\usepackage{lmodern} 
\usepackage{framed}
\definecolor{shadecolor}{named}{Snow2}
\usepackage{babel}  
\usepackage{csquotes} 
\usepackage[
    hyperref=auto,  
    mincrossrefs=999,
    backend=biber,
sorting = none, 
style=numeric-comp,
firstinits=true, 
clearlang=true, 
refsegment=chapter,
defernumbers=true
]{biblatex}
\addbibresource{Chap1.bib} 
\geometry{
    paper=a4paper,
    inner=2.5cm, 
    outer=3.8cm, 
    bindingoffset=.5cm,
    top=1.5cm, 
    bottom=1.5cm, 
    showframe,}
\begin{document}
\frontmatter 
\pagestyle{plain} 
\begin{titlepage}
\begin{center}
\end{center}
\end{titlepage}
\pagestyle{thesis}
\include{Chapters/Chapter1}
\printbibliography[heading=bibintoc]
\end{document}

The MastersDoctoralThesis.cls file has not been changed and was downloaded from http://latextemplates.com/template/masters-doctoral-thesis

Citation example \cite{}, \citep{} using .bib file (Chap1.bib):

@article{giguere2019increased,
  title={Increased vulnerability of nigral dopamine neurons after expansion of their axonal arborization size through D2 dopamine receptor conditional knockout},
  author={Gigu{\`e}re, Nicolas and Delignat-Lavaud, Beno{\^\i}t and Herborg, Freja and Voisin, Aurore and Li, Yuan and Jacquemet, Vincent and Anand-Srivastava, Madhu and Gether, Ulrik and Giros, Bruno and Trudeau, Louis-{\'E}ric},
  journal={PLoS genetics},
  volume={15},
  number={8},
  pages={e1008352},
  year={2019},
  publisher={Public Library of Science}
}

Chapter1.tex:

\chapter{Parkinson's Disease} 
\label{Chapter1} 
\newcommand{\keyword}[1]{\textbf{#1}}
\newcommand{\tabhead}[1]{\textbf{#1}}
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\file}[1]{\texttt{\bfseries#1}}
\newcommand{\option}[1]{\texttt{\itshape#1}}
\section{thank}
you for your patience \citep{giguere2019increased}.
moewe
  • 175,683
  • That is possible with biblatex. Have a look at refsections (in particular the option refsection=chapter, or refsection=section, may be interesting for you). Note that you'll have a much smoother experience with refsections if you are using Biber instead of BibTeX. With BibTeX you'll have to run BibTeX on one .aux file for each refsection. With Biber you still run Biber only on the main .bcf file. – moewe Jun 19 '20 at 13:34
  • A simple example is at https://tex.stackexchange.com/q/452924/35864 – moewe Jun 19 '20 at 13:35
  • I have now changed to: \usepackage[backend=biber,style=authoryear,refsection=chapter]{biblatex} and \printbibliography[heading=subbibliography, title=\bibname\ for \chaptername~\thechapter] at the end of the chapter. However, this does neither produce errors, nor citations/bibliography. Furhter, I changed \citep to \autocite. – poebelchen Jun 19 '20 at 14:49
  • You need to run Biber on your document now (a compile sequence is now LaTeX, Biber, LaTeX, LaTeX, where "LaTeX" is your favourite flavour of LaTeX: pdfLaTeX, LuaLaTeX, XeLaTeX, ....). Previously your document ran BibTeX, so you may have to modify your workflow or your editor settings https://tex.stackexchange.com/q/154751/35864 – moewe Jun 19 '20 at 14:58
  • I changed to LuaLaTex + Biber but am still not typesetting any bibliography. Also when I use: \usepackage{babel} %Uncommented for BibLatex \usepackage{csquotes} %Uncommented for BibLatex \usepackage[ hyperref=auto,
    mincrossrefs=999, backend=biber, sorting = none, % to have references appear as they are cited style=numeric-comp, firstinits=true, %added new clearlang=true, %added new refsegment=chapter, defernumbers=true ]{biblatex} with: \printbibliography[heading=subbibliography]
    – poebelchen Jun 19 '20 at 15:16
  • I'm afraid you will have to post a real minimal working example (https://tex.meta.stackexchange.com/q/228/35864 - edit your question to include it) together with the .blg file (the log of the Biber run) and the relevant bits of the .log file. Such things are really hard to investigate without a proper example and log infos and double hard if there are only code snippets in the comments. – moewe Jun 19 '20 at 15:18
  • Added, the .blg does not even typeset, may it be that it does not work with xcolor? As the log gives: ColourStack::popColour: colourstack size is 0. My apologies if this is slightly odd. – poebelchen Jun 19 '20 at 18:43
  • Thank you for taking the time to post some code. Unfortunately, the code in the question does not constitute a minimal working example. A minimal working example should be a fully compilable example document containing enough bits of the preamble (that's probably the case here) and of the document body (i.e. the stuff between \begin{document}...\end{document}` - that is missing here) to reproduce what you are currently doing/seeing. It should always be possible to compile the MWE in a new, empty folder. Please test that before submission. – moewe Jun 20 '20 at 06:58
  • MastersDoctoralThesis is one of the many LaTeX templates one can find on the web today. It is available in many different (outdated and not so outdated) versions on various sites. Can you please point us to the specific version you used. If you haven't yet fully committed to the class you may want to consider dropping it and using a more conventional setup. In my experiences MastersDoctoralThesis works OK-ish as long as you don't need to change a lot, but then it usually falls apart quickly. Older versions also had 'interesting' coding. – moewe Jun 20 '20 at 07:00
  • My apologies. The following is the template link: latextemplates.com/template/masters-doctoral-thesis Which class would you recommend to use? Thanks :) – poebelchen Jun 20 '20 at 09:18
  • Please consider editing the link directly into the question so people don't have to go through the comments to find this valuable piece of information. I usually recommend one of the standard classes (article, report or book), the KOMA-Script classes (scrartcl, scrreprt or scrbook in analogy to the three standard classes) or memoir (which has a book and article mode). KOMA-Script classes and memoir offer some nice customisation features out of the box for which the standard classes need additional code/packages. ... – moewe Jun 20 '20 at 09:25
  • ... Whether you take article, report or book does not matter a great deal as many things can be changed easily with options. There are only a few real differences. It comes down to using article for shorter works (essays, research papers), report for medium length works (technical reports, theses) and book for long books (long theses). See also https://tex.stackexchange.com/q/782/35864 and https://tex.stackexchange.com/q/36988/35864 – moewe Jun 20 '20 at 09:28
  • Thanks a lot! I will consider moving to "book" in that case. Would that also aid the bibliography biber function? – poebelchen Jun 20 '20 at 09:36
  • It will definitely make debugging a whole lot easier (as you can see in https://tex.stackexchange.com/q/452924/ refsections work w/ standard classes). There is a chance we could debug this issue even with MastersDoctoralThesis but in any case it is crucial that we get to see a compilable example document (that we can run on our machines) that reproduces the issue. (As mentioned above, the code that is currently in the question is a step forward, but unfortunately not sufficient. There are many guides to writing an MWE, one of which is http://tex.meta.stackexchange.com/q/228/ on this site.) – moewe Jun 20 '20 at 09:58
  • Updated :) It mostly resembles the template (also for the cls. file). – poebelchen Jun 20 '20 at 10:13
  • We're getting closer. Note that we don't have your file Chapters/Chapter1.tex. So if you could add some dummy content resembling the file content directly where you have \include{Chapters/Chapter1} in your code, we might get there. Note that you must at least \cite one entry from Chap1.bib in the dummy text, otherwise we won't see any bibliography output. – moewe Jun 20 '20 at 10:15
  • Thanks for posting all the code, I'll have a look at it now. I haven't run any code yet, but I can already tell you that the \i in Delignat-Lavaud, Beno{\^\i}t could be problematic. Replace it with Delignat-Lavaud, Beno{\^{i}}t or even better Delignat-Lavaud, Benoît. – moewe Jun 20 '20 at 10:26
  • I fixed one % that would hide a closing brace and thus cause an error that might have been just a copy-and-paste issue. Note also that with your setting you should say \autocite or \parencite instead of \citep. I also get an error about the colour Snow2 being undefined, so I removed \definecolor{shadecolor}{named}{Snow2} in my tests. – moewe Jun 20 '20 at 10:30
  • Okay, so now the \autocite works (which might have been the the xcolor issue mentioned in the .log – poebelchen Jun 20 '20 at 10:37

1 Answers1

0

You can use the strategy from Create per chapter bibliography.

With the option refsection=chapter, (not refsegment=chapter,) you get separate refsections for each \chapter. Then you just need to call \printbibliography[heading=subbibintoc] at the end of each chapter.

The following condensed example shows how that could work. Two fictional chapters are shown directly in the document body, but you could of course externalise them into .tex files of their own.

\documentclass[english]{MastersDoctoralThesis}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{framed}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[
  backend=biber,
  style=numeric-comp,
  sorting=none,
  defernumbers=true,
  giveninits=true,
  refsection=chapter,
]{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document} % Chapters/Chapter1.tex \chapter{Parkinson's Disease}\label{chap:parkinson} \section{Lorem} Ipsum dolor \autocite{sigfridsson}.

\printbibliography[heading=subbibintoc]

% Chapters/Chapter2.tex \chapter{Other Disease}\label{chap:other} \section{Dolor} Sit amet \autocite{worman}.

\printbibliography[heading=subbibintoc] \end{document}

Chapter 1 with bibliography


As mentioned in the comments there were some errors unrelated to the bibliography in the MWE posted initially (\definecolor{shadecolor}{named}{Snow2}, commented curly braces). Even though these error were not related to the bibliography, they could nevertheless stopped the bibliography from appearing properly.

moewe
  • 175,683