0

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.

moewe
  • 175,683
Myshkin
  • 653
  • 1
    Did you run the normal cycle (pdf)latex -> bibtex -> (pdf)latex (twice)? – Bernard Jul 23 '20 at 10:49
  • I am using overleaf – Myshkin Jul 23 '20 at 11:12
  • The commands \addbibresource{bibliography.bib} in the preamble and \bibliography{ref.bib} towards the end of the document are in direct conflict with each other. Be sure to (a) delete \bibliography{ref.bib} and to make sure that bibliography.bib contains all needed bibliographic entries. – Mico Jul 23 '20 at 11:13
  • 1
    Three other comments: (i) Don't load hyperref twice. (ii) Don't load biblatex twice. (iii) Since you employ biblatex with the options natbib=true and style=authoryear, you should be using the plainnat bibliographystyle, not the plain bibliography style. – Mico Jul 23 '20 at 11:15
  • Replace bibliography{ref.bib} with the normal (with biblatex) \printbibliography. – Bernard Jul 23 '20 at 11:18
  • I did all you guy's suggestion, still not getting it.... – Myshkin Jul 23 '20 at 11:22
  • Do you get any errors (which can be checked by clicking the icon next to the compile button)? – Marijn Jul 23 '20 at 12:27

1 Answers1

1

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.

moewe
  • 175,683