# splitbib: conflict between \SBresetdepth and export option?

I use the splitbib package to produce a publication list broken into sections for different kinds of publications. I want each section to begin numbering at 1. For this purpose splitbib provides the SBresetdepth counter; setting it >0 makes the numbering reset for each category.

I would now like to move into the 21st century and provide a live doi link as part of each entry. I have read several relevant questions and answers here, and have succeeded in getting correct links using natbib and hyperref as suggested.

However, there's a snag. To work properly with natbib, splitbib requires me to use its [export] option. That works, but when I use [export], I find that the numbering does not restart in each category as desired; it runs continuously throughout the list. This problem is not related to natbib, as my MWE below demonstrates; it happens with as plain-Jane a use of splitbib as I can construct.

\begin{filecontents}{sbrefs.bib}
@STRING{jcp = {J. Chem.\ Phys.}}
@Article{wei16,
author =   {Wei~Wei  and Colin~J. Wallace and George~C. McBane   and Simon~W. North  },
title =    {Photodissociation Dynamics of {OCS} Near 214 nm Using Ion Imaging},
journal =      jcp,
year =     2016,
volume =   145,
number =   2,
pages =    024310}

@Article{mcba13,
author =   {G.~C. McBane and J.~A. Schmidt and M.~S. Johnson and
R. Schinke},
title =    {Ultraviolet photodissociation of {OCS}: Product
energy and angular distributions},
journal =  jcp,
year =     2013,
volume =   138,
number =   9,
pages =    094314
}

@BOOK{halp06,
title = {Experimental Physical Chemistry: A Laboratory Textbook},
publisher = {W. H. Freeman},
year = {2006},
author = {Arthur M. Halpern and George C. McBane},
edition = {3rd}
}

\end{filecontents}

% .tex file begins here
\documentclass{article}
%\usepackage{splitbib}  % works correctly, resetting counters for each category if SBresetdepth>0
\usepackage[export]{splitbib}  % numbers entries continuously throughout

\setcounter{SBresetdepth}{1}

% define categories and their citations
\begin{category}{Books}
\SBentries{halp06}
\end{category}
\begin{category}{Journal Articles}
\SBentries{wei16,mcba13}
\end{category}

\begin{document}
\bibliographystyle{unsrt}

%  This \nocite command gives citation keys for all the pubs
\nocite{
wei16,
mcba13,
halp06}

\bibliography{sbrefs}
\end{document}


Is this a bug in splitbib? Is there a convenient fix?

• Welcome! Does use Biblatex/Biber count as convenient? – cfr Jul 26 '16 at 3:34
• Sure, if (1) it doesn't take too long to figure out how to use it, and (2) I can continue to use my normal .bib file (as I think I can). – George McBane Jul 26 '16 at 14:57
• Yes. Biblatex/Biber supports additional entry types and fields etc. in a .bib, but these are extensions. When I switched to Biblatex/Biber, I just kept using the same .bib files - just needed some minor modifications to the document (e.g. to load biblatex and adjust the command to produce the bibliography). I also had used natbib, so I initially used Biblatex's natbib compatibility mode. Do you want the categories specified in the document rather than the .bib? – cfr Jul 26 '16 at 15:17
• Yes, I would like categories specified in the .tex file (since the .bib file is my main one, and the categories are not desired when I send .bib information to publishers.) Also, I'd love to have the entry labels decrease within each category rather than increase; is that straightforward with biblatex? – George McBane Jul 26 '16 at 15:23
• Personally, I'd put the categories in the .bib and filter them out to create a .bib for publishers. However, if your categories correspond to entry types, you don't need to specify separate categories anyway. Can you confirm whether this is the case? That is, are 'books' and 'articles' representative or are your real categories more arbitrary? – cfr Jul 26 '16 at 15:56

When you use the export option, splitbib does not overwrite the document's default definitions of \bibitem etc. This means that whatever style you would otherwise have, you should have.

In the MWE you posted, this means that \bibitem is formatted according to the configuration provided by unsrt.bst. Its definition of \bibitem is going to increment the counter at each new entry. splitbib doesn't change this.

To see this, note that if we use a simple thebibliography environment then the counter is reset even if export is given as an argument.

\documentclass{article}
\usepackage[export]{splitbib}  % numbers entries continuously throughout

\setcounter{SBresetdepth}{1}

% define categories and their citations
\begin{category}{Books}
\SBentries{halp06}
\end{category}
\begin{category}{Journal Articles}
\SBentries{wei16,mcba13}
\end{category}

\begin{document}

%  This \nocite command gives citation keys for all the pubs
\nocite{%
wei16,
mcba13,
halp06}

\begin{thebibliography}{1}
\bibitem{weil6} Wei

\bibitem{mcha13} Michael Chard

\bibitem{halp06} Hillary Allen Little-Pinker

\end{thebibliography}

\end{document}


produces

because the .sbb file looks like this

\begin{thebibliography}{1}
\item[]\SBtitle
{Books}
\relax
\bibitem
{halp06}
Hillary Allen Little-Pinker

\item[]\SBtitle
{\SBmisctitle }
\relax
\bibitem
[\SBmiscprefix 1]
{weil6}
Wei

\bibitem
[\SBmiscprefix 2]
{mcha13}
Michael Chard

\end{thebibliography}


Obviously, there's no .bbl here as we're not using BibTeX.

In contrast

\begin{filecontents}{\jobname.bib}
@STRING{jcp = {J. Chem.\ Phys.}}
@Article{wei16,
author =   {Wei~Wei  and Colin~J. Wallace and George~C. McBane   and Simon~W. North  },
title =    {Photodissociation Dynamics of {OCS} Near 214 nm Using Ion Imaging},
journal =      jcp,
year =     2016,
volume =   145,
number =   2,
pages =    024310}

@Article{mcba13,
author =   {G.~C. McBane and J.~A. Schmidt and M.~S. Johnson and
R. Schinke},
title =    {Ultraviolet photodissociation of {OCS}: Product
energy and angular distributions},
journal =  jcp,
year =     2013,
volume =   138,
number =   9,
pages =    094314
}

@BOOK{halp06,
title = {Experimental Physical Chemistry: A Laboratory Textbook},
publisher = {W. H. Freeman},
year = {2006},
author = {Arthur M. Halpern and George C. McBane},
edition = {3rd}
}

\end{filecontents}

% .tex file begins here
\documentclass{article}
%\usepackage{splitbib}  % works correctly, resetting counters for each category if SBresetdepth>0
\usepackage[export]{splitbib}  % numbers entries continuously throughout

\setcounter{SBresetdepth}{1}

% define categories and their citations
\begin{category}{Books}
\SBentries{halp06}
\end{category}
\begin{category}{Journal Articles}
\SBentries{wei16,mcba13}
\end{category}

\begin{document}
\bibliographystyle{unsrt}

%  This \nocite command gives citation keys for all the pubs
\nocite{%
wei16,
mcba13,
halp06}

\bibliography{\jobname}

\end{document}


produces

In this case, we have the following in the .sbb file

\begin{thebibliography}{1}
\item[]\SBtitle
{Books}
\relax
\bibitem
{halp06}
Arthur~M. Halpern and George~C. McBane. \newblock {\em Experimental Physical Chemistry: A Laboratory Textbook}. \newblock W. H. Freeman, New York, 3rd edition, 2006.

\item[]\SBtitle
{Journal Articles}
\relax
\bibitem
{wei16}
Wei Wei, Colin~J. Wallace, George~C. McBane, and Simon~W. North. \newblock Photodissociation dynamics of {OCS} near 214 nm using ion imaging. \newblock {\em J. Chem.\ Phys.}, 145(2):024310, 2016.

\bibitem
{mcba13}
G.~C. McBane, J.~A. Schmidt, M.~S. Johnson, and R.~Schinke. \newblock Ultraviolet photodissociation of {OCS}: Product energy and angular distributions. \newblock {\em J. Chem.\ Phys.}, 138(9):094314, 2013.

\end{thebibliography}


and a .bbl containing

\begin{thebibliography}{1}

\bibitem{wei16}
Wei Wei, Colin~J. Wallace, George~C. McBane, and Simon~W. North.
\newblock Photodissociation dynamics of {OCS} near 214 nm using ion imaging.
\newblock {\em J. Chem.\ Phys.}, 145(2):024310, 2016.

\bibitem{mcba13}
G.~C. McBane, J.~A. Schmidt, M.~S. Johnson, and R.~Schinke.
\newblock Ultraviolet photodissociation of {OCS}: Product energy and angular
distributions.
\newblock {\em J. Chem.\ Phys.}, 138(9):094314, 2013.

\bibitem{halp06}
Arthur~M. Halpern and George~C. McBane.
\newblock {\em Experimental Physical Chemistry: A Laboratory Textbook}.
\newblock W. H. Freeman, New York, 3rd edition, 2006.

\end{thebibliography}


As can be seen, the .bbl is just bog-standard - splitbib leaves this alone. But now we're using BibTeX, so the bibliography consists of the contents of the unadulterated .bbl and not the .sbb, Therefore, the labels used for the bibliographical entries are no determined by splitbib in this case.

# EDIT

To obtain the desired result, the easiest approach is to switch to Biblatex/Biber.

For example,

\begin{filecontents}{\jobname.bib}
@STRING{jcp = {J. Chem.\ Phys.}}
@Article{wei16,
author =   {Wei~Wei  and Colin~J. Wallace and George~C. McBane   and Simon~W. North  },
title =    {Photodissociation Dynamics of {OCS} Near 214 nm Using Ion Imaging},
journal =      jcp,
year =     2016,
volume =   145,
number =   2,
pages =    024310}

@Article{mcba13,
author =   {G.~C. McBane and J.~A. Schmidt and M.~S. Johnson and
R. Schinke},
title =    {Ultraviolet photodissociation of {OCS}: Product
energy and angular distributions},
journal =  jcp,
year =     2013,
volume =   138,
number =   9,
pages =    094314
}

@BOOK{halp06,
title = {Experimental Physical Chemistry: A Laboratory Textbook},
publisher = {W. H. Freeman},
year = {2006},
author = {Arthur M. Halpern and George C. McBane},
edition = {3rd}
}

\end{filecontents}

% .tex file begins here
\documentclass{article}
\usepackage[backend=biber,defernumbers=true]{biblatex}
\bibliography{\jobname}

\begin{document}
%  This \nocite command gives citation keys for all the pubs
\nocite{%
wei16,
mcba13,
halp06}

\printbibliography[type=book,title=Books]
\printbibliography[type=article,title=Journal Articles,resetnumbers=true]

\end{document}


produces

If you need categories which do not correspond to entry types or to any other feature of .bib entries already present, you can either add the information into the .bib in one of various forms or customise categories within the document.

For example, using the same .bib as before, we can create two arbitrary categories in the document preamble.

\documentclass{article}
\usepackage[backend=biber,defernumbers=true]{biblatex}
\bibliography{\jobname}
\DeclareBibliographyCategory{favourites}
\DeclareBibliographyCategory{necessary}

\begin{document}
%  This \nocite command gives citation keys for all the pubs
\nocite{%
wei16,
mcba13,
halp06}

\printbibliography[category=favourites,title=My Favourite Sources,resetnumbers=true]
\printbibliography[category=necessary,title=Necessary Evils,resetnumbers=true]

\end{document}


to produce

• That's a nice explanation of the problem. What's the solution? How should I do this, while continuing to get the information from my main .bib file for consistency? – George McBane Jul 26 '16 at 15:15
• @GeorgeMcBane Please see edit for a Biblatex/Biber solution, since you indicated this was an option. (It uses precisely the same .bib as you provided in the question.) If you were asking how to do it with splitbib, I'm sorry but I'm afraid I don't know. I've never used the package before, which is probably part of it. But, in general, multiple bibliographies in a single document is easier with Biblatex/Biber. Moreover, Biblatex is just generally much more flexible and powerful than BibTeX and much easier to customise beyond that, if need be. – cfr Jul 26 '16 at 16:27
• You may want to tweak the style a bit. The Biblatex manual has very good documentation of the standard styles it offers. Also, if you're using natbib, you can set the compatibility option to avoid having to find and replace natbib's citation commands in your document. (This is very handy when switching with existing documents based on natbib!) – cfr Jul 26 '16 at 16:29