2

I cannot make Latex read my bib file here is the code

\documentclass[10pt]{article}
\begin{document}
Hello
\cite{Willis2009} 

\bibliographystyle{dcu} 
\bibliography{1_ref_bib}

\end{document}

Willis2009 is in the bib file

  • 4
    TeXnically speaking, LaTeX doesn't read the contents of a .bib file; parsing the contents of bib files is BibTeX's job. Did you run BibTeX after running LaTeX (followed by two more LaTeX runs)? What error and/or warning messages are in the .blg ("BibTeX log") file? Is the bib file named 1_ref_bib.bib? Can BibTeX find the file 1_ref_bib.bib? – Mico Jan 30 '17 at 18:09
1

The code below works.

The dcu bibliography style is part of the harvard package. Be sure to load either harvard or the natbib/har2nat pair of packages in the preamble. The filecontents business is just in lieu of a "real" bib file; you can take that stuff out if you already have a bib file.

EDIT

Run latex (pdflatex, xelatex, lualatex, whatever), then bibtex, then latex twice more. Your bib file should be in the same folder as your latex file.

\documentclass{article}

\usepackage{harvard}

\usepackage{filecontents}
\begin{filecontents}{1_ref_bib.bib}
@article{Willis2009,
    author={Willie Willis},
    title={How much wood would a woodchuck chuck if a woodchuck would chuck wood?},
    year={2009}
}
\end{filecontents}

\begin{document}
    Hello
    \cite{Willis2009} 

    \bibliographystyle{dcu} 
    \bibliography{1_ref_bib}

\end{document}
  • 1
    You already did that in a comment, though, but I guess repetition doesn't hurt. – JPi Jan 30 '17 at 18:29
  • How to run bibtex? – José M Jan 31 '17 at 17:49
  • I come up with this mistake – José M Jan 31 '17 at 17:56
  • This is BibTeX, Version 0.99d (MiKTeX 2.9) The top-level auxiliary file: test4.aux The style file: dcu.bst I couldn't open database file 1_ref_bib.bib ---line 4 of file test4.aux : \bibdata{1_ref_bib : } I'm skipping whatever remains of this command I found no database files---while reading file test4.aux Warning--I didn't find a database entry for "Willis2009" (There were 2 error messages) – José M Jan 31 '17 at 17:57
  • It cannot find 1_ref_bib.bib Make sure it's in the same folder as your latex file. – JPi Jan 31 '17 at 18:13
-1

See this answer: https://texblog.org/2011/12/12/bib2tex-converting-bibtex-to-bibitems/.

bib2tex: Converting bibtex to bibitems 12. December 2011 by tom 3 Comments

A friend asked me today to help him convert a bibtex-file to a \LaTeX bibliography (\bibitem{}), since the journal he submits his paper to doesn’t accept bibtex-files (*.bib). So what we were trying to do is to convert a set of bibtex-references of the following form (from cell): @article{bartel2009, Author = {Bartel, David P. }, Date = {2009/01/23}, Journal = {Cell}, Month = {01}, Number = {2}, Pages = {215--233}, Title = {Micro{RNA}s: Target Recognition and Regulatory Functions}, Volume = {136}, Year = {2009}}

to a format that \LaTeX understands, e.g.: \bibitem[Bartel(2009)]{bartel2009} David~P. Bartel. \newblock Micro{RNA}s: Target recognition and regulatory functions. \newblock \emph{Cell}, 136\penalty0 (2):\penalty0 215--233, 01 2009.

There is an easy way of converting references by making use of the bibtex-command. It does exactly what we needed in the background. Typesetting the document once (latex) and generating the references with the bibtex-command will create a metafile called “document.bbl”, containing all the referenced bibitems in \LaTeX-format.

  • Any chance of something similar working with BibLaTeX? I tried to repeat the same strategy, but the .bll file does not contain things that the .tex file is likely to understand (instead of "bibitem" it has "entry" and the whole syntax looks completely different to me. – Brightsun Jun 28 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.