[Tex/LaTex] BibTeX Errors “the literal stack is empty” and “‘128’ is a function literal” with Optics Express Template

bibtex

I'm having an issue compiling the bibliography for a document using the Optics Express Template. I get error messages which say:

—the literal stack isn't empty for entry Haug2004 while executing—line 2689 of file osajnl.bst

and

`'128' is a function literal, not a string or missing field, for entry Miller while executing—line 2689 of file osajnl.bst

I've looked on Google/StackExchange here, here, here and here but none of these really solve my problem. Particularly, the last two suggest there is a mistake in the osajnl.bst file, which seems unlikely to me as the template seems to be well tested.

A minimal working example would be as follows:

    \documentclass[10pt,letterpaper]{article}
    \usepackage{opex3}
    \usepackage{color}
    \usepackage[colorlinks=true,urlcolor=blue,linkcolor=black,citecolor=black,breaklinks=true,bookmarks=false]{hyperref}
    \begin{document}

    \title{XXX}

    \begin{abstract}
    YYY
    \end{abstract}

    \bibliography{/path/to/file/bibliography.bib}
    \bibliographystyle{osajnl}

    \section{Introduction}
    This is very interesting \cite{Haug2004,Miller}.
    \end{document}

Now, the bibliography entries for Haug2004 and Miller are as follows (which are generated by exporting my Mendeley library.)

    @book{Haug2004,
    address = {Singapore},
    author = {{Haug, H. and Koch, S.}},
    doi = {10.1142/7184},
    edition = {{4th}},
    isbn = {9812386092},
    publisher = {World Scientific Publishing},
    title = {Quantum theory of the optical and electronic properties of semiconductors},
    url = {http://cds.cern.ch/record/1055549$\backslash$nhttp://www.worldscientific.com/doi/pdf/10.1142/9789814503389{\_}bmatter},
    year = "2004"
    }

    @incollection{Miller,
    abstract = {In this article, we will introduce quantum wells, and will concentrate on some of the physical effects that are seen in optical experiments. Quantum wells also have many interesting properties for electrical transport, though we will not discuss those here. We will briefly allude to some of the optoelectronic devices, though again we will not treat them in any detail.},
    address = {London},
    author = {Miller, David A B},
    booktitle = {Quantum Dynamics of Simple Systems},
    chapter = {9},
    editor = {Oppo, G.L. and Barnett, S.M. and Riis, E. and Wilkinson, M},
    isbn = {0750304901},
    keywords = {Excitons,Quantum Wells},
    mendeley-tags = {Excitons,Quantum Wells},
    pages = {239--266},
    publisher = {Institute of Physics},
    title = {Optical Physics of Quantum Wells},
    year = {1996}
    }

Then, compiling the .tex (first code block) as pdflatex using TeXworks, it goes fine, but then when I do BibTeX, then it spits out the error messages above. Also, if I look at osajnl.bst, there are only 1354 lines, so I don't see why it's saying there's an error in line 2689.

Does anyone have any suggestions how to overcome this problem? Thank-you!

Best Answer

I have encountered the same problem and found a solution. When you use

\bibliography{/path/to/file/bibliography.bib}
\bibliographystyle{osajnl}

a file created your_article.bbl that includes error when you have a book reference in the bibliography.bib file. I don't know why and how, but here is a solution: look at your_article.bbl and fix the book references. Or, instead, use below in the your_article.tex file directly

%\bibliographystyle{osajnl}
%\bibliography{references}
\begin{thebibliography}{10}
\newcommand{\enquote}[1]{``#1''}
\bibitem{your_reference}
...
\end{thebibliography}

I hope this helps. At least it works for me.