TransWikia.com

referencing problem in Bibtex

TeX - LaTeX Asked on December 10, 2021

I am using the reference BibTeX file as ref.bib, I am using cite command to cite in the following latex environment

documentclass[10pt,compress]{beamer}
usepackage[T1]{fontenc}
usetheme{Madrid}
usepackage{amsmath,amssymb,amsfonts}
useoutertheme{shadow}
useinnertheme{rounded}
setbeamertemplate{navigation symbols}{}
setbeamerfont{structure}{family=rmfamily,series=bfseries}
usefonttheme[onlymath]{serif}
usepackage{caption}
usepackage{rotating}
usepackage{multicol}
usepackage{hyperref}
usepackage{enumerate}
usepackage{tikz-cd}
bibliographystyle{plain}
usepackage[natbib=true,style=authoryear,backend=bibtex,useprefix=true]{biblatex}
addbibresource{bibliography.bib}
usepackage[style=authoryear]{biblatex}
usepackage{hyperref}
usetikzlibrary{matrix}
usepackage{bm}

and

begin{frame}[t,allowframebreaks]
frametitle{References}
printbibliography
bibliography{ref.bib}
end{frame}

But I am not getting any reference in the pdf . Thanks for helping.

One Answer

You are mixing two incompatible methods to generate citations and a bibliography in LaTeX.

You have bibliographystyle{plain} and bibliography{ref.bib} in the document body, which are used to generate BibTeX-based bibliographies. (It doesn't matter on a current system, but technically bibliography{ref.bib} is wrong. The file name argument to bibliography must not include the file extension, so bibliography{ref} would be correct).

But then you also load biblatex (twice! usepackage[natbib=true,style=authoryear,backend=bibtex,useprefix=true]{biblatex} and usepackage[style=authoryear]{biblatex}, load packages only once to avoid confusion and option conflicts) and use its commands addbibresource{bibliography.bib} (pointing to a different file than the bibliography) and printbibliography.

biblatex and the BibTeX-based bibliography method are incompatible and you need to choose one of the two.


biblatex

If you choose biblatex, you need to remove all bibliographystyle calls and you may not have a bibliography call in the document body. (You can give the .bib file in a bibliography call in the preamble, but it is recommended to use addbibresource - where the file extension must be included).

Your biblatex document would look roughly like this

documentclass{beamer}
usepackage[T1]{fontenc}
usepackage{amsmath,amssymb}

usetheme{Madrid}
useoutertheme{shadow}
useinnertheme{rounded}
setbeamertemplate{navigation symbols}{}
setbeamerfont{structure}{family=rmfamily,series=bfseries}
usefonttheme[onlymath]{serif}

usepackage[natbib=true,style=authoryear,backend=bibtex,useprefix=true]{biblatex}

addbibresource{biblatex-examples.bib}


begin{document}
begin{frame}
Lorem autocite{sigfridsson}
end{frame}
begin{frame}[t,allowframebreaks]
frametitle{References}
printbibliography
end{frame}
end{document}

Note, however, that it is strongly recommended to use Biber instead of BibTeX with biblatex. That should be as easy as changing backend=bibtex, to backend=biber, and running Biber instead of BibTeX (or telling your editor to do that: Biblatex with Biber: Configuring my editor to avoid undefined citations).


BibTeX

If you want to use BibTeX, remove all mentions of biblatex and its addbibresource and printbibliography commands. Instead use bibliographstyle and bibliography.

A BibTeX-based document would look like this

documentclass{beamer}
usepackage[T1]{fontenc}
usepackage{amsmath,amssymb}

usetheme{Madrid}
useoutertheme{shadow}
useinnertheme{rounded}
setbeamertemplate{navigation symbols}{}
setbeamerfont{structure}{family=rmfamily,series=bfseries}
usefonttheme[onlymath]{serif}

bibliographystyle{plain}


begin{document}
begin{frame}
Lorem cite{incollection-full}
end{frame}
begin{frame}[t,allowframebreaks]
frametitle{References}
bibliography{xampl}
end{frame}
end{document}

Note that you should never load packages twice (in the question, hyperref and biblatex are loaded twice). In this case it is not necessary to load hyperref at all, since biblatex already takes care of that.

Answered by moewe on December 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP