Bibtex, Latex compiling

The 'compile' button is running a default compilation sequence. It sounds as if this is probably pdfLaTeX in your case. (You can probably change this if you wanted - many editors allow you to customise the default.)

To generate your bibliography, you need to look at what is in your document. How are you managing references? If you use commands such as

\bibliographystyle{stylename}
\bibliography{bibfilename}

Then you need to run

  • pdflatex -> bibtex -> pdflatex -> pdflatex

If you have something like this:

\usepackage{biblatex}
\addbibresource{bibfilename.bib}% or \bibliography{bibfilename}
...
\printbibliography

Then you need to run

  • pdflatex -> biber -> pdflatex -> pdflatex

It is possible to use bibtex with biblatex but it is not default. Unless you have

\usepackage[backend=bibtex]{biblatex}

you don't need to worry about this. If you do use this option, you would use the bibtex compilation sequence above rather than the biber one.

To run the compilations, you can either use the command line or your editor. Most editors have buttons or menus with options for non-default compilation. Even though pdfLaTeX is default, there is probably a button or menu option for bibTeX (and perhaps biber). You can probably customise things further to suit your work-flow.


Here's a trick I like to use:

  1. Create a python script in the root directory of your project, called e.g. compile_refs.py and paste the following code into it:

    #!/usr/bin/python
    
    import subprocess, sys
    
    commands = [
        ['pdflatex', sys.argv[1] + '.tex'],
        ['bibtex', sys.argv[1] + '.aux'],
        ['pdflatex', sys.argv[1] + '.tex'],
        ['pdflatex', sys.argv[1] + '.tex']
    ]
    
    for c in commands:
        subprocess.call(c)
    
  2. When you want to compile references you just run: python compile_refs.py main_file_name.


Here's a useful Makefile you can use to automate the compiling process described in the answer by cfr:

DOCNAME=report

all: report

.PHONY: clean

report:
    pdflatex $(DOCNAME).tex
    bibtex $(DOCNAME).aux
    pdflatex $(DOCNAME).tex
    pdflatex $(DOCNAME).tex

view: report
    open $(DOCNAME).pdf

clean:
    rm *.blg *.bbl *.aux *.log

Just paste this into a file called Makefile in the same directory as your main .tex file and replace report in the variable definition DOCNAME=report with whatever your file is named.

Then you can use this as follows:

  1. make or make report will create the PDF doc from the TeX sources.
  2. make view will make the PDF if not already created and open it with your system default PDF viewer.
  3. make clean will clean up the intermediate files created during PDF creation.

If you need to use biber instead of bibtex, you can just replace the call to bibtex with a call to biber.

Tags:

Bibtex