0

I want to create an article in Latex with natbib and the following structure:

  1. Introduction
  2. Chapter 2
  3. Chapter 3
  4. Discussion

The article's references should have the following characteristics:

  • Introduction and Discussion should "share" their reference list
  • Chapter 2 and Chapter 3 should each have their own reference list (only containing the references that are used in Chapter 2 and Chapter 3, respectively)
  • References that are used in Chapter 2 and/or Chapter 3, but not in Introduction or Discussion should not be included in the References of Introduction/Discussion.
  • References should be printed after Chapter 2, after Chapter 3 and Discussion
  • there should be no reference list after Introduction (all references from Introduction should be used in the reference list of the discussion)

I have created the following MWE:

\documentclass[11pt,a4paper,english,arial,twoside]{article}\usepackage[]{graphicx}\usepackage[]{color}
%\usepackage[backend=bibtex,natbib,style=authoryear,maxcitenames=2]{biblatex}
%\addbibresource{citations}
\usepackage[authoryear,sectionbib, sort&compress]{natbib}
\usepackage{chapterbib}
\usepackage{filecontents}

\begin{document}


\begin{filecontents*}{bibliography_mwe.bib}
@article{ref1,
    title={ref1},
    author={ref1},
    year={1},
    institution={ref1}
}

@article{ref2,
    title={ref2},
    author={ref2},
    year={2},
    institution={ref2}
}

@article{ref3,
    title={ref3},
    author={ref3},
    year={3},
    institution={ref3}
}

@article{ref4,
    title={ref4},
    author={ref4},
    year={4},
    institution={ref4}
}

@article{ref5,
    title={ref5},
    author={ref5},
    year={5},
    institution={ref5}
}

@article{ref6,
    title={ref6},
    author={ref6},
    year={6},
    institution={ref6}
}

@article{ref7,
    title={ref7},
    author={ref7},
    year={7},
    institution={ref7}
}

@article{ref8,
    title={ref8},
    author={ref8},
    year={8},
    institution={ref8}
}
\end{filecontents*}
\section{Introduction}
bla bla bla bla bla \newline
\cite{ref1} \newline
bla bla bla bla bla \newline
\cite{ref2} \newline
bla bla bla bla bla \newline
\cite{ref3} \newline
bla bla bla bla bla \newline

\begin{filecontents*}{chap2_mwe.tex}
\section{Chapter 2}
bla bla bla bla bla \newline
\cite{ref4} \newline
bla bla bla bla bla \newline
\cite{ref5} \newline

\bibliographystyle{alpha}
\bibliography{bibliography_mwe}
\end{filecontents*}

\begin{filecontents*}{chap3_mwe.tex}
\section{Chapter 3}
bla bla bla bla bla \newline
\cite{ref6} \newline
bla bla bla bla bla \newline
\cite{ref7} \newline

\bibliographystyle{alpha}
\bibliography{bibliography_mwe}
\end{filecontents*}


\include{chap2_mwe}
\include{chap3_mwe}

\section{Discussion}

bla bla bla bla bla \newline
\cite{ref4} \newline
bla bla bla bla bla \newline
\cite{ref8} \newline

\bibliographystyle{alpha}
\bibliography{bibliography_mwe}

\end{document}

I would like to have the following output:

  • Reference list of Chapter 2: ref4, ref5
  • Reference list of Chapter 3: ref6, ref7
  • Reference list of Introduction&Discussion: ref1, ref2, ref3, ref4, ref8.

Do you have any idea how this can work?

My idea with using filecontents* environments for Chapter 2 and Chapter 3, does not work, when compiling:

bibtex chap2_mwe.aux
bibtex chap3_mew.aux
bibtex mwe.aux
pdflatex_mwe.tex
pdflatex_mwe.tex

EDIT as proposed by @moewe: using bibtex and refsection only one bibliography is created. Maybe I am missing something here... EDIT: works if I have used it correctly (see below)

\documentclass[11pt,a4paper,english,arial,twoside]{article}
\usepackage[]{graphicx}\usepackage[]{color}
\usepackage[style=alphabetic,backend=bibtex]{biblatex}
\addbibresource{bibliography_mwe}
\usepackage{filecontents}


\begin{filecontents*}{bibliography_mwe.bib}
@article{ref1,
    title={ref1},
    author={ref1},
    year={1},
    institution={ref1}
}

@article{ref2,
    title={ref2},
    author={ref2},
    year={2},
    institution={ref2}
}

@article{ref3,
    title={ref3},
    author={ref3},
    year={3},
    institution={ref3}
}

@article{ref4,
    title={ref4},
    author={ref4},
    year={4},
    institution={ref4}
}

@article{ref5,
    title={ref5},
    author={ref5},
    year={5},
    institution={ref5}
}

@article{ref6,
    title={ref6},
    author={ref6},
    year={6},
    institution={ref6}
}

@article{ref7,
    title={ref7},
    author={ref7},
    year={7},
    institution={ref7}
}

@article{ref8,
    title={ref8},
    author={ref8},
    year={8},
    institution={ref8}
}
\end{filecontents*}

\begin{document}

\section{Introduction}\label{sec:int}

bla bla bla bla bla \newline
\cite{ref1} \newline
bla bla bla bla bla \newline
\cite{ref2} \newline
bla bla bla bla bla \newline
\cite{ref3} \newline
bla bla bla bla bla \newline

\begin{refsection}
\section{Chapter 2}\label{sec:2}
bla bla bla bla bla \newline
\cite{ref4} \newline
bla bla bla bla bla \newline
\cite{ref5} \newline

\printbibliography[heading=subbibliography]
\end{refsection}

\begin{refsection}
\section{Chapter 3}\label{sec:3}
bla bla bla bla bla \newline
\cite{ref6} \newline
bla bla bla bla bla \newline
\cite{ref7} \newline

\printbibliography[heading=subbibliography]
\end{refsection}

\section{Discussion}\label{sec:disc}

bla bla bla bla bla \newline
\cite{ref4} \newline
bla bla bla bla bla \newline
\cite{ref8} \newline

\printbibliography[heading=subbibliography]

\end{document}

enter image description here

EDIT: solution: run pdflatex mwe.tex bibtex mwe.aux bibtex mwe1-blx.aux bibtex mwe2-blx.aux pdflatex mwe.tex

3
  • It's too late for me to look into this in more detail, but out of the box natbib (or BibTeX in general) doesn't support multiple bibliographies, no matter if you use \include (and/or filecontents) or not. You'll need additional packages like ctan.org/pkg/chapterbib or ctan.org/pkg/bibunits, but I'm not sure if those are enough for what you want. – moewe Apr 30 '20 at 21:02
  • biblatex can do a lot more in that regard (but I'm not sure if what you want is easily doable with biblatex, either.) Possibly interesting/related: tex.stackexchange.com/a/44602/35864, tex.stackexchange.com/q/17474/35864, tex.stackexchange.com/q/229846/35864 – moewe Apr 30 '20 at 21:05
  • Thank you @moewe . At least with my MWE I am getting separate (correct) References for Chapter 2 and 3. The only problem is that Introduction&Discussion includes all used references. If there is a solution with biblatex that would be great, too. Looking at your links it seems, that they are dealing with slightly different question. I guess, in my case it is most tricky that the two connected sections (Introduction&Discussion) are split up by Chapter 2 and Chapter 3. – tnaake Apr 30 '20 at 21:30
0

Here are two approaches with biblatex. When you split bibliographies in biblatex you can choose between two ways of dividing the bibliographies

  • refsections keep their contents completely separated and independent.
  • refsegments just add a small note (similar to keyword) to an entry that it was cited in a certain refsegment. All entries are still considered together for sorting and uniqueness computations.

In practice you often won't be seeing a difference between the two approaches, but it is possible to create situations where the difference matters.

In general refsegments and refsections can't be split or nested. An exception is refsection 0 that can be split. In the refsection code below we use that refsection 0 can be split and use it for the introduction and discussion. That's the reason why we can't use automatic refsections: They would produce different refsections for the introduction and the discussion and there would be no way to merge them. For the refsegment approach that is not as much of a concern, since we can easily filter by multiple refsegments.

refsection

\documentclass[11pt,a4paper,english,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=bibtex, style=alphabetic, maxcitenames=2]{biblatex}

\usepackage[colorlinks]{hyperref}

\addbibresource{biblatex-examples.bib}

\begin{document}
\section{Introduction}\label{sec:int}
Lorem \cite{pines}
ipsum \cite{aksin}
dolor \cite{maron}

\begin{refsection}
\section{Chapter 2}\label{sec:2}
lorem \cite{sigfridsson}
ipsum \cite{worman,knuth:ct:c}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:2}}]
\end{refsection}

\begin{refsection}
\section{Chapter 3}\label{sec:3}
lorem \cite{nussbaum}
ipsum \cite{geer,knuth:ct:b}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:3}}]
\end{refsection}

\section{Discussion}\label{sec:disc}

dolor \cite{sigfridsson}
sit \cite{cicero}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:int} and \nameref{sec:disc}}]
\end{document}

References for chapters 2 and 3

refsegments

\documentclass[11pt,a4paper,english,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=bibtex, style=alphabetic, refsegment=section, maxcitenames=2]{biblatex}

\usepackage[colorlinks]{hyperref}

\addbibresource{biblatex-examples.bib}

\begin{document}
\section{Introduction}\label{sec:int}
\newcommand*\intrefsegment{} % we'll need that later
\edef\intrefsegment{\therefsegment}
Lorem \cite{pines}
ipsum \cite{aksin}
dolor \cite{maron}

\section{Chapter 2}\label{sec:2}
lorem \cite{sigfridsson}
ipsum \cite{worman,knuth:ct:c}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:2}},
  segment=\therefsegment]

\section{Chapter 3}\label{sec:3}
lorem \cite{nussbaum}
ipsum \cite{geer,knuth:ct:b}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:3}},
  segment=\therefsegment]

\section{Discussion}\label{sec:disc}

dolor \cite{sigfridsson}
sit \cite{cicero}

% we remembered the segment from the introduction in \intrefsegment
\defbibfilter{intdisc}{%
     segment=\intrefsegment\space
  or segment=\therefsegment
}

\printbibliography[heading=subbibliography,
  title={\refname\ of \nameref{sec:int} and \nameref{sec:disc}},
  filter=intdisc]
\end{document}

References for chapter 2 and 3


The differences between the two approaches become apparent in the two Knuth citations. Since refsections are independent, the two different citations knuth:ct:b and knuth:ct:c both get the same label in different sections. refsegments, on the other hand, are not independent and there the labels differ.


While both approaches work with backend=bibtex,, I still recommend switching to Biber (backend=biber,). Especially the refsection solution benefits from Biber because you only have to run Biber on one file (once) and not on multiple files. In general you only have access to all biblatex features if you use Biber.

3
  • @tnaake Really? It does for me in both MWEs. It's just that that list is on the next page in the document, so I didn't include it in the screenshot. Did you try the exact same code I posted or something else? I recommend you try and get the code I posted working first, if you haven't done that already (note that you need to change nothing, the file biblatex-examples.bib that I used will be found automatically, since it is installed together with biblatex). – moewe May 1 '20 at 6:35
  • Sorry, @moewe. Now it worked. I did not run bibtex mwe1-blx.aux and bibtex mwe2-blx.aux. Thank you so much! – tnaake May 1 '20 at 6:49
  • 1
    @tnaake One more reason to switch to Biber: With Biber you just run biber mwe and that's it. – moewe May 1 '20 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.