0

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?

Alan Munn
  • 218,180
  • There are books available on this subject ... – MS-SPO Jun 10 '22 at 15:32
  • 1
    the example should work, so perhaps you should instead provide an error and the log-file. – Ulrike Fischer Jun 10 '22 at 15:32
  • @UlrikeFischer There were no errors. The text "You can cite an online resource \cite{ford}." printed out just fine. However, there were no references that were loaded. – user1535147 Jun 10 '22 at 15:35
  • The example works if you run pdflatex <filename>.tex, then biber <filename>, then pdflatex <filename>.tex again. You only ran the first command. – Sergio Jun 10 '22 at 15:43
  • 3
    See also https://tex.stackexchange.com/q/141957/35864, https://tex.stackexchange.com/q/13509/35864, though my favourite hello world example is https://gist.github.com/moewew/e92edad4f3b96d3ed9ef0308d61a6945. Keep in mind that a document using biblatex needs 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 .blg file. See also https://tex.stackexchange.com/q/286706/. – moewe Jun 10 '22 at 15:44
  • @Sergio Thanks, it works. That is extremely unintuitive. Given how widespread Latex is, you'd think this should be solved with a click of a button in TexWorks. – user1535147 Jun 10 '22 at 16:13
  • All modern editors can be configured to do all that (and more) automatically in the background. It does help to know what's involved, though. – Ingmar Jun 10 '22 at 16:19
  • 1
    You might consider configuring TeXworks to use a wrapper like latexmk. Details here. – frabjous Jun 10 '22 at 16:19
  • You can configure texworks to run biber in same way that you run pdflatex and the other compilers. Then you only need to remember that is only an intermediate step (or use latexmk, 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

1 Answers1

0

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
musarithmia
  • 12,463