75

I want to list my references in a beamer presentation using thebibliography environment, with the nice little

  • book icon (\beamertemplatebookbibitems) and

  • article icon (\beamertemplatearticlebibitems)

in front of each source.

Is there an icon for websites too? something like \beamertemplatewebsitebibitems? If not, is there a way to implement this easily ?

2 Answers 2

88

There's the online option for the bibliography item template; an example showing the predefined options:

\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{thebibliography}{9}
\setbeamertemplate{bibliography item}[online]
\bibitem{A} ItemA
\setbeamertemplate{bibliography item}[book]
\bibitem{B} ItemB
\setbeamertemplate{bibliography item}[article]
\bibitem{C} ItemC
\setbeamertemplate{bibliography item}[triangle]
\bibitem{D} ItemD
\setbeamertemplate{bibliography item}[text]
\bibitem{E} ItemE
\end{thebibliography}
\end{frame}

\end{document}

enter image description here

Of course, you can also use your own image(s):

\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{thebibliography}{9}
\setbeamertemplate{bibliography item}{\includegraphics[width=1.5em]{ctanlion}}
\bibitem{A} CTAN lion drawing by Duane Bibby.
\end{thebibliography}
\end{frame}

\end{document}

enter image description here

4
  • when i compile your exact same code, i get an article icon instead of the online icon. the other icons are okay. no compilation error at all. i noticed that using [onlinee], [bookk] or [some_string] produces article icons as well without error messages. am i using an old version of some package ? i use Texmaker 3.3.4 on Win XP and MiKTeX 2.9.3888
    – Fry
    Aug 22, 2012 at 7:51
  • And i think i have Biblatex installed, because when i type kpsewhich biblatex.sty to cmd.exe i get: C:/Program Files/Latex/Installation/tex/latex/biblatex/biblatex.sty
    – Fry
    Aug 22, 2012 at 8:10
  • Workaround: got my own online icon (google) and included it like you described. perfect.
    – Fry
    Aug 22, 2012 at 10:19
  • @Fry yes, if online doesn't give you the icon that appears in the image of my answer, you might have an old version of some package(s): update your system (MikTeX has a package manager for that (I don't use MikTeX)). My answer has nothing to do with biblatex; you are generating your bibliography without it as you said in your question, so my answer works independently of biblatex. Yes, as I mentioned in my answer, you can use your own images. Aug 22, 2012 at 16:30
59

With biblatex you can extend the bibliography item template to automatically select the appropriate icon.

\documentclass{beamer}
\usepackage[style=authoryear]{biblatex}
\usepackage{hyperref}

\setbeamertemplate{bibliography item}{%
  \ifboolexpr{ test {\ifentrytype{book}} or test {\ifentrytype{mvbook}}
    or test {\ifentrytype{collection}} or test {\ifentrytype{mvcollection}}
    or test {\ifentrytype{reference}} or test {\ifentrytype{mvreference}} }
    {\setbeamertemplate{bibliography item}[book]}
    {\ifentrytype{online}
       {\setbeamertemplate{bibliography item}[online]}
       {\setbeamertemplate{bibliography item}[article]}}%
  \usebeamertemplate{bibliography item}}

\defbibenvironment{bibliography}
  {\list{}
     {\settowidth{\labelwidth}{\usebeamertemplate{bibliography item}}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{glashow,markey,knuth:ct:a,knuth:ct:b,companion,bertram,ctan}
\begin{frame}[noframenumbering,plain,allowframebreaks]{References}
\printbibliography
\end{frame}
\end{document}

enter image description here

6
  • How can we put two bibitems (that is in form of icons) horizontally after some spaces? Jun 13, 2014 at 16:54
  • 1
    Wonderful! In the meantime, your code solved an issue I was having where the bib icons were bleeding over the left margin. I'm glad I came upon this while searching for something else. XD Jun 15, 2017 at 14:16
  • @Audrey, wonderful solution! However, I am using a modification from here and here \renewcommand*{\bibfont}{\tiny} \renewcommand{\pgfuseimage}[1]{\lower-3pt\hbox{\hskip15pt{\scalebox{.5}{\includegraphics{#1}}}\hskip-10pt}} and added webpage to your \ifentrytype{online}. With this setup, somehow the globe symbol is not scaled. How can I fix that?
    – BadAtLaTeX
    Jan 4, 2018 at 23:34
  • Anyone having a similar issue and wondering: The solution was to switch the \includegraphics{}. I have described it in a comment here; together with an addition to include other web-sources {\ifboolexpr{ test {\ifentrytype{online}} or test {\ifentrytype{webpage}} or test {\ifentrytype{url}} }. Save the original command \let\oldpgfuseimage\pgfuseimage and use that one\oldpgfuseimage{#1} instead of \includegraphics{#1}.
    – BadAtLaTeX
    Jan 17, 2018 at 9:11
  • You can get the biblatex-examples.bib file from here.
    – gfe
    May 4, 2020 at 6:27

You must log in to answer this question.

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