3

I want to use bibtex in a beamer presentation and format the citations with natbib. This code works:

\documentclass{beamer}
\usepackage{listings}
\usepackage{hyperref}
%\usepackage[super,sort,comma]{natbib}
\usepackage{filecontents}

\begin{filecontents}{mybib.bib}
@book{author_book,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
year = {2005},
}
\end{filecontents}

\begin{document}
\begin{frame}
\frametitle{Title}
Test \cite{author_book}
\end{frame}

\begin{frame}
  \frametitle{References}
  \bibliographystyle{plain}
  \bibliography{mybib}{}
\end{frame}
\end{document}

But when I uncomment:

\usepackage[super,sort,comma]{natbib}

I get the citation format I want but the hyperlinks are lost. How can I solve it?

0

1 Answer 1

2

Too long for a comment:

hyperref is loaded by the beamer class. At that stage natbib is not loaded, so hyperref does not activate its natbib compatibility code. There is no easy way to turn that code on, a second loading of hyperref is simply ignored, and beamer messes with some of the same macros that natbib does. (Incidentally using natbib you should use matching \bibliographystyle such as plainnat.)

If you want superscript citations with hyperlinks, then you can use biblatex with either its \supercite command or with a superscript option its \autocite command:

\documentclass{beamer}

\usepackage[autocite=superscript]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{mybib.bib}
@book{author_book,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
year = {2005},
}
\end{filecontents}

\addbibresource{mybib.bib}

\begin{document}


\begin{frame}
\frametitle{Title}
Test \autocite{author_book}
\end{frame}

\begin{frame}
  \frametitle{References}
\printbibliography
\end{frame}
\end{document}

The above code runs with biber; if you prefer bibtex then call the biblatex package as:

\usepackage[autocite=superscript,backend=bibtex]{biblatex}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .