[Tex/LaTex] Errors with \bibentry with bibliography style that puts macro in bbl file

bibentrybibtex

The following example works fine. However, if \bibliographystle{plainnat} is replaced by \bibliographystle{te}, where te.bst is the style available at http://econtheory.org/technical/te.bst, then two errors are generated: "Undefined control sequence. Hotelling, Harold (1929), \enquote …" and "Undefined control sequence. …ding, Massachusetts. \bibAnnoteFile …".

The problem seems to be that \enquote and \bibAnnoteFile are needed to format the reference, but are not supplied in time. (The bibliographystyle puts their definitions in the bbl file.)

Is there a simple solution?

\begin{filecontents}{mytestbib.bib}
@article{HotellingEJ1929,
  author = {Hotelling, Harold},
  title = {Stability in competiton},
  journal = {Economic Journal},
  year = {1929},
  volume = {39},
  pages = {41-57}
}

\end{filecontents}
\documentclass{article}
\usepackage{filecontents}
\usepackage{natbib}
\usepackage{bibentry}

\begin{document}

\nobibliography{mytestbib}

A full in-text cite of \bibentry{HotellingEJ1929}.

A regular citation of \cite{HotellingEJ1929}.

\bibliographystyle{plainnat}

\end{document}

Best Answer

From my understanding of the problem (which is far from being perfect), each macro used within the bibitems of the bbl file needs to be made available to bibentry when the later is called in the code. The way I've been able to do this, is to make them global within the Tex file explicitly with \global\def.

However, for \enquote, this is different because the command is defined in the bbl directly, which as you noted, results in an "\enquote is already defined" error. To circumvent this issue, as noted by @ChristianHupfer, you can comment out those following two lines in the te.bst file:

%  write$ newline$
%  "\newcommand{\enquote}[1]{``#1''}"

and add a definition of \enquote explicitly in the preamble of your Tex document (as you already said in a previous comment).

Here is a modified version of your MWE that works on my system without error (with the two lines listed above commented in the te.bst file):

\begin{filecontents}{mytestbib.bib}
@article{HotellingEJ1929,
  author = {Hotelling, Harold},
  title = {Stability in competiton},
  journal = {Economic Journal},
  year = {1929},
  volume = {39},
  pages = {41-57}
}

\end{filecontents}

\documentclass{article}
\usepackage{filecontents}
\usepackage{natbib}
\usepackage{bibentry}

\bibliographystyle{te}
\newcommand{\enquote}[1]{``#1''}
\global\def\bibAnnoteFile{}

\begin{document}

\nobibliography*

\noindent A full in-text cite of \bibentry{HotellingEJ1929}.

\bibliography{mytestbib}

\end{document}

Which results in:

enter image description here