1

I was tasked with sifting through a paper and getting rid of all the errors (exciting, I know). The only error I could not figure out is the following:

! Undefined control sequence.
<argument> ...\blx@tempe @\blx@refcontext@context

l.14

? h
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

?

I've searched all over, but could not find a solution that worked. Here is an example of the code:

\documentclass[10pt,letterpaper]{article}
\usepackage[backend=biber, style=ieee ,defernumbers=true]{biblatex}
\usepackage{float} % Allows for control of flat positions
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{gensymb}    

\addbibresource{bibliography.bib}
\printbibliography

\begin{document}

blablabla here's all the writing and stuff I took out. 
Oh, look, I'm citing some paper \cite{ganan1998generation}

\end{document}

For the bibliography.bib file, the way the author was calling in references is:

@article{ganan1998generation,
  title={Generation of steady liquid microthreads and micron-sized monodisperse sprays in gas streams},
  author={Ga{\~n}{\'a}n-Calvo, Alfonso M},
  journal={Physical Review Letters},
  volume={80},
  number={2},
  pages={285},
  year={1998},
  publisher={APS}
}

Other solutions online have stated that the issue comes from calling on multiple citations, but that is not the case here. I commented out all the \cite{bib1,bib2,etc} commands throughout the text and still got the same errors.

I should also mention that the undefined control sequence error is being thrown 8 times, all with a different <argument> description.

I'm not sure what is happening here and could use a hand. I've tried the solutions from the following pages: page 1, page 2, page 3

NoVa
  • 135
  • 1
    Wild guess: try deleting the .aux file and compile again – Phelype Oleinik Feb 11 '20 at 00:32
  • @PhelypeOleinik, where can I find that? I'm using Overleaf. – NoVa Feb 11 '20 at 00:33
  • 1
    At the right end of the Recompile button there's a sheet-of-paper icon (Logs and output files---click it), and then there is a trash bin icon at the bottom, to the right. – Phelype Oleinik Feb 11 '20 at 00:36
  • Done, I'm still getting the same errors – NoVa Feb 11 '20 at 00:37
  • 1
    Ah. \printbibliography should go where you actually want the bibliography to appear. In the preamble it's an error. – Phelype Oleinik Feb 11 '20 at 00:40
  • I believe that the bibliography located there is a requirement of the paper we're submitting too. Do you mean that it should be located after \begin{document}? If so, I tried that and still got the errors. Actually, it turns 14 errors into 97 when I do that. – NoVa Feb 11 '20 at 00:42
  • jk, you were right. I just reran it after clearing the cache and it worked – NoVa Feb 11 '20 at 00:44
  • @PhelypeOleinik, if you post your answer below, I'll accept it as the answer so you can get the points. – NoVa Feb 11 '20 at 00:48
  • 1
    Yes, if you want the bibliography at the beginning of the document, then move \printbibliography after the \begin{document}. Nothing that produces typeset output should be before \begin{document}. The number of errors is usually meaningless. One error triggers 10 more and so on until TeX just gives up. Usually solving the first will get rid of all others. Okay, I'll write an answer – Phelype Oleinik Feb 11 '20 at 00:48

1 Answers1

3

That error (not terribly clear, I'll give you that) happens because you are using \printbibliography in the preamble of the document. The command \printbibliography, as the name advertises, prints the bibliography, so it must appear after the \begin{document} (where you want the bibliography to appear).

That error appears before the usual Missing \begin{document} error because biblatex does a lot of processing of the bibliography at \begin{document}, so some commands (for example the one that raised the error) are not yet defined in the preamble.

Also the bibliography relies a lot on external (what Overleaf calls cached) files. Usually a failed compilation will result in an unusable file, which will persist on the error even if you fixed the problem, so it's a good idea to try deleting these files if something's not working.

  • I'm wondering if biblatex should error more gracefully here. Is there a sort of inverse \@onlypreamble? I guess we could also try and guard all the commands that error here, but I'm wondering if that is wort it ... – moewe Feb 11 '20 at 07:51
  • @moewe I was wondering about that too. On the one hand, the error is quite cryptic and a clearer message would indeed be helpful. On the other hand, I don't know if this is a terribly common mistake... As for the inverse \@onlypreamble, I think you could do \AtBeginDocument{\newrobustcmd*{\printbibliography}{...}} – Phelype Oleinik Feb 11 '20 at 09:41
  • @moewe Just crossed my mind: a simpler solution than delaying defining \printbibliography as an error in the preamble and delaying the definition of \printbibliography to \begin{document} would be to add something like a \leavevmode at the beginning (as long as it doesn't interfere with the output, of course...) – Phelype Oleinik Feb 11 '20 at 10:57
  • Mhhh, I was hoping to avoid \AtBeginDocument because biblatex uses that quite extensively already and it feels wrong to in essence say that all stuff that does typesetting should be defined only then. But then again \@onlypreamble is also just a glorified \AtBeginDocument... The \leavevmode is interesting, but I don't understand all its implications, so I'd rather not try that. – moewe Feb 11 '20 at 20:12
  • @moewe It has to be used carefully: a\par b\par c\par a\par \leavevmode\par c\par. Perhaps much better would be \ifx\document\@onlypreamble okay\else error\fi – Phelype Oleinik Feb 11 '20 at 20:35
  • I was also looking at the suggestions from https://tex.stackexchange.com/q/16295/35864. I'll have a think about this ... still not sure if all the effort is worth it. – moewe Feb 11 '20 at 20:40