# Citations out of order with appendix and split bibliographies in backmatter?

As References before appendix points out, I can use citations both in mainmatter and appendix of a book, with only a single \printbibliography at end of mainmatter and before appendix.

In the below MWE, I would like to do the same, but with split bibliographies for each chapter in backmatter:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[defernumbers=true,style=ieee]{biblatex}
\bibliography{biblatex-examples}

\begin{document}
\frontmatter
\mainmatter

\newrefsegment
\chapter{First chapter}
bla bla \cite{westfahl:space} bla bla \cite{aksin} ...

\printbibliography[sorting=none,segment=\therefsegment,resetnumbers=true]

\appendix

\chapter{Second chapter}
bla bla ... \cite{angenendt} bla bla \cite{baez/article}

\backmatter
\chapter{Back chapter one}

\newrefsegment
blah blah ... \cite{baez/article} ... blah blah \cite{bertram} and blah blah \cite{doody}

\printbibliography[sorting=none,segment=\therefsegment,resetnumbers=true]

\chapter{Back chapter two}

\newrefsegment
blah blah ... \cite{doody} ... blah blah \cite{matuz:doody} and blah blah \cite{gillies}

\printbibliography[sorting=none,segment=\therefsegment,resetnumbers=true]

\end{document}


That doesn't quite work - even if I compiled with pdflatex test.tex && biber test && pdflatex test.tex && pdflatex test.tex (click for full res):

Namely,

• the main matter bibliography prints only citations [1] to [2], while I would have expected citations [3] and [4] from the appendix to be included too (as per link above).
• In the appendix, \cite{baez/article} somehow becomes [1], even if \cite{westfahl:space} should have been [1] already
• "Back chapter one" references are OK - but in "Back chapter two", the ordering is [3], [1], [2], probably because \cite{doody} was indeed [3] in "Back chapter one".
• Even if both "Back chapter one" and "Back chapter two" refer to \cite{doody}, its bibliography entry is different in bibliography of "Back chapter one" from the one in "Back chapter two".

So how can I get:

• The main matter bibliography to show both main matter and appendix citation in order - and at the same time,
• the back chapter bibliographies to be correctly ordered (in appearance order) for each chapter, and with exactly the same bibliography entries - regardless if a citation has been used in a previous backmatter chapter?

Well, thanks to Proper way to include unnumbered chapters in a per-chapter bibliography using biblatex, it seems I got most of the problems solved, except one - if a single reference (here doody) is used twice: then the first time it is formatted as a bibliographic entry it is larger - and the second time it is different, smaller.

Since I got this through trial & error mostly, I still don't understand what is really going on - so a more erudite answer will be appreciated.

Anyways, from the link above I realized first I might be using \newrefsegment wrong: in OP, I have it before \chapter - in the link MWEs, it is usually after \chapter. That wasn't the solution, and neither was my attempt to add \endrefsegment. What worked was:

• Do not use \newrefsegment at all - use begin/end{refsection}
• Start the \begin{refsection} immediately after a \chapter (and \end{refsection} before a \chapter)
• In \printbibliography then, do not use segment=\therefsegment, use section=\therefsection

So the fixed MWE is:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[defernumbers=true,style=ieee]{biblatex}
\bibliography{biblatex-examples}

\begin{document}
\frontmatter
\mainmatter

\chapter{First chapter}
\begin{refsection}

bla bla \cite{westfahl:space} bla bla \cite{aksin} ...

\printbibliography[sorting=none,section=\therefsection,resetnumbers=true]

\appendix

\chapter{Second chapter}
bla bla ... \cite{angenendt} bla bla \cite{baez/article}

\end{refsection}

\backmatter
\chapter{Back chapter one}
\begin{refsection}

% \newrefsegment
blah blah ... \cite{baez/article} ... blah blah \cite{bertram} and blah blah \cite{doody}

% \printbibliography[sorting=none,segment=\therefsegment,resetnumbers=true]
\printbibliography[sorting=none,section=\therefsection,resetnumbers=true]

\end{refsection}

\chapter{Back chapter two}
\begin{refsection}

% \newrefsegment
blah blah ... \cite{doody} ... blah blah \cite{matuz:doody} and blah blah \cite{gillies}

% \printbibliography[sorting=none,segment=\therefsegment,resetnumbers=true]
\printbibliography[sorting=none,section=\therefsection,resetnumbers=true]

\end{refsection}

\end{document}


... and it results with this output (click for high res):

As is visible, all citations are unsorted (that is, they are "sorted" by order of appearance); the order of appearance is correct for all three bibliographies - so all is good. Except that, \cite{doody} in the second (Back chapter one) bibliography is:

[3] T. Doody, “Hemingway’s style and jake’s narration,” The Journal of Nar-
rative Technique, vol. 4, no. 3, pp. 212–225, 1974, excerpt in R. Matuz, Ed.,
Contemporary Literary Criticism, vol. 61, Detroit: Gale, 1990, pp. 204–208.


... while in the third (Back chapter two) bibliography, the same citation is:

[1] T. Doody, “Hemingway’s style and jake’s narration,” The Journal of Nar-
rative Technique, vol. 4, no. 3, pp. 212–225, 1974.


... and I have no idea why the bibliography entry formatting here is shorter/different.