[Tex/LaTex] How to switch from Natbib to Biblatex in pre-made document class/template

biblatexbibliographies

I am using this template to write my thesis. The template uses Natlib for references, whereas I really need Biblatex.

When I simply try to change \usepackage[natbib] for biblatex I get the error message

This is BibTeX, Version 0.99d (TeX Live 2016/Debian)
Capacity: max_strings=100000, hash_size=100000, hash_prime=85009
The top-level auxiliary file: aagot-1-report.aux
The style file: acm.bst
Illegal, another \bibstyle command---line 80 of file aagot-1-report.aux
 : \bibstyle
 :          {acm}
 I'm skipping whatever remains of this command
Database file #1: Mendeleytry.bib.bib
Warning--I didn't find a database entry for ""
You've used 14 entries,code here

The solution

\usepackage[backend=bibtex, natbib=true, style=numeric]{biblatex}

didn't work.

Another possible solution was said to be to recompile from scratch to delete the .aux file, but that resulted in

/usr/share/texlive/texmf-dist/tex/latex/biblatex/biblatex.sty:462:
LaTeX Error:
 Command \bibhang already defined.
           Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.462 \newlength{\bibhang}

I have tried to use this "marco" to override the \requirePackage settings, but that also didn't work and resulted into

LaTeX Error: Two \documentclass or \documentstyle comm
ands.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.45 \documentclass[whitelogo]{
                           tudelft-report} 

Where I can't seem to delete any of the document classes without getting the functionality of the tudelft-package and the biblatex citing (or in fact getting it to work at all!)

(no line number):
[0] Config.pm:343> INFO - This is Biber 2.5
[0] Config.pm:346> INFO - Logfile is 'aagot-1-report.blg'
[62] biber:290> INFO - === Tue Apr 24, 2018, 22:24:06
[246] Utils.pm:165> ERROR - aagot-1-report.bcf is malformed, last biblatex 
run probably failed. Deleted aagot-1-report.bbl
[246] Biber.pm:113> INFO - ERRORS: 1

Is there any way I can still make this template work with Biblatex? Natlib seems to deeply rooted in the file and I don't know how to change it/access the settings/the ".sty"-file.
Can I use the example documentclass combined with biblatex (instead of the standard natbib) without losing the great parts of the rest of the document class?

Thanks very much 🙂

Best Answer

If you are are a student at the TU Delft you may want to check back with your supervisor that you really have to use biblatex. You could also contact those responsible for the template for assistance.

If you are not studying at TU Delft you probably should not be using that template. Templates like this are really, really hard to modify if you want anything changed – and if you are not at TU Delft, chances are you need some changes. See also https://github.com/johannesbottcher/templateConfusion. If something goes wrong templates like this are far harder to debug than if you start with an established documentclass like report, book, one of the KOMA classes or memoir. Templates often load many packages, often many packages you don't need or want – this greatly increases the chances for incompatibilities (as you had to find out). It is also much harder for people to help you if you use such a complicated set-up.

Additionally there may be legal issues here: The template that can be downloaded from https://www.tudelft.nl/en/tu-delft-corporate-design/downloads/ have no explicit license statements. And even though I would normally assume that it is fine to use the template for your documents (IANAL, though), these templates also include the house font TUDelft-UltraLight.ttf again with no indication of the license – using fonts without licenses could be much more problematic.

Anyway, your problem is that the class (and the .tex file) loads natbib. natbib is incompatible with biblatex. So if you want to use biblatex you need to prevent the class from loading natbib. This can be done with the scrlfile package: Add \RequirePackage{scrlfile} and then \PreventPackageFromLoading{natbib} before loading \documentclass{tudelft-report}. Other than that you also need to follow the steps from What to do to switch to biblatex? and How do I transition from natbib to biblatex?

The report.tex from https://www.tudelft.nl/en/tu-delft-corporate-design/downloads/ would then look like

\RequirePackage{scrlfile}          % <- to prevent
\PreventPackageFromLoading{natbib} % <- natbib from loading
\documentclass[whitelogo]{tudelft-report}
\usepackage[backend=biber,style=numeric,natbib=true]{biblatex}% <- load biblatex instead
\addbibresource{report.bib}% <- the .bib file needs to be given here

%\usepackage{natbib}% <- no idea why the template loads natbib again, again we don't do that
\usepackage{changes}

\begin{document}
\frontmatter
\title[tudelft-white]{Title}
\subtitle[tudelft-black]{Optional subtitle}
\author[tudelft-white]{J.\ Random Author}
\affiliation{Technische Universiteit Delft}
\coverimage{tank.jpg}
\covertext[tudelft-white]{
    \textbf{Cover Text} \\
    possibly \\
    spanning 
    multiple 
    lines
    \vfill
    ISBN 000-00-0000-000-0
}
\setpagecolor{tudelft-cyan}
\makecover[split]

\input{title}

\input{preface}

\tableofcontents

\mainmatter

\input{chapter-1}

\appendix
\cite{Reference1,Reference2,Reference3}

\printbibliography% <- to print the bibliography
\end{document}

Remember to run Biber and not BibTeX on this file. See Biblatex with Biber: Configuring my editor to avoid undefined citations (see Question mark or bold citation key instead of citation number for background about what Biber and BibTeX do, see Troubleshooting for biber for first aid with Biber issues).


If you are using the TU Delft dissertation template dissertation.cls you will need to stop both natbib and chapterbib from loading, so your file will start with

\RequirePackage{scrlfile}              % <- to prevent
\PreventPackageFromLoading{natbib}     % <- natbib and
\PreventPackageFromLoading{chapterbib} % <- chapterbib from loading
\documentclass{dissertation}
\usepackage[backend=biber,style=numeric,natbib=true]{biblatex}% <- load biblatex instead
\addbibresource{diss.bib}% <- the .bib file needs to be given here