3

I am new to LaTeX and I've been reading that apparently the biblatex package would suit me better than natbib. I read this other post but I can't make it work with my document.

This is a sample of my preamble:

\documentclass[12pt,letterpaper]{report}

\usepackage{sectsty} 
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=3cm,right=2cm, top=3cm, bottom=3cm]{geometry}
\usepackage[autostyle, spanish=mexican]{csquotes}

\usepackage[authoryear]{natbib} %Bibliografía
\bibliographystyle{humannat} % 
\usepackage{hyperref}

\hypersetup{colorlinks, citecolor=blue}
\makeatletter
\AtBeginDocument{
\renewcommand\NAT@open{\color{blue}(}}
\makeatother

\begin{document}
This is the text of the document which includes \cite{examples} and \citep{examples} from a 
.bib document saved in the same folder of the .tex document.
\bibliography{Bibliografia}
\end{document}

I simple do not know what to do and I am not sure if I can't use my .bib file named Bibliografia or if i need to use something for biber. I tried adding the options natbib=true, the commands \printbibliography while erasing the commands for natbib \bibliographystyle \bibliography{}.

I just don't know what to do than sticking with my natbib options. Should I change the inputencand babel package to suit spanish with biblatexor something? is there a problem with that usc package or hyperref can't be used with biblatex?

EDIT: moewe answer has worked but now I have to fix hyperref and colour the citation part that I had fixed with the \makeatletter to \makeatother commands. Any ideas?

  • You are not using the right commands. This answer show at the end a minimal example of how use biblatex (including natbib=true) and explain the compilation process. Compare with the above examples not using biblatex. Check than you can compile the last example as is with biber. – Fran Apr 22 '18 at 20:07
8

What to do to switch to biblatex? already lists the step you have to do (in no particular order)

  • Replace \usepackage[authoryear]{natbib} with \usepackage[style=authoryear, backend=biber]{biblatex}.
  • Remove \bibliographystyle{humannat}.
  • Remove \bibliography{Bibliografia} and add \addbibresource{Bibliografia.bib} (with file extension!) in the preamble (in theory you could keep using \bibliography{Bibliografia}, but it must be moved into the preamble, it can't stay after \begin{document}; \addbibresource is preferred over \bibliography).
  • Add \printbibliography where you want to see your bibliography.

  • Use \textcite instead of \citet, \parencite instead of \citep. Alternatively, you may keep on using \citet and \citep if you add natbib=true to the loading options.

You'll have to apply a few more tweaks as well

  • Remove \usepackage{ucs} - it is incompatible with biblatex.
  • Replace \usepackage[utf8x]{inputenc} with \usepackage[utf8]{inputenc}. For Spanish texts utf8 should be enough.
  • Remove the \makeatletter...\makeatother bit redefining \NAT@open. That works for natbib but not for biblatex.

Your document should look roughly like this now

\documentclass[12pt,letterpaper]{report}

\usepackage{sectsty} 
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=3cm,right=2cm, top=3cm, bottom=3cm]{geometry}
\usepackage[autostyle, spanish=mexican]{csquotes}

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

\hypersetup{colorlinks, citecolor=blue}

\addbibresource{Bibliografia.bib}

\begin{document}
This is the text of the document which includes \cite{examples} and \parencite{examples} from a 
.bib document saved in the same folder of the .tex document.
\printbibliography
\end{document}

Finally and extremely importantly, configure your editor to run Biber instead of BibTeX for you, see Biblatex with Biber: Configuring my editor to avoid undefined citations When with natbib you used to run LaTeX, BibTeX, LaTeX, LaTeX you now need to run (assuming your document is called paper.tex)

pdflatex paper
biber paper
pdflatex paper
pdflatex paper

Question mark or bold citation key instead of citation number explains what Biber does really well, but you will want to look at Biblatex with Biber: Configuring my editor to avoid undefined citations to get your editor to run Biber.

If you have problems with this at first, delete all temporary files (.aux, .bbl, .bcf) and recompile from scratch. Troubleshooting for biber gives some handy first advice in case you have problems getting Biber to run.

There is nothing special you need to do to get the support for Spanish working, it should work out of the box because biblatex picks up the language from babel.

  • I did as you said but I'm getting two error messages now. The first is that the command \addbibliography{} is not recognized. It is undefined. The other is : ERROR - Error: Found biblatex control file version 3.4, expected version 3.2. This means that your biber (2.6) and biblatex (3.11) versions are incompatible. See compat matrix in biblatex or biber PDF documentation. – Jebal Apr 22 '18 at 20:59
  • For the first error, note the misspelling of addbibliograhphy in this answer. I'd use addbibresource there. For the second error I'd update using tlmgr, e.g.: tex.stackexchange.com/questions/367996/… – Ramashalanka Apr 22 '18 at 23:43
  • I redid the whole document and updated the packages using MikTex update. It has worked now! But now I need to find a way to replace the \makeatletter - \makeatother part to hyperref and colour the whole citatio. – Jebal Apr 23 '18 at 2:52
  • 1
    @Ramashalanka Thanks for catching that. Corrected now. – moewe Apr 23 '18 at 4:40
  • @Jebal The thing about the hyperref is a new question. But you can have a look at tex.stackexchange.com/q/425283/35864 and tex.stackexchange.com/q/15951/35864 – moewe Apr 23 '18 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.