using both multibbl and natbib?

In a book I have multiple bibliographies (several per chapter) and, with the help of Dai Bowen in a previous question, I successfully overcame that by using multibbl package but I now face an incompatibility with natbib.

Natbib allows me to properly format the text notably with the absolutely necessary [longnamesfirst] option and \citep, \citealp, \citeauthor, \citeyear, etc. commands.

Is there a workaround so these packages coexist or any idea how I could do otherwise?

The short answer is no, the packages will not naturally coexist multibbl and natbib do various redefining of internal citation commands which are incompatible.

The sensible answer is that for multiple bibliographies, using biblatex will probably be much easier, as it can easily handle multiple bibliographies (e.g. this answer) and (with the natbib package option) will define all the commands like \citeauthor etc. and therefore has the capabilities of both multibbl and natbib in a single package.

The longer answer is that it does seem to be possible to get elements of the two packages working together, it's hardly elegant and unfortunately I haven't found a way to get longnamesfirst working so far. The main incompatibility is in their redefinition of \@citex, multibbl redefines it as

\def\@citex[#1]#2#3{%
\let\@citea\@empty
\@cite{\@for\@citeb:=#3\do
{\@citea\def\@citea{,\penalty\@m\ }%
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\@ifundefined{#2@auxfile}{}{\expandafter\immediate%
\write\csname #2@auxfile\endcsname{\string\citation{\@citeb}}}%
\@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
\@latex@warning
{Citation \@citeb' on page \thepage \space undefined}}%
{\hbox{\csname b@\@citeb\endcsname}}}}{#1}}


which inserts an extra argument and swaps the default

\if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi


for

\@ifundefined{#2@auxfile}{}{\expandafter\immediate%
\write\csname #2@auxfile\endcsname{\string\citation{\@citeb}}}%


while natbib does \let\@citex\NAT@citex or \let\@citex\NAT@citexnum depending on package options. We therefore need to insert the extra .aux file name argument into both of these. The \citeyear, \citeauthor, and commands in natbib don't rely on \@citex but instead have their own call which must also be adjusted to accept two arguments, the first being the .aux file name and the second the citation key.

Packaged together into one file, some of the necessary changes seem to be

\begin{filecontents}{bibexample.bib}
@book{goossens93,
author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title     = "The LaTeX Companion",
year      = "1993",
}
\end{filecontents}

\documentclass{article}

\usepackage{multibbl}
\newbibliography{biblio1}
\usepackage[longnamesfirst]{natbib}

\makeatletter

\def\NAT@citex%
[#1][#2]#3#4{\let\@citea\@empty
\@cite{\let\NAT@nm\@empty\let\NAT@year\@empty
\@for\@citeb:=#4\do
{\edef\@citeb{\expandafter\@firstofone\@citeb}%
\@ifundefined{#3@auxfile}{}{\expandafter\immediate%
\write\csname #3@auxfile\endcsname{\string\citation{\@citeb}}}%
\@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea%
{\reset@font\bfseries ?}\NAT@citeundefined
\PackageWarning{natbib}%
{Citation \@citeb' on page \thepage \space undefined}}%
\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year
\NAT@parse{\@citeb}\ifNAT@full\let\NAT@nm\NAT@all@names\else
\let\NAT@nm\NAT@name\fi
\ifNAT@swa
\ifx\NAT@last@nm\NAT@nm\NAT@yrsep
\ifx\NAT@last@yr\NAT@year \NAT@exlab\else\unskip\ \NAT@date\fi
\else\@citea{\NAT@nm}\NAT@aysep
\ \NAT@date \fi \def\@citea{\NAT@sep\ }%
\else
\ifx\NAT@last@nm\NAT@nm\NAT@yrsep\ifx\NAT@last@yr\NAT@year
\NAT@exlab\else \unskip\ \NAT@date\fi
\else\@citea{\NAT@nm}\ \NAT@open\if\relax#1\relax\else#1\ \fi
\NAT@date\fi
\def\@citea{\NAT@close\NAT@sep\ }%
}}\ifNAT@swa\else\if\relax#2\relax\else\NAT@cmt\ #2\fi
\NAT@close\fi}{#1}{#2}}

\def\NAT@citexnum[#1][#2]#3#4{\let\@citea\@empty
\@cite{\@for\@citeb:=#4\do
{\@citea\def\@citea{\NAT@sep\penalty\@m\NAT@space}%
\edef\@citeb{\expandafter\@firstofone\@citeb}%
\@ifundefined{#3@auxfile}{}{\expandafter\immediate%
\write\csname #3@auxfile\endcsname{\string\citation{\@citeb}}}%A
\@ifundefined{b@\@citeb\@extra@b@citeb}{%
{\reset@font\bfseries?}
\NAT@citeundefined\PackageWarning{natbib}%
{Citation \@citeb' on page \thepage \space undefined}}%

\renewcommand\citeauthor[2]{%
\@ifundefined{#1@auxfile}{}{\expandafter\immediate%
\write\csname #1@auxfile\endcsname{\string\citation{#2}}}%
\@ifundefined{b@#2\@extra@b@citeb}{%
{\reset@font\bfseries ?}\NAT@citeundefined
\PackageWarning{natbib}%
{Citation #2' on page \thepage \space undefined}}%
{\NAT@parse{#2}\ifx\NAT@noname\NAT@name
{\reset@font\bfseries(author?)}\PackageWarning{natbib}
{Author undefined for citation #2'
\MessageBreak
on page \thepage}\else
}

\renewcommand\citeyear[2]{%
\@ifundefined{#1@auxfile}{}{\expandafter\immediate%
\write\csname #1@auxfile\endcsname{\string\citation{#2}}}%
\@ifundefined{b@#2\@extra@b@citeb}{%
{\reset@font\bfseries ?}\NAT@citeundefined
\PackageWarning{natbib}%
{Citation #2' on page \thepage \space undefined}}%
{\NAT@parse{#2}\if\relax\NAT@date\relax
{\reset@font\bfseries(year?)}\PackageWarning{natbib}
{Year undefined for citation #2'
\MessageBreak
on page \thepage}\else
}

\renewcommand\citefullauthor[2]{%
\@ifundefined{#1@auxfile}{}{\expandafter\immediate%
\write\csname #1@auxfile\endcsname{\string\citation{#2}}}%
\@ifundefined{b@#2\@extra@b@citeb}{%
{\reset@font\bfseries ?}\NAT@citeundefined
\PackageWarning{natbib}%
{Citation #2' on page \thepage \space undefined}}%
{\NAT@parse{#2}\ifx\NAT@noname\NAT@all@names
{\reset@font\bfseries(author?)}\PackageWarning{natbib}
{Author undefined for citation #2'
\MessageBreak
on page \thepage}\else
}

\makeatother

\begin{document}
\cite{biblio1}{goossens93}

\citet{biblio1}{goossens93}

\citep{biblio1}{goossens93}

\citealp{biblio1}{goossens93}

\citeauthor{biblio1}{goossens93}

\citeyear{biblio1}{goossens93}

\citefullauthor{biblio1}{goossens93}

\bibliographystyle{biblio1}{plainnat}
\bibliography{biblio1}{bibexample}{References}

\end{document}


• And I realise this was written based on a 1997 version of natbib.sty which I managed to find through Google. On the plus-side the example I compiled did use the latest (2010) natbib.sty and worked... will try to update the relevant parts of my answer when I've got time to study the current version of natbib.sty more thoroughly. – Dai Bowen Jul 28 '17 at 18:58
• I tried Biblatex but I encountered the strong drawback that we cannot use a custom style with it (as answered here) so I'm back to the starting point with the same dilemna. How can I have multiple bibliographies with natbib and custom style? – Hornet Aug 3 '17 at 7:45

Multibbl and natbib do no coexist. Biblatex does not allow a custom style.

So I finally opted for chapterbib which best meets my main requirements (multiple bibliographies, using natbib and custom styles) even if it also has some drawbacks (I would notably have prefered a bibliography “tag” as Multibbl or two tags \begin{refsection} and \end{refsection} as Biblatex)

Edit: I have just found out that Chapterbib also allows tags (\begin{cbunit} and \end{cbunit}) instead of \include so it's a good choice

• I wouldn't say "biblatex does not allow a custom style", rather the contrary, it is likely the most customizable alternative. See, e.g. tex.stackexchange.com/q/12806/105447. – gusbrs Aug 3 '17 at 10:49
• Biblatex simply doesn't use .bst files to set the style, Biblatex is more powerful and can do everything BibTeX can and more, but if the BibTeX style you want has not been "translated" to Biblatex then you will have to manually set up the style in Biblatex (which should be simpler than creating an entirely new bst` mind). – Dai Bowen Aug 3 '17 at 15:57
• Ah ok, thank you for those comments. In my case I indeed already have several .bst files ready to use, hence my choice to not create them from scratch for Biblatex. But good to know. – Hornet Aug 4 '17 at 12:07