On several occations I have read instructions like "run Latex on your file, then run Bibtex, and afterwards run Latex again..." . I am using TeXstudio as editor and when compiling any tex-code I simply press the compile-button. What happens behind this did not matter to me as the pdf I wanted was created anyway. Now that I am using .bib files for referencing, I am having a problem where the solution to this was the same as above. But how do I do it? I only know the compile-button. How can I run Latex individually from Bibtex and Bibtex individually from Latex? And which of both is running when simply pressing "compile"?

  • 3
    I do have a suspicion: pressing compile button = Latex, pressing F11 = running Bibtex . At least it's doing what I want.
    – Lucas
    Oct 2, 2014 at 21:20
  • It sounds as if compile button = pdfLaTeX. But this probably depends on how you have configured your editor. Most editors have options (buttons or items in menus) which let you choose other compilation options e.g. bibTeX or biber. If you are using biblatex, you probably need to use biber. If you are using bibtex, you definitely need to use bibtex. [You can use bibtex with biblatex but it is not default.]
    – cfr
    Oct 2, 2014 at 21:24
  • 1
    What I mean is: if you have written your document using bibtex commands (e.g. \bibliographystyle{}), then you need to do pdflatex -> bibtex -> pdflatex -> pdflatex. If you have written it using biblatex (\usepackage{biblatex}) then, by default, you need biber: pdflatex -> biber -> pdflatex. So what you use to compile in the second step depends on how you are managing things in your document.
    – cfr
    Oct 2, 2014 at 21:37
  • 1
    @cfr: sorry, there was a message above the comment asking if the discussion should be moved to chats.
    – Lucas
    Oct 2, 2014 at 22:50
  • 1
    Jesus christ. I have been looking all over for this exact solution. Your comment about F11 fixed everything. I guess I should add a bibtex button to my texstudio set up. May 9, 2016 at 7:32

6 Answers 6


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


Then you need to run

  • pdflatex -> bibtex -> pdflatex -> pdflatex

If you have something like this:

\addbibresource{bibfilename.bib}% or \bibliography{bibfilename}

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


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.

  • If getting file.aux not found when using pdflatex, replace those calls with latex and call pdflatex after you complete the sequence.
    – mcp
    May 1, 2022 at 18:16

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:

    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:
  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:


all: report

.PHONY: clean

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

view: report
    open $(DOCNAME).pdf

    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.

  • additionally for biber, you must use $(DOCNAME).bcf instead Oct 14, 2020 at 4:54
  • You should include view in the .PHONY targets. Feb 16, 2021 at 0:42
  • When making this Makefile, make sure to use tabs and not spaces.
    – Veech
    Apr 19, 2021 at 18:11

A simple solution: latexmk. I can't say it works in all cases, but for some basic setting (thesis, paper), it works well.

Here is an example extracted from its man-doc (e.g. you have thesis.tex in your current folder):

latexmk thesis

--> run latex enough times to resolve cross-references

latexmk -pvc -ps thesis 

--> run latex enough times to resolve cross-references, make a postscript file, start a previewer. Then watch for changes in the source file thesis.tex and any files it uses. After any changes rerun latex the appropriate number of times and remake the postscript file. If latex encounters an error, latexmk will keep running, watching for source file changes.

latexmk -c

--> remove .aux, .log, .bbl, .blg, .dvi, .pdf, .ps & .bbl files

So with one command, we can make latexmk works in the interactive mode, every change in .tex or event .bib file will be re-complied automatically. More detailed docuement here.


IF YOU ARE USING TEXSTUDIO. Go To : settings --> compilations and run by waiting the excution of every step :

1 pdflatex. --> 2 bibtex . --> 3 pdflatex . --> 4 pdflatex .


Building on the top answer, here's my simple script to do it for BibTex:

pdflatex $BASE.tex
if [ $? -ne 0 ]; then
    echo "Compilation error. Check log."
    exit 1
bibtex $BASE
pdflatex $BASE.tex
pdflatex $BASE.tex
exit 0

Which I run with ./latexcompile.sh mytexdoc (note the lack of file extension).

Don't forget to do chmod +x latexcompile.sh to make it executable!

You must log in to answer this question.

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