2

I am trying to make a Harvard style bibliography, using bibtex and the package natbib, for a journal which requires it, but the online facility I have to use won't take the .bib to process it. So I have cut and paste the contents of the .bbl file where the input command for the bibliography would have been. This processes runs once quite happily, but you have to do it twice, and the second time, I get the error:

********
./filename: Improper alphabetic constant
<to be read again>
                  \protect
l.7 blah\cite{paper1,paper2}
?
and typing h for help gives
A one-character control sequence belongs after a ` mark.
So I am essentially inserting \0 here.
******

Now, if I hit q for batchmode I get a the .pdf I want, but the online facility will not allow me to do that and it just fails. My own system reproduces the error, so it is not a problem with their facility. I am using natbib 8.31 and TeXShop 3.62

test file:

\documentclass[12pt,a4paper]{article}

\usepackage{natbib} %harvard style

\begin{document}

blah\cite{paper1,paper2}

\bibliographystyle{agsm}
%\bibliography{testbib}

\begin{thebibliography}{xx}

\harvarditem{Auth}{{2001}{\em a}}{paper1}
Auth, P.~J.  \harvardyearleft {2001}{\em a}\harvardyearright , `{paper1}', {\em {Journal 1}} {\bf {11}}({5}),~{417--436}.

\harvarditem{Auth}{{2001}{\em b}}{paper2}
Auth, P.~J.  \harvardyearleft {2001}{\em b}\harvardyearright , `{paper2}', {\em {Journal 2}} {\bf
  {1}}({1}),~{3--67}.

\end{thebibliography}
\end{document}
moewe
  • 175,683
Eliz M.
  • 31
  • 4
  • 1
    Can you show us the source .bib file for those entries, please? I have a hunch that there may be too many curly brackets flying around there. – moewe Jul 31 '18 at 15:38

2 Answers2

2

natbib does not like the format of the years in

\harvarditem{Auth}{{2001}{\em a}}{paper1}

Either manually change them to

\harvarditem{Auth}{2001a}{paper1}

or switch from natbib to harvard.


After playing around with the MWE in Mico's answer and comparing his .bbl with yours, I can't help but notice that yours features quite a bit more curly brackets than the one produced from a usual .bib file.

My current working hypothesis is that your .bib file contains too many curly brackets. Did you wrap fields in two pairs as in

journal = {{Journal 1}},
volume  = {{1}},

\documentclass[12pt,a4paper]{article}
\usepackage{harvard} %harvard style

\begin{document}
blah\cite{paper1,paper2}

\begin{thebibliography}{xx}
\harvarditem{Auth}{{2001}{\em a}}{paper1}
Auth, P.~J.  \harvardyearleft {2001}{\em a}\harvardyearright , `{paper1}', {\em {Journal 1}} {\bf {11}}({5}),~{417--436}.

\harvarditem{Auth}{{2001}{\em b}}{paper2}
Auth, P.~J.  \harvardyearleft {2001}{\em b}\harvardyearright , `{paper2}', {\em {Journal 2}} {\bf
  {1}}({1}),~{3--67}.
\end{thebibliography}
\end{document}

The citation reads "blah(Auth 2001*a*, Auth 2001*b*)" with italic *a* and *b*

or

\documentclass[12pt,a4paper]{article}
\usepackage{natbib}

\begin{document}
blah\cite{paper1,paper2}

\begin{thebibliography}{xx}
\harvarditem{Auth}{2001{\em a}}{paper1}
Auth, P.~J.  \harvardyearleft {2001}{\em a}\harvardyearright , `{paper1}', {\em {Journal 1}} {\bf {11}}({5}),~{417--436}.

\harvarditem{Auth}{2001{\em b}}{paper2}
Auth, P.~J.  \harvardyearleft {2001}{\em b}\harvardyearright , `{paper2}', {\em {Journal 2}} {\bf
  {1}}({1}),~{3--67}.
\end{thebibliography}
\end{document}

The citation reads "blahAuth (2001*a*,*b*)" with *a* and *b* in italics

moewe
  • 175,683
  • 1
    The natbib package actually handles the bibliography styles of the harvard bundle (such as agsm and dcu) just fine. My hunch is that the OP introduced some transcription errors when he/she copied the contents of the bbl file into the tex file. – Mico Jul 31 '18 at 15:32
  • 1
    @Mico That's pretty much the conclusion I came to when I tried your example with asmg.bst (thanks for the MWE!) which produced considerably fewer curly brackets. – moewe Jul 31 '18 at 15:34
  • HI, thanks for you comments. All I changed were the names of the author and the papers and the journals, as these were not relevant. But yes, there are many curly brackets. They are Bibtex style records downloaded from Web of Science and they do look to have just about every field with doubl brackets!!! – Eliz M. Jul 31 '18 at 16:17
  • Brilliant- everything works after I remove all the double curly brackets. THANK YOU all so much, I would never have thought to query those. – Eliz M. Jul 31 '18 at 17:56
  • Who knew TeX was poor at handling nested braces...this probably explains the seemingly inexplicable problem I was having, so two big thumbs up for this answer! –  Oct 05 '22 at 14:18
2

First off, the bbl file seems to have some errors. I assume they crept in when somebody (you?) applied some changes by hand to the contents of the bbl file. (For sure, they would not appear to have been generated by LaTeX or the natbib citation management package.)

For instance,

\harvarditem{Auth}{{2001}{\em a}}{paper1}

is wrong. It should be

\harvarditem{Auth}{2001{\em a}}{paper1}

Similarly, you need to replace

\harvarditem{Auth}{{2001}{\em b}}{paper2} 

with

\harvarditem{Auth}{2001{\em b}}{paper2}

Second, once you've copied the contents of the bbl file into the tex file (and deleted the \bibliography statement), you should also delete (or comment out) the directives \usepackage{natbib} and \bibliographystyle{agsm} statements. Finally, rerun LaTeX on the newly-modified tex file; it should compile correctly, making it ready to be uploaded to the publisher's website.


Just for completeness, here's the code that gives rise to the bbl contents mentioned above.

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{paper1,
  author = "Perri Jane Auth", title = "Amiable Thoughts",
  journal = "Circularity Today", year = 2001, volume = 1, number = 2, pages = "3-4",
}
@article{paper2,
  author = "Perri Jane Auth", title = "Darker Thoughts",
  journal= "Circularity Today", year = 2001, volume = 5, number = 6, pages = "7-8",
}
\end{filecontents}

\documentclass{article}
\usepackage{natbib}
\bibliographystyle{agsm}

\begin{document}
\cite{paper1,paper2}
\bibliography{mybib}
\end{document}

The resulting bbl file should have the following contents:

\begin{thebibliography}{xx}

\harvarditem{Auth}{2001{\em a}}{paper1}
Auth, P.~J.  \harvardyearleft 2001{\em a}\harvardyearright , `Amiable
  thoughts', {\em Circularity Today} {\bf 1}(2),~3--4.

\harvarditem{Auth}{2001{\em b}}{paper2}
Auth, P.~J.  \harvardyearleft 2001{\em b}\harvardyearright , `Darker thoughts',
  {\em Circularity Today} {\bf 5}(6),~7--8.

\end{thebibliography}

The typeset bibliography should look like this:

enter image description here

Mico
  • 506,678
  • The only explanation I have for the superfluous braces is that the OP wrote year = {{2001}} for some reason. Indeed some other fields also come out in the .bbl with too many braces. Maybe the OP mistakenly believed that the already bad practice of putting the title field in double braces should be mirrored for other fields as well. – moewe Jul 31 '18 at 15:32
  • @moewe - Very nice sleuthing! Let's see if the OP weighs in with some additional information about the actual properties of the entries with keys paper1 and paper2. – Mico Jul 31 '18 at 15:42
  • 1
    I left a comment under the question and edited my answer to make the suggestion about the double curly brackets. We will see. – moewe Jul 31 '18 at 15:44
  • No, I absolutely did NOT introduce double brackets around every single field in over 100 references in the paper I am trying to process!! This is how they came from an online citation service. However I can try to remove them. – Eliz M. Jul 31 '18 at 16:22
  • About deleting the usepackage{natbib} and bibliographystyle commands, the file did not process at all!! I did try that. – Eliz M. Jul 31 '18 at 16:23
  • Brilliant!!!! I would never have thought of the double brackets, however, they are now all gone from my original .bib and so is my problem -- THANK YOU – Eliz M. Jul 31 '18 at 16:45
  • 1
    @ElizM. - So glad you've arrived at a workable solution. If you feel sufficiently motivated to do so and have time to spare, you may want to send a polite comment to the online citation service (Web of Science, right?) to inform them that encasing all fields in extra pairs of curly braces is neither necessary nor harmless. :-) – Mico Jul 31 '18 at 17:20