I am trying to create and cite a reference in Latex. Examples in the internet is are really all over the place. This answer provided a very good example but alas, \printbibliography does not work. There is a rabbit hole of reasons why it does not work which I really do not care for. Can someone provide a working example source code for BibLaTeX?
- 218,180
- 101
1 Answers
Assuming you have a fully working LaTeX installation, you need (1) a bibliography file in biblatex format, and (2) a document that calls the biblatex package and brings in your bibliography file with the \addbibresource command.
The easiest way to compile is to use latexmk, which will call the LaTeX engine and biber behind the scenes. You can customize the engine and other factors based on the arguments you give to latexmk (latexmk -pdf uses pdflatex, -pdfxe uses XeLaTeX, -outdir=aux sends all the output to the aux dir so you don't have to deal with all the log files, etc.).
You can customize the bibliography style by passing options to biblatex or calling another package built on it. For example, I use biblatex-chicago for citations according to the Chicago Manual of Style (\usepackage[authordate]{biblatex-chicago}).
The bibliography file either needs to be in the same directory as the document file, or in your TeX path, such as in your local $TEXMF directory ($HOME/texmf/tex/latex/local/ on my Linux system).
Bibliography: mybib.bib
@Book{Knuth:TAOCP1,
author={Knuth, Donald E.},
title={The Art of Computer Programming, Volume 1: Fundamental Algorithms},
shorttitle={The Art of Computer Programming I},
location={Upper Saddle River, NJ},
publisher={Addison-Wesley},
year=1997,
keywords={computer science, programming, mathematics, algorithms}
}
Document: mydoc.tex
\documentclass{article}
\usepackage{biblatex}
\addbibresource{mybib.bib}
\begin{document}
See \autocite[1]{Knuth:TAOCP1}.
\printbibliography
\end{document}
To compile PDF doc.pdf
latexmk -pdf doc.tex
- 12,463
pdflatex <filename>.tex, thenbiber <filename>, thenpdflatex <filename>.texagain. You only ran the first command. – Sergio Jun 10 '22 at 15:43biblatexneeds to be compiled with LaTeX, Biber, LaTeX, LaTeX (where "LaTeX" can be your favourite flavour of LaTeX: pdfLaTeX, LuaLaTeX, XeLaTeX, ...), see also https://tex.stackexchange.com/q/63852/35864. If you are having trouble getting the bibliography to show you may want to check the.blgfile. See also https://tex.stackexchange.com/q/286706/. – moewe Jun 10 '22 at 15:44biberin same way that you runpdflatexand the other compilers. Then you only need to remember that is only an intermediate step (or uselatexmk, but if you abuse of the previews, instead of make a complete (and long) compilation every time, it could better just run pdflatex only and pdflatex+biber only when you need to check new cites and references or so). – Fran Jun 10 '22 at 19:23