1

Before I begin: I'm sorry for the probably rudimentary question I'll be asking. Please be sure it's not for lack of trying/research.

I'm using TeXShop. I've got my document. I have a .bib file, saved in the same folder as all the stuff TeXShop generates when I run it (I'm using JabRef).

I cannot get in-text citations or a bibliography running.

I have at the bottom of my document

\bibliographystyle{plain}

and

\bibliography {$Users/my name/Documents/Latex/name of bib file}

I have also put \cite{Ref_key6} in the document.

All I'm getting is when I look at the document after hitting "typeset" is a [?] where the citation should be and a section called "References" with nothing written under it .

If there is a relatively jargon-free explanation as to how to get TeXshop to see my .bib file and how to get my citations in I'd be deeply appreciative.

7
  • 1
    Are you running BibTeX?
    – Sigur
    Jul 16 '13 at 0:05
  • 2
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Jul 16 '13 at 0:16
  • Apologies, apologies-I ran Bibtex and received the error message 'm skipping whatever remains of this command I found no database files---while reading adam's paper.aux Warning--I didn't find a database entry for "ref_key6" Given how slow I am in my learnings with technology, if any help is forthcoming I also ask for a bit of patience. (There were 2 error messages)
    – adam
    Jul 16 '13 at 1:20
  • @adam Is ref_key6 the actual name of your citation key? Also, are there any accented characters in your BibTeX file? Try changing your citation key to 'test' and eliminating accented characters. Then, try compiling a document that looks like: \documentclass{article} \usepackage{natbib} \begin{document} \citep{test} \bibliographystyle{plain} \bibliography{my_bibliography} \end{document} Doing this is how you compile a Minimal Working Example (MWE), which will allow us to better help you.
    – Adam Liter
    Jul 16 '13 at 1:31
  • If you can create a minimal .bib file and a minimal .tex file that reproduce the same errors and update the question by copying and pasting that minimal code, then we will likely be able to help you faster. :-)
    – Adam Liter
    Jul 16 '13 at 1:36
4

In order to successfully use BibTeX, you need to execute the following sequence of commands:

  1. run latex on the .tex file
  2. run bibtex
  3. run latex again
  4. run latex again

The first pass of latex detects a citation command in your .tex file, as well as the \bibliographystyle{...} and \bibliography{...} commands. Then, running bibtex formats the citation based on the \bibliographystyle{...} command. Running latex the second time makes the appropriate links, and, finally, running latex the third time puts everything in place.

(In TeXShop, you run latex by either clicking on Typeset in the window or by the shortcut COMMAND+T; bibtex is run by changing the dropdown menu next to the Typeset button to BibTeX and then clicking Typeset or by using the shortcut SHIFT+COMMAND+B.)

A couple things you may want to note:

First, if the .bib file is in the same directory as the .tex file, you do not need to specify the entire file path.

Second, you probably want to avoid having spaces in the name of your .bib file. If the name, for example, is my bibliography.bib, you probably want to change it to my_bibliography.bib, and you can include it simply with \bibliography{my_bibliography}, leaving off the file extension.

Third, if these instructions are confusing, there is an engine called pdflatexmk, which is, I think, a Perl script that was written to execute latex and bibtex the correct number of times on a .tex file. This is available as an engine with any recent version of TeXShop. By default, it is inactive. If you type:

mv ~/Library/TeXShop/Engines/Inactive/Latexmk/pdflatexmk.engine ~/Library/TeXShop/Engines/ 

into the command line (i.e., Terminal) it will move this script into the active folder for you, and then you can access this from the dropdown menu in TeXShop right next to the Typeset button, after quitting and reopening TeXShop. (You can also do this by using 'drag & drop' techniques and Finder, though you will probably need to reveal your Library folder, if you're running a recent OS X.)

Finally, a suggestion: you need not make separate .bib files for each document that you write in LaTeX. You can make one 'master' file, and put it in the ~\Library\texmf\bibtex\bib directory (which is a place that will always be found when you run latex, bibtex, and/or pdflatexmk). Only citations that you have cited with a \cite{...} command will actually show up in the References section of the document. I find that this is a good way to manage citations, rather than having separate files for everything, particularly if there are works that you you end up citing multiple times.


Update (as per some recent comments):

First, make sure that your TeX distribution is up to date.

Then, if you have not already set up the requisite texmf directory structure for adding your own .sty files, .bib files, etc., you can follow the instructions here to do so.

After following those instructions, you can move your .bib file to the ~\Library\texmf\bibtex\bib directory. This should take care of any problems that latex \ bibtex might have in locating the .bib file. (Again, doing this might require you to reveal your Library folder.)

Moreover, MWEs for both the .bib file and .tex file will look as follows:

.bib file, which is named master.bib and located in ~\Library\texmf\bibtex\bib:

@article{ref_key6,
Author = {Example Author},
Journal = {Example Journal},
Number = {1},
Pages = {1-32},
Title = {Example Title},
Volume = {1},
Year = {2013}}

and the .tex file:

\documentclass{article}

\usepackage{natbib}

\begin{document}

I am going to cite `ref\_key6' here.\citep{ref_key6}

\bibliographystyle{plain}
\bibliography{master}

\end{document}

enter image description here

9
  • Thank you so much for such a prompt and thorough reply! I've performed (1) - (4) above and the result is the same: a [?} where the citation should be in text and nothing under "references" (and I performed (1)-(4) without making changes to what my tex situation was before, with the \bibliography{plain} and \bibliography {mybibfile} and the in text command \cite{ref_key6} I'm being told I need to click something about "roots" or type into the tex document something about natib. Again, thank you so much for the help and I think we can figure this out!
    – adam
    Jul 16 '13 at 1:42
  • Do you have a recent version of TeX Live installed? And did you put \usepackage{natbib} in the preamble of your .tex document?
    – Adam Liter
    Jul 16 '13 at 1:49
  • I have the Tex Live utility and I did not put that command into the preamble. I put the command into my preamble (apologies for not specifying that both \bibliography commands are at the end of my content) and performed (1)-(4) and nothing has changed.
    – adam
    Jul 16 '13 at 1:56
  • @adam Are you still using the \cite{...} command? Try changing to either \citet{...} or \citep{...}. You can see this reference sheet for natbib commands.
    – Adam Liter
    Jul 16 '13 at 2:01
  • Neither of them worked-is the command inside the fancy bracket correct, {ref_key6}? Could that be it?
    – adam
    Jul 16 '13 at 2:10
0

I just met the same problem as yours: "?" for the citation and nothing under the "References". I just made two changes and now the problem has been solved.

  1. As Adam points out, you probably want to avoid having spaces in the name of your .bib file and change the space to "_".
  2. You might want to add to following command in your TeX field \nocite{*} before the bibliography.

Then I found with excitement that the problem was solved.

Hope this is helpful.

1
  • 2
    What \nocite{*} does is to add all references in the .bib file to the reference list, which may not be desirable. By default only the works that are actually cited end up in the reference list. \nocite{<citation key>} adds an item to the list without generating a citation in the text, and \nocite{*} adds everything. Oct 12 '13 at 6:31

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.