Changing from natbib to BibLaTex bibliography result in major errors

I am using Overleaf to write my master thesis. I have used natbib package (works fine) but I want to change to biblatex to be able to use different styles. I am using JabRef as a bibliography manager, by uploading my bibliography as a bib file on Overleaf. As I mentioned, this works fine when using natbib, but when I changed the commands to biblatex and compile I sometimes get error messages saying "undefined on input line 3" and the citations marked as just bold citekeys in the document, and sometimes i get a fatal error and no pdf produced with lots of errors:

Compile Error. Sorry, your LaTeX code couldn't compile for some reason. Please check the errors below for details, or view the raw log.

*Runaway argument? {Inheritance is involved in up to one third of colon cancer cases. Hi\ETC. ! File ended while scanning use of \field. \par

l.70 \begin{document} I suspect you have forgotten a }', causing me to read past where you wanted me to stop. I'll try to recover; but if the error is serious, you'd better typeE' or X' now and fix your file.

acknowledgements/acknowledgements.tex, line 9 Illegal parameter number in definition of \NewCount.

               *1 l.9 \begin{itemize}
You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up?


I'm going to assume that you meant ##.**

++++ the errors go on and on.

This is the my code in the main document:

\documentclass[a4paper,12pt,twoside]{report}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\DeclareUnicodeCharacter{2212}{-}
\usepackage{csquotes}
\usepackage{newcent}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{multicol}
%AKRONYM
\usepackage{acronym}
%NOMENKLATUR
\usepackage{nomencl}
\renewcommand{\nomname}{\LARGE{Nomenclature}}
\makenomenclature
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage{wrapfig}
\usepackage{subfiles}
\usepackage{setspace}
\usepackage{tocloft}
\setlength\cftparskip{0pt}
\setlength{\cftbeforesecskip}{1pt}
\setlength{\cftbeforechapskip}{6pt}
\usepackage{titlesec}
\titlespacing{\subsubsection}{0pt}{\parskip}{-\parskip}
%\setcounter{secnumdepth}{3}
%\titlespacing*{\section}
%{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
%\titlespacing*{\subsection}
%{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}

%BIBLIOGRAFI
%NATBIB
%\usepackage[square,numbers,round,sort&compress]{natbib}
%BIBLATEX
\usepackage[backend=biber,citestyle=nature, sorting=none, natbib=true]{biblatex}
\include{thesis.preamble}
\begin{document}
\title{\LARGE {\bf } Haplotype analysis \\
\vspace*{6mm}
}
\maketitle
\preface
\body
\part{Part 1}
\part{Part 2}
\input{Method/Method}
\input{Results/Results.tex}
%NATBIB
%\bibliographystyle{unsrt}
%\bibliography{bibliografimaster.bib}
%BIBLATEX
\printbibliography
\newpage
{\Huge\textbf{Appendix}}
\appendix
% appendices come here
\input{Appendix/appendix.tex}
\end{document}


I have included the code i use both for natbib citation style and for biblatex (with percent in front of natbib so its not used). I have also removed all the natbib commands to see if this makes any change, but it doesn't. The natbib commands I use works fine, so I just wanted to include them to show what I have done and that these arguments works.

I have probably included lots of irrelevant commands in my working example, but I wonder if any of the arguments I have used can explain why natbib seems to work and not biblatex?

I have made a working example using the same bib file using biblatex (the same commands i used in my master project above), and this works fine.

\documentclass{article}
\usepackage[utf8]{inputenc}
\title{TesterReferanser}
\author{SS}
\date{January 2019}
\usepackage[backend=biber,citestyle=nature, sorting=none, natbib=true]{biblatex}
\begin{document}
\maketitle
\section{Introduction}
må teste referanser \cite{RN272}.
\printbibliography
\end{document}


Result in nice citations and bibliography!!

Therefore, i believe that some other commands i have used in the preamble is the reason for the error message.

I would be so grateful is someone can help me with this. What am i missing??

• The preamble as shown does not look particularly problematic for biblatex. It loads quite a lot packages in general (and I suggest you try and get rid of packages you don't need), but none of them is known to have problems with biblatex. We don't know thesis.preamble, which could contain problematic code, so you may want to investigate that file. Would it be possible to produce a minimal example from your long, non-working code that reproduces the issue with as little code as possible (cf. tex.meta.stackexchange.com/q/228/35864 and tex.meta.stackexchange.com/q/4407/35864# – moewe Jan 9 '19 at 14:12
• The error {Inheritance is involved in up to one third of colon cancer cases. Hi\ETC. ! File ended while scanning use of \field suggests that one of your .bib entries has an abstract field where a special character like % is not properly escaped (indeed a short google search reveals ncbi.nlm.nih.gov/pmc/articles/PMC2586153 and there is indeed a % in the abstract). I usually recommend not to export the abstract field at all, it only unnecessarily bloats the files involved. See also tex.stackexchange.com/q/352662/35864 – moewe Jan 9 '19 at 14:16

The reported error

Runaway argument?
{Inheritance is involved in up to one third of colon cancer cases. Hi\ETC.
! File ended while scanning use of \field.
<inserted text>
\par
l.36 \begin{document}


is usually thrown when a non-verbatim field in your .bib file contains an unescaped % character. The exact location of the error is in the .bbl file, which contains something along the lines of

  \field{abstract}{Lorem ipsum % dolor}


the error occurs at the beginning of the document, when the .bbl file is read.

Since % is a comment character in TeX, TeX will ignore everything after the % and in particular will not see the closing curly brace. That missing brace then causes the error. The error is even thrown if you don't want to print that particular field. The mere fact that it is a field known to biblatex's data model is enough.

BibTeX-based bibliography solutions like natbib have less issues with unescaped %s in fields. If the field is not printed, an unescaped special character is no problem whatsoever, because it is never written to a file that is read by TeX. If the field is printed, the output will very probably be wrong and there might be errors, but that is not a sure thing.

A short Google search of the text in the error message leads us to https://doi.org/10.1016/j.ddmec.2008.05.004 and indeed the abstract there reads

Inheritance is involved in up to one-third of colon cancer cases. Highly penetrant inherited syndromes account for approximately 3%, while more common, but less penetrant inherited factors play a role in the remainder. Approaches to recognizing each of these categories and syndromes, using genetic testing for diagnosis where indicated, and accomplishing proper cancer screening and surveillance will be outlined in this review.

and contains a %character. Even worse the .bib file exported by Elsevier looks as follows

@article{BURT2007293,
title = "Inheritance of colorectal cancer",
journal = "Drug Discovery Today: Disease Mechanisms",
volume = "4",
number = "4",
pages = "293 - 300",
year = "2007",
issn = "1740-6765",
doi = "https://doi.org/10.1016/j.ddmec.2008.05.004",
url = "http://www.sciencedirect.com/science/article/pii/S1740676508000369",
author = "Randall Burt",
abstract = "Inheritance is involved in up to one-third of colon cancer cases. Highly penetrant inherited syndromes account for approximately 3%, while more common, but less penetrant inherited factors play a role in the remainder. Approaches to recognizing each of these categories and syndromes, using genetic testing for diagnosis where indicated, and accomplishing proper cancer screening and surveillance will be outlined in this review."
}


The % in 3% is not escaped. That is an error!

A correct entry would look like

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{burt,
author   = {Randall Burt},
title    = {Inheritance of colorectal cancer},
journal  = {Drug Discovery Today: Disease Mechanisms},
volume   = {4},
number   = {4},
pages    = {293-300},
doi      = {10.1016/j.ddmec.2008.05.004},
date     = {2007-12},
abstract = {Inheritance is involved in up to one third of colon cancer
cases. Highly penetrant inherited syndromes account for
approximately 3\%, while more common, but less penetrant
inherited factors play a role in the remainder.
Approaches to recognizing each of these categories and
syndromes, using genetic testing for diagnosis where
indicated, and accomplishing proper cancer screening and
surveillance will be outlined in this review.},
}
\end{filecontents}

\begin{document}
\cite{sigfridsson,burt}
\printbibliography
\end{document}


In general I recommend not to export the abstract field to the .bib file. It does more harm than good and is almost never printed, so all it does is bloat the .bib and .bbl files.

To remove a field in JabRef go to "Edit > Set/clear/rename fields". Under "Field name" insert abstract, then choose whether you want to remove the field for all entries or only selected entries and finally choose "Clear fields" in the last section.

If you then click "OK", all abstract fields will be cleared. You can then save the changes.

If you don't want to fix all wrong abstract fields manually and can't or don't want to turn off exporting the field in JabRef, Prevent biber from choking on "%" characters in abstract? describes how to get rid of the field on the fly before it can do any damage.

• do you know how i can turn off exporting the abstract in JabRef? I dont find where i can change this in the program. – SGS Jan 9 '19 at 14:55
• @SofieGeck Have a look at the updated answer, please. – moewe Jan 9 '19 at 15:27
• Thank you!! This sorted most of the errors!! I still get some "undefined cituations". Can i ask what type of settings you use in Jabref to make them "suitable" for Biblatex? Do you use Biblatex og bibtex mode? Do you remove any other fields? Which type of format of author and editor names? Thank you again!! – SGS Jan 9 '19 at 15:45
• @SofieGeck I don't really use JabRef myself. I only have it installed for the occasional question on this site. If you are using biblatex I of course recommend biblatex` mode. Whether or not I would remove additional fields depends on their contents and other details. I'm not sure what you mean by the type of format for author and editor (all methods in tex.stackexchange.com/q/557/35864 are valid). If the answer helped you, please consider accepting it: tex.stackexchange.com/help/someone-answers – moewe Jan 9 '19 at 15:51
• You can run on of the cleanup operations for the abstract field. There is Latex cleanup which should escape the percent sign. So no need to remove it in JabRef. See the help help.jabref.org/en/CleanupEntries – Christoph S Jan 9 '19 at 18:23