# Bibliography specific needs for a huge report

I am the integrator of a big activity report (~800 pages, several thousand bib entries) for my lab. For this edition, we have particular bibliography needs and I am searching for the best way to implement it (packages and architecture). To summarize, my lab includes 5 departments, each one including several teams. The expected result is:

• Lab introduction with related bibliography
• First department report, including citations of related teams, without bibliography at the end
• Team 1 of dep 1, without bibliography at the end
• Team 2 of dep 1, without bibliography at the end
• ...
• Last team of dep 1, without bibliography at the end
• Bibliographies, clustered team by team (so all teams bibliographies for this department, with bib entries sharing the same counter -- if last entry of team 1 is, say n, the first entry of team 2 should be n+1), knowing that if the department cites a given ref, and a team cites the same ref, the ref number shloud be the same.
• Second department report, including citations of related teams, without bibliography at the end
• Team 1 of dep 2, without bibliography at the end
• ...
• ...
• Last department report, ...
• Lab conclusion with related bibliography

Currently, I handle 5 departments and around 35 teams... For the previous edition, it was easier: The global architecture was the same, but a bibliographic part was at the end of each department/team. I used chapterbib and everything worked fine (with some home-made bibliographic tools to merge/purge bib entries).

For this edition, things are more complicated. I already did some tests with chapterbib, even with the "gather" option, but I do not get satisfactory results (to be more specific, it does not work at all for now). So I wonder if my approach is possible or if there is an easier solution, possibly by changing package ... Your opinion? Any help is welcome!

Thanks, Philippe

Edit. Important point: Each department / team is currently related to a single file. I would like to keep, as much as possible, this organization as it favors a better edition for the corresponding responsables.

• Use biblatex/biber and refsections/refsegment. – Ulrike Fischer Apr 14 '16 at 15:49

This was a bug in biber to do with idempotence of some sourcemaps (in your case, append operations) across refsections. It is fixed in biber 2.5 which you can find in the development folder on Sourceforge. You will need to be using the development version of biblatex 3.4 also on Sourceforge.

• I've downloaded the dev branch of biber from github.com/plk/biber, which contains a biber binary (version 2.1). I've recompiled it, but it's still the 2.1 version which is generated. But do not take so much time for me. Since yesterday, I've realized that I have to use a particular .bst file. And as there is no converter to obtain the related file needed by biber, I try again to build my report with bibtex... I'm sorry. Thank you anyway for all your help! – Philippe Dosch Apr 20 '16 at 13:55
• If you want to use biblatex, you can get the biber 2.5 binary from Sourceforge along with the biblatex 3.4 development version – PLK Apr 20 '16 at 19:31

I'm not so far of the perfect solution, but I'm still in troubles. For now, my code is:

\documentclass[twoside,11pt]{book}

\usepackage{fontspec,xltxtra}
\usepackage{lipsum}

\usepackage[backend=biber,defernumbers=true]{biblatex}

\usepackage{hyperref}
\usepackage{nameref}
\usepackage{csquotes}

\pagestyle{plain}

\section*{%
Bibliography for #1}}

\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{equ1.bib}
\step[fieldset=KEYWORDS, fieldvalue=equ1, append]
}
\map{
\perdatasource{equ2.bib}
\step[fieldset=KEYWORDS, fieldvalue=equ2, append]
}
\map{
\perdatasource{equnoname1.bib}
\step[fieldset=KEYWORDS, fieldvalue=eqnn1, append]
}
\map{
\perdatasource{equ3.bib}
\step[fieldset=KEYWORDS, fieldvalue=equ3, append]
}
\map{
\perdatasource{equ4.bib}
\step[fieldset=KEYWORDS, fieldvalue=equ4, append]
}
\map{
\perdatasource{equnoname2.bib}
\step[fieldset=KEYWORDS, fieldvalue=eqnn2, append]
}
}
}

\begin{document}

\part{My report}

\begin{refsection}
\include{dep1}
\include{equ1}
\include{equ2}

\nocite{*}

\end{refsection}

\begin{refsection}
\include{dep2}
\include{equ3}
\include{equ4}

\nocite{*}

\end{refsection}

\end{document}


For dep1.tex:

\chapter{Dep One}

Yop~\cite{equn2,eqde1}
et aussi~\cite{eqnn1}


For equ1.tex:

\section{Equ1}

\lipsum[1]

Yop~\cite{equn1}
\nocite{*}


For equ2.tex:

\section{Equ2}

\lipsum[1]

Yop~\cite{eqde1}
\nocite{*}


For equ1.bib:

@Book{equn1,
author =   {Xxxx Yyyy},
title =    {First biblio test},
publisher =    {Yop},
year =     {2016}
}

@Book{equn2,
author =   {Xxxx Yyyy},
title =    {Second biblio test},
publisher =    {Yopla},
year =     {2016}
}


For equ2.bib:

@Book{eqde1,
author =   {Aaaa Bbbb},
title =    {First biblio test},
publisher =    {Yop},
year =     {2016}
}

@Book{eqde2,
author =   {Aaaa Bbbb},
title =    {Second biblio test},
publisher =    {Yopla},
year =     {2016}
}


For eqnoname1.bib:

@Book{eqnn1,
author =   {Uuuu Oooo},
title =    {First biblio test},
publisher =    {Yop},
year =     {2016}
}

@Book{eqnn2,
author =   {Uuuu Oooo},
title =    {Second biblio test},
publisher =    {Yop},
year =     {2016}
}


(Almost) The same thing for dep2.tex, equ3.tex, equ4.tex, equ3.bib, equ4.bib and equnoname2.bib. Here is my makefile:

all: main

main:
xelatex main.tex
biber main
xelatex main.tex
xelatex main.tex


I hope it is enough for a MWE. After compilation, I obtain almost what I search for, but there are still some issues:

• I don't understand why I have to put "section=1" in the last \printbibliography commands, as the doc says that whenever this commands is inserted in a refsection environment it takes automatically the good section number (so not in my case)
• I use the DeclareSourceMap command to automatically build a full bibliography of a given bib file (solution found on TeX StackExchange, given by PLK, not sure if an easier way exists now)
• The last but not the least, all references of dep2 are associated to "[0]", even if the final dep2 bibliography is well built (i.e. with numbers from 1 to [6]).

If it is a good answer start, I'm clearly wrong somewhere. Any tips?

Full source code: source code
PDF result: PDF

Thanks, Philippe

• Your problem is only that you used append in the sourcemap which seems to operate across refsection boundaries. This might be considered a bug in biber which I can look into but since you don't have keywords in any of the entries anyway, you don't seem to need append in the sourcemap. Take this out and your example works fine for me. Be aware that you have two refsections here, 1 and 2 (refsection 0 contains everything outside an explicit refsection) and so putting section=1 in the second \printbibliography is spurious and tries to use data from the first refsection. – PLK Apr 18 '16 at 20:03
• Thanks for your answer. There is actually no "keywords" field in these examples, but there may be in my real bibliographic files. That's why I picked "append" that seemed suitable to cover the diversity of references. But you're right, if I remove "append" and the "section=1" attributes, it works. I suspected that "section = 1" was not good, but if I did not put it in my initial example, no bibliography was generated and references were all at [0]. It was the only way I found to make it work. – Philippe Dosch Apr 20 '16 at 13:06
• BTW, a remark about the labels defined with the \addbibresource commands: It would be interesting to use them directly in \printbibliography (or, better, in refsection environments) to describe what one wishes to consider (and less ambiguous). I also tried to use them in the refsections (the doc suggests that we can do it), but this caused compilation errors (Undefined control sequence. <argument> ...xt@sorting }{\abx@field@localnumber). – Philippe Dosch Apr 20 '16 at 13:17
• Hmm, if you can generate a minimal example of this, I would appreciate it. – PLK Apr 20 '16 at 19:32