Memoir class - bibliography environment reference to wrong bibunit

I am writing my thesis using the memoir class.

I have a main which calls all the needed files.

One of these files is the "summary" which calls two different tex files with respective bibliographies (I need to have the summary in two languages, English and Danish).

The problem is that the second bibliography (danish) doesn't show up (the references are placed perfectly but they cross-reference to the bibliography environment of the English summary).

EDIT: it seems that the danish summary keeps looking at the english bib file. The references are placed only if they have been cited in the english summary and they won't show up otherwise. If the reference key differ between the two bib files (e.g. test1 and test1d in the example below), the reference will not be placed properly.

Attached the MWE

\documentclass[b5paper,10pt,authoryear,longnamesfirst]{memoir}

\begin{filecontents}{englishsummary.bib}
@Article{test1,
author =   {Test Testesen},
title =    {Test},
journal =      {Test journal},
year =     {2018},
}
@Article{test2,
author =   {Test T. Test},
title =    {TestB},
journal =      {Journal of testing},
year =     {2018},
}
\end{filecontents}

\begin{filecontents}{danishsummary.bib}

@Article{test1d,
author =   {Test Testesen},
title =    {Test},
journal =      {Test journal},
year =     {2018},
}
@Article{test2d,
author =   {Test T. Test},
title =    {TestB},
journal =      {Journal of testing},
year =     {2018},
}
\end{filecontents}

% preamble
\let\newfloat\undefined
\usepackage[capbesideposition={top,center},capposition=top]{floatrow}

\usepackage[scaled=0.75]{beramono}
\usepackage[utf8]{inputenc}
\usepackage[english,danish]{babel}
\usepackage{microtype}

\usepackage{bibunits}
\usepackage[authoryear,sectionbib,longnamesfirst]{natbib}

\setlrmarginsandblock{*}{1.228571in}{0.75}
\setulmarginsandblock{1in}{*}{1.2}

\usepackage{cleveref}
% END PREAMBLE

\begin{document}

\selectlanguage{english}
\frenchspacing
\tableofcontents*
%SUMMARY
\let\oldbibsection\bibsection
\let\oldbibsection\bibsection
\renewcommand\bibsection{\section*{\bibname}}

% English summary
\begin{bibunit}[elsarticle-harv]
\chapter*[Summary]{Summary}

some english text \citep{test1} and \cite{test2}.
%\clearpage
\putbib[englishsummary.bib]
\end{bibunit}
% END OF English SUMMARY

% Danish summary
\begin{bibunit}[elsarticle-harv_danish]
\chapter*[Danish summary]{Danish summary}
\selectlanguage{Danish}
\frenchspacing
\setcounter{footnote}{0}
%DANISH SUMMARY
some danish text \citep{test1d} and \cite{test2d}.
\clearpage
\putbib[danishsummary.bib]
\end{bibunit}
% END OF DANISH SUMMARY
\selectlanguage{english}
\frenchspacing
\let\bibsection\oldbibsection
\end{document}

• Please provide a MWE (from \documentclass through \begin{document} to \end{document}) that shows the error so that we can process it and try to help. For instance you use the memoir class but also the bibunit environment which is not supplied by memoir; where does it come from? – Peter Wilson Aug 29 '18 at 18:06
• @PeterWilson Hi, I added the preamble. Let me know if anything else is needed. The log doesn't return any error as the references appear correctly, the fact that the bibliography environment is missing doesn't seem to be recognized as a problem – Gio Aug 30 '18 at 8:01
• Could you please clean this up (a lot), there are many constructions and packages that are completely irrelevant for this question. Also where does the Danish bst file come from? You are imputing stuff we do not have access to, so please help us help you by making something that is minimal and self contained that others can test without having to add a lot of stuff. – daleif Aug 30 '18 at 8:56
• Woul;d you please still make this into a single example instead of several sniplets. There is no need for the rest of us to replicate your folder structure. As you can see from my example below, there is no issues in making a single MWE. – daleif Aug 31 '18 at 9:43
• @daleif I think you just found the problem. If I change the bibtex configuration file to plainnat the danish bibliography environment pops up. Now I need to figure out what's special about the file I was calling – Gio Aug 31 '18 at 10:11

Here is a re-edit of the OPs current MWE (20180831 12:10)

\documentclass[oneside]{memoir}
\usepackage{filecontents}
\begin{filecontents*}{englishsummary.bib}
@Article{test1,
author =   {Test Testesen},
title =    {Test english},
journal =      {Test journal},
year =     {2018},
}
@Article{test2,
author =   {Test T. Test},
title =    {TestB english},
journal =      {Journal of testing},
year =     {2018},
}
\end{filecontents*}
\begin{filecontents*}{danishsummary.bib}
@Article{test1d,
author =   {Test TestesenD},
title =    {Test danish},
journal =      {Test journal},
year =     {2018},
}
@Article{test2d,
author =   {Test T. TestD},
title =    {TestB danish},
journal =      {Journal of testing},
year =     {2018},
}
\end{filecontents*}

\usepackage[utf8]{inputenc}
\usepackage[danish,english]{babel}

\usepackage{bibunits}
\usepackage[authoryear,sectionbib,longnamesfirst]{natbib}

\begin{document}

\selectlanguage{english}
\tableofcontents*

% English summary
\begin{bibunit}[plainnat]
\chapter*[Summary]{Summary}

some english text \citep{test1} and \cite{test2}.
%\clearpage
\putbib[englishsummary]
\end{bibunit}
% END OF English SUMMARY

% Danish summary
\begin{bibunit}[plainnat]
\chapter*[Danish summary]{Danish summary}
\selectlanguage{Danish}
\frenchspacing

some danish text \citep{test1d} and \cite{test2d}.

\putbib[danishsummary]
\end{bibunit}
\end{document}


As far as I can see on my system the citations are correct. I added the filecontents package and switched to the starred version of that env, then the two bibfiles will be changed on disk if we alter them in the text file.

Too long for a comment, here is a super small MWE of memoir working with bibunits

Remember to run bibtex on all buX.aux (I use the latexmk tool, it will automatically detect the buX.aux files and run bibtex on them

So what exactly is the problem on your document?

\documentclass[a4paper]{memoir}
\begin{filecontents}{mytest.bib}
@Article{test1,
author =   {Test Testesen},
title =    {Test},
journal =      {Test journal},
year =     {2018},
}
@Article{test2,
author =   {Test T. Test},
title =    {TestB},
journal =      {Journal of testing},
year =     {2018},
}
\end{filecontents}

\usepackage[danish,english]{babel}
\usepackage{bibunits}
\usepackage[authoryear,sectionbib,longnamesfirst]{natbib}

\begin{document}

\tableofcontents*

%English summary
\begin{bibunit}[plainnat]
\chapter*[Summary]{Summary}

some text

\cite{test1}

\putbib[mytest]
\end{bibunit}

% Danish summary
\begin{bibunit}[plainnat]
\chapter*[Danish summary]{Danish summary}