TransWikia.com

How to generate a second biblatex bibliography without duplicating entries in the second one?

TeX - LaTeX Asked on December 25, 2020

I am trying to add a ‘Methods’ section to my report, and am struggling with generating the references as I would like, so would appreciate a little help. So far, a MWE of the output looks like this:

enter image description here

Any source that has been referred to in the Main Section correctly appears in the Main References. However, I will often cite a source in the Methods section which has already been referenced once in the Main Section, but it appears in the Methods References as well. I would like to have only unique ones to appear in the Methods Refs, and not have duplicates in both sections.

In the example above, the Horowitz and Hill reference should NOT appear again in the Methods Refs. But I should still be able to reference it in Methods and it should point to (1). How can I achieve this?

The code to generate the above example is

documentclass{article}

usepackage[backend=biber,
            style=numeric-comp,
            firstinits=true,
            sorting=none,
            doi=false,isbn=false,url=false,eprint=false]{biblatex}
usepackage{hyperref}
usepackage[capitalise]{cleveref}
addbibresource{bibliography_list.bib}

begin{document}

section{Main Section}
Here is my reference for the main section: autocite{horowitz1989art}.
printbibliography[title={Main References}]

subsection{Methods}
begin{refsection}
My references for the Methods are: autocite{bloch2000measurement,horowitz1989art,DfE}.
printbibliography[heading=subbibliography,title={Methods References}]
end{refsection}

end{document}

and the bib file

@book{horowitz1989art,
  title={The art of electronics},
  author={Horowitz, Paul and Hill, Winfield},
  year={1989},
  publisher={Cambridge Univ. Press}
}

@online{DfE,
  author = {},
  organization = {{Department for Education}},
  title = {Guidance for schools: coronavirus (COVID-19)},
  url = {https://www.gov.uk/government/collections/guidance-for-schools-coronavirus-covid-19},
  urldate = {2020-07-24},
  year = 2020
}

@article{bloch2000measurement,
  title={Measurement of the spatial coherence of a trapped Bose gas at the phase transition},
  author={Bloch, Immanuel and H{"a}nsch, Theodor W and Esslinger, Tilman},
  journal={Nature},
  volume={403},
  number={6766},
  pages={166--170},
  year={2000},
  publisher={Nature Publishing Group}
}

2 Answers

You cannot nest refsection environments, but you can make subsets of references using keywords, said "AAA" and "BBB", e.g.:

@book{horowitz1989art,
  title={The art of electronics},
  author={Horowitz, Paul and Hill, Winfield},
  keywords={AAA, whatever},
  year={1989},
  publisher={Cambridge Univ. Press}
}

Then, you only need print by keyword without sorting cites:

documentclass{article}
usepackage[sorting=none]{biblatex}
usepackage[colorlinks,citecolor=blue]{hyperref}
addbibresource{bibliography_list.bib}

begin{document}

section{Main Section}

Here is my reference for the main section: autocite{horowitz1989art}.

printbibliography[title={Main References},keyword=AAA]

subsection{Methods}

My references for the Methods are: autocite{horowitz1989art,bloch2000measurement,DfE}.
printbibliography[heading=subbibliography,title={Methods References},keyword=BBB]
end{document}

Result:

mwe

Answered by Fran on December 25, 2020

refsections are always kept completely independent, so you can't easily print only references that were not cited in the previous section in section 1. Note also that with refsections the same work may get a different number in different refsections, so you can't leave out entries in the bibliography anyway as your readers would have no way to identify the sources correctly.

I suggest you use refsegments. refsegments are similar to refsections, but they are not kept separate. Instead they act more of less like an additional keyword or a category classification: biblatex can filter bibliographies by refsegments.

Unfortunately, there is no built-in 'only in this refsegment'-test. That has to be built manually. In your MWE that is fairly straightforward, but it may get a bit more complex if you use more refsgements (because you have to stack not segment=0 and ... and not segment=n-1 to get to the references in segment=n; refsegments are started counting from 0, everything that is not behind a newrefsegment or inside a begin{refsegment}...end{refsegment} belongs to segment 0). We use bibfilters to be able to negate the test for a refsegment. But strictly speaking the first test filter=onlymain, could be replaced by segment=0, in this MWE.

Note that we will need the defernumbers option for continuous numbering in the bibliographies (well, strictly speaking the sorting=none, means that in this setup defernumbers is probably not that essential, but it is with other sorting options). This option may need a few more LaTeX runs than you are used to. If you get weird output, delete the .aux file and rerun LaTeX, Biber, LaTeX, LaTeX, LaTeX.

documentclass{article}

usepackage[backend=biber,
            style=numeric-comp,
            firstinits=true,
            sorting=none,
            defernumbers,
            doi=false, eprint=false, url=false, isbn=false,]{biblatex}
usepackage{hyperref}
usepackage[capitalise]{cleveref}

defbibfilter{onlymain}{%
  segment=0
}

defbibfilter{onlymethods}{%
  not segment=0
}


begin{filecontents}{jobname.bib}
@book{horowitz1989art,
  title     = {The Art of Electronics},
  author    = {Horowitz, Paul and Hill, Winfield},
  year      = {1989},
  publisher = {Cambridge Univ. Press},
}
@online{DfE,
  author  = {{Department for Education}},
  title   = {Guidance for schools: coronavirus (COVID-19)},
  url     = {https://www.gov.uk/government/collections/guidance-for-schools-coronavirus-covid-19},
  urldate = {2020-07-24},
  year    = 2020,
}
@article{bloch2000measurement,
  title   = {Measurement of the Spatial Coherence
             of a Trapped {Bose} Gas at the Phase Transition},
  author  = {Bloch, Immanuel and Hänsch, Theodor W. and Esslinger, Tilman},
  journal = {Nature},
  volume  = {403},
  number  = {6766},
  pages   = {166--170},
  year    = {2000},
}
end{filecontents}
addbibresource{jobname.bib}

begin{document}

section{Main Section}
Here is my reference for the main section: autocite{horowitz1989art}.
printbibliography[filter=onlymain, title={Main References}]

subsection{Methods}
begin{refsegment}
My references for the Methods are: autocite{bloch2000measurement,horowitz1989art,DfE}.
printbibliography[heading=subbibliography,filter=onlymethods,title={Methods References}]
end{refsegment}

end{document}

First bibliography with entry 1, second with 2 and 3.


In a long document with several segments (or even with just two longer segments) the list might be a bit hard to navigate because your reader may not know a priori in which reference list to look for a reference (they'd have to keep in mind the last number for each reference list). It may help your readers along if you add

newrefcontext[labelprefix=M]

before the printbibliography[heading=subbibliography,filter=onlymethods,title={Methods References}] in the Methods section. That way your readers get a simple visual cue as to whether to look.


In general I find that as a reader I prefer a single global bibliography over several smaller ones for the simple reason that after a while I have figure out where the global bibliography is, so I can easily switch back and forth. If there are several bibliographies, there are more places I would need to skip to. This is especially painful if it is not glaringly obvious from the references themselves (or the surroundings, say the chapter number) where I have to look for the reference. (Of course some of that can be mitigated to some degree with hyperlinks, but they won't work in print and sometimes I don't even want to jump in a PDF, so I have the document open twice: I'll be reading one version and I'll have the other version open in the reference section, if I have to skip around several times, that makes my workflow harder.)

Answered by moewe on December 25, 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