2

I'm new with Mactex and I've been trying to insert references; however, even when I use the sample templates, the question mark is printed instead of citation number and my references does not print. Here is sample of my code and the printed document: sample of "references.bib" file:

@article{einstein,
  author =       "Albert Einstein",
  title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
                 [{On} the electrodynamics of moving bodies]",
  journal =      "Annalen der Physik",
  volume =       "322",
  number =       "10",
  pages =        "891--921",
  year =         "1905",
  DOI =          "http://dx.doi.org/10.1002/andp.19053221004"
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}

@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

and here is sample of my main code:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}

\usepackage[square,numbers]{natbib}
\bibliographystyle{unsrtnat}

\title{Bibliography management: \texttt{natbib} package}
\author{Share\LaTeX}

\begin{document}

\maketitle

This document is an example of \texttt{natbib} package using in bibliography management. Three items are cited: \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Einstein journal paper \cite{einstein}, and the Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are \cite{latexcompanion,knuthwebsite}. 

\medskip

\bibliography{references}

\end{document}

and this is the printed document: enter image description here

Akso, this is the warning that I get:

Package natbib Warning: Citation `knuthwebsite' on page 1 undefined on input li ne 14.

No file bib.bbl.

Package natbib Warning: There were undefined citations.

  • I tried all the solution in that link nut it doesn't work. It seems that the main problem is the latex is not able to sync! – mahsa rezaee Aug 06 '18 at 00:55
  • Where is your .bib file located? Does bibtex give you errors? What editor are you using? – Alan Munn Aug 06 '18 at 01:21
  • this is the error that I get: Package natbib Warning: Citation `knuthwebsite' on page 1 undefined on input li ne 14.

    No file bib.bbl.

    Package natbib Warning: There were undefined citations.

    – mahsa rezaee Aug 06 '18 at 01:43
  • Edit your question to show the error. Don't put it in a comment. – Alan Munn Aug 06 '18 at 01:44
  • Also, the pdf file which is compile has no references and citation – mahsa rezaee Aug 06 '18 at 01:46
  • Where is your .bib file? Is it in the same folder as your .tex file? – Alan Munn Aug 06 '18 at 01:48
  • yes, the .bib file is in the same directory as my main file. I have this issue even with the sample template I download of the internet. – mahsa rezaee Aug 06 '18 at 01:50
  • What does the .blg file say? – Alan Munn Aug 06 '18 at 01:58
  • .blg file does not compile! I tried my code on an other computer, it works fine. Is it by any chance the software problem?! I use the texshop 4.01 – mahsa rezaee Aug 06 '18 at 02:11
  • 1
    The .blg file should be a log file created when bibtex is run. It doesn't compile. Try adding the following: % !TEX TS-program = pdfLaTeXmk at the beginning of your file and recompiling. – Alan Munn Aug 06 '18 at 02:19
  • this file does not create! what should I do? maybe that's the reason it doesn't sync! – mahsa rezaee Aug 06 '18 at 02:22
  • Ok, that's helpful. Are you actually running bibtex then? Try Command-T, (compile) Command-B, (bibtex) Command-T, (compile) Command-T (compile) in TeXShop. – Alan Munn Aug 06 '18 at 02:24
  • my reference file is ".bib" and when I try to run it, I receive the error "I couldn't open file name `references.aux'" – mahsa rezaee Aug 06 '18 at 03:20
  • Open your main tex file and do the steps Alan told you to do. Do not switch to any other file. – Johannes_B Aug 06 '18 at 04:54
  • It was slightly helpful because now though I still have question mark instead of number in text and my references does not printed, at least it recognized my bibliography and insert this section in my Pdf. – mahsa rezaee Aug 06 '18 at 05:24

0 Answers0