Latex can't find citations in .bib file

I am having trouble getting latex to access the .bib file that jabref saves.
When I compile I get the warning “Citation XXX on page X undefined on input line XXX”.

In order to cite from a library, I need to export a subset of the entries as a separate .bib file and use that in my \addbibresource{} call in latex.

Did I miss something or were we suppose to directly use the jabref database?

Yes, you could in theory directly use the jabref database.

Is your other .bib file in the latex folder and does contain the entries you want to cite?

It could also be a compilation error. Are you using bibtex or biblatex? → Could you provide the preamble of your latex file?

I know that if you use biblatex, in most cases you have to compile like this to end up with the final pdf:

latex → biber → latex → latex

I am using biblatex.
I am running latex via the sublime text plugin LatexTools. I think the plugin sorts out the compiling commands. I also don’t think the issue is with LatexTools because it does work if I select a subset of the database and export as a separate .bib file.
If I had to guess I would say that it could be some issue that comes up if latex and Jabref are reading the file at the same time(?).
Or maybe there is some refs that have wonky formatting that causes latex to not recognise the .bib file (?).

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[noenc]{tipa}
\usepackage{tipx}
\usepackage[geometry,weather,misc,clock]{ifsym}
\usepackage{pifont,eurosym,amsmath,wasysym,amssymb,amsfonts,textcomp}
\usepackage[T3,T1]{fontenc}
\usepackage{mathptmx}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{xcolor,microtype}
\usepackage[explicit]{titlesec}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
\usepackage[vmargin = 1.25cm,hmargin = 2.54cm,includeheadfoot,head = 1.3cm,headsep = 1.12cm,foot = 1.3cm,footskip = 2.5cm]{geometry}
\usepackage{array,supertabular,hhline,colortbl,hyperref}
\usepackage{xcolor, soul}
\sethlcolor{green}
\usepackage[draft]{changes}
\usepackage{graphicx}
\usepackage[style = apa]{biblatex}
\addbibresource{/home/rjd/JabRef/JabRef_FullCollection.bib} %% the .bib is needed on the name
\usepackage[switch, modulo]{lineno}
\linenumbers
\usepackage{setspace}
\doublespacing
\usepackage{caption}
\usepackage{authblk}
\usepackage{newfloat}
\usepackage{datetime2}
\hypersetup{colorlinks = true,allcolors = blue,pdfauthor = Ryan Daniels}
\titleformat{\section}[block]{\filright\normalfont\normalsize\normalcolor\fontsize{14pt}{17pt}\selectfont\scshape}{\thesection}{6pt}{#1}
\titlespacing*{\section}{0pt}{0.5cm}{0.35cm}
\titleformat{\subsection}[block]{\filright\normalfont\normalsize\normalcolor\fontsize{12pt}{14pt}\selectfont}{\thesubsection}{6pt}{#1}
\titlespacing*{\subsection}{0pt}{0.5cm}{0.35cm}
\titleformat{\subsubsection}[block]{\filright\normalfont\normalsize\normalcolor\fontsize{12pt}{14pt}\selectfont}{\thesubsubsection}{6pt}{#1}
\titlespacing*{\subsubsection}{0pt}{0.5cm}{0.35cm}
\setcounter{secnumdepth}{3}
\providecommand\textsubscript[1]{\ensuremath{{}_{\text{#1}}}}
\makeatletter
\newcommand\arraybslash{\let\@arraycr}
\makeatother
\fancypagestyle{Standard}{\fancyhf{}
\fancyhead[L]{}
\fancyfoot[L]{Page {\textbar} \thepage{}}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\renewcommand\thepage{\arabic{page}}
}
\pagestyle{Standard}
\setlength{\skip\footins}{0.119cm}
\renewcommand\footnoterule{\vspace*{ - 0.018cm}\setlength\leftskip{0pt}\setlength\rightskip{0pt plus 1fil}\noindent\textcolor{black}{\rule{0.25\columnwidth}{0.018cm}}\vspace*{0.101cm}}
\setlength\tabcolsep{1mm}
\renewcommand\arraystretch{1.3}
\graphicspath{{./Figures/}}
\renewcommand{\linenumberfont}{\normalfont\bfseries\small\color{gray}}
\DeclareFloatingEnvironment[
fileext = los ,
listname = {List of Supplemental Figures} ,
name = Figure S
]{SuppFig}

\DeclareFloatingEnvironment[
fileext = los ,
listname = {List of Supplemental Tables} ,
name = Table S
]{SuppTab}

\title{Title of some research}

\author[1]XXXX \thanks{corresponding author: XXXX}}

\affil[1]{XXX}
\date{\today}

\begin{document}

\printbibliography

\end{document}

Ah, try \_ in the file name :smiley:

like this: \addbibresource{/home/rjd/JabRef/JabRef\_FullCollection.bib}

Or simply remove the _
If I remember correctly, an underscore is a special symbol in latex. Not sure, would need to look it up.

Quite the opposite actually!
If I use the escape character then latex can’t find the file. I have tried both _ and \_ in the file names and only _ works.

I have found some extra info too (that might be useful for someone else).

  • With Latextools, I need to clear the cache if biblatex give errors before trying again. Even on the working subsetted version of the .bib file, I needed to clear the cache.
  • It doesn’t seem to be an issue with compiling Latex while the .bib file is open in JabRef. I tested compiling and editing in JabRef on the working subsetted .bib file and I had no issues.

I guess there is a ref in my library that has something special about it that is causing some trouble.

It is definitely something in my library. I exported my entire library to an intermediate .bib file for compiling and it gave the same issues.
If I subset parts of the library and replace the intermediate .bib file, everything compiles without issue.
The intermediate .bib file is what Latex is using.

I have a new question:
Is there a recommended way to ‘hide’ entries in my library so that it is not exported to the bib file (and I can filter out which ever entry is causing the problem)?
Since the library is stored as a bib file, I am guessing I will have to move all my poorly-formatted entries to a separate library until they have been checked.

I would suggest to make a backup of your library.

Then open the non-working library you want to compile with a text editor and use the 50% rule to debug things:

Put a % somewhere in the middle of the file → save the file → then try to compile.
If compilation works, the fault must be in the second half of your file. If compilation does NOT work, the fault must be in the first half of your file.

Repeat this process until you hit the entry that gives problems.

To better visualise, it might help you to think of it as if you were cutting a cake in ever smaller slices. 1/1 (Full cake) → 1/2 (half the cake)–> 1/4 → 1/8 → 1/16 → 1/16 → 1/32 → 1/64 → …
You will find the fault pretty fast.

PS: % is a special character in latex: it marks everything that comes after it as a comment

Often, I encounter the same problem of one erroneous entry in a .bib file affecting the compilation. Usually, the output will help with finding the issue. Do you have an error like ‘I’m skipping whatever remains of this file’? If so, it is usually preceded by the offending entry.

JabRef does not do the compilation, therefore JabRef does not have such a command.

If you use biblatex, you could check Biber for sophisticated commands. If you use other compilation methods, then you would need to check these other compilation processing backends.

What I have done now (because I needed a functioning library) is I have moved all my quality checked refs in one library and everything else in another library. Every new entry goes to the ‘dumping ground’ until I have read it and am sure that it is something I will use. I add it to a QC group in the dumping ground library and at some point later I move all the QC group entries to the functional library.

I’m sorry for not being clear: I was referring to the output from BiBTeX, not from JabRef.