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.
Best Answer
In order to successfully use
BibTeX
, you need to execute the following sequence of commands:latex
on the.tex
filebibtex
latex
againlatex
againThe first pass of
latex
detects a citation command in your.tex
file, as well as the\bibliographystyle{...}
and\bibliography{...}
commands. Then, runningbibtex
formats the citation based on the\bibliographystyle{...}
command. Runninglatex
the second time makes the appropriate links, and, finally, runninglatex
the third time puts everything in place.(In TeXShop, you run
latex
by either clicking onTypeset
in the window or by the shortcutCOMMAND+T
;bibtex
is run by changing the dropdown menu next to theTypeset
button toBibTeX
and then clickingTypeset
or by using the shortcutSHIFT+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, ismy bibliography.bib
, you probably want to change it tomy_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 executelatex
andbibtex
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: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 inLaTeX
. 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 runlatex
,bibtex
, and/orpdflatexmk
). 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 thatlatex
\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 namedmaster.bib
and located in~\Library\texmf\bibtex\bib
:and the
.tex
file: