Compiling LaTex bib source
Asked Answered
S

4

67

I am writing my thesis in Latex, and I have the references in an own thesis.bib file which look as follows

@Article{xxx,
  author =       "D.A. Reinhard",
  title =        "Case Study",
  year =         "1985",
}

and I reference them in my main document as ~\cite{xxx}

When I compile then the main document with: pdflatex main.tex than it shows me question marks instead of the proper references to the bibliography. Do I also need to compile the bib source on its own? If yes, can somebody please tell me the command for Linux

Many thanks!

Surfing answered 17/3, 2010 at 11:50 Comment(0)
H
88

You need to compile the bibtex file.

Suppose you have article.tex and article.bib. You need to run:

  • latex article.tex (this will generate a document with question marks in place of unknown references)
  • bibtex article (this will parse all the .bib files that were included in the article and generate metainformation regarding references)
  • latex article.tex (this will generate document with all the references in the correct places)
  • latex article.tex (just in case if adding references broke page numbering somewhere)
Highpriced answered 17/3, 2010 at 11:57 Comment(6)
Also, consider using latex mk (phys.psu.edu/~collins/software/latexmk-jcc), a perl program that automatically runs whatever is needed (latex, bibtex, makeindex, etc.) in the correct order to produce an updated final document whenever you change something.Allegraallegretto
I strongly second that recommendation of latexmk. I couldn't live without it :)Boilermaker
I edited this answer because the bibtex command does not allow an extension. (and the extension would be ".aux" not ".tex" for it even if it did)Lutanist
Consider using pdflatex instead of latex to directly produce a .pdf file.Bedpan
This answer does not answer the question as it asks specifically about using the pdflatex command.Sortition
Replacing 'latex' with 'pdflatex' works like a charmStclair
P
23

You have to run 'bibtex':

latex paper.tex
bibtex paper
latex paper.tex
latex paper.tex
dvipdf paper.dvi
Polymorphous answered 17/3, 2010 at 11:53 Comment(0)
H
15

I am using texmaker as the editor. you have to compile it in terminal as following:

  1. pdflatex filename (with or without extensions)
  2. bibtex filename (without extensions)
  3. pdflatex filename (with or without extensions)
  4. pdflatex filename (with or without extensions)

but sometimes, when you use \citep{}, the names of the references don't show up. In this case, I had to open the references.bib file , so that texmaker could capture the references from the references.bib file. After every edition of the bib file, I had to close and reopen it!! So that texmaker could capture the content of new .bbl file each time. But remember, you have to also run your code in texmaker too.

Hartfield answered 6/2, 2014 at 21:45 Comment(1)
instead of closing and opening the references.bib, you can also go to edit-->refresh bibliography. It works!!Hartfield
C
7

Just in case it helps someone, since these questions (and answers) helped me really much; I decided to create an alias that runs these 4 commands in a row:

Just add the following line to your ~/.bashrc file (modify the main keyword accordingly to the name of your .tex and .bib files)

alias texbib = 'pdflatex main.tex && bibtex main && pdflatex main.tex && pdflatex main.tex'

And now, by just executing the texbib command (alias), all these commands will be executed sequentially.

Cockatrice answered 12/5, 2015 at 15:32 Comment(1)
why we have to run pdflatex main.tex two times?Vinegary

© 2022 - 2024 — McMap. All rights reserved.